This file contains 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
// uses isset to remove notices | |
$ip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; |
This file contains 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 | |
set -o errexit | |
set -o nounset | |
# Docker | |
sudo apt update | |
sudo apt --yes --no-install-recommends install software-properties-common apt-transport-https ca-certificates | |
wget --quiet --output-document=- https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release --codename --short) stable" |
This file contains 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 | |
// code length 5 characters | |
$code = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 1, 5); |
This file contains 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
def dict_flatten(d, parent_key='', sep=''): | |
items = [] | |
for k, v in d.items(): | |
new_key = parent_key + sep + str(k) if parent_key else str(k) | |
if v and isinstance(v, collections.MutableMapping): | |
items.extend(dict_flatten(v, new_key, sep=sep).items()) | |
else: | |
items.append((new_key, v)) | |
return dict(items) |
This file contains 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
# where proxy | |
proxy () { | |
export http_proxy="http://127.0.0.1:8087" | |
export https_proxy="http://127.0.0.1:8087" | |
echo "HTTP Proxy on" | |
} | |
# where noproxy | |
noproxy () { | |
unset http_proxy |
This file contains 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 | |
$from = 1; | |
$to = 360; | |
$figure_lenght = 4; | |
$pic_one_row = 3; | |
$file_prefix = "output_"; | |
$file_extension = ".jpg"; | |
$output_folder = "./result/"; | |
$output_index = 1; |
This file contains 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
/** | |
* sanitize utf8mb4 characters | |
*/ | |
function _utf8_4byte_to_3byte($input) { | |
if (!empty($input)) { | |
$utf8_2byte = 0xC0 /*1100 0000*/; $utf8_2byte_bmask = 0xE0 /*1110 0000*/; | |
$utf8_3byte = 0xE0 /*1110 0000*/; $utf8_3byte_bmask = 0XF0 /*1111 0000*/; | |
$utf8_4byte = 0xF0 /*1111 0000*/; $utf8_4byte_bmask = 0xF8 /*1111 1000*/; | |
$sanitized = ""; |
This file contains 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
/** | |
* Send a POST requst using cURL | |
* @param string $url to request | |
* @param array $post values to send | |
* @param array $options for cURL | |
* @return string | |
*/ | |
function curl_post($url, array $post = NULL, array $options = array()) | |
{ | |
$defaults = array( |