Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,946
» Latest member: blackopsdlc
» Forum threads: 22,010
» Forum posts: 22,977

Full Statistics

Online Users
There are currently 1778 online users.
» 0 Member(s) | 1772 Guest(s)
Applebot, Baidu, Bing, Facebook, Google, Yandex

Latest Threads
[DevBlog MS] Microsoft is...
Forum: C#, Visual Basic, & .Net Frameworks
Last Post: xSicKxBot

» Replies: 0
» Views: 12
[WoW Retail News] BlizzCo...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 13
What is Celestial Codex i...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 13
[Ubuntu News] Fine tune y...
Forum: Linux, FreeBSD, and Unix types
Last Post: xSicKxBot

» Replies: 0
» Views: 11
[WoW Retail News] Xal'ata...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 31
[Ubuntu News] Scaling And...
Forum: Linux, FreeBSD, and Unix types
Last Post: xSicKxBot

» Replies: 0
» Views: 22
[WoW Retail News] Comment...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 20
How to unlock Maya Aguina...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 25
[Steam Release] The Unive...
Forum: New Game Releases
Last Post: xSicKxBot

» Replies: 0
» Views: 30
[DevBlog MS] Creating a m...
Forum: C#, Visual Basic, & .Net Frameworks
Last Post: xSicKxBot

» Replies: 0
» Views: 38

 
  [Tut] How to Compress PDF Files Using Python?
Posted by: xSicKxBot - 03-31-2022, 08:07 PM - Forum: Python - No Replies

How to Compress PDF Files Using Python?




Problem Formulation


Suppose you have a PDF file, but it’s too large and you’d like to compress it (perhaps you want to reduce its size to allow for faster transfer over the internet, or perhaps to save storage space). 

Even more challenging, suppose you have multiple PDF files you’d like to compress. 

Multiple online options exist, but these typically allow a limited number of files to be processed at a time.  Also of course there is the extra time involved in uploading the originals, then downloading the results.  And of course, perhaps you are not comfortable sharing your files with the internet.

Fortunately, we can use Python to address all these concerns.  But before we learn how to do this, let’s first learn a little bit about PDF files.

About Compressing PDF Files


According to Dov Isaacs, former Adobe Principal Scientist (see his discussion here) PDF documents are already substantially compressed. 

The text and vector graphics portions of the documents are already internally zip-compressed, so there is little opportunity for improvement there. 

Instead, any file compression improvements are achieved through compression of image portions of PDF documents, along with potential loss of image quality. 

So compression might be achievable, but the user must choose between how much compression versus how much image quality loss is acceptable.

Setup


A programmer going by the handle Theeko74 has written a Python script called “pdf_compressor.py”. This script is a wrapper for ghostscript functions that do the actual work of compressing PDF files. 

This script is offered under the MIT license and is free to use as the user wishes.

? Hint: make sure you have ghostscript installed on your computer. To install ghostscript, follow this detailed guide and come back afterward.

Now download pdf_compressor.py from GitHub here.

Ultimately we will be writing a Python script to perform the compression. 

So we create a directory to hold the script, and use our preferred editor or IDE to create it (this example uses Linux command line to make the directory, and uses vim as the editor to make script “bpdfc.py”; use your preferred choice for creating the directory and creating the script within it):

$ mkdir batchPDFcomp
$ cd batchPDFcomp
$ vim bpdfc.py

We won’t write out the script just yet – we’ll show some details for the script a little later in this article.

When we do write the script, within it we’ll import “pdf_compressor.py” as a module

To prepare for this we should create a subdirectory below our Python script directory. 

Also, we’ll need to copy pdf_compressor.py into that subdirectory, and we’ll need to create a file __init__.py within the same subdirectory (those are double underscores each side of ‘init’):

$ mkdir pdfc
$ cp ~/Downloads/pdf_compressor.py ~/batchPDFcomp/pdfc/
$ cd pdfc
$ vim __init__.py

What we have done here is created a local package pdfc containing a module pdf_compressor.py

? Note: The presence of file __init__.py indicates to Python that that directory is part of a package, and to look there for modules.

Now we are ready to write our script.

The PDF Compression Python Script


Here is our script:

from pdfc.pdf_compressor import compress
compress('Finxter_WorldsMostDensePythonCheatSheet.pdf', 'Finxter_WorldsMostDensePythonCheatSheet_compr.pdf', power=4)

As you can see it’s a very short script. 

First we import the “compress” function from “pdf_compressor” module. 

Then we call the “compress” function.  The function takes as arguments: the input file path, the output file path, and a ‘power’ argument that sets compression as follows, from least compression to most (according to the documentation in the script):

Compression levels:

  • 0: default
  • 1: prepress
  • 2: printer
  • 3: ebook
  • 4: screen

Running the Script


Now we can run our script:

$ python bpdfc.py
Compress PDF...
Compression by 51%.
Final file size is 0.2MB
Done.
$

We have only compressed one PDF document in this example, but by modifying the script to loop through multiple PDF documents one can compress multiple files at once. 

However, we leave that as an exercise for the reader!

We hope you have found this article useful. Thank you for reading, and we wish you happy coding!



https://www.sickgaming.net/blog/2022/03/...ng-python/

Print this item

  [Tut] Bootstrap Sticky Navbar Menu on Scroll using CSS and JavaScript
Posted by: xSicKxBot - 03-31-2022, 08:07 PM - Forum: PHP Development - No Replies

Bootstrap Sticky Navbar Menu on Scroll using CSS and JavaScript

by Vincy. Last modified on January 13th, 2022.

The Bootstrap navbar is a menu responsive header with navigation. Bootstrap supports enabling many UI effects with this navbar component. For example,

  1. Sticky navbar on scrolling the content.
  2. Slide-in effect by using Bootstrap expand-collapse
  3. Mobile-friendly responsive menu navigation.

This article is for creating a Bootstrap sticky navbar on the page top header. It shows both static and dynamic content on the navigation header. Let us see how to display a sticky navbar on a page using Bootstrap.

This quick example shows code to display the stick navbar. It includes Boostrap into the code by using CDN URL. You can also install Bootstrap via composer into your application vendor directory.

It uses Bootstrap sticky-top to the .navbar element.

Quick Example


Include this into the HTML <head>


<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

Put this Bootstrap sticky navbar into the <body>


<nav class="navbar navbar-expand-lg navbar navbar-expand-sm sticky-top navbar-dark bg-dark"> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"><a class="nav-link" href="#">Home</a></li> <li class="nav-item active"><a class="nav-link" href="#">Contact</a> </li> <li class="nav-item active"><a class="nav-link" href="#">About</a> </ul> </div>
</nav>

Bootstrap navbar default behaviour


The below list shows the default behaviour of the Bootstrap navbar. This article features this UI component more by making it sticky on scrolling.

  • Navbar is responsive by default in any viewport.
  • It is hidden for printing but can be overridden by adding .d-print to the .navbar.
  • It lets assistive mechanism to identify navbar by using <nav>. Bootstrap recommends to add role=”navigation” attribute for the <div> like containers.

Uses  of  Bootstrap sticky navbar


The Bootstrap sticky navbar provides a fixed header element mostly at the top. Sometimes, it will be used in the page and form footer.

The following list of items shows some of the uses of a sticky navbar in a website.

  1. To create a fixed header menu. Eg: The header menu links like ‘Contact’, ‘Request a quote’ will be useful if they are sticky on scroll.
  2. To create fixed footer links. Eg: The social media share option in the footer can be sticky to let the user to share the content at any time of reading.
  3. To keep a HTML form footer sticky on scroll. The payment form with the ‘Pay now’ or ‘Buy now’ control should be fixed regardless of the page scroll. It reduces friction and allows users to buy the product easily.

Bootstrap sicky navbar with static menu HTML


This code will help users having static websites who want to add a sticky navbar in the header.

This example includes an expandable static header menu. It shows the sub-menu dropdown on clicking the main menu link.

bootstrap-sticky-navbar-static.php


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<style>
.container { height: 1000px;
}
</style>
<body> <nav class="navbar navbar-expand-lg navbar navbar-expand-sm sticky-top navbar-dark bg-dark"> <a class="navbar-brand" href="#">Site logo</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"><a class="nav-link" href="#">Home</a></li> <li class="nav-item active"><a class="nav-link" href="#">Contact</a> </li> <li class="nav-item active"><a class="nav-link" href="#">About</a> </li> <li class="nav-item dropdown active"><a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Services </a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="#">Map integration</a> <a class="dropdown-item" href="#">Chart generation</a> <a class="dropdown-item" href="#">Report generation </a> </div></li> <li class="nav-item dropdown active"><a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Projects </a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="#"> Chat plugin</a> <a class="dropdown-item" href="#">Form builder</a> </div></li> <li class="nav-item active"><a class="nav-link disabled" href="#">What's new</a></li> </ul> <form class="form-inline my-2 my-lg-0"> <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> </form> </div> </nav> <div class="container"> <div class="row"> <div class="col-12 py-4"> <h1>Page scroll content</h1> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tincidunt dolor eget lorem blandit, auctor porttitor enim faucibus. Mauris sed elit sollicitudin, aliquam lorem nec, suscipit ex. Sed mollis rhoncus scelerisque. Morbi varius a est sed luctus. Morbi sapien velit, venenatis a sapien vitae, commodo rutrum erat. Nam volutpat diam ac convallis egestas. Nunc convallis tempor hendrerit. Aenean turpis quam, viverra eu eros quis, ornare tristique velit. </div> </div> </div>
</body>
</html>

Bootstrap navbar with data-target link


In the bootstrap sticky navbar, it allows specifying the data target to expand.

In this example, the header navbar shows a cart icon on page load. The header HTML also contains the cart info hidden by default.

The navbar cart element targets this hidden cart info to expand it on the click event.

navbar-with-data-target.php


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<style>
.container { height: 1000px;
}
</style>
<body> <div class="pos-f-t sticky-top"> <div class="collapse " id="navbarToggleExternalContent"> <div class="bg-dark p-4 text-right"> <div class="text-light ">Item count = 5</div> <div class="text-light ">Total price = $375</div> </div> </div> <nav class="navbar navbar-dark bg-dark"> <div class="col-lg-12"> <button class="navbar-toggler float-right" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-shopping-cart"> <circle cx="9" cy="21" r="1"></circle> <circle cx="20" cy="21" r="1"></circle> <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path></svg> </button> </div> </nav> </div> <div class="container"> <div class="row"> <div class="col-12 py-4"> <h1>Page scroll content</h1> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tincidunt dolor eget lorem blandit, auctor porttitor enim faucibus. Mauris sed elit sollicitudin, aliquam lorem nec, suscipit ex. Sed mollis rhoncus scelerisque. Morbi varius a est sed luctus. Morbi sapien velit, venenatis a sapien vitae, commodo rutrum erat. Nam volutpat diam ac convallis egestas. Nunc convallis tempor hendrerit. Aenean turpis quam, viverra eu eros quis, ornare tristique velit. </div> </div> </div>
</body>
</html>

The below screenshot cart icon and the expanded cart info. It displays the number of items in the cart and the total amount.

bootstrap sticky navbar cart info

bootstrap data target

Dynamic menu in the sticky navbar


This example includes HTML as like as the static menu example. The difference is the menu items are from the database.

This code uses a PHP class DataSource.php to process the database operations. It uses MySqli with prepared-statement to access the database.

bootstrap-sticky-navbar-dynamic.php


<?php
namespace Phppot; use Phppot\DataSource;
require_once __DIR__ . '/DataSource.php';
$conn = new DataSource();
$query = "SELECT * FROM tbl_menu where parent = 0";
$mainresult = $conn->select($query);
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<style>
.container { height: 1000px;
}
</style>
<body> <nav class="navbar navbar-expand-lg navbar navbar-expand-sm sticky-top navbar-dark bg-dark"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <?php foreach ($mainresult as $key => $val){?> <li class="nav-item dropdown active"><a class="nav-link " href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo $mainresult[$key]["menu_name"];?></a> <?php $query = "SELECT * FROM tbl_menu where parent= ?"; $paramType = "i"; $paramValue = array( $mainresult[$key]["id"] ); $subresult = $conn->select($query, $paramType, $paramValue); ?> <?php if (! empty($subresult)) {?> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <?php foreach ($subresult as $k => $v) {?> <a class="dropdown-item" href="#"><?php echo $subresult[$k]["menu_name"];?></a> <?php }?> </div> <?php } } ?> </li> </ul> <form class="form-inline my-2 my-lg-0"> <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> </form> </div> </nav> <div class="container"> <div class="row"> <div class="col-12 py-4"> <h1>Page scroll content</h1> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tincidunt dolor eget lorem blandit, auctor porttitor enim faucibus. Mauris sed elit sollicitudin, aliquam lorem nec, suscipit ex. Sed mollis rhoncus scelerisque. Morbi varius a est sed luctus. Morbi sapien velit, venenatis a sapien vitae, commodo rutrum erat. Nam volutpat diam ac convallis egestas. Nunc convallis tempor hendrerit. Aenean turpis quam, viverra eu eros quis, ornare tristique velit. </div> </div> </div>
</body>
</html>

Responsive Bootstrap sticky navbar


Bootstrap navbar is responsive by default. In a mobile viewport, it displays a slide-down responsive menu. On clicking the menu-expand icon it drops down the menu items.

responsive-navbar.php


<?php
namespace Phppot; use Phppot\DataSource;
require_once __DIR__ . '/DataSource.php';
$conn = new DataSource();
$query = "SELECT * FROM tbl_menu";
$result = $conn->select($query);
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<style>
.container { height: 1000px;
}
</style>
<body> <nav class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarTogglerDemo03"> <ul class="navbar-nav mr-auto mt-2 mt-lg-0"> <?php foreach ($result as $key => $val){?> <li class="nav-item active"><a class="nav-link" href="#"><?php echo $result[$key]["responsive_name"];?> </li> </a><?php }?> </ul> <form class="form-inline my-2 my-lg-0"> <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> </form> </div> </nav> <div class="container"> <div class="row"> <div class="col-12 py-4"> <h1>Page scroll content</h1> Dolor sit amet, consectetur adipiscing elit. </div> </div> </div>
</body>
</html>

Database script


Import this database script to display a dynamic Bootstrap sticky navbar. It contains menu items and the parent-child relationship data.

database.sql


CREATE TABLE `tbl_menu` ( `id` int(11) NOT NULL, `menu_name` text NOT NULL, `parent` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; --
-- Dumping data for table `tbl_menu`
-- INSERT INTO `tbl_menu` (`id`, `menu_name`, `parent`) VALUES
(1, 'Site logo', '0'),
(2, 'Home', '0'),
(3, 'Contact', '0'),
(4, 'About', '0'),
(5, 'Services', '0'),
(8, 'Map integration', '5'),
(9, 'Chart generation', '5'),
(10, 'Report generation', '5'),
(11, 'Projects', '0'),
(12, 'Chat plugin', '11'),
(13, 'Form builder', '11'),
(14, 'What\'s new', '0'); --
-- Indexes for table `tbl_menu`
--
ALTER TABLE `tbl_menu` ADD PRIMARY KEY (`id`); ALTER TABLE `tbl_menu` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

Bootstrap sticky navbar output


bootstrap sticky navbar

responsive sticky navbar
Download

↑ Back to Top



https://www.sickgaming.net/blog/2022/01/...avascript/

Print this item

  (Indie Deal) FREE Unhack, Capcom Sale, DBZ Kakarot Deal
Posted by: xSicKxBot - 03-31-2022, 08:07 PM - Forum: Deals or Specials - No Replies

FREE Unhack, Capcom Sale, DBZ Kakarot Deal

Unhack FREEbie
[freebies.indiegala.com]
As the top unhacker in Smash Security, join forces with the AI companion Weedy to become an unstoppable duo and hunt down the 5k Worm.

Capcom Sale, up to 83% OFF
[www.indiegala.com]
Resident Evil, Monster Hunter, Devil May Cry, Street Fighter, Mega Man and more.

Save 73% on DRAGON BALL Z: KAKAROT
[www.indiegala.com]
Relive the story of Goku and other Z Fighters in DRAGON BALL Z: KAKAROT! Beyond the epic battles, experience life in the DRAGON BALL Z world as you fight, fish, eat, and train with Goku, Gohan, Vegeta and others. Explore the new areas and adventures as you advance through the story and form powerful bonds with other heroes from the DRAGON BALL Z universe....

https://www.youtube.com/watch?v=vGScfDMeId8
Stay Inside, Stay Safe and Enjoy Good Games.
Check out IndieGala on Twitter, YouTube & Facebook[www.facebook.com]


https://steamcommunity.com/groups/indieg...0026694878

Print this item

  PC - Young Souls
Posted by: xSicKxBot - 03-31-2022, 08:07 PM - Forum: New Game Releases - No Replies

Young Souls



As orphans, Jenn and Tristan's life path brought them to a mysterious scientist, who took them in and cared for them as his own children. But one day, he disappeared under very odd circumstances.

While searching desperately for him, the duo found a hidden cellar and the Moon Gate portal, transporting them to a dangerous parallel world where goblins thrive.

Your adventure begins as you fight to bridge these two very different worlds.

Young Souls is a gorgeous 2D brawler meets story-rich action RPG. Fight hordes of belligerent goblins, level up with hundreds of weapons and accessories, explore, and journey between worlds, as rebellious twins battle their way to save their foster father.

Publisher: The Arcade Crew

Release Date: Mar 10, 2022




https://www.metacritic.com/game/pc/young-souls

Print this item

  News - Will Smith Was Asked To Leave After Oscars Slap But He Refused, Academy Says
Posted by: xSicKxBot - 03-31-2022, 08:07 PM - Forum: Lounge - No Replies

Will Smith Was Asked To Leave After Oscars Slap But He Refused, Academy Says

The newest chapter of the Will Smith/Chris Rock drama at the Oscars has unfolded. The Academy of Motion Picture Arts and Sciences said that Smith was asked to leave the venue after he struck Rock on stage, but the Independence Day star refused, according to the Associated Press. TMZ's sources, meanwhile, say this is not the case and that Smith was told by a producer that he could stay. Some said Smith could stay and others wanted him gone, according to the report.

"There were various discussions during several commercial breaks, but they never reached a consensus," TMZ reported.

Smith, who has publicly apologized to Rock and the Academy, is facing potential disciplinary action. The Academy's board met this week to begin discussions about punishing Smith for violating its conduct standards. Smith could be suspended or expelled from the Academy, or face other sanctions, the group said. Harvey Weinstein, Roman Polanski, and Billy Cosby are among the very small group of people to have been expelled from the Academy.

Continue Reading at GameSpot

https://www.gamespot.com/articles/will-s...01-10abi2f

Print this item

  (Free Game Key) Total War: WARHAMMER & City of Brass - Free Epic Games
Posted by: xSicKxBot - 03-31-2022, 08:07 PM - Forum: Deals or Specials - No Replies

Total War: WARHAMMER & City of Brass - Free Epic Games

Visit the store page and add the games to your account:

Total War: WARHAMMER[store.epicgames.com] alongside its free DLC's[store.epicgames.com]

City of Brass[store.epicgames.com]

City of Brass is a recurring giveaway, being given once on the Epic Store on May 2019. The games are free to keep until Apr 7th 2022 - 15:00 UTC.

Next week's freebie:
Rogue Legacy
The Vanishing of Ethan Carter

We are welcoming everyone to join our discord[discord.gg]. We are more active there on finding giveaways, small or large, and there are daily raffles you can participate.

?GrabFreeGames.com ?Twitter ?Steam Curator ?Facebook[fb.me]?Discord[discord.gg]
❤️Support us: ✔️HumbleBundle Partner[www.humblebundle.com] Epic Tag: GrabFreeGames


https://steamcommunity.com/groups/GrabFr...9644695076

Print this item

  [Tut] How to Swap List Elements in Python?
Posted by: xSicKxBot - 03-31-2022, 01:50 AM - Forum: Python - No Replies

How to Swap List Elements in Python?

Problem Formulation


Given a list of size n and two indices i,j < n.

Swap the element at index i with the element at index j, so that the element list[i] is now at position j and the original element list[j] is now at position i.

Examples:

  • Swapping indices 0 and 2 in list [1, 2, 3] modifies the list to [3, 2, 1].
  • Swapping indices 1 and 2 in list [1, 2, 3] modifies the list to [1, 3, 2].
  • Swapping indices 1 and 3 in list ['alice', 'bob', 'carl', 'denis'] modifies the list to ['alice', 'denis', 'carl', 'bob'].

Method 1: Multiple Assignment


To swap two list elements by index i and j, use the multiple assignment expression lst[i], lst[j] = lst[j], lst[i] that assigns the element at index i to index j and vice versa.

lst = ['alice', 'bob', 'carl']
i, j = 0, 2 # Swap index i=0 with index j=2
lst[i], lst[j] = lst[j], lst[i] print(lst)
# ['carl', 'bob', 'alice']

The highlighted line works as follows:

  • First, it obtains the elements at positions j and i by running the right-hand side of the assignment operation.
  • Second, it assigns the obtained elements in one go to the inverse indices i and j (see left-hand side of the assignment operation).

To help you better understand this code snippet, I’ve recorded a quick video that shows you how the generalization of multiple assignment, i.e., slice assignment, works as a Python One-Liner:




Method 2: Swap Two Elements by Value Using indexof()


Let’s quickly discuss a variant of this problem whereby you want to swap two elements but you don’t know their indices yet.

To swap two list elements x and y by value, get the index of their first occurrences using the list.index(x) and list.index(y) methods and assign the result to variables i and j, respectively. Then apply the multiple assignment expression lst[i], lst[j] = lst[j], lst[i] to swap the elements.

The latter part, i.e., swapping the list elements, remains the same. The main difference is highlighted in the following code snippet:

lst = ['alice', 'bob', 'carl']
x, y = 'alice', 'carl' # Get indices i and j associated with elements x and y
i, j = lst.index(x), lst.index(y) # Swap element at index i with element at index j
lst[i], lst[j] = lst[j], lst[i] print(lst)
# ['carl', 'bob', 'alice']

Do you need a quick refresher on the list.index() method?

? Background: The list.index(value) method returns the index of the value argument in the list. You can use optional start and stop arguments to limit the index range where to search for the value in the list. If the value is not in the list, the method throws a ValueError.

Feel free to also watch the following quick explainer video:




Python One-Liners Book: Master the Single Line First!


Python programmers will improve their computer science skills with these useful one-liners.

Python One-Liners

Python One-Liners will teach you how to read and write “one-liners”: concise statements of useful functionality packed into a single line of code. You’ll learn how to systematically unpack and understand any line of Python code, and write eloquent, powerfully compressed Python like an expert.

The book’s five chapters cover (1) tips and tricks, (2) regular expressions, (3) machine learning, (4) core data science topics, and (5) useful algorithms.

Detailed explanations of one-liners introduce key computer science concepts and boost your coding and analytical skills. You’ll learn about advanced Python features such as list comprehension, slicing, lambda functions, regular expressions, map and reduce functions, and slice assignments.

You’ll also learn how to:

  • Leverage data structures to solve real-world problems, like using Boolean indexing to find cities with above-average pollution
  • Use NumPy basics such as array, shape, axis, type, broadcasting, advanced indexing, slicing, sorting, searching, aggregating, and statistics
  • Calculate basic statistics of multidimensional data arrays and the K-Means algorithms for unsupervised learning
  • Create more advanced regular expressions using grouping and named groups, negative lookaheads, escaped characters, whitespaces, character sets (and negative characters sets), and greedy/nongreedy operators
  • Understand a wide range of computer science topics, including anagrams, palindromes, supersets, permutations, factorials, prime numbers, Fibonacci numbers, obfuscation, searching, and algorithmic sorting

By the end of the book, you’ll know how to write Python at its most refined, and create concise, beautiful pieces of “Python art” in merely a single line.

Get your Python One-Liners on Amazon!!



https://www.sickgaming.net/blog/2022/03/...in-python/

Print this item

  [Oracle Blog] Introducing Java SE 11
Posted by: xSicKxBot - 03-31-2022, 01:50 AM - Forum: Java Language, JVM, and the JRE - No Replies

Introducing Java SE 11

DOWNLOAD JAVA 11 How time flies! Over the last several months, Oracle announced changes to evolve the Java platform ensuring it continues forward with a vibrant future for users. Those advances included: Increasing the pace and predictability of delivery Since the release of Java 9, the Java platfor...

https://blogs.oracle.com/java/post/intro...java-se-11

Print this item

  [Tut] HTML Contact Form Template to Email with Custom Fields
Posted by: xSicKxBot - 03-31-2022, 01:50 AM - Forum: PHP Development - No Replies

HTML Contact Form Template to Email with Custom Fields

by Vincy. Last modified on January 5th, 2022.

Why do we need a contact form on a website? It is to enable (prospective) customers to connect with you.

Elon Musk says, “…maximize the area under the curve of customer happiness…”.

So, increasing the possibilities of reading the customer’s mind will drive us forward to attain the goal. The contact form interface is one of the tools to know our customers.

Let’s design a simple and useful contact form component for your website. The below sections explain how to create a contact form from the scratch.

Uses of a contact form in a website


There are a few more advantages of having a contact form interface.

  1. It helps have conversions by knowing the requirement of the customers.
  2. It helps to know the scope of improvements.
  3. It helps to collect the end users’ ideas and opinions relevant to the business model.

About this example


This example code is for designing an HTML contact form with the following features.

  1. Contact form with custom fields.
  2. Add/Delete custom fields dynamically via jQuery.
  3. Send an email with the posted form data.
  4. Storing the form data into the database.

Application configuration


This HTML contact form backend code allows both send an email and the store-to-database action. But, The store-to-database feature is optional and disabled initially.

This configuration file has the flag to enable or disable the store-to-database feature.

By default, the ENABLE_DATABASE flag is set to false. Make it true to show the “store-to-database” control in the UI.

config.php


<?php const ENABLE_DATABASE = false;
?>

HTML contact form landing page code


This HTML code is to display a contact form on a landing page. The index.php file includes the following to make an HTML contact form dynamic.

  • It contains the form HTML.
  • It includes the application configuration file.
  • It requires the form action PHP file to process data submitted by the user.
  • It includes the form validation javascript and required jQuery dependency.

By connecting all the contact form example components, this file lets the HTML contact form be interactive.

It shows two controls to save to the database or to send an email. By default the save to the database control will be hidden. It is configurable to display this option.

index.php


<?php require_once __DIR__ . '/contact-form-action.php';?>
<?php require_once __DIR__ . '/config.php';?>
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>HTML Contact Form with Add More Custom Fields</title>
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/contact.js">
</script>
</head>
<body> <h1>HTML Contact Form with with Add More Custom Fields</h1> <div class="form-container"> <form name="mailForm" id="mailForm" method="post" action="" enctype="multipart/form-data" on‌submit="return validate()"> <div class="input-row"> <label style="padding-top: 20px;">Name</label> <span id="userName-info" class="info"></span><br /> <input type="text" class="input-field" name="userName" id="userName" /> </div> <div class="input-row"> <label>Subject</label> <span id="subject-info" class="info"></span><br /> <input type="text" class="input-field" name="subject" id="subject" /> </div> <div class="input-row"> <label>Message</label> <span id="userMessage-info" class="info"></span><br /> <textarea name="userMessage" id="userMessage" class="input-field" id="userMessage" cols="60" rows="6"></textarea> </div> <div class="input-row"> <div class="custom-field-name"> <input type="text" class="custom-field" name="Fieldname[]" id="Fieldname" placeholder="Fieldname" /> </div> <div class="custom-field-value"> <input type="text" class="custom-field" name="Fieldvalue[]" id="Fieldvalue" placeholder="Fieldvalue" /> </div> <div class="col"> <div class="custom-field-col"> <div on‌Click="addMore();" class="plus-button" title="Add More"> <img src="./images/icon-add.svg" alt="Add More"> </div> <div on‌Click="remove();" class="minus-button" title="Remove"> <img src="./images/icon-remove.svg" alt="Remove"> </div> </div> </div> </div> <div class="col"> <input type="submit" name="send" id="send" class="btn-submit" value="Send email" /> <div class="col"> <?php if(ENABLE_DATABASE == true){?> <input type="submit" name="savetodatabase" class=btn-submit id="savetodatabase" value="Save database" /> <?php }?> </div> <div id="pageloader"> <img id="loading-image" src="./images/loader.gif" /> </div> </div> <div id="statusMessage"> <?php if (! empty($message)) { ?> <p class='<?php echo $type; ?>Message'><?php echo $message; ?></p> <?php } ?> </div> </form> </div>
</body>
</html>

Contact form validation script using jQuery


Form validation can be done either on the server-side or client-side. But, validation on the client-side with Javascript is very usual. And it is quite easy and seamless also.

So, I created a jQuery-based validation script to validate the HTML contact form. It requires all fields to be mandatory except the custom fields.

The contact form custom fields are optional. But, in PHP, it checks the custom field name and value not to be empty. This server-side validation will be done before preparing the contact-form action parameter.

Other JavaScript handlers


This contact.js file does not only include the validation handler. But also, defines handlers to add, delete custom field rows in the UI.

It allows anyone row of custom field inputs to be in the HTML contact form. It is coded in the showHideControls() function of the below file.

contact.js


function validate() { var valid = true; $(".info").html(""); var userName = document.forms["mailForm"]["userName"].value; var subject = document.forms["mailForm"]["subject"].value; var userMessage = document.forms["mailForm"]["userMessage"].value; if (userName == "") { $("#userName-info").html("(required)"); $("#userName").css('background-color', '#FFFFDF'); valid = false; } if (subject == "") { $("#subject-info").html("(required)"); $("#subject").css('background-color', '#FFFFDF'); valid = false; } if (userMessage == "") { $("#userMessage-info").html("(required)"); $("#userMessage").css('background-color', '#FFFFDF'); valid = false; } handleLoader(valid); return valid;
}
function handleLoader(valid) { if (valid == true) { if ($("#savetodatabase")) { $("#savetodatabase").hide();// hide submit } $("#send").hide(); $("#loading-image").show();// show loader }
}
function addMore() { $(".input-row:last").clone().insertAfter(".input-row:last"); $(".input-row:last").find("input").val(""); showHideControls();
}
function remove() { $(".input-row:last").remove(".input-row:last"); $(".plus-button:last").show(); $(".minus-button:last").hide(); $(".input-row:last").find("input").val("");
}
function showHideControls() { $(".plus-button").hide(); $(".minus-button").show(); $(".minus-button:last").hide(); $(".plus-button:last").show();
}

PHP contact form action to send email or store to Database


Generally, the contact form action will send an email with the body of posted form data. This example gives additional support to store the posted message and the details in the database.

This will be suitable when the HTML contact form is used to collect the following.

  • Users’ feedback
  • Support request
  • Project inquiry
  • Comments

This PHP code handles the form submission by checking the posted action index. It uses the PHP mail() function to send the HTML contact form email. If you want to send an email via SMTP using the PHPMailer library, the link has the code for it.

Refer PHP.net manual to know more about this mail() function.

If the user clicks the ‘Save to database’ button, it connects the Database via the DataSource class. It triggers insert action by sending the form data in the query parameters.

contact-form-action.php


<?php
namespace Phppot; use Phppot\DataSource;
require_once __DIR__ . '/DataSource.php';
require_once __DIR__ . '/index.php';
if (! empty($_POST["savetodatabase"])) { $conn = new DataSource(); $query = "INSERT INTO tbl_contact_mail(userName,subject,userMessage)VALUES(?,?,?)"; $paramType = 'sss'; $paramValue = array( $_POST["userName"], $_POST["subject"], $_POST["userMessage"] ); $id = $conn->insert($query, $paramType, $paramValue); if (! empty($_POST["Fieldname"])) { $customFieldLength = count($_POST["Fieldname"]); for ($i = 0; $i < $customFieldLength; $i ++) { if (! empty($_POST["Fieldname"][$i]) && $_POST["Fieldvalue"][$i]) { $query = "INSERT INTO tbl_custom_field(fieldName,fieldValue,contact_id)VALUES(?,?,?)"; $paramType = 'ssi'; $paramValue = array( $_POST["Fieldname"][$i], $_POST["Fieldvalue"][$i], $id ); $conn->insert($query, $paramType, $paramValue); } } } if ($query==true) { $message = "Data Saved"; $type = "success"; } else { $message = "Problem in data"; $type = "error"; }
} elseif (! empty($_POST["send"])) { if (isset($_POST["userName"])) { $userName = $_POST["userName"]; } if (isset($_POST["subject"])) { $subject = $_POST["subject"]; } if (isset($_POST["userMessage"])) { $message = $_POST["userMessage"]; } $htmlBody = '<div>' . $message . '</div>'; $htmlBody .= '<br>'; $htmlBody .= '<div style=font-weight:bold;>More details:' . '</div>'; for ($i = 0; $i < count($_POST["Fieldname"]); $i ++) { if (isset($_POST["Fieldname"][$i]) && (isset($_POST["Fieldvalue"][$i]))) { $fieldname = $_POST["Fieldname"][$i]; $fieldvalue = $_POST["Fieldvalue"][$i]; $htmlBody .= '<div>' . $fieldname . '<div style=display:inline-block;margin-left:10px;>' . $fieldvalue . '</div>'; } } $htmlBody .= '<br><br><br>'; $htmlBody .= '<div>Thank You...!' . '</div>'; // Run loop
$recipient="recipient@domain.com"; if (mail($recipient, $subject, $htmlBody)) { $message = "Mail sent successfully"; $type = "success"; } else { $message = "Problem in sending email"; $type = "error"; }
} ?>

Database script


This .sql file contains the create a statement and required indices of the tbl_contact table.

Import this SQL after setting up this example code in your PHP environment.

Note: This is only required if you need the “Store to database” option.

database.sql


-- -------------------------------------------------------- --
-- Table structure for table `tbl_contact`
-- CREATE TABLE `tbl_contact` ( `id` int(11) NOT NULL, `userName` varchar(255) NOT NULL, `subject` varchar(255) NOT NULL, `userMessage` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- --
-- Table structure for table `tbl_custom_field`
-- CREATE TABLE `tbl_custom_field` ( `id` int(11) NOT NULL, `contact_id` int(11) NOT NULL, `fieldName` varchar(11) NOT NULL, `fieldValue` varchar(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; --
-- Indexes for dumped tables
-- --
-- Indexes for table `tbl_contact`
--
ALTER TABLE `tbl_contact` ADD PRIMARY KEY (`id`); --
-- Indexes for table `tbl_custom_field`
--
ALTER TABLE `tbl_custom_field` ADD PRIMARY KEY (`id`); --
-- AUTO_INCREMENT for dumped tables
-- --
-- AUTO_INCREMENT for table `tbl_contact`
--
ALTER TABLE `tbl_contact` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; --
-- AUTO_INCREMENT for table `tbl_custom_field`
--
ALTER TABLE `tbl_custom_field` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

html contact form custom field

Conclusion


I hope this article gives you a useful contact form component for your website. It will be helpful to have a good idea to create a form like this on your own.

Custom field integration with contact forms a rare and tricky requirement. Share your thoughts in the comments section to continue posting useful codes.

Download

↑ Back to Top



https://www.sickgaming.net/blog/2022/01/...om-fields/

Print this item

  (Indie Deal) Anime Sale, Nacon, Raiser Deals
Posted by: xSicKxBot - 03-31-2022, 01:50 AM - Forum: Deals or Specials - No Replies

Anime Sale, Nacon, Raiser Deals

Anime Sale, up to 95% OFF
[www.indiegala.com]
Fusion! With the power of anime and gaming combined, the Anime Sale was born! Official anime/manga video games, anime-inspiring games, famous classic/modern Japanese franchises, otaku-favorite titles & more.

Nacon & Raiser Games Sale, up to 85% OFF
[www.indiegala.com]
[www.indiegala.com]
https://youtu.be/07stTeEzL2I
Stay Inside, Stay Safe and Enjoy Good Games.
Check out IndieGala on Twitter, YouTube & Facebook[www.facebook.com]


https://steamcommunity.com/groups/indieg...0023805401

Print this item