Skip to content

Instantly share code, notes, and snippets.

View soldair's full-sized avatar

Ryan Day soldair

  • Google
  • San Jose CA
View GitHub Profile
#!/bin/sh
#rotate android 3gp video and transcode to mp4
# mit / gpl and all that
# copyright 2010 ryan day, ryanday.org
#
#NOTE: OGG CONVERSION IS FAILING FOR SOME REASON
#
#PURPOSE:
# to rotate and transcode a 3gp/h.263 video, amr audio to mp4/h.264 , mp3 audio
# to take the mp4 and make a compatable
/* CPA LEAD AD NERF - stop cpa lead embedded ad widgets
copyright 2010 ryan day
http://ryanday.org
mit /gpl and all that
*/
/*
a co worker ran into a real ugly ad server that binds all sorts of unload callbacks and uses bad messaging in the onbefore unload confirmation box that would cause you to stay instead of leave. All to try and keep flashing ads in your face.
the source:
<?php
/*php enable gzip ... safely function.
Sometimes its hard to guarantee that output has not been started and that output has not already been written to a buffer. most of the time you are asked to make a site perform better and they want it now.
copyright ryanday 2010
http://ryanday.org
mit/lgpl and all that
this function will only start gzip if it can.
this function will take the contents of all currently active output buffers and echo their contents after gzip headers have been set into the gzip buffer.
/* async method chaining pattern jquery reflection.
this a en example of how to reflect the jquery / any object into a proxy and use
async method chaining pattern is discussed here by dustin diaz of twitter
http://www.dustindiaz.com/async-method-queues/
*/(function($){
var Queue = function(chain){this.q = chain||[]};
Queue.prototype = {
q:[],
<?php /*quick and useful benchmarking static class
copyright Ryan Day 2010
http://ryanday.org
lgpl
USE:
bench::mark('all');
sleep(1);
bench::mark('app');
<?php /*mongodb custom php session handler
copyright 2010 ryan day
lgpl
*/
$mongo = new Mongo();
//MongoSession::setConfig('collection','session_test');
$mongo_session = new MongoSession($mongo);
/*javascript rank password function
copyright ryanday 2010
mit/gpl license
feel free to use and include as long as the code retains the above copyright. =)
PURPOSE:
i needed to present users with a password quality visual alert on keyup for the password on a registration form. this is the core function with no depends
USE://jquery example
@soldair
soldair / pecl_install_memcached.sh
Created March 12, 2011 01:05
install memcached php extension on openSuse
#assumed su
pecl install -B memcached
if [ -d "/usr/share/php5/PEAR/pear/download" ]
then
# openSuse 11.3
cd /usr/share/php5/PEAR/pear/download
cd `ls | grep memcached`
else
# openSuse 11.2
cd /usr/local/
@soldair
soldair / bench.php
Created June 28, 2011 21:26
fastest way to get a hash based on the githash in php
<?php
/*
~>php bench.php
md5_file 634.3932 ms
hash_file/md5 714.4802 ms
parse contents 911.6130 ms
parse contents substr 852.8361 ms
contents first chunk 590.0660 ms
all ran with 30000 itterations
@soldair
soldair / arraycopyutil.js
Created October 25, 2011 01:45
copy, appendTo and appendToCopy for js arrays
var cpy = function(a){return Array.prototype.slice.call(a)}
,appendTo = function(b,a){var c = cpy(b);c.unshift(a.length,0);a.splice.apply(a,c);return a}
,appendToCopy = function(b,a){return appendTo(b,cpy(a))}
module.exports = {copy:cpy,appendTo:appendTo,appendToCopy:appendToCopy};