View sort.js
// From: https://stackoverflow.com/a/36079484
// The unsorted data
let data = {
a: 'A',
c: 'C',
b: 'B'
};
// Create it sorted
View example.php
<?php
$a = [
(object)['size' => 15, 'person' => (object)['name' => 'Andy', 'job' => 'developer'], 'pet' => 'dog'],
(object)['size' => 9, 'person' => (object)['name' => 'Candy', 'job' => 'stripper'], 'pet' => 'hamster'],
(object)['person' => (object)['name' => 'Bubbles', 'job' => 'painter'], 'pet' => 'fish'],
(object)['person' => (object)['name' => 'Bob', 'job' => 'Breeder'], 'pet' => 'hamster'],
(object)['person' => (object)['name' => 'Bob', 'job' => 'Bus conductor'], 'pet' => ''],
];
View gist:d366e76122f1ad32052d8b82dd2d516c
# first make sure MP4Box is install
sudo apt-get install gpac
# then run this from the command line
for i in *.h264; do MP4Box -add $i ${i%.*}.mp4; done
View volume.py
from RPi import GPIO
from time import sleep
import subprocess
clk = 5
dt = 6
btn = 26
# vals from output of amixer cget numid=1
min = 0
View .bashrc
# change the colour of the base directory depending on whether
# I'm in the live/staging/dev areas. Also show the user and host
# as well as the bash history number of the command.
C_DEV="\[\033[0;32m\]" # green
C_STAGE="\[\033[0;33m\]" # yellow
C_LIVE="\[\033[1;31m\]" # bold red
C_PATH="\[\033[0;37m\]" # white
C_COUNT="\[\033[0;36m\]" # cyan
C_NONE="\[\033[0m\]" # reset
View phprc
date.timezone = "Europe/London"
expose_php = 0
extension = phar.so
extension = fileinfo.so
extension = intl.so
suhosin.executor.include.whitelist = phar
[opcache]
zend_extension=opcache.so
View toner.js
/**
* Usage:
*
* <img src="pic.jpg" data-colour="blue" />
* <img src="pic.jpg" data-colour="green" data-contrast="40" />
* <img src="pic.jpg" data-colour="pink" data-brightness="30" />
* <img src="pic.jpg" data-colour="#ddc258" data-contrast="40" data-brightness="30" />
* <script>$(function(){ $(img['data-colour']).toner(); });</script>
*/
;(function ($, window, document, undefined) {
View char-word-count.js
$(function(){
var txt = $('.content')[0].text(),
charCount = txt.length,
wordCount = txt.replace(/[^\w ]/g, "").split(/\s+/).length;
$('#somwhereInYourDocument').text("The text had " + charCount + " characters and " + wordCount +" words");
});
View aspect-ratio.php
<?php
function ratio($a, $b)
{
$gcd = function($a, $b) use (&$gcd) {
return ($a % $b) ? $gcd($b, $a % $b) : $b;
};
$g = $gcd($a, $b);
return $a/$g . ':' . $b/$g;
}
View phpstorm.bat
@echo off
SET PhpStormPath=C:\Program Files (x86)\JetBrains\PhpStorm 8.0.2\bin\PhpStorm64.exe
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm" /t REG_SZ /v "" /d "Open in PhpStorm" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm" /t REG_EXPAND_SZ /v "Icon" /d "%PhpStormPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in PhpStorm\command" /t REG_SZ /v "" /d "%PhpStormPath% \"%%1\"" /f
echo Adding folder entries