Skip to content

Instantly share code, notes, and snippets.

View wjlroe's full-sized avatar
📷

William Roe wjlroe

📷
View GitHub Profile
(use '(incanter core charts excel))
;; read .xls file of Australian airline passenger data from the 1950s.
(with-data (read-xls "http://incanter.org/data/aus-airline-passengers.xls")
(view $data)
;; time-series-plot needs time in millisecs
;; create a function, to-millis, to convert a sequence of Date objects
;; to a sequence of milliseconds
(let [to-millis (fn [dates] (map #(.getTime %) dates))]
(view (time-series-plot (to-millis ($ :date)) ($ :passengers)))))
X = fun() ->
lists:foldl(fun(Pid, Acc) ->
case erlang:process_info(Pid,message_queue_len) of
undefined ->
Acc;
{_, Len} ->
if
Len > 3 ->
[{Len, process_info(Pid)} | Acc];
true ->
@jsimmons
jsimmons / config.lua
Created September 14, 2010 08:32
Mongrel2 config loading, in lua
local chat_demo = Handler {
send_spec = 'tcp://127.0.0.1:9999';
send_ident = '8b7c7833-0932-4d9a-92c3-3b8c06d9b855';
recv_spec = 'tcp://127.0.0.1:9998';
recv_ident = '';
}
local chat_demo_dir = Dir {
base = 'static/chatdemo/';
index_file = 'index.html';
(defn watch
"Returns (running) thread which observes the value of f every delay
milliseconds, and calls the callback fn if the value changes. callback
will be called with the old and new values from f"
([f callback delay]
(let [proc (fn []
(loop [x1 ::watch-init]
(let [x2 (f)]
(when (not= x1 x2)
(callback x1 x2))
@thommay
thommay / gist:1131973
Created August 8, 2011 15:37 — forked from baldowl/gist:796353
Interactive fog session: how to get a bunch of signed URLs for European buckets with fog 0.4.1
require 'active_support/time'
bucket = Fog::Storage.new(:provider => 'AWS').directories.select {|d| d.key == 'my_bucket'}
files = bucket.files.select {|f| f.content_length > 0 &&
f.key =~ %r{client-name.*\.zip}}
expiration = Time.now.next_month.end_of_month
signed_urls = files.map {|f| f.url(expiration)}
fixed_signed_url = signed_urls.map do |su|
su.sub(%r{s3\.(.*)/my_bucket}, "my_bucket.s3.#{$1}")
end
require 'riak/cluster'
cluster = Riak::Cluster.new(:count => 4, :source => "/usr/local/Cellar/riak/1.0.3/libexec/bin", :root => "~/mycluster")
cluster.create
cluster.start
cluster.join
@mbbx6spp
mbbx6spp / README.md
Created February 7, 2012 17:58
Websockets with Netty (Scala translation) - WORK IN PROGRESS! Currently it expects an integer and will respond with its square. It isn't very interesting but it serves as a boilerplate/skeleton.

Experimentation with Netty and Scala's Types

Status

  • Only first pass complete: raw translation from Java example to Scala.
  • Second pass [incomplete]: abstracting to make server and client specific code composable.

TODO:

  • Create declarative and composable Pipeline definition
@seancribbs
seancribbs / xmlsimple.erl
Created February 27, 2012 20:18
Module to simplify XML reading/manipulation stuffs in Erlang
%% @doc Uses SAX to convert an XML document into a simple nested-tuple
%% structure. Ignores namespaces.
-module(xmlsimple).
-export([file/1,
string/1,
emit/1,
emit_file/2]).
-include_lib("xmerl/include/xmerl.hrl").
@tlync
tlync / gist:1992497
Created March 7, 2012 10:54
Reload a web page on iPhone Simulator (elisp)
(defun web-reload-iphonesimulator ()
"Reload a page on iPhone Simulator. Run process associated to the *Messages* buffer"
(interactive)
(start-process-shell-command
"iphonesimulator-process"
"*Messages*"
"osascript -e 'tell application \"System Events\"' -e 'tell process \"iPhone Simulator\"' -e 'click button \"Reload\" of window 1' -e 'end tell' -e 'end tell'"))
@toranb
toranb / filtersortpagemixin.js
Created September 24, 2012 02:37
filter/sort/pagination mixin for ember.js
var get = Ember.get;
/**
* @extends Ember.Mixin
*
* Implements common filter / sort / pagination behavior for array controllers
* */
Ember.FilterSortSliceMixin = Ember.Mixin.create({
filterBy: '',