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 / gist:5558889
Created May 11, 2013 04:27
Sample BitBucket payload for hook services
{
"canon_url": "https:\/\/bitbucket.org",
"commits": [
{
"author": "mauris",
"branch": "master",
"files": [
{
"file": "test",
"type": "added"
@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 / git-deletealltags.bat
Created April 28, 2013 03:05
Script to delete all git tags remotely and locally on Windows Command Batchfile. Based on https://gist.github.com/matthewmccullough/898798
@echo off
for /F %%G IN ('git tag') DO git push origin :%%G && git tag -d %%G
@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 / 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 / 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 / gist:3629548
Created September 5, 2012 02:49
Generating Random even or odd number using mt_rand and bitshifting
<?php
$randomValue = mt_rand();
$even = $randomValue & ~1;
$odd = $randomValue | 1;
// magical unicorn isn't it?
@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 / 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;
};