This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
trap "exit 1" TERM | |
TOP_PID=$$ | |
function alert() | |
{ | |
echo "Do something" | |
kill -s TERM $TOP_PID | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import sys | |
def main(): | |
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
host = "127.0.0.1" | |
port = 8888 | |
try: | |
soc.connect((host, port)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$exportData = [ | |
'db0' => ['table0', 'table1'], | |
'db1' => ['table0'] | |
]; | |
$user = 'test'; | |
$password = 'test123'; | |
$host = '127.0.0.1'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sortedSet = range(1, 10000000); | |
$randomSet = $sortedSet; | |
shuffle($randomSet); | |
$cnt = count($sortedSet); | |
$filter = $cnt / 2; | |
$sortedSetChunks = array_chunk($sortedSet, $filter); | |
$randomSetChunks = array_chunk($randomSet, $filter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//example of shallow copy | |
$arr = array(1, 2); | |
$arr1 = &$arr; | |
$arr1[0]++; | |
echo "\nCopied by reference\n"; | |
echo $arr[0], "\n"; | |
echo $arr1[0], "\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include("Lib.php"); | |
class ImageResizerMultiProcess | |
{ | |
private $sizes = []; | |
public function setSizes($sizes) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import concurrent.futures | |
from PIL import Image | |
from resizeimage import resizeimage | |
from os import listdir, getpid | |
from os.path import isfile, join | |
SOURCE_DIR = '/var/tmp/source/' | |
TARGET_DIR = '/var/tmp/target/' | |
MAX_PROCESSES = 4 | |
MAX_THREADS = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
shopt -s nullglob | |
source_files=(/home/kuntal/Videos/Tom.and.Jerry.The.Golden.Collection.Volume.One.720p.BluRay/*.mkv) | |
convert() { | |
source_file=$(echo $0 | cut -f1 -d:) | |
target_file=$(echo $0 | cut -f2 -d:) | |
echo "source file: $source_file" | |
ffmpeg -i $source_file $target_file | |
echo "converted file: $target_file" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shoot off 300 requests at the server, with a concurrency level of 10, to test the number of requests it can handle per second | |
# -p POST | |
# -H Authentication headers | |
# -T Content-Type | |
# -c Concurrent clients | |
# -n Number of requests to run | |
# -l Accept variable document length | |
# -k Connection keep-alive | |
# -v Verbosity level |
OlderNewer