Skip to content

Instantly share code, notes, and snippets.

elben /
Last active September 15, 2015 01:16
Fundamental programming exercises. Happens to be in Ruby.

This is a principled approach to programming. We use Ruby as the delivery language, but the things you learn here applies to all programming languages. What you learn will be important in your day-to-day Ruby programming, but my primary goal is for you to understand common, important concepts of computation.

Ruby made unfortunate mistakes in its design—mistakes that we Ruby programmers have to deal with on a daily basis. Of course, we get used to those mistakes and start to think of them as "features" or "that's just how those things work." I will often "ignore" those mistakes at first so that you will understand the fundamental idea. The mistakes are edge cases that we have to worry about, but they should not get in your way of learning. Hence why some people (mainly people with exposure to Ruby) will consider the order of things very odd.

Type the examples into IRB and complete every exercise. Merely reading will not give you true understanding.

Important vocabulary are in bold.

1. Functions

elben / polls-api-nfl.markdown
Last active August 29, 2015 14:11
Polls API for NFL

Documentation that covers the Polls API with constrained topics. The example poll below is powered a stream's constrained topics, and all keyword management will be through the streams UI.

How to create a poll powered by constrained topics (in development):

Poll API

elben / understanding-transducers.clj
Last active February 14, 2021 10:55
Understanding Transducers. See README below.
(ns my-transducers.core
(:require [clojure.core.async :as async]))
;; Understanding Transducers
;; This is the source code for the blog post Understanding Transducers, found
;; here:
elben /
Last active May 8, 2016 12:40
Using core.async for Producer-consumer Systems

Using core.async for Producer-consumer Systems

# Set up input file
repeat 10000 echo "." >> input

# Run inline
time lein run inline < input > output

# Run async
/ .*(?:#{shard}).* /i
elben / snake-nibbles.bas
Created October 5, 2012 05:36
The first program I saw my in my life. And it changed my life.
' Q B a s i c N i b b l e s
' Copyright (C) Microsoft Corporation 1990
' Nibbles is a game for one or two players. Navigate your snakes
' around the game board trying to eat up numbers while avoiding
' running into walls or other snakes. The more numbers you eat up,
' the more points you gain and the longer your snake becomes.
stub_request(:get, '').with(:query => hash_including({"query" => "mytestquery"})).to_return(:body => "{}")
TypeError: can't convert RR::WildcardMatchers::HashIncluding into String
webmock (1.8.7) lib/webmock/request_pattern.rb:97:in `+'
webmock (1.8.7) lib/webmock/request_pattern.rb:97:in `add_query_params'
webmock (1.8.7) lib/webmock/request_pattern.rb:135:in `add_query_params'
import org.specs2._
class HelloWorldSpec extends Specification { def is =
"This is a specification to check the 'Hello world' string" ^
"The 'Hello world' string should" ^
"contain 11 characters" ! e1^
"start with 'Hello'" ! e2^
"end with 'world'" ! e3^
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath /Applications/IntelliJ IDEA 10 IDEA 10
diff --git a/src/lucandra/ b/src/lucandra/
index e88e789..5596b87 100644
--- a/src/lucandra/
+++ b/src/lucandra/
@@ -34,6 +34,7 @@ import;
import org.apache.cassandra.db.*;
import org.apache.cassandra.thrift.ColumnParent;
import org.apache.cassandra.utils.ByteBufferUtil;
+import org.apache.cassandra.utils.FBUtilities;
import org.apache.log4j.Logger;