Skip to content

Instantly share code, notes, and snippets.

View MrJaba's full-sized avatar

Tom Crinson MrJaba

View GitHub Profile
@MrJaba
MrJaba / tmp2.clj
Last active August 29, 2015 14:28
Various 4Clojure Problems
(ns tmp2)
(def data [1 1 2 3 2 1 1])
(def data2 [1 2 1 3 1 2 4])
( #(reduce (fn [acc el]
(if-not (some #{el} acc)
(conj acc el)
acc))
@MrJaba
MrJaba / programming-resources.txt
Created June 19, 2014 07:33
List of interesting programming resources
Podcasts:
Ruby Rogues - http://rubyrogues.com/
Ruby5 - http://ruby5.envylabs.com/
FunctionalGeekery - http://www.functionalgeekery.com/
Screencasts:
Destroy all software - https://www.destroyallsoftware.com/screencasts
Ruby Tapas - http://www.rubytapas.com/
News:
@MrJaba
MrJaba / destructuring.clj
Created January 20, 2013 13:28
Clojure Destructuring Examples
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
(def name ["Tom" "David" "Crinson"])
(str (nth name 2) ", "
(nth name 0) " "
(nth name 1))
@MrJaba
MrJaba / CoffeeSearch.coffee
Created October 12, 2012 12:24
Coffee Search
$- >
initializeLinkSearch()
initializeLinkSearch = ->
$("#search").keyup ->
resetLinks()
displayLinksMatching searchTerm()
resetLinks = ->
links = $('.links li a')
@MrJaba
MrJaba / jdbc_tap.clj
Created July 5, 2012 13:58
Cascalog JDBCTap Example
(defn query-params []
(into-array String ["?col1" "?col2"]))
(defn column-names []
(into-array String ["col1" "col2"]))
; Becomes the 'where' part of the UPDATE statement - use primary key for example
(defn update-params []
(into-array String ["?col1"]))
@MrJaba
MrJaba / db_tap.clj
Created July 4, 2012 15:08
JDBCtap issue
(ns paduka.db_tap
(:use cascalog.api)
(:require [cascalog [vars :as v] [ops :as c] [workflow :as w]]
[clojure.string :as s])
(:import [com.twitter.maple.jdbc JDBCScheme JDBCTap TableDesc]
[cascading.tuple Fields])
(:gen-class))
(defn mysql-tap []
(let [scheme (JDBCScheme. (Fields. (into-array String ["id" "screen_name" "content"])) (into-array String ["id" "screen_name" "content"]))
@MrJaba
MrJaba / module_wrapper.rb
Created June 12, 2012 15:37
Wrapping a class method by including a module
module Wrapper
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def wrap!
class << self
@MrJaba
MrJaba / Rakefile
Created June 3, 2012 09:29
jRuby Rake file trap test
desc "Show off odd trap behaviour"
task :trap do
trap("INT") { puts "trapped INT"; exit(true) }
at_exit { puts "here" }
puts "sleeping"
sleep 10
end
@MrJaba
MrJaba / test.rb
Created April 25, 2012 19:33
JRuby oddness?
# jruby 1.6.7 (ruby-1.9.2-p312)
require 'open-uri'
a = open("http://pinterest.com/pin/56295064062363076/").read
a.encoding
=> #<Encoding:UTF-8>
b = StringIO.new(a).read
b.encoding
=> #<Encoding:ASCII-8BIT>
Encoding.default_internal
@MrJaba
MrJaba / gist:2006079
Created March 9, 2012 10:57
Column Filter
SingleColumnValueFilter.new (Bytes.toBytes('data'), Bytes.toBytes('followers_count'), CompareFilter::CompareOp.valueOf('GREATER_OR_EQUAL'),BinaryComparator.new(Bytes.to_bytes(10)))