Skip to content

Instantly share code, notes, and snippets.

View gf3's full-sized avatar
๐ŸŠ
workin' goodly

Gianni Chiappetta gf3

๐ŸŠ
workin' goodly
View GitHub Profile
@gf3
gf3 / prototype-doc-workflow.txt
Created February 16, 2010 17:28 — forked from dandean/prototype-doc-workflow.txt
Prototype documentation workflow
#####
## INITIAL CONFIGURATION
#####
# Fork sstephenson/prototype on GitHub
# Go to this url and click the fork button. This will create a prototype
# repository under your GitHub account.
http://github.com/sstephenson/prototype
%h1.lol
NO U
@gf3
gf3 / getHtml.fuse.js
Created February 4, 2010 20:14
getHTML
(function($, doc) {
var getHTML = function getHTML() {
return $.String(this.raw.outerHTML);
};
if (!('outerHTML' in doc.documentElement)) {
var dummy = doc.createElement('html');
getHTML = function getHTML() {
dummy.appendChild(this.raw.cloneNode(true));
var result = dummy.innerHTML;
@gf3
gf3 / prototype.konami.js
Created December 18, 2009 13:02
KONAMI cheat code for your site!
// Example
document.observe("lol:konami", function() {
$(document.body).insert(new Element('h1').update("KONAMI!!!").setStyle({fontWeight: "bold", color: "red"}));
});
@gf3
gf3 / description.txt
Created December 18, 2009 07:12 — forked from mislav/description.txt
Git Workflow
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]
@gf3
gf3 / gist:166083
Created August 11, 2009 20:09
Truncate a string to the closest word
// 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
@gf3
gf3 / gist:156663
Created July 27, 2009 18:19
Proposed syntax for IRC bot
// 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]);
});
=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
document.observe('dom:loaded', function() {
$$('input[tabindex="1"]')[0].focus();
});
@gf3
gf3 / gist:146218
Created July 13, 2009 16:02
Get the iframe document object
// 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."));