View core.clj
(ns instagroup.core
(:require [net.cgrand.enlive-html :as html]
[clj-http.client :as http]
[clj-http.cookies :as cookies]
[clojure.java.io :as io]
[clojure.string :as s]
[clojure.pprint :as pp])
(:import java.io.ByteArrayInputStream)
(:gen-class))
View gist:9917706
$ dig datastax.com
; <<>> DiG 9.8.3-P1 <<>> datastax.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31423
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;datastax.com. IN A
View gist:9892004
(defmacro defdyntest
[test-meta test-name & test-body]
`(let [fn# (deftest ~test-name ~@test-body)]
(alter-meta! fn# merge ~test-meta)
fn#))
(let [tname (symbol 'test-1)]
(defdyntest {} tname (println 1)))
; => #'user/tname
;; this should be #'user/test-1
View gist:8996177
> a
[ 'Wed Dec 11 2013 04:00:00 GMT+0400 (MSK)',
'Tue Dec 10 2013 04:00:00 GMT+0400 (MSK)',
'Sun Dec 15 2013 04:00:00 GMT+0400 (MSK)',
'Sat Dec 14 2013 04:00:00 GMT+0400 (MSK)' ]
> a.map(function(d){return new Date(d)}).sort()
[ Sat Dec 14 2013 04:00:00 GMT+0400 (MSK),
Sun Dec 15 2013 04:00:00 GMT+0400 (MSK),
Tue Dec 10 2013 04:00:00 GMT+0400 (MSK),
Wed Dec 11 2013 04:00:00 GMT+0400 (MSK) ]
View index.html
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/colorbrewer.v1.min.js"></script>
<style>
body {
background: #ccc;
font: 14/1.5 Helvetica, sans-serif;
}
View index.html
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/colorbrewer.v1.min.js"></script>
<style>
.axis {
shape-rendering: crispEdges;
stroke-width: 2;
}
View test.rb
require 'benchmark'
chars = 'abcdeABCDE!@#$%1234 '
res_str = ''
n = 1000
100_000.times do
res_str << chars[rand(chars.length)]
end
Benchmark.bm(15) do |x|
View gist:6175003
class A;
def initialize a
@a = a
end
def to_str
@a.dup
end
def == o
View gist:6137952
case
when utterance.silent?
...
when utterance.loud?
...
...
else
...
end
View gist:6057189
require 'minitest/autorun'
require 'uri'
class UriValidator
ALLOWED_PROTOS = [URI::HTTP, URI::HTTPS, URI::FTP]
def initialize uri
@uri = uri
end