This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Generics | |
import Language.Haskell.Parser | |
import Language.Haskell.Pretty | |
import Language.Haskell.Syntax | |
main = do | |
input <- getContents | |
case parseModule input of | |
ParseOk mod -> putStrLn $ prettyPrint $ everywhere (mkT desugarExp) mod | |
ParseFailed loc msg -> failed loc msg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Low rank approximation for the lena image | |
""" | |
import numpy as np | |
import scipy as sp | |
from scipy import linalg | |
import pylab as pl | |
X = sp.lena().astype(np.float) | |
pl.gray() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#------------------------------------------------------------------------------ | |
# Aggregate Print useful information from /proc/[pid]/smaps | |
# | |
# pss - Roughly the amount of memory that is "really" being used by the pid | |
# swap - Amount of swap this process is currently using | |
# | |
# Reference: | |
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do you ever define #method_missing and forget #respond_to? I sure | |
# do. It would be nice if we could do them both at the same time. | |
module MatchMethodMacros | |
def match_method(matcher, &method_body) | |
mod = Module.new do | |
define_method(:method_missing) do |method_name, *args| | |
if matcher === method_name.to_s | |
instance_exec(method_name, *args, &method_body) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn clj->js | |
"Recursively transforms ClojureScript maps into Javascript objects, | |
other ClojureScript colls into JavaScript arrays, and ClojureScript | |
keywords into JavaScript strings." | |
[x] | |
(cond | |
(string? x) x | |
(keyword? x) (name x) | |
(map? x) (.strobj (reduce (fn [m [k v]] | |
(assoc m (clj->js k) (clj->js v))) {} x)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; highlight support for multiple languages | |
(defconst mumamo-highlight-tag-start-regex | |
(rx "{%" | |
(0+ space) | |
"highlight" | |
space | |
(submatch | |
(1+ (any "a-za-z"))) | |
(0+ space) | |
"%}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pallet.crate.rvm | |
"Standard rvm install" | |
(:require | |
[pallet.crate.git :as git] | |
[pallet.action.conditional :as conditional] | |
[pallet.action.exec-script :as exec-script] | |
[pallet.action.package :as package] | |
[pallet.action.remote-file :as remote-file] | |
[pallet.action.user :as user] | |
[pallet.context :as context] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Emulates the QuickCheck ?SOMETIMES macro. | |
module Sometimes | |
def run_with_retries(example_to_run, retries) | |
self.example.metadata[:retries] ||= retries | |
retries.times do |t| | |
self.example.metadata[:retried] = t + 1 | |
self.example.instance_variable_set(:@exception, nil) | |
example_to_run.run | |
break unless self.example.exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns test.cometd-client | |
(:import (org.cometd.bayeux.client ClientSessionChannel$MessageListener) | |
(org.cometd.client BayeuxClient BayeuxClient$State) | |
(org.cometd.client.transport ClientTransport LongPollingTransport) | |
(org.eclipse.jetty.client HttpClient))) | |
(def channel-name "/my-channel") | |
(def client-url "http://localhost:8080/cometd") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; lein settings | |
(defproject foo "1.0.0-SNAPSHOT" | |
:description "Test App" | |
:dependencies [[com.datomic/datomic "0.1.2678"] | |
[frinj "0.1.2" :exclusions [org.clojure/clojure]]]) | |
;; load libs | |
(use 'frinj.core 'frinj.calc) | |
(frinj-init!) | |
(use '[datomic.api :only (q db) :as d]) |