Skip to content

Instantly share code, notes, and snippets.

View andrewvc's full-sized avatar

Andrew Cholakian andrewvc

View GitHub Profile
@andrewvc
andrewvc / count-clj-sloc.sh
Created July 23, 2012 04:19
Counting SLOC in clojure is pretty easy since the syntax is so simple.
# Count SLOC
export SLF=`mktemp -t cljsloc`; find src test -name "*.clj" | xargs egrep -v "(^[[:space:]]*$|^[[:space:]]*;)" | cut -d: -f1 > $SLF && echo "Files"; uniq -c $SLF; echo "Total" `cat $SLF | wc -l`; rm $SLF
@fogus
fogus / gist:2765987
Created May 22, 2012 01:32 — forked from sviperll/gist:2762734
My thoughts on new programming language

I have been thinking a lot about implementing functional lazy language targeting JVM with syntax like:

class Maybe a = Just a | Nothing
  implements Monad, Eq when a implements Eq, Ord when a implements Ord
  where {
    derive Ord;
    derive Eq;

override {

@davidrupp
davidrupp / jetty.clj
Created October 29, 2011 03:43 — forked from minimal/jetty.clj
Websockets with clojure + jetty
;; Copyright (c) James Reeves. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.
(ns compojure.server.jetty
"Clojure interface to start an embedded Jetty server."
@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!")
@ZJONSSON
ZJONSSON / index.html
Created October 1, 2011 19:36
Using data() enter and exit in D3
<!DOCTYPE html>
<html>
<head></head>
<body></body>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript">
// Define the SVG domain in a viewbox to get automatic resize to
// window. This is a good alternative to d3.scale for simple stuff
svg=d3.select("body")
@michiakig
michiakig / ants.clj
Created July 19, 2011 22:37
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
@nesquena
nesquena / index_users_emails.rb
Created July 14, 2011 00:11
Add concurrent index in Postgres Rails migration
class IndexUsersEmails < ActiveRecord::Migration
def self.up
execute "END"
add_pg_index :users, :email, :lock => false
execute "BEGIN"
end
end
@mza
mza / validate.rb
Created May 6, 2011 10:32
Really simple CloudFormation template validation
require 'rubygems'
require 'fog'
require 'yaml'
config = YAML::load_file(File.dirname(__FILE__) + '/config.yml')
cf = Fog::AWS::CloudFormation.new(
:aws_access_key_id => config['key'],
:aws_secret_access_key => config['secret']
)
@ibdknox
ibdknox / socket.clj
Created October 31, 2010 06:48
compojure with websockets
(ns wl.core
(:use compojure.core, aleph.core, aleph.http, hiccup.core, hiccup.page-helpers)
(:require [compojure.route :as route])
(:gen-class))
(def broadcast-channel (channel))
(defn chat-handler [ch handshake]
(receive ch
(fn [name]