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))
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:
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')
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"]))
View module_wrapper.rb
module Wrapper
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def wrap!
class << self
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
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)))