Skip to content

Instantly share code, notes, and snippets.

View daifu's full-sized avatar

Daifu Richard Ye daifu

View GitHub Profile
@daifu
daifu / app.js
Created May 31, 2013 21:41 — forked from johnkpaul/app.js
//in your application, rather than using window.location to get the current url
App.getLocation = function(){
return window.location.protocol + '//' + window.location.host
+ '/' + Backbone.history.options.root + Backbone.history.getFragment()
}
@daifu
daifu / LICENSE.txt
Created July 24, 2012 02:06 — forked from eliperelman/LICENSE.txt
String.prototype.trim polyfill for 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Eli Perelman http://eliperelman.com
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@daifu
daifu / _snippet.html
Created July 16, 2012 23:46 — forked from elijahmanor/_snippet.html
Differences Between jQuery .bind() vs .live() vs .delegate() vs .on() Methods
<ul id="members" data-role="listview" data-filter="true">
<!-- ... more list items ... -->
<li>
<a href="detail.html?id=10">
<h3>John Resig</h3>
<p><strong>jQuery Core Lead</strong></p>
<p>Boston, United States</p>
</a>
</li>
<!-- ... more list items ... -->
@daifu
daifu / orm.js
Created July 8, 2012 19:45 — forked from maccman/orm.js
orm.js
if (typeof Object.create !== "function")
Object.create = function(o) {
function F() {}
F.prototype = o;
return new F();
};
var Model = {
init: function(){ },
@daifu
daifu / juggernaut_heroku.md
Created July 8, 2012 19:43 — forked from maccman/juggernaut_heroku.md
Juggernaut on Heroku

Clone repo:

git clone git://github.com/maccman/juggernaut.git
cd juggernaut

Create Heroku app:

heroku create myapp --stack cedar
heroku addons:add redistogo:nano

git push heroku master

@daifu
daifu / hr.less
Created July 8, 2012 19:39 — forked from maccman/hr.less
HR CSS3 Tapering
/* See http://cl.ly/8KmQ for an example */
hr {
margin: 15px 0;
position: relative;
border: 1px solid transparent;
.box-shadow(0, 1px, 2px, rgba(0,0,0,0.3));
&:before, &:after {
content: "";
@daifu
daifu / juggernaut_channels.rb
Created July 8, 2012 09:26 — forked from maccman/juggernaut_channels.rb
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@daifu
daifu / app.rb
Created July 8, 2012 09:25 — forked from maccman/app.rb
Sinatra Async UI chat
#!/usr/bin/env ruby
# coding: utf-8
require 'sinatra'
set :server, 'thin'
set :sessions, true
streams = Hash.new {|k, v| k[v] = [] }
helpers do
def session_id
@daifu
daifu / grid-toggle.js
Created July 7, 2012 18:11 — forked from adamstac/grid-toggle.js
Create, show, and hide grid toggle with jQuery
$(document).ready(function() {
// Create, show, and hide grid toggle
$('body').append('<div id="grid"></div>');
$('body').append('<a href="#" class="toggle-grid"><span class="show">Show Grid</span><span class="hide">Hide Grid</span></a>');
$('a.toggle-grid').toggle(function() {
$('#grid').slideDown('fast');
$('.toggle-grid .hide').show();
$('.toggle-grid .show').hide();
}, function() {