Skip to content

Instantly share code, notes, and snippets.

View adeolaawoyemi's full-sized avatar
🏠
Working from home

Adeola Awoyemi adeolaawoyemi

🏠
Working from home
  • Yahoo
  • San Jose, CA
View GitHub Profile
sub new {
my $self = shift;
my $args = @_ && ref $_[0] eq 'HASH' ? shift : { @_ };
my $class = ref($self) || $self;
return bless $args, $class;
}
@adeolaawoyemi
adeolaawoyemi / no_plan.pl
Created February 7, 2011 10:27
creating a test w/o a plan
#!/opt/local/bin/perl
use strict;
use warnings;
use Test::More;
my $name = 'barney';
my $status = 'in trouble';
ok($name, 'we have $name');
isnt($name, '', "\$name isn't empty");
@adeolaawoyemi
adeolaawoyemi / getName.js
Created February 17, 2011 12:54
function to get a Function's name
Object.prototype.getName = function() {
var funcNameRegex = /function (.{1,})\(/;
var results = (funcNameRegex).exec((this).constructor.toString());
return (results && results.length > 1) ? results[1] : "";
};
@adeolaawoyemi
adeolaawoyemi / gist:909587
Created April 8, 2011 10:02
callBabel with object_property_filter
getPhotoWithTransformations : function(id, forceFetch)
{
if(forceFetch || !(photo = pbx.babel.photos[id]))
{
photo = pbx.babel.callBabel('Community.Photo.Fetch', {
objectid : id,
object_property_filter : ['transformation', 'is_edited']
//object_property_filter : { ':default' : { ':standard' : 't', 'transformation' : 'r', 'is_edited' : 'r' } }
}).response;
pbx.babel.photos[id] = photo;
@adeolaawoyemi
adeolaawoyemi / gist:1231640
Created September 21, 2011 09:14
wait for jQuery before using it to bind
var bindTimer = setInterval(function() {
if ("undefined" != typeof jQuery && isMobileDevice) {
$('.myclass').bind('click', clickHandlerToMobilePage);
clearTimeout(bindTimer);
}
}, 50);
@adeolaawoyemi
adeolaawoyemi / gist:2032887
Created March 14, 2012 00:14
clearfix micro hack
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:table;
}
.cf:after {
clear:both;
}
@adeolaawoyemi
adeolaawoyemi / reset.css
Created March 20, 2012 23:55
HTML5 CSS Reset
/*
html5doctor.com Reset Stylesheet
v1.6.1
Last Updated: 2010-09-17
Author: Richard Clark - http://richclarkdesign.com
Twitter: @rich_clark
*/
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
@adeolaawoyemi
adeolaawoyemi / gist:2143454
Created March 21, 2012 01:32
jQuery latest
http://code.jquery.com/jquery-latest.js
@adeolaawoyemi
adeolaawoyemi / gist:2933733
Created June 15, 2012 00:02
Simulate keypress usnig javascript (doesn't work in Safari or Chrome)
var elem = (document.getElementsByClassName('mentionsTextarea'))[0];
elem.value = 'www.youtube.com';
elem.blur();
elem.value += ' ';
var evt = document.createEvent('KeyboardEvent');
evt.initKeyEvent(
'keypress',
true, // key down events bubble
true, // and they can be cancelled
null, // Use the default view
@adeolaawoyemi
adeolaawoyemi / gist:2954331
Created June 19, 2012 13:50
Automatically select all text in a TextField when user clicks inside it
my_tf.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
my_tf.addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
function onFocusIn(event:FocusEvent):void {
setTimeout(event.target.setSelection, 50, 0, event.target.text.length);
}
function onFocusOut(event:FocusEvent):void {
event.target.setSelection(0,0);
}