Skip to content

Instantly share code, notes, and snippets.

View gbuesing's full-sized avatar

Geoff Buesing gbuesing

View GitHub Profile
/*
Turns CommonJS package into a browser file.
Minifying requires UglifyJS (http://github.com/mishoo/UglifyJS)
to be in the dir above this one.
uses node-jake http://github.com/mde/node-jake
run with 'jake [build|minify|clean]'
*/
var fs = require("fs"),
path = require("path"),
@remy
remy / trim-canvas.js
Last active April 5, 2024 12:49
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,
@otobrglez
otobrglez / Article.rb
Created July 12, 2011 20:51
Finding related articles using Jaccard index and tags
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info: http://en.wikipedia.org/wiki/Jaccard_index
class Article < ActiveRecord::Base
def related(limit=10)
Article.find_by_sql(%Q{
SELECT
a.*,
( SELECT array_agg(t.name) FROM taggings tg, tags t
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@jeremy
jeremy / gist:4211803
Created December 5, 2012 03:05
Template- and asset-aware ETags

Declared ETags, together with Russian Doll caching, can be used to automatically mix your template and asset versions into the ETags set in your controllers. This avoids the need to blow all browser caches on each deploy and neatly contains the scope of "freshness fallout" when you tweak a view.

To include the template's version in the ETag:

  # Incorporate the cache version for this action into our ETag.
  # This allows template changes to bubble up into HTTP cache
  # freshness and bust browser caches when we make changes.
  etag do
    begin
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@willurd
willurd / web-servers.md
Last active April 25, 2024 09:21
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@yoavg
yoavg / lm_example
Created May 22, 2015 23:43
Unreasonable Effectiveness of LMs
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The unreasonable effectiveness of Character-level Language Models\n",
"## (and why RNNs are still cool)\n",
"\n",
"###[Yoav Goldberg](http://www.cs.biu.ac.il/~yogo)\n",