Skip to content

Instantly share code, notes, and snippets.

Tom Crinson MrJaba

Block or report user

Report or block MrJaba

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MrJaba
MrJaba / tmp2.clj
Last active Aug 29, 2015
Various 4Clojure Problems
View tmp2.clj
(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 Jun 19, 2014
List of interesting programming resources
View programming-resources.txt
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 Jan 20, 2013
Clojure Destructuring Examples
View destructuring.clj
;; 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))
View CoffeeSearch.coffee
$- >
initializeLinkSearch()
initializeLinkSearch = ->
$("#search").keyup ->
resetLinks()
displayLinksMatching searchTerm()
resetLinks = ->
links = $('.links li a')
@MrJaba
MrJaba / jdbc_tap.clj
Created Jul 5, 2012
Cascalog JDBCTap Example
View jdbc_tap.clj
(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"]))
View db_tap.clj
(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 Jun 12, 2012
Wrapping a class method by including a module
View module_wrapper.rb
module Wrapper
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def wrap!
class << self
@MrJaba
MrJaba / Rakefile
Created Jun 3, 2012
jRuby Rake file trap test
View Rakefile
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 Apr 25, 2012
JRuby oddness?
View test.rb
# 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
View gist:2006079
SingleColumnValueFilter.new (Bytes.toBytes('data'), Bytes.toBytes('followers_count'), CompareFilter::CompareOp.valueOf('GREATER_OR_EQUAL'),BinaryComparator.new(Bytes.to_bytes(10)))
You can’t perform that action at this time.