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 | |
/** | |
* Promise-based programming tutorial. | |
* | |
* In this tutorial, we use promises to tackle several concurrent problems and make them run faster. | |
* Promises are now available in most languages (C#, PHP, Javascript, etc.). | |
* | |
* What they do is, instead of doing a long-running, I/O blocking task | |
* (e.g., read a file, fetch a URL, etc.), they promise to do it in the future | |
* and return the result. |
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 | |
VAULT=${1:-myvault} | |
# Set your profile before by doing aws --profile XXX configure | |
PROFILE=${2:-myprofile} | |
REGION=${3:-us-east-1} | |
SLEEP_TIME=60 | |
# Getting your account ID | |
ACCOUNTID=$(aws --profile $PROFILE sts get-caller-identity | jq -r ".Account") |
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
#!/usr/bin/env php | |
<?php | |
$sample_count=$argv[1]??1; | |
$sleep=$argv[2]??100; | |
$sleep*=1000; | |
$users=[]; | |
for ($i=0;$i<$sample_count;++$i) | |
{ | |
$res=sample(); | |
foreach ($res as $data) |
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 | |
function bin2text($binary) | |
{ | |
return implode(" ", str_split(bin2hex($binary), 32)); | |
} | |
function aes_256_ctr($data, $key, $iv, &$counter = 0) | |
{ | |
assert(strlen($data)%32 == 0); | |
assert(strlen($iv) == 16); | |
assert(strlen($key) == 32); |
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 | |
/** | |
* Grab a /proc/X file and parse as key value pairs separated by colon | |
* @param string $proc name | |
* @return array | |
*/ | |
function parse_colon_proc($proc) | |
{ | |
$res = shell_exec("cat /proc/{$proc}"); | |
$res = explode(PHP_EOL, $res); |
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 | |
/** | |
* This script can be used to modify videos on Youtube programatically. | |
* It does not need Google API libraries, it merely uses PHP's CURL. | |
* | |
* Before starting to work with this, read the comments below for oAuth_token() | |
* function. It requires you do 3 steps (twice run this code while uncommenting, | |
* once login on your browser). Once you have done that and updated the constants | |
* below, you're good to go! |
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 | |
/** | |
* @author AbiusX <[email protected]> | |
* @version 1.0 | |
*/ | |
/** | |
* Calculate taxes based on salary, self-employment salary, | |
* dividends and capital gains. Especially useful for S Corps | |
* |
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 | |
/** | |
* Call captcha to prevent spam calls | |
* Uses Twilio TwiML syntax | |
* @author abiusx | |
* @version 1.1 | |
*/ | |
$name="John Doe"; // Put your name here | |
$number="+14342904141"; // Put your real phone number here |
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 | |
/** | |
* Array map, but maps values to new keys instead of new values | |
* @return array same arrays with keys mapped | |
*/ | |
function array_map_key($callback,$array) | |
{ | |
$out=array_reduce($array, function ($carry,$val) use ($array,$callback){ | |
$key=call_user_func($callback,$val); | |
$carry[$key]=$val; |
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/sh | |
if [[ $# -lt 1 ]]; then | |
echo "Usage: $0 NAME [PORT]"; | |
exit 1 | |
fi | |
NAME=$1 | |
PORT=${2:-80} | |
if [ "${PWD##*/}" != "${NAME}" ]; then | |
mkdir -p "${NAME}" | |
cd "${NAME}" |
NewerOlder