Skip to content

Instantly share code, notes, and snippets.

View chrisinajar's full-sized avatar

Chris Vickery chrisinajar

  • The Internet
  • Portland, OR
View GitHub Profile
This file has been truncated, but you can view the full file.
(function () {
var v = 0,
q = [],
o = {},
s = {},
A = {
"<": "lt",
">": "gt",
"&": "amp",
'"': "quot",
@chrisinajar
chrisinajar / gist:2510984
Created April 27, 2012 17:20 — forked from anonymous/gist:2510889
Issue with defining variable. first console logs correct result, second one shows unmodified variable
app.get('/canvas', function(req,res) {
database.activegalleries(function(results){
for (gallery in results){
var name = results[gallery]['gallery_name'];
database.viewgallery(name, function(imgs){
results[gallery]['imgs']=imgs;
console.log(results[gallery])
});
var doStuff = function(val, cb) {
// Call the callback later!
setTimeout(function() { cb(val); }, 1);
}
var total = 5;
for (var i = 0, c = 0; i < total; ++i) {
doStuff(i, function(val) {
console.log('Got a return value! ' + val);
@chrisinajar
chrisinajar / gist:2520170
Created April 28, 2012 16:48
stylus not working
app = express.createServer()
viewdir = __dirname + '/views'
staticdir = __dirname + '/static'
app.configure ->
app.use express.errorHandler({ dumpExceptions: true, showStack: true })
app.use express.logger()
app.use express.bodyParser()
@chrisinajar
chrisinajar / fizzbuzz.js
Created May 18, 2012 02:13
javascript fizzbuzz solution
// initialize string override sequence
var j,sp = {
s: String.prototype.toString,
l: function(){console.log(this.s());}
}, d=['F','B'], fd=function(l) {sp[l]=function(){return l+this;};};
// splines.reticulate
fd(d[0]);
fd(d[1]);
for(j in sp)
String.prototype[j] = sp[j];
park_trip_button_bind: function(park_id){
if (typeOf(park_id) == 'array'){
for (var i in park_id) (function(i) {
$("#tripadd_"+park_id[i]).bind('click',function(){
bp.add_remove_park_trip(park_id[i]);
});
})(i);
} else {
$("#tripadd_"+park_id).bind('click',function(){
bp.add_remove_park_trip(park_id);
@chrisinajar
chrisinajar / gist:3889750
Created October 14, 2012 20:38
better chat window
// Make a bookmark with this in it:
javascript:(function(){$("#button-chat-expand").click(function() {$("#chat").animate({top:0})}); $("#button-chat-collapse").click(function() {$("#chat").animate({top:285})});$("#chat").css($("#playback").position()).width(842);$("#chat-messages").width(823); $.each(document.styleSheets, function(i, styleSheet) { $.each(styleSheet.cssRules, function(j, rule) { if (rule.selectorText == '.chat-message, .chat-mention, .chat-emote, .chat-skip, .chat-moderation, .chat-system, .chat-update' || rule.selectorText == '.chat-superuser' || rule.selectorText == '.chat-moderator') rule.style.width = '788px'; })});})();
@chrisinajar
chrisinajar / gist:4556830
Last active December 11, 2015 06:08
bookmarklet to reload all CSS on a given page
javascript:(function() { $("link[rel='stylesheet']").each(function(i, node) {var map = {};$.each(node.attributes, function(i, node) {map[node.name.toLowerCase()] = node.value;});$("<link />", map).appendTo('head');$(node).remove();}) })()
@chrisinajar
chrisinajar / gist:5379848
Created April 13, 2013 20:01
Plug.DJ chat logger and log reader
// Basid plug.dj logger. Sloppy, doens't unlisten to events
(function() {
var load = function(name) {
try {
return JSON.parse(localStorage["_log_" + name]);
} catch (e) {
return null;
}
}
var save = function(name, value) {
@chrisinajar
chrisinajar / fib,js
Created July 1, 2013 18:12
Calculate Fibonacci Sequence
// calculate up until e
function fibb(e) {
var i = 0;
(function(le) {
return (function(f) {
return f(f);
}(function(f) {
return le(function(x) {
return f(f)(x);
});