Skip to content

Instantly share code, notes, and snippets.

View appden's full-sized avatar

Scott Kyle appden

View GitHub Profile
@appden
appden / pronto2broadlink.py
Last active July 16, 2023 18:43
Convert Pronto IR hex codes to LIRC pulses then Broadlink packets compatible with python-broadlink
@appden
appden / reload.bash
Created March 27, 2011 18:27
Reload your bash profile in all open bash instances
# 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
// 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){
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){
// a suggestion to Objective-J for better performance
var HTMLEntities = {
'&': '&',
'"': '"',
"'": ''',
'<': '&lt;',
'>': '&gt;'
};
// 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);
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;
}
Request.Twitter = new Class({
Extends: Request.JSONP,
options: {
linkify: true,
url: 'http://twitter.com/statuses/user_timeline/{term}.json',
data: {
count: 5
}
// set the class of a jQuery collection
jQuery.fn.setClass = function(className){
return this.each(function(){
this.className = className || '';
});
};
// 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');
});