Skip to content

Instantly share code, notes, and snippets.

@csm
csm / zen.sh
Created January 31, 2015 00:09
Continuous compilation of Grafana
#!/bin/bash
while true; do
until grunt build; do
fswatch -1 src/
done
grunt server &
new_job_started="$(jobs -n)"
if [ -n "$new_job_started" ];then
server_pid=$!
@csm
csm / Log output
Last active August 29, 2015 14:14
Exception running nodetool decommission, Cassandra 2.0.11.82 (DSE 4.5.3)
INFO [CompactionExecutor:113] 2015-02-04 22:11:22,600 CompactionTask.java (line 115) Compacting [SSTableReader(path='x'), SSTableReader(path='x'), SSTableReader(path='x'), SSTableReader(path='x')]
INFO [CompactionExecutor:113] 2015-02-04 22:11:22,639 CompactionTask.java (line 287) Compacted 4 sstables to [x,]. 36,329 bytes to 11,065 (~30% of original) in 37ms = 0.285200MB/s. 1,039 total partitions merged to 280. Partition merge counts were {1:159, 2:53, 3:258, }
INFO [RMI TCP Connection(1642)-x] 2015-02-04 22:11:22,670 StorageService.java (line 970) DRAINED
ERROR [CompactionExecutor:114] 2015-02-04 22:11:22,679 CassandraDaemon.java (line 199) Exception in thread Thread[CompactionExecutor:114,1,RMI Runtime]
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@45ad7114 rejected from org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor@7ddafbc8[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed ta
import java.io.*;
import java.net.*;
public class NetTest {
public static void main(String[] argv) throws Throwable {
Socket socket = new Socket();
try {
System.out.println("connecting socket...");
socket.bind(new InetSocketAddress(InetAddress.getLocalHost(), 31337));
socket.connect(new InetSocketAddress(InetAddress.getByName(argv[0]), 4242));
@csm
csm / lion-ifconfig.txt
Created July 25, 2011 04:28
Lion ifconfig -- new interface
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether XX:XX:XX:XX:XX:XX
media: autoselect
status: inactive
@csm
csm / lion-airdrop.txt
Created July 25, 2011 04:43
Lion ifconfig -- airdrop on
p2p7: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether XX:XX:XX:XX:XX:XX
inet6 fe80::1855:caff:fef2:5bc7%p2p7 prefixlen 64 scopeid 0x8
media: autoselect
status: active
@csm
csm / xkcd.py
Created August 10, 2011 22:57
Random passphrase generator.
# RE: http://xkcd.com/936/
import random
n = 4
f = open('/usr/share/dict/words', 'r')
w = f.readlines()
print " ".join(map(lambda x : x.strip(), random.sample(w, n)))
@csm
csm / gist:2483382
Created April 24, 2012 20:22
CouchDB invocation error
Command line invocation:
/Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/bin/erl +Bd -noinput -os_mon start_memsup false start_cpu_sup false disk_space_check_interval 1 disk_almost_full_threshold 1 -sasl errlog_type error +K true +A 4 -env ERL_LIBS /Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/lib/couchdb/erlang/lib -couch_ini /Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/etc/couchdb/default.ini /Users/csm/Library/Developer/Xcode/DerivedData/Magni-fofbzndvghoaitbkravzhufuwzey/Build/Products/Debug/X\ Y.app/Contents/Resources/CouchDB/Versions/1.2/Resources/etc/couchdb/local.ini /Users/csm/Library/Application Support/Memeo\ C1/local.ini -s couch
Output:
{"init terminati
@csm
csm / lintest.py
Created October 4, 2012 22:53
Linear hashing example
import collections
import random
i = 0
n = 0
d = [collections.OrderedDict()]
def lin(k):
global i
(defn js-engine
[]
(if-let [engine (.getEngineByName (ScriptEngineManager.) "JavaScript")]
engine
(throw (Exception. "no JavaScript engine found. Sorry"))))
(defn run-slides-js
[s]
(let [engine (js-engine)
script (str "(function() {\n"
@csm
csm / recyclable.clj
Last active September 14, 2017 19:29
(import '[io.netty.util Recycler])
(defprotocol Recyclable
(recycle! [this] "Recycles this object."))
(defprotocol Init
(init! [this values]))
(defmacro defrecyclable
[name fields & {:keys [max-capacity] :or {max-capacity 8096}}]