Skip to content

Instantly share code, notes, and snippets.

(comment
(:b (DefaultMap. :foo {:a 1}))
; => :foo
(:a (DefaultMap. :foo {:a 1}))
; => 1
(merge-with conj (DefaultMap. [] {}) {:a 1} {:a 2} {:a 3})
; => {:a [1 2 3]}
)
;;; method implementations basically taken from clojure.core/emit-defrecord
@philippbosch
philippbosch / cross-browser-rgba-mixin.scss
Created July 19, 2010 10:49
image-less RGBA backgrounds for real browsers and Internet Explorer
@mixin rgba-background($color, $opacity) {
background-color: $color;
background-color: rgba($color, $opacity);
background-color: transparent\9;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#{'#'+hex(round($opacity*255)) + '' + hex(red($color)) + '' + hex(green($color)) + '' + hex(blue($color))},endColorstr=#{'#'+hex(round($opacity*255)) + '' + hex(red($color)) + '' + hex(green($color)) + '' + hex(blue($color))});
zoom: 1;
}
@georgkreimer
georgkreimer / gist:537794
Created August 19, 2010 12:44
pretty print json in ruby
require 'json'
my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" }
puts JSON.pretty_generate(my_json)
Which gets you...
{
"array": [
1,
2,
3,
i
me
my
myself
we
our
ours
ourselves
you
your
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active April 14, 2025 11:07
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
import logging
import timeit
logger = logging.getLogger(__name__)
def log_noop():
pass
def log_simple():
logger.info("Testing")
import logbook
import timeit
logger = logbook.Logger(__name__)
def log_noop():
pass
def log_simple():
logger.info("Testing")
@nissuk
nissuk / gist:780757
Created January 15, 2011 06:58
jQuery Validation Pluginの簡単な例
<!DOCTYPE html>
<html>
<head>
<title>jQuery Validation Pluginの簡単なサンプル</title>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script>(function(){
// 標準メッセージの上書き(日本語化等)とカスタム項目のメッセージを設定します。
$.extend($.validator.messages, {
email: 'メールアドレスの形式で入力して下さい。(例: [email protected])',
@jakebellacera
jakebellacera / ajax-send.js
Created February 22, 2011 19:03
JQuery validate form that submits via AJAX
/*
ajax-send.js - copyright Jake Bellacera (http://jakebellacera.com)
This script uses JQuery & JQuery Validate (https://github.com/jzaefferer/jquery-validation)
For this example, we will have a form named '#ajaxform', you can of course change this to whatever you'd like.
*/
$(function(){
$('#submitbutton').click(function() {
@ddgromit
ddgromit / fisheryates.coffee
Created March 8, 2011 01:56
CoffeeScript Implementation of the Fisher-Yates array sorting algorithm
# Adapted from the javascript implementation at http://sedition.com/perl/javascript-fy.html
# Randomizes the order of elements in the passed in array in place.
fisherYates = (arr) ->
i = arr.length;
if i == 0 then return false
while --i
j = Math.floor(Math.random() * (i+1))
tempi = arr[i]