Skip to content

Instantly share code, notes, and snippets.

@brentonashworth
brentonashworth / gist:1343920
Created November 7, 2011 00:50
ClojureScript Demo
;; ClojureScript Demo
;; ==================
(use 'cljs.closure)
;; ClojureScript compiler examples
(println (-compile '(defn add [a b] (+ a b)) {}))
(println (-compile '(defn add [& args] (reduce + args)) {}))
@textarcana
textarcana / git-log2json.sh
Last active August 4, 2025 13:00
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features 😀THIS GIST NOW HAS A FULL GIT REPO: https://github.com/context-driven-testing-toolkit/git-log2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@mattiasholmqvist
mattiasholmqvist / pallet-example-project.clj
Created October 13, 2011 05:40
Example pallet project for ec2. Working for eu-locations
(defproject example "1.0.0-SNAPSHOT"
:description "Example"
:dependencies [[org.cloudhoist/pallet "0.6.5-SNAPSHOT" :exclusions
[org.jclouds/jclouds-core
org.jclouds/jclouds-compute
org.jclouds/jclouds-blobstore
org.jclouds.drivers/jclouds-log4j]]
[org.cloudhoist/pallet-crates-all "0.5.0"]
[org.jclouds.provider/aws-ec2 "1.1.1"]
[org.jclouds.provider/aws-s3 "1.1.1"]
@ibdknox
ibdknox / alephNoir.clj
Created October 2, 2011 19:53
aleph and noir
(require '[noir.server :as server])
(use 'noir.core 'aleph.http 'lamina.core)
(defn async-response [response-channel request]
(enqueue response-channel
{:status 200
:headers {"content-type" "text/plain"}
:body "async response"}))
(defpage "/" [] "hey from Noir!")
@fogus
fogus / this.clj
Created September 30, 2011 19:12
How to access this in ClojureScript (subject to change)
;;;;;; GLOBAL THIS
(defn f []
(this-as self
(println self))
[self])
(f)
;; #<Object Global>
;;=> [#<undefined>]
use 5.14.1;
my $str = q {This is the best thing ever.};
my $re = qr{(.i.) .+? (.e.)};
$str =~ $re;
for (1 .. $#-) {
my $substr = substr $str, $-[ $_ ], $+[ $_ ] - $-[ $_ ];
printf "match %s (from %2s to %2s): %s\n", $_, $-[ $_ ], $+[ $_ ], $substr;
@vizanto
vizanto / gist:1222023
Created September 16, 2011 12:32
Tomcat on vmfest managed Ubuntu VM _almost_ configured.
(ns nodes.core
(:require [pallet compute, resource]
pallet.compute.vmfest
vmfest.manager, vmfest.virtualbox.image
[pallet.crate.tomcat :as tomcat]
[pallet.action.package :as package]
[pallet.action.exec-script :as exec-script]
[pallet.utils :as utils]
[pallet.session :as session]
[pallet.script.lib])
@alexander-yakushev
alexander-yakushev / tetris.clj
Created September 10, 2011 00:28
Tetris implementation in Clojure
(ns tetris.core
(:import (java.awt Color Dimension BorderLayout)
(javax.swing JPanel JFrame JOptionPane JButton JLabel)
(java.awt.event KeyListener))
(:use clojure.contrib.import-static deflayout.core
clojure.contrib.swing-utils)
(:gen-class))
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_DOWN VK_UP VK_SPACE)
@nifl
nifl / grok_vi.mdown
Created August 29, 2011 17:23
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@fogus
fogus / express-sample.cljs
Created August 25, 2011 21:25 — forked from jneira/express-sample.cljs
Clojurescript / node.js basic examples
(ns express_sample
(:require [cljs.nodejs :as node]))
(def express (node/require "express"))
(def app (. express (createServer)))
(defn -main [& args]
(doto app
(.use (. express (logger)))
(.get "/" (fn [req res]