Skip to content

Instantly share code, notes, and snippets.

View davidguttman's full-sized avatar

David Guttman davidguttman

View GitHub Profile
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 October 21, 2010 22:58
raphael path svg string
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 04:52
TwitterChimes Part 2 - 01
#/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 06:42
TwitterChimes Part 2 - index.html 01
<!-- /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>
class Time
def to_half_hour_start
if self.min >= 30
self.to_hour_end - 30.minutes
else
self.to_hour_start
end
end
 vget: (name) ->
   if @has name
     @get name
   else
     @[name]()
@davidguttman
davidguttman / deploy_rails_app_on_ubuntu.md
Created October 18, 2011 06:11 — forked from he9lin/deploy_rails_app_on_ubuntu.md
Setup Rails application production environment on Ubuntu

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 October 26, 2011 22:17
quick render bench for backbone (and coffeescript)
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 November 9, 2011 15:37 — 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)
// 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.
*/
# 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