Skip to content

Instantly share code, notes, and snippets.

@fojas
fojas / rAF.js
Created May 23, 2012 14:37 — forked from ethertank/rAF.js
requestAnimationFrame / cancelAnimationFrame
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
// little saving...
(function(w, a, b, af, x, lastTime, v) {
var c = "c" + a,
@fojas
fojas / redis-server
Created March 15, 2012 18:57 — forked from tessro/redis-server
A CentOS initscript for Redis
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.redis.redis-server</string>
<key>Program</key>
<string>/usr/local/redis/bin/redis-server</string>
<key>ProgramArguments</key>
@fojas
fojas / blockit.js
Created August 19, 2011 23:50
Flying block
(function($){
$.extend($.fn,{
blockit: function(options){
new BlockIt(this, options);
return this;
}
});
var BlockIt = function(el, options){
var options = options || {},
@fojas
fojas / wth_sort
Created April 14, 2011 05:23
my other confusing sort
function wth_sort(k){
for(var l,p=(l=k.slice()).shift(),m={},n=((m['true']=[])&&(m['false']=[]));l.length;)m[l[0]>p].push(l.shift());
return (p&&arguments.callee(m[!1]).concat(p).concat(arguments.callee(m[!0])))||k;
}
@fojas
fojas / wtf_sort
Created April 14, 2011 03:55
my confusing sort
function wtf_sort(llll){
for(var l1ll=llll.length;l1ll;)
for(var l11l,ll1l=(l11l=llll.length)-(l1ll--);(l11l--)-(ll1l);(llll[l11l]<llll[l11l-1])?llll[l11l]=(llll[l11l-1]^=llll[l11l]^=llll[l11l-1])^llll[l11l]:l11l);
return llll;
}
// listener object for attaching functions to be called after events
/**
* listener - Singleton. used to subscribe to and fire events
*/
var listener = function(){
/**
* @param {Object} evts the container for all event listeners
* @private
*/
# Capistrano task for tailing logs on multiple servers
desc "tail log files, use '-s grep=[search text]' and '-s file=[file name]' to grep and tail specific file respectively"
task :tail_logs, :roles => :app do
set :grep, fetch(:grep, "")
set :file, fetch(:file,"~/current/log/production.log")
set(:g) { (grep == "") ? "" : " | grep #{grep}" }
run "tail -f #{file} #{g}" do |channel, stream, data|
#put hostname in front of each line
puts "#{data}".gsub( /(^)/i,"#{channel[:host]} \\1")
// jQuery extension for checking if css media query is supported
(function($){
$.mediaCheck = function (qry){
var ret,
style = document.createElement('style'),
id = 'mqc_'+Math.floor(Math.random()*100)+new Date().getTime(),
rules = document.createTextNode('@media '+qry+' {#'+id+'{visibility:hidden !important}}'),
head = $('head')[0];
body = $('body');