Skip to content

Instantly share code, notes, and snippets.

View arr-ee's full-sized avatar

Max Barnash arr-ee

  • London, UK
  • 09:07 (UTC +01:00)
View GitHub Profile
@arr-ee
arr-ee / index.html
Last active August 29, 2015 13:55
All palettes from colorbrewer
<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;
}
@arr-ee
arr-ee / gist:8996177
Created February 14, 2014 05:17
Javascript is awesome at sorting stuff.
> 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) ]
(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
$ 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
@arr-ee
arr-ee / core.clj
Created July 4, 2014 22:16
Tiny Instapaper scraper
(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))
avg-cpu: %user %nice %system %iowait %steal %idle
0.31 0.00 0.10 6.00 0.04 93.54
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda1 1.58 10.04 35.74 503162 1791880
sda2 0.00 0.01 0.00 576 0
sda3 310.48 1752.07 15284.97 87844994 766356400
avg-cpu: %user %nice %system %iowait %steal %idle
0.16 0.00 0.10 6.44 0.03 93.27
@arr-ee
arr-ee / dabblet.css
Created May 15, 2012 13:35 — forked from LeaVerou/dabblet.css
Vertical centering with Flexbox + margin fallback
/**
* Vertical centering with Flexbox + margin fallback
* Lea Verou & David Storey
*/
html, body { height: 100%; }
body {
width: 100%; /* needed for FF */
margin: 0;
@arr-ee
arr-ee / dabblet.css
Created July 29, 2012 23:56
Untitled
.container {
font: 16px/24px Helvetica;
width: 400px;
text-align: center;
position: relative;
}
.separator {
border: none;
border-bottom: 1px solid grey;
@arr-ee
arr-ee / gist:3357278
Created August 15, 2012 07:04
Unmaintainable
1.9.3p125 :001 > User
=> User(id: integer, name: string, created_at: datetime, updated_at: datetime)
1.9.3p125 :002 > User.create name: 'test'
=> #<User id: 1, name: "test", created_at: "2012-08-15 06:58:45", updated_at: "2012-08-15 06:58:45">
1.9.3p125 :003 > u = User.first
=> #<User id: 1, name: "test", created_at: "2012-08-15 06:58:45", updated_at: "2012-08-15 06:58:45">
1.9.3p125 :004 > u.last_name
NoMethodError: undefined method `last_name' for #<User:0x007fa9a59a9d08>
1.9.3p125 :005 > u.last_name = 'failed'
NoMethodError: undefined method `last_name=' for #<User:0x007fa9a59a9d08>
maxbarnash@pinky:~/work/project@development$ ack 'include Mongoid::Document' app/ -ch
33
maxbarnash@pinky:~/work/project@development$ ack '< ActiveRecord::Base' app/ -ch
36