Skip to content

Instantly share code, notes, and snippets.

/*
* A simple example of user demographic dataset generation in scala.
*
* This highlights the following scala bits:
* - Java integration
* - Annotations
* - Tail recursion optimization
* - Enums
* - Vals vs. vars
* - Working with singleton objects
@jessitron
jessitron / transformers
Created January 14, 2013 00:06
These methods perform transformations on their input. They'll be tied together in different ways separately. Look for the blog post at blog.jessitron.com.
// from https://github.com/jessitron/BlogCode/blob/master/optionAsFlow.scala
object transformers {
def openFile(n: String) : Option[java.io.File] = {
val f = new java.io.File(n) // catch IOException
if (f.exists)
Some(f)
else
None

Array abstraction in Clojure

Few days ago Mike Anderson wrote [a proposal][mike] for a generic matrix API in Clojure which could compete with NumPy. I wanted to write a similar post for months, but was reluctant to start. This problem is very dear to me. Basically, it is a matter if I can use Clojure for most of my work, or it remains a toy language for me. Thanks to Mike for bringing the question up. Though, I have a different vision of how we should approach arrays and matrices in Clojure.

@ceteri
ceteri / Main.java
Created January 5, 2013 05:18
COUNT(DISTINCT c) in Cascading, for Mikhail Gavryuchkov
package example;
import java.util.Properties;
import cascading.flow.Flow;
import cascading.flow.FlowDef;
import cascading.flow.hadoop.HadoopFlowConnector;
import cascading.pipe.CoGroup;
import cascading.pipe.Pipe;
import cascading.pipe.assembly.CountBy;
@erikreagan
erikreagan / mac-apps.md
Created August 4, 2012 19:18
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

@dcj
dcj / StormBuildLion
Created September 19, 2011 20:42
Getting Storm to build on Mac OS X Lion
Note: When I started, JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
$ git clone https://github.com/nathanmarz/jzmq.git
Cloning into jzmq...
remote: Counting objects: 611, done.
remote: Compressing objects: 100% (204/204), done.
remote: Total 611 (delta 317), reused 570 (delta 292)
Receiving objects: 100% (611/611), 304.06 KiB | 298 KiB/s, done.
Resolving deltas: 100% (317/317), done.
require 'sinatra'
require 'pp'
require 'redis'
require 'json'
configure do
redis = JSON.parse(ENV['VMC_SERVICES']).select {|srvc| srvc['name'] =~ /redis-.*?/ }.first['options']
redis_conf = {:host => redis['hostname'], :port => redis['port'], :password => redis['password']}
@@redis = Redis.new redis_conf
Rails::Initializer.run do |config|
#.......
config.middleware.use 'ResqueWeb'
end
@thbar
thbar / Gemfile
Created February 13, 2011 17:46
How to use a bundler group to define a reduced-memory consumption environment for your workers
# these gems won't be loaded by our Rakefile with WORKER_ENVIRONMENT enabled
gem 'rails', '3.0.3'
gem 'haml', '3.1.0.alpha.147'
# ...
# load these both for the app and the workers
group :default, :worker do
gem 'mongo', '1.1.5'
gem 'bson', '1.1.5'
gem 'bson_ext', '1.1.5'
@pol
pol / set_iTerm_background.sh
Created January 11, 2011 01:42
Set the background color of iTerm based on RAILS_ENV
#!/usr/local/bin/bash
set_term_bgcolor(){
local R=$1
local G=$2
local B=$3
/usr/bin/osascript <<EOF
tell application "iTerm"
tell the current terminal
tell the current session