Skip to content

Instantly share code, notes, and snippets.

diff --git a/engines/default_engine/default_engine.c b/engines/default_engine/default_engine.c
index e877ecc..89e694b 100644
--- a/engines/default_engine/default_engine.c
+++ b/engines/default_engine/default_engine.c
@@ -878,16 +878,17 @@ static TAP_ITERATOR default_get_tap_iterator(ENGINE_HANDLE* handle,
static void default_handle_disconnect(const void *cookie,
ENGINE_EVENT_TYPE type,
const void *event_data,
const void *cb_data) {
#!/usr/bin/python
import unicodedata
import sys
reload(sys).setdefaultencoding("utf8")
s = 'u'
for i in xrange(1, 3000):
if unicodedata.category(unichr(i)) == 'Mn':
# My pseudocode always looks like python.
lock_index = get_lock_index(hash_table_index)
if lock_index < find_first_set(lock_bitvector):
for bit_index set in lock_bitvector:
locks[bit_index].unlock()
lock(locks[lock_index])
for bit_index set in lock_bitvector:
locks[bit_index].lock()
else:
@awreece
awreece / delete.c
Last active December 19, 2015 01:19
increment_version() // Block all incoming readers.
while (num_readers() != 0) {} // Wait for all current readers to finish.
old_val = val
val = NULL
increment_version() // Allow readers again.
if old_val->refcount == 1
diff --git a/src/bench_cuckoo.cc b/src/bench_cuckoo.cc
index cac4f27..64014f0 100644
--- a/src/bench_cuckoo.cc
+++ b/src/bench_cuckoo.cc
@@ -70,7 +70,9 @@ void* exec_thread(void* p) {
tp->hits = 0;
tp->gets = 0;
tp->puts = 0;
+#ifdef __linux__
tp->cpu = sched_getcpu();
-bash-4.2$ zsh
1372804922.4544186592 ~/.zshenv begin
1372804922.4672951698 ~/.zshenv end
1372804923.7818441391 .zshrc begin
1372804925.4863743782 Finished loading zprezto
1372804925.4869053364 .zshrc end
(gdb) list
1 int main() {
2 #pragma omp parallel
3 {
4 int x = 0;
5 }
6 return 0;
7 }
(gdb) b temp.cpp:4
Breakpoint 1 at 0x400672: file temp.cpp, line 4.
@awreece
awreece / nc.zsh
Last active December 19, 2015 15:38
#!/bin/zsh
zmodload zsh/net/tcp
if [[ $# -ne 2 ]] || [[ $1 == '-l' ]]; then
echo "$0 <host> <port>:" >&2
echo " Sends stdin to <host>:<port>" >&2
exit 1
fi
@awreece
awreece / output
Last active December 20, 2015 08:39
Fun bash fact of the day: keep your variable names short - you can get a noticeable performance improvement! (don't actually do that, if you care about this kind of performance in bash pick a different language -.-)
Testing bash
It took an average of 8.765s to assign to the variable v
It took an average of 8.884s to assign to the variable vvvvv
It took an average of 8.973s to assign to the variable vvvvvvvvvv
It took an average of 9.040s to assign to the variable vvvvvvvvvvvvvvvvvvvv
file=word.lst
sed -e ":s s/\([a]\)\(b\)/\2\1/g;s/\([a-b]\)\(c\)/\2\1/g;s/\([a-c]\)\(d\)/\2\1/g;s/\([a-d]\)\(e\)/\2\1/g;s/\([a-e]\)\(f\)/\2\1/g;s/\([a-f]\)\(g\)/\2\1/g;s/\([a-g]\)\(h\)/\2\1/g;s/\([a-h]\)\(i\)/\2\1/g;s/\([a-i]\)\(j\)/\2\1/g;s/\([a-j]\)\(k\)/\2\1/g;s/\([a-k]\)\(l\)/\2\1/g;s/\([a-l]\)\(m\)/\2\1/g;s/\([a-m]\)\(n\)/\2\1/g;s/\([a-n]\)\(o\)/\2\1/g;s/\([a-o]\)\(p\)/\2\1/g;s/\([a-p]\)\(q\)/\2\1/g;s/\([a-q]\)\(r\)/\2\1/g;s/\([a-r]\)\(s\)/\2\1/g;s/\([a-s]\)\(t\)/\2\1/g;s/\([a-t]\)\(u\)/\2\1/g;s/\([a-u]\)\(v\)/\2\1/g;s/\([a-v]\)\(w\)/\2\1/g;s/\([a-w]\)\(x\)/\2\1/g;s/\([a-x]\)\(y\)/\2\1/g;s/\([a-y]\)\(z\)/\2\1/g;t s;" < $file