Skip to content

Instantly share code, notes, and snippets.

David Guttman davidguttman

Block or report user

Report or block davidguttman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:627112
function Refresher (opts) {
if (! (this instanceof arguments.callee)) {
return new arguments.callee(arguments);
}
var self = this;
self.settings = {
interval: opts.interval || 5*60*1000
};
@davidguttman
davidguttman / gist:639541
Created Oct 21, 2010
raphael path svg string
View gist:639541
points_to_svg_string: function(points) {
if (!points[0]) {
return "";
}
var svg_string = "M" + points[0][0] + " " + points[0][1];
for (var i = 1; i < points.length; i++) {
var x = points[i][0],
y = points[i][1];
svg_string = svg_string + "L" + x + " " + y;
}
@davidguttman
davidguttman / script.coffee
Created May 10, 2011
TwitterChimes Part 2 - 01
View script.coffee
#/public/js/script.coffee
# Let's create an empty object to store our stuff
TC = {}
# A method to setup our socket
TC.init_socket = ->
@socket = new io.Socket "localhost", port: 3010
@socket.on "message", @handle_message
@socket.connect()
@davidguttman
davidguttman / index.html
Created May 10, 2011
TwitterChimes Part 2 - index.html 01
View index.html
<!-- /public/index.html -->
...
<script src="/js/libs/jquery-1.5.2.js"></script>
<script src="/socket.io/socket.io.js"></script>
<!-- New Friends -->
<script src="/js/libs/processing-1.1.0.js"></script>
<script src="/js/libs/soundmanager2.js"></script>
View gist:1150534
class Time
def to_half_hour_start
if self.min >= 30
self.to_hour_end - 30.minutes
else
self.to_hour_start
end
end
View gist:1254931
 vget: (name) ->
   if @has name
     @get name
   else
     @[name]()
@davidguttman
davidguttman / deploy_rails_app_on_ubuntu.md
Created Oct 18, 2011 — forked from he9lin/deploy_rails_app_on_ubuntu.md
Setup Rails application production environment on Ubuntu
View deploy_rails_app_on_ubuntu.md

Setup Rails application production environment on Ubuntu

Add deploy user

ssh root@YOURDOMAIN
adduser deploy
visudo # Add deploy ALL=(ALL) ALL

Install necessary libraries

@davidguttman
davidguttman / gist:1318185
Created Oct 26, 2011
quick render bench for backbone (and coffeescript)
View gist:1318185
old_render = @render
@render = =>
t0 = new Date()
ret = old_render()
t1 = new Date()
t = t1 - t0
window.benches or= {}
window.benches.rows or= []
window.benches.rows.push t
@davidguttman
davidguttman / perlin-noise-classical.js
Created Nov 9, 2011 — forked from banksean/perlin-noise-classical.js
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
View perlin-noise-classical.js
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
View view_loader.coffee
# ViewLoader will load a list of partial views/templates from a json list (default is '/views/view_list.json'). Each view will be appended to the page in <script type="text/template"> tags with the id of the filename. One they have all been appended, the callback will be called.
class window.ViewLoader
constructor: (opts={}, @callback) ->
if (typeof opts) == "function"
@callback = opts
opts = {}
else
@callback = opts.success
@opts = opts
You can’t perform that action at this time.