Skip to content

Instantly share code, notes, and snippets.

@jimsynz
jimsynz / rebuild.rb
Created November 4, 2010 23:01
Rebuild static HAML and SASS files as changes are saved.
require 'rubygems'
require 'fssm'
monitor = FSSM::Monitor.new
monitor.path File.dirname(__FILE__) do
update do |base,relative|
# Why are they not strings?!?
base = base.to_s
relative = relative.to_s
extension = relative.split('.').last
@netzpirat
netzpirat / 0_README.md
Created November 12, 2010 10:42
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@jagregory
jagregory / gist:710671
Created November 22, 2010 21:01
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork git@github...my-fork.git
@dotmaster
dotmaster / gist:726802
Created December 3, 2010 10:23
hijacking Javascript console.log revamped with StackTrace (just Google Chrome)
// usage as usual: console.log('inside coolFunc',this,arguments);
if (typeof console !== "undefined") {
console.logJack = console.log;
window.log={}
window.log.history = window.log.history || {}; // store logs to a global history for reference
console.log=function(){
var timestamp= (new Date); //create a timestamp of the log
var millis=timestamp.getTime();
var readableString=timestamp.toUTCString();
@pguillory
pguillory / gist:729616
Created December 5, 2010 23:51
Hooking into Node.js stdout
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}
@koshigoe
koshigoe / mount-ram.sh
Created February 11, 2011 14:57
Like tmpfs in Mac OSX
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
@thelinuxlich
thelinuxlich / model.coffee
Created March 3, 2011 20:25
Sample Knockout.js model written in Coffeescript
# Modelo base
class @Model
constructor: (defaults,urls) ->
@__defaults = if typeof defaults is "object" then defaults else {}
@__urls = if typeof urls is "object" then defaults else {}
@set(@__defaults)
get: (attr) ->
ko.unwrapObservable @[attr]
function highlight(stackTraceDiv) {
//replace filenames to link
var text = stackTraceDiv.html();
var highlighted = text.replace(/[0-9a-z_A-Z\-\.\/]+:\d+/g, '<a class="ide-link" href="/?message=$&">$&</a>');
stackTraceDiv.html(highlighted);
//bind links click event
$('a.ide-link').click(function(e) {
e.preventDefault();
var url = $(this).attr("href");
@xjamundx
xjamundx / express-pagination.js
Created April 19, 2011 05:28
sample pagination using express route-specific middleware
// articles per page
var limit = 10;
// pagination middleware function sets some
// local view variables that any view can use
function pagination(req, res, next) {
var page = parseInt(req.params.page) || 1,
num = page * limit;
db.articles.count(function(err, total) {
res.local("total", total);
@chrishulbert
chrishulbert / SizableImageCell.m
Created April 21, 2011 06:18
Make a UITableViewCell with a resized image
@interface SizableImageCell : UITableViewCell {}
@end
@implementation SizableImageCell
- (void)layoutSubviews {
[super layoutSubviews];
float desiredWidth = 80;
float w=self.imageView.frame.size.width;
if (w>desiredWidth) {
float widthSub = w - desiredWidth;