Skip to content

Instantly share code, notes, and snippets.

View camdez's full-sized avatar

Cameron Desautels camdez

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
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@a2ndrade
a2ndrade / gist:5814355
Last active March 23, 2021 07:34
Datomic: Getting the id of an inserted entity
;; see http://stackoverflow.com/questions/17190334/getting-the-id-of-an-inserted-entity-in-diatomic
(require '[datomic.api :as d])
(def uri "datomic:mem://test")
(d/create-database uri)
(def conn (d/connect uri))
;; create an atribute
(d/transact conn [{:db/id #db/id[:db.part/db]
:db/ident :some/attribute
:db/valueType :db.type/string
@mattt
mattt / UTTypeForImageData.m
Created March 27, 2014 23:19
A quick function for determining an image's file type by its first couple of bytes
@import MobileCoreServices;
static CFStringRef UTTypeForImageData(NSData *data) {
const unsigned char * bytes = [data bytes];
if (data.length >= 8) {
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) {
return kUTTypePNG;
}
}
@eslick
eslick / datomic-schema.clj
Last active May 6, 2016 02:56
One solution to integrating Schema and Datomic
(in-ns test
(:require
[schema.macros :as macros]
[schema.utils :as sutils]))
;; Wrapper type needed because Entity values do not implement
;; IPersistentMap interface
(defrecord EntitySchema
[schema]
Schema
@CuriousGnu
CuriousGnu / beezid_scraper.py
Created April 3, 2016 14:15
Beezid.com - Auction Scraper
import pycurl
import json
import time
from StringIO import StringIO
i = 0
bnums = []
while True :
print(str(i))