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
<? | |
function aes128_cbc_encrypt($key, $data, $iv) { | |
if(16 !== strlen($key)) $key = hash('MD5', $key, true); | |
if(16 !== strlen($iv)) $iv = hash('MD5', $iv, true); | |
$padding = 16 - (strlen($data) % 16); | |
$data .= str_repeat(chr($padding), $padding); | |
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); | |
} |
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 math | |
def convertSize(size): | |
size_name = ("B","KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") | |
i = int(math.floor(math.log(size,1024))) | |
p = math.pow(1024,i) | |
s = round(size/p,2) | |
if (s > 0): | |
return '%s %s' % (s,size_name[i]) | |
else: |
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
#user nobody; | |
#Defines which Linux system user will own and run the Nginx server | |
worker_processes 1; | |
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores. | |
#error_log logs/error.log; #error_log logs/error.log notice; | |
#Specifies the file where server logs. |
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
# Ubuntu 14 | |
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb | |
sudo dpkg -i puppetlabs-release-trusty.deb | |
sudo apt-get update | |
apt-get install puppetmaster | |
puppet -V | |
sudo puppet apply --modulepath ./modules manifests/default.pp |
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
$ for f in *.wav; do ffmpeg -i $f "${f%.*}.mp3"; done |
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 json | |
import pyexiv2 | |
import os | |
import shutil | |
from models import StorageVolume | |
STORAGE_CONFIG = { | |
'bits_levels': [ 2, 1 ], | |
'volumes': [ |
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
set -g default-terminal "screen-256color" | |
set -g mode-mouse on | |
set-window-option -g mode-mouse on | |
set -g mouse-resize-pane on | |
set -g mouse-select-pane on | |
set -g mouse-select-window on | |
set -g base-index 1 | |
set -g status-utf8 on | |
set -g status-keys vi | |
set -g status-interval 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
function sendCORSRequest(url, method) | |
{ | |
// IE8+ only Cross domain JSON GET request | |
if ('XDomainRequest' in window && window.XDomainRequest !== null) { | |
var xdr = new XDomainRequest(); // Use Microsoft XDR | |
xdr.open('get', url); | |
xdr.onload = function (data) { | |
var dom = new ActiveXObject('Microsoft.XMLDOM'), | |
json = $.parseJSON(xdr.responseText); |
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
Convert every *.jpg into a thumbnail with 85% quality and size 125 x Auto, named tn-{originalfilename} | |
$ for file in *.jpg; do convert $file -thumbnail 125x -quality 85 tn-$file; done | |
$ for file in *.jpg; do convert $file -resize 800x600\! $file; done | |
Get screenshot from video frame | |
$ ffmpeg -ss 00:09:00 in.avi -vcodec png -vframes 1 -an -f rawvideo -s 119x64 out.png | |
or | |
$ffmpeg -ss 00:09:00 in.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 119x64 out.jpg |
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
var mysql = require('mysql'); | |
var toMarkdown = require('to-markdown').toMarkdown; | |
var fs = require('fs'); | |
var os = require('os'); | |
var connection = mysql.createConnection({ | |
host : 'localhost', | |
user : 'user', | |
password : 'password', | |
database : 'database' |