Skip to content

Instantly share code, notes, and snippets.

View devth's full-sized avatar
Deep Work

Trevor Hartman devth

Deep Work
View GitHub Profile
Teacup::Stylesheet.new :main do
style :my_style,
constraints: [
constrain_left(0),
constrain_width(100),
constrain_top(0),
constrain(:bottom).equals(:superview, :bottom),
]
end
@a2ndrade
a2ndrade / gist:5651065
Created May 25, 2013 23:00
Datomic: memoized predicate functions
;; see http://stackoverflow.com/questions/16386793/datomic-query-function-that-filters-and-binds
(require '[datomic.api :as d])
(def uri "datomic:mem://test")
(d/create-database uri)
(def conn (d/connect uri))
;; sample attribute definiton
(d/transact conn [{:db.install/_attribute :db.part/db
:db/id #db/id[:db.part/db]
@willurd
willurd / web-servers.md
Last active May 16, 2026 19:21
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ashrithr
ashrithr / kafka.md
Last active March 13, 2026 03:04
kafka introduction

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@alexyoung
alexyoung / tmux.conf
Created July 19, 2013 16:12
tmux cheap powerline
#!/usr/bin/env sh
ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%\n", $10/$5 * 100)}'
@zmanji
zmanji / gist:6575133
Created September 15, 2013 23:15
Lol Scala.
Zameers-MacBook-Air:~ zmanji$ scala
Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.
scala> null == null.asInstanceOf[Int]
<console>:8: warning: comparing values of types Null and Int using `==' will always yield false
null == null.asInstanceOf[Int]
^
res0: Boolean = true
@mkristian
mkristian / Mavenfile
Last active December 23, 2015 23:59
Mavenfile to use warbler to create the war file and replaces the maven artifact with that. the pom.xml is equivalent to the Mavenfile which got genreated by ruby-maven/tesla.
packaging :war
phase :package do
plugin 'de.saumya.mojo:jruby-maven-plugin', '1.0.0-rc3' do
execute_goal( :jruby,
:id => 'pack-war with warbler',
:filename => 'warble',
:gemUseSystem => true )
execute_goal( :jruby,
:id => 'move war to maven build dir',
@fjavieralba
fjavieralba / KafkaLocal.java
Last active March 23, 2021 09:57
Embedding Kafka+Zookeeper for testing purposes. Tested with Apache Kafka 0.8
import java.io.IOException;
import java.util.Properties;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServerStartable;
public class KafkaLocal {
public KafkaServerStartable kafka;
public ZooKeeperLocal zookeeper;
@martinklepsch
martinklepsch / random-color.clj
Last active April 23, 2022 20:07
Generate a random HEX color in cojure or clojurescript
(require '[clojure.string :as s])
;; My initial attempt
(def c [:0 :1 :2 :3 :4 :5 :6 :7 :8 :9 :A :B :C :D :E :F])
(str "#" (s/join (map name (repeatedly 6 #(rand-nth c)))))
;; Another option not using keywords (/ht locks in #clojure)
(def c [0 1 2 3 4 5 6 7 8 9 \A \B \C \D \E \F])
(str "#" (s/join (repeatedly 6 #(rand-nth c))))
;; the last line can be simplified even more (/ht xificurC in #clojure)
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell