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
import binascii | |
import struct | |
def pronto2lirc(pronto): | |
codes = [long(binascii.hexlify(pronto[i:i+2]), 16) for i in xrange(0, len(pronto), 2)] | |
if codes[0]: | |
raise ValueError('Pronto code should start with 0000') | |
if len(codes) != 4 + 2 * (codes[2] + codes[3]): | |
raise ValueError('Number of pulse widths does not match the preamble') |
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
# put this in your bash profile (change the line below if you use .bash_profile) | |
# refresh profile on USR1 signal | |
trap 'eval $(PATH= /usr/libexec/path_helper -s) && source ~/.profile' USR1 | |
# send USR1 signal to all bash instances | |
reload() { | |
ps -xo pid,command | grep ' \-bash' | awk '{print $1}' | while read pid; do | |
kill -USR1 $pid | |
done |
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
// fun experiment :-) | |
Element.implement('wait', function(duration){ | |
var el = this, stack = []; | |
stack.each.delay(duration || 500, stack, function(info){ | |
el = el[info.name].apply(el, info.args); | |
}); | |
return Object.map(Element.prototype, function(method, name){ |
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
Class.Mutators.jQuery = function(name){ | |
var self = this; | |
jQuery.fn[name] = function(arg){ | |
var instance = this.data(name); | |
if ($type(arg) == 'string'){ | |
var prop = instance[arg]; | |
if ($type(prop) == 'function'){ | |
var returns = prop.apply(instance, Array.slice(arguments, 1)); | |
return (returns == instance) ? this : returns; | |
} else if (arguments.length == 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
// a suggestion to Objective-J for better performance | |
var HTMLEntities = { | |
'&': '&', | |
'"': '"', | |
"'": ''', | |
'<': '<', | |
'>': '>' | |
}; |
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
// Puncture a closure, absolute madness | |
Function.prototype.puncture = function(){ | |
var wormhole = function(__cmd__){ | |
return eval(__cmd__); | |
}; | |
var source = ('' + this).match(/function.+?\{([\s\S]*)\}/)[1]; | |
var fn = new Function('this.wormhole=' + wormhole + '\n' + source); |
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
Function.stab(function(){ | |
Array.from(document.html.childNodes); | |
}, function(){ | |
var old = Array.from; | |
Array.from = function(item, slice){ | |
if (typeOf(item) == 'collection'){ | |
var l = item.length, array = new Array(l - slice), i = slice; | |
while (i++ < l) array[i - slice] = item[i]; | |
return array; | |
} |
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
Request.Twitter = new Class({ | |
Extends: Request.JSONP, | |
options: { | |
linkify: true, | |
url: 'http://twitter.com/statuses/user_timeline/{term}.json', | |
data: { | |
count: 5 | |
} |
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
// set the class of a jQuery collection | |
jQuery.fn.setClass = function(className){ | |
return this.each(function(){ | |
this.className = className || ''; | |
}); | |
}; |
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
// adds in support for having just msxml.dll, see issue #739 on -core | |
Browser.Request = function(){ | |
return $try(function(){ | |
return new XMLHttpRequest(); | |
}, function(){ | |
return new ActiveXObject('MSXML2.XMLHTTP'); | |
}, function(){ | |
return new ActiveXObject('Microsoft.XMLHTTP'); | |
}); |
NewerOlder