Skip to content

Instantly share code, notes, and snippets.

@drone29a
drone29a / randon_schema_ex.clj
Created July 17, 2014 12:32
A random Schema example
(defn integer-string? [s]
(and (string? s)
(every? (partial contains? #{\0 \1 \2 \3 \4 \5 \6 \7 \8 \9}) s)))
(def IntStr (sc/pred integer-string?))
(def DateStr (sc/pred (comp not nil? #(.parse (SimpleDateFormat. "yyyy-MM-dd") % (ParsePosition. 0)))))
(def FundingAgentLevel
{(sc/required-key "id") String
(sc/required-key "name") String
(sc/optional-key "abbr") String})
@drone29a
drone29a / jme3_local_install.py
Last active December 20, 2015 08:29
Use lein localrepo to install jMonkeyEngine3 jars. Build jME3 with "ant build-engine" then run this script from "<jme3_root>/engine/dist/lib".
import os
import subprocess
path = os.path.dirname(os.path.realpath(__file__))
def install_cmd(fname, group_id, art_id, version):
return "lein localrepo install %s %s/%s %s" % (fname, group_id, art_id, version)
for fname in os.listdir(path):
name = os.path.splitext(fname)[0]
(import java.util.concurrent.Executors)
(use '[plumbing.core :only [wait-until with-log]])
(require '[work.core :as work]
'[fetcher.core :as fetcher])
(def test-feed-urls
["http://daringfireball.net/index.xml" "http://www.rollingstone.com/siteServices/rss/allNews" "http://feeds.feedburner.com/iamwhitePosterous" "http://www.9to5mac.com/feed" "http://abovethecrowd.com/feed/" "http://feeds.feedburner.com/pulsosocial" "http://www.bytearray.org/?feed=rss2" "http://usabilitytestinghowto.blogspot.com/feeds/posts/default" "http://mgalligan.com/rss" "http://feeds.searchengineland.com/searchcap" "http://feeds.feedburner.com/palletops" "http://googledevjp.blogspot.com/feeds/posts/default" "http://blog.boxee.tv/feed/" "http://twitgoo.com/1r6osl/?format=rss" "http://davidrcole.com/feed/" "http://milancermak.posterous.com/rss.xml" "http://typedia.com/blog/feed/" "http://diveintohtml5.org//hg.diveintohtml5.org/hgweb.cgi/atom-log" "http://www.curious-creature.org/feed/" "http://networkeffect.allthingsd.com/fee
;;Steps toward pulling otu composiiton strategy. need to do same for input so calcs ca be push through or pill through.
(defn async [f task out] (f task out))
(defn sync [f task out] (out (f task)))
(defn in-pool
[p f]
(fn [& args]
(.submit p (fn [] (apply f args)))))
;;TODO; unable to shutdown pool. seems recursive fns are not responding to interrupt. http://download.oracle.com/javase/tutorial/essential/concurrency/interrupt.html
(defn set-log-level!
([level]
(set-log-level! [(org.apache.log4j.Logger/getRootLogger)] level))
([loggers level]
(let [loggers (map (fn [l] (if (string? l)
(org.apache.log4j.Logger/getLogger l)
l))
loggers)]
(doseq [l loggers]
(.setLevel l (case level
import re
test = '<a href="http://m.twitter.com/" rel="nofollow">mobile web</a>'
p = re.compile("\<.*[a|A].*\>(.*)\<.*/[a|A].*\>")
m = p.match(test)
print m.groups()[0]
@drone29a
drone29a / gist:183278
Created September 8, 2009 22:22 — forked from saikat/gist:183275
- (void)setSelected:(BOOL)isSelected
{
[self setBackgroundColor:isSelected ? [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:"Resources/screen-selection.png" size:CGSizeMake(1.0, 24.0)]] : nil];
}
;;; Not too bad for a :once fixture
(defn test-ns-hook
[]
(init-db (fn [] (get-tests)
(put-tests))))
;;; Gets ugly fast for :each fixtures
(defn test-ns-hook
[]
(init-db (fn [] (get-tests))
//
// FileUpload.j
// Editor
//
// Created by Francisco Tolmasky on 03/04/08.
// Copyright 2005 - 2008, 280 North, Inc. All rights reserved.
//
import <Foundation/CPObject.j>
import <Foundation/CPValue.j>
(defn domap
"A map for side-effects. The argument order is the same as map, but
unlike map the function results are not retained. Takes a function
followed by any number of collections and applies the function to the
first item in each coll, then the second etc. Returns nil."
[fn & colls]
(let [num-colls (count colls)]
(doseq [args (partition num-colls (apply interleave colls))]
(apply fn args))))