Skip to content

Instantly share code, notes, and snippets.

@troy
troy / save-redfin-listing-images-bashrc
Created September 10, 2009 13:22
Given a redfin.com house listing URL, save all full-size images
# usage: redfin-images "http://www.redfin.com/WA/Seattle/123-Home-Row-12345/home/1234567"
function redfin-images() {
wget -O - $1 | grep "full:" | awk -F \" '{print $4}' | xargs wget -
}
@jrburke
jrburke / build.js
Created December 22, 2011 05:58
Doing multiple almond builds with a nodejs script, example
//Download jquery.js and place it in the build, do not use require-jquery.js
//in the build, since each of the build layers just needs almond and not the
//full require.js file.
//This file is run in nodejs to do the build: node build.js
//Load the requirejs optimizer
var requirejs = require('./r.js');
//Set up basic config, include config that is
//common to all the requirejs.optimize() calls.
@vybs
vybs / rhino_dust.java
Created January 17, 2012 02:15
Sample code to rendering dust template using Rhino
package com.linkedin.dust.renderer;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException;
@driehle
driehle / backbone-validation-bootstrap.js.coffee
Last active February 11, 2021 15:09
Render error messages of Backbone.Validation for Twitter Bootstrap
# --------------------------------------------
# This code is for Twitter Bootstrap 2!
# --------------------------------------------
#
# The MIT License (MIT)
# Copyright (c) 2012-2015 Dennis Riehle
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@msteiger
msteiger / GradientExtensionHandler.java
Created January 11, 2013 09:05
An ExtensionHandler for Apache Batik's svggen part that uses SVGGraphics2D to convert Swing drawing routines to SVG elements. Currently supports LinearGradientPaint and RadialGradientPaint. Feel free to comment and extend ..
import static org.apache.batik.util.SVGConstants.*;
import java.awt.Color;
import java.awt.LinearGradientPaint;
import java.awt.MultipleGradientPaint;
import java.awt.Paint;
import java.awt.RadialGradientPaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
@toolmantim
toolmantim / brunch_uglify.coffee
Last active December 13, 2015 18:58
Various configurations to ensure newlines are preserved in minified Javascript files. Fork it and add another language/framework/compressor combination!
# Brunch - http://brunch.io/
#
# Using uglify-js-brunch - https://github.com/brunch/uglify-js-brunch
#
# Use the following settings in your Brunch configuration file
exports.config =
plugins:
uglify:
output:
@jwebcat
jwebcat / gist:5122366
Last active June 20, 2024 13:35 — forked from lemenkov/gist:1674929
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
// Usage:
// Put this in a separate file and load it as the first module
// (See https://github.com/jrburke/requirejs/wiki/Internal-API:-onResourceLoad)
// Methods available after page load:
// rtree.map()
// - Fills out every module's map property under rtree.tree.
// - Print out rtree.tree in the console to see their map property.
// rtree.toUml()
// - Prints out a UML string that can be used to generate UML
// - UML Website: http://yuml.me/diagram/scruffy/class/draw
@jasoncrawford
jasoncrawford / model.js
Last active September 5, 2016 16:25
Simple relations for Backbone models. Not as full-featured as Backbone-relational (http://backbonerelational.org/) or Supermodel (http://pathable.github.io/supermodel/), but pretty lightweight and concise. Disclaimer: I excerpted this from some other code I wrote and haven't tested it independently. Use at your own risk
var relationEvents = ['add', 'change', 'remove', 'reset', 'sort', 'destroy', 'request', 'sync'];
var Model = exports.Model = Backbone.Model.extend({
hasMany: {
// Subclasses can override to set relations like this:
//
// key: function () { return new Collection([], options); },
},
hasOne: {
@jbmoelker
jbmoelker / bootstrap.js
Last active January 15, 2016 19:22
requirejs-bootstrap-plugin
// Create shim for requested bootstrap component and require
// and return jQuery so you do not have to inject it separately
// every time you use a bootstrap component.
define({
load: function (name, req, onload, config) {
// Set this path to wherever the bootstrap components live.
// Contents should match https://github.com/twbs/bootstrap/tree/master/js
var component = 'path/to/bootstrap/js/'+name;
var shim = {};