Skip to content

Instantly share code, notes, and snippets.

View OscarGodson's full-sized avatar
:shipit:
Workin'

Oscar Godson OscarGodson

:shipit:
Workin'
  • CTO
  • Portland, OR
  • 22:43 (UTC -07:00)
View GitHub Profile
jQuery(function(){
jQuery('.lcp_catlist li a')
//Set up the imgs for the green overlay
.find('img').css({
position:'relative',
zIndex:'1',
height: '120px',
width: '120px'
})
//Back to the <a>s
@OscarGodson
OscarGodson / makemyvideobigger.js
Created June 20, 2011 18:07
Tumblr + Vimeo Mod To Make Videos Larger Than 500
/**
* Makes Vimeo videos on Tumblr larger than the max of 500px that Tumblr forces
* Change the 650 to whatever you want, but do NOT add px or %
* The height, by default, is set to auto which will calculate the 16:9 video size.
* You can set the height to a static number as well if you want.
* If you have any questions feel free to ask me: @oscargodson | oscargodson.com
*/
(function(){
var iframes = document.body.getElementsByTagName('iframe')
, newVimeoWidth = 650
var str = "" +
"First line goes here" +
"Second line goes here" +
"and now the third" +
"and hell, let's throw in this line" +
"while we're at it" +
"";
var parseTemplate = function(s,j){
for(x in j){ var r = new RegExp('{{'+x+'}}','g'); s = s.replace(r,j[x]); }
return s;
}
@OscarGodson
OscarGodson / multiple-expressions-ternary.js
Created September 12, 2011 18:29
Multiple expressions in the ternary operator
//NOTE: don't use semicolon inside a ternary, use a comma like so:
x == 1 //If x == 1
? alert(x) //Alert 1
:( //Else...
alert('Error'), //alert an error
x = 1, //Change x to 1
alert('All Fixed!') //Alert the user again, say it's fixed
);
var list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
list = list.sort(function(){
return Math.random() - 0.5;
});
alert(list);
@OscarGodson
OscarGodson / parseUrl.js
Created September 16, 2011 05:42
Parses a URL and returns a JS obj of key->value pairs with the URL params
var parseUrl = function(url){
var q = {}
, r = new RegExp("([^?=&]+)(=([^&]*))?", "g");
url.replace(r,function($0, $1, $2, $3){ q[$1] = $3; });
return q;
}
/**
* var example = parseUrl('http://google.com?foo=bar&hello=world');
*
@OscarGodson
OscarGodson / bacon.js
Created September 16, 2011 18:52
How to eat bacon with JavaScript
var bacon = new Bacon('hickory');
bacon.cook(function(cookedBacon){
cookedBacon.nom();
});
@OscarGodson
OscarGodson / fakejax.js
Created September 21, 2011 19:03
A quick and dirty way to prototype AJAX
/**
* fakejax is a simple way to prototype AJAX. It will give you a random response time of 0-3 seconds
* and it will also give you a 1 in 10 chance of returning an error
* @param {String} dummyCall This is the fake path like "/api/users"
* @param {Object} returnThis This is what you want it to return if it's successful like {data:'hi'}
* @param {Function} callback This is the callback to your AJAX after it completes
* @example http://jsbin.com/oguyoz/5
*/
var fakejax = function(dummyCall,returnThis,callback){
dummyCall = dummyCall || '';