Skip to content

Instantly share code, notes, and snippets.

View mauris's full-sized avatar
🟢
Get things done

Sam Y mauris

🟢
Get things done
View GitHub Profile
@mauris
mauris / hash32shiftmult.php
Created August 12, 2012 16:02
hash32shiftmult PHP port
function hash32shiftmult($key){
$seed = 0x27d4eb2d; // a prime or an odd constant
$key = ($key ^ 61) ^ ($key >> 16);
$key = $key + ($key << 3);
$key = $key ^ ($key >> 4);
$key *= $seed;
$key = $key ^ ($key >> 15);
return $key;
};
sudo npm i -g bower coffee-script cordova electron-packager electron-prebuilt express-generator forever grunt grunt-cli gulp static ionic jsdom-cli less mathjs q nodemon node-static ngist
@mauris
mauris / gist:3481335
Created August 26, 2012 16:03
Bitwise &= for multiple boolean checks
<?php
function op($d){
return $d;
}
$ok = true;
$ok &= op(true);
$ok &= op(true);
@mauris
mauris / gist:3649712
Created September 6, 2012 01:37
Distinctive Random Colour Generation
function randomColor($id){
$rawR = mt_rand(0, 10) * 25.5;
$rawG = mt_rand(0, 10) * 25.5;
$rawB = mt_rand(0, 10) * 25.5;
$mix = ceil(($id % 5) / 5 * 255);
$r = ceil(($rawR + $mix) % 255);
$g = ceil(($rawG + $mix) % 255);
$b = ceil(($rawB + $mix) % 255);
return str_pad(dechex(($r << 16) | ($g << 8) | $b), 6, '0', STR_PAD_LEFT);
@mauris
mauris / prng01.php
Created September 12, 2012 05:21
Pseudo Random Number Generation (PRNG) using Trigonometry
<?php
function prng01($min = null, $max = null){
if($min === null){
$min = 0;
}
if($max === null){
$max = PHP_INT_MAX;
}
static $seed = 3;
@mauris
mauris / test-agent
Created October 21, 2012 04:04
Test Agent - Pull, Detect, Test
#!/usr/bin/env php
<?php
if($argc > 1){
chdir($argv[1]);
}
echo "Test Agent\n";
echo "Updating repository...";
exec('git pull --quiet');
@mauris
mauris / sshkeyprep.sh
Created April 30, 2013 13:16
Prepare your SSH daemon for key exchange authentication!
# bootstrap
mkdir ~/.ssh
cd ~/.ssh
# create authorized_keys file
touch authorized_keys
# at this step, add authorized keys into the touch
# prepare file permissions
chmod 700 ~/.ssh/
@mauris
mauris / routing.yml
Created May 25, 2013 15:26
Sample Routing YAML for Packfire Framework 2.1
imports: null
prefix: null
routes:
home:
methods:
- get
- head
uri: "/{page}.{format}"
action: "Packfire\\Test\\Controller:action"
defaults:
@mauris
mauris / FileTree.js
Created November 15, 2016 14:41
Submission
/**
* This code was extracted from https://github.com/mauris/gitguard/blob/master/src/components/FileTree/index.js
* Using AngularJS, this 60-LoC file forms the controller neccessary for the frontend of a file tree component
* to be working.
*
* Whenever a folder from the list is selected, the code will request the server for the list of files in that path.
*/
const app = require('../../app');
let $controller = function ($http, $scope) {
export RUNFILE=BabyNames; javac $RUNFILE.java; for file in *.in; do java $RUNFILE < $file | diff ${file%.*}.out -; done