๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = { | |
business: { | |
id: 123, | |
service: "Cleaners", | |
name: "Weeoo", | |
user: { | |
id: 987, | |
name: "Jeff Smith" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof Function.prototype.curry === 'undefined') { | |
Function.prototype.curry = function() { | |
var func = this | |
, a = Array.prototype.slice.call(arguments, 0) | |
return function () { | |
var a_len = a.length | |
, length = arguments.length | |
while (length--) | |
a[a_len + length] = arguments[length] | |
return func.apply(this, a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* loadJSONP( url, hollaback [, context] ) -> Null | |
* - url (String): URL to data resource. | |
* - hollaback (Function): Function to call when data is successfully loaded, | |
* it receives one argument: the data. | |
* - context (Object): Context to invoke the hollaback function in. | |
* | |
* Load external data through a JSONP interface. | |
* | |
* ### Examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Many times, when creating a site, I need hidden elements on a page that I must later make visible. Of course it would | |
be great if one could simply hide them via CSS, and later [easily] show them via javascript. However this is not the | |
case, javascript has some difficulties overriding styles set in a stylesheet. So, I've found the best way to | |
accomplish this is to use a combo of CSS and javascript in a two-step process: | |
1. Hide the elements via CSS class โ so they are hidden when the user first sees the page | |
2. Hide the elements via javascript and remove the corresponding CSS class, after the DOM has loaded. | |
The second step has the potential to be quite expensive on the DOM, but I feel that it's an acceptable trade-off | |
because the elements in question are already hidden. This way they are ready to be manipulated, one doesn't need to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to get the iframe document object | |
// Assume 'iframe' is a variable to the iframe DOM element | |
var iframe_document = null; | |
if (iframe.contentDocument) iframe_document = iframe.contentDocument; | |
else if (iframe.contentWindow) iframe_document = iframe.contentWindow.document; | |
else if (iframe.document) iframe_document = iframe.document; | |
else throw(new Error("Cannot access iframe document.")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.observe('dom:loaded', function() { | |
$$('input[tabindex="1"]')[0].focus(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
License: latest LGPL :D | |
As per my discussion with Gianni (@gf3), | |
http://twitter.com/phillmv/status/2659984348 | |
http://twitter.com/phillmv/status/2660026344 | |
http://twitter.com/phillmv/status/2660059102 | |
http://twitter.com/phillmv/status/2660184885 | |
http://twitter.com/phillmv/status/2660283856 and | |
http://twitter.com/phillmv/status/2660306850 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Proposed syntax for IRC bot | |
// --------------------------- | |
jerk(function() { | |
// `watch_for` takes a regular expression, and matches it against everything that is said | |
watch_for(/^api (\w+)\.(\w+)/, function(message) { | |
// Message object has properties: match_data, channel, user, text | |
// `say` replies in the channel that the message was heard in | |
say(message.user.nick + ": Something " + message.match_data[1]); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Truncate a string to the closest word | |
String.prototype.truncateToWord = function( length ) { | |
return this | |
.slice( 0, length + 1 ) | |
.split( /\s+/ ) | |
.slice( 0, -1 ) | |
.join( " " ) | |
} | |
// Examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
so my workflow is that each ticket gets a branch. Before merging the branch to master | |
it needs to be peer-reviewed. So sometimes I have a bunch of branches that are off | |
being reviewed while I work on something else. | |
Currently when I run "git branch" I see: | |
[branch 1] | |
[branch 2] | |
[branch 3] | |
*[branch 4] | |
[branch 5] |