Skip to content

Instantly share code, notes, and snippets.

View findzen's full-sized avatar

Justin Taylor findzen

  • Los Angeles, CA
View GitHub Profile
@findzen
findzen / gist:3708434
Created September 12, 2012 17:32
git shortcuts
#### GIT ####
alias ga='git add'
alias gp='git push'
alias gl='git log'
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias gm='git commit -m'
alias gma='git commit -am'
alias gb='git branch'
@findzen
findzen / cookie.js
Created July 24, 2012 22:59
Cookie
@findzen
findzen / gist:2765591
Created May 22, 2012 00:11
Parse Twitter RSS feed and cache using SimplePie
<?php
require_once 'lib/simplepie.inc';
require_once 'lib/json_format.php';
$response = array(
'tweets' => parse_feed( 'http://search.twitter.com/search.atom?q=from%3acnnbrk+OR+from%3anpratc' )
);
function parse_feed( $url )
@findzen
findzen / gist:2763272
Created May 21, 2012 16:58
StorageRoom webhook test
<?php
$file = fopen( 'test.json', 'w' ) or die( 'Failed to open file' );
$json = file_get_contents( 'php://input' );
fwrite( $file, $json ) or header( 'HTTP/1.1 500 Internal Server Error' );
fclose( $file );
/* EOF */
@findzen
findzen / gist:1731354
Created February 3, 2012 17:46
History.js HTML4 / HTML5 parity
// save hash value for HTML5 browsers arriving to site via HTML4 hashed url
// this should be done before $(document).ready and History.js is loaded
window.initHash = window.location.hash;
$(document).ready(function() {
var baseURL = History.getBaseUrl(),
currentURL = History.getState().url,
relativeURL = currentURL.replace( baseURL, '' );
if ( !Modernizr.history && currentURL !== baseURL ) {
@findzen
findzen / hash.js
Created January 23, 2012 19:47
hash generator
var hash = function(s){
var n;
if (typeof(s) == 'number' && s === parseInt(s, 10)){
s = Array(s + 1).join('x');
}
return s.replace(/x/g, function(){
var n = Math.round(Math.random() * 61) + 48;
n = n > 57 ? (n + 7 > 90 ? n + 13 : n + 7) : n;
return String.fromCharCode(n);
});
@findzen
findzen / Array.max
Created December 7, 2011 22:03
Array.max
// returns max value in array
Array.max = function(array) {
return Math.max.apply(Math, array);
}
@findzen
findzen / Array.shuffle.js
Created December 7, 2011 21:52
Array shuffle
Array.shuffle = function(array) {
var tmp, current, top = array.length;
if(top) while(--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
@findzen
findzen / .htaccess
Created November 14, 2011 23:58
refer all requests to index.php (Apache)
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
@findzen
findzen / gist:1358706
Created November 11, 2011 18:00
base href
<?php
define('BASE_HREF', '//' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/');
?>
<base href="<?=BASE_HREF?>" />