Skip to content

Instantly share code, notes, and snippets.

View hadees's full-sized avatar

Evan Alter hadees

  • inKind
  • Austin, TX
View GitHub Profile
@johnthethird
johnthethird / customdomain.rb
Created September 23, 2011 22:23 — forked from dwabnitz/customdomain.rb
rack middleware to resolve a custom domain to an original subdomain in a multi-tenant application
require 'net/dns/resolver'
# Custom Domain
#
# Require net-dns gem
#
# A Rack middleware to to resolve the custom domain to original subdomain
# for your multi telent application.
#
# It's all transperant to your application, it performs cname lookup and
@ocean90
ocean90 / box-shadow.html
Last active April 1, 2025 12:13
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@skorianez
skorianez / gist:1308103
Created October 24, 2011 00:06
JCrop + Carrierwave
# https://github.com/gzigzigzeo/carrierwave-meta
# Integrating CarrierWave with JCrop
# Let implement the behavior like at this demo: deepliquid.com/projects/Jcrop/demos.php?demo=thumbnail
# The uploader:
class CropUploader < SobakaUploader
include CarrierWave::Meta
# Crop source is a source image converted from original which could be bigger than source area (left image in the example).
version :crop_source do
@esses
esses / bookmark.js
Created November 15, 2011 20:28
Quick Cross-Browser jQuery Bookmark Script
$('a#bookmark').click(function(e){
e.preventDefault();
var bookmarkURL = this.href;
var bookmarkTitle = this.title;
try {
if (window.sidebar) { // moz
window.sidebar.addPanel(bookmarkTitle, bookmarkURL, "");
} else if (window.external || document.all) { // ie
window.external.AddFavorite(bookmarkURL, bookmarkTitle);
} else if (window.opera) { // duh
@bigfive
bigfive / gist:1399762
Created November 28, 2011 09:33
Ruby on Rails. Module to handle 'quantity' attributes by overriding the << and delete methods of the has_many association
class Package < ActiveRecord::Base
has_many :products, :through => :packagings, extend => QuantityAssociation
# ... do stuff
end
module QuantityAssociation
def include_duplicates
@mhawksey
mhawksey / gist:1442370
Last active February 1, 2025 00:36
Google Apps Script to read JSON and write to sheet
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var dataAll = JSON.parse(response.getContentText()); //
var data = dataAll.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}
@taxilian
taxilian / example.jst
Created December 14, 2011 06:01
example of a select statement in an underscore template
<select name="formitem_school">
<% if(schools && schools.length > 0) {
<option value="select_schools">Select School</option>
<% schools.each(function(t) { %>
<option value="<%= t.id %>" <% if(curSchool == t.id){ print('selected'); } %>><%= t.get("name") %></option>
<% });
} else { %>
<option value"schools_none">No Schools</option>
<% }
</select>
@danopia
danopia / about.md
Created December 28, 2011 11:30
Cards Against Humanity playing cards

Cards Against Humanity

Below are the white and black card sets published by Cards Against Humanity. Take them and come back with a bot. You have 48 hours, starting from an arbitrary time that I forget.

Black cards with 2 blanks are pick 2. Black cards with 3 blanks are pick 3, draw 2.

The rules are on the official web site.

These cards are taken from this PDF.

@johnnyg
johnnyg / transplant.py
Created January 19, 2012 12:53
Deluge transplant script - allows you to selectively import & export torrents
from deluge._libtorrent import lt
from deluge.core.torrentmanager import TorrentManagerState
from shutil import copy, _samefile
import cPickle
import os
class Transplant(object):
def __init__(self, config_dir="", torrent_ids=None, torrents=None):
self.state_dir = ""
self.torrents = {}
@ziadoz
ziadoz / awesome-php.md
Last active February 3, 2025 20:55
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.