Skip to content

Instantly share code, notes, and snippets.

var CSS="body { background: #fff; color: #000; font-family: Helvetica, Verdana, sans-serif; } .section { background: #e6b277; padding: 1em; margin: 1em; border: 1px solid #521302; } .example code { display: block; background: #e6d4a5; border: 1px solid #521302; padding: 0.8em; line-height: 1.4em; } #ex1 ul .first { font-size: 1.5em; color: #f0f; }";
var directChildMatch = CSS.match(/[a-zA-Z0-9\.-_\+\~#\s]*?\>\s?[a-zA-Z0-9\.-_\+\~#]*/gi);
if(directChildMatch) directChildMatch=directChildMatch.join(", ");
alert(directChildMatch);
@daemianmack
daemianmack / ianschenk's fabfile
Created October 15, 2010 17:33
Looks like a good springboard to start with.
from fabric.api import *
APTITUDE_CACHE = set()
PIP_CACHE = set()
EASY_INSTALL_CACHE = set()
def aptitude(package):
aptitude_update()
if package not in APTITUDE_CACHE:
@daemianmack
daemianmack / ianschenk's fabfile
Created October 18, 2010 11:06
Looks like a good starting point.
from fabric.api import *
APTITUDE_CACHE = set()
PIP_CACHE = set()
EASY_INSTALL_CACHE = set()
def aptitude(package):
aptitude_update()
if package not in APTITUDE_CACHE:
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.contrib import files
USAGE = """
================================================================
NOTE:
using this fabfile expects that you have the python utility

Selenium with Python

Author: Baiju Muthukadan
Email:baiju.m.mail AT gmail.com
Version: 0.3.2
(defn map-while [f s pred]
(map f (filter pred s)))
@daemianmack
daemianmack / gist:2054543
Created March 17, 2012 02:47
Breaking dollars
(def coin-values {"h" 50 "q" 25 "d" 10 "n" 5 "p" 1})
(defn get-range [x cents]
(range (+ 1 (/ cents (coin-values x)))))
(defn list-combos [cents]
(for [h (get-range "h" cents)
q (get-range "q" cents)
d (get-range "d" cents)
n (get-range "n" cents)
@daemianmack
daemianmack / gist:2166073
Created March 23, 2012 01:37
My mars-rover solution
;; A squad of robotic rovers are to be landed by NASA on a plateau on
;; Mars. This plateau, which is curiously rectangular, must be
;; navigated by the rovers so that their on-board cameras can get a
;; complete view of the surrounding terrain to send back to Earth.
;; A rover's position and location is represented by a combination of
;; x and y co-ordinates and a letter representing one of the four
;; cardinal compass points. The plateau is divided up into a grid to
;; simplify navigation. An example position might be 0, 0, N, which
;; means the rover is in the bottom left corner and facing North.
@daemianmack
daemianmack / gist:2327943
Created April 7, 2012 11:40
my mars-rover solution with boundary checking and an attempt at concurrency
(ns mars_rover)
(use '[clojure.string :only (split)])
(defmulti handle-move (fn [x y move facing] [(str move) facing]))
(defmethod handle-move ["M" "N"] [x y move facing] [x (+ y 1) facing])
(defmethod handle-move ["M" "E"] [x y move facing] [(+ x 1) y facing])
(defmethod handle-move ["M" "S"] [x y move facing] [x (- y 1) facing])
(defmethod handle-move ["M" "W"] [x y move facing] [(- x 1) y facing])
@daemianmack
daemianmack / rubyuse.rb
Created May 5, 2012 01:55 — forked from alandipert/rubyuse.rb
A different way to organize Ruby code
class Ns
def initialize
use.each do |pkg, method_names|
method_names.each do |name|
self.class.send(:define_method, name) do |*args|
pkg.method(name).call(*args)
end
end
end
end