Skip to content

Instantly share code, notes, and snippets.

@akorobov
akorobov / swank-standalone.clj
Created March 30, 2012 21:13
running standalone swank server
;; required jars: swank-clojure clj-stacktrace
;; to start from command line:
;; java -cp ~/.clojure/clojure-1.3.0.jar:~/.clojure/swank-clojure-1.4.0.jar:~/.clojure/clj-stacktrace/0.2.4/clj-stacktrace-0.2.4.jar clojure.main swank.clj
;; automatically import repl and javadoc in swank when running 1.3.0
(if (>= (.compareTo (clojure-version) "1.3.0") 0)
(do (use 'clojure.repl)
(use 'clojure.java.javadoc)
(use 'clojure.reflect)))
@akorobov
akorobov / inv.hs
Created June 24, 2012 01:46
count inversions using modified merge sort
-- regular merge sort
mergesort :: (a -> a-> Bool) -> [a] -> [a]
mergesort pred [] = []
mergesort pred [x] = [x]
mergesort pred xs = merge pred (mergesort pred left) (mergesort pred right) where
(left, right) = splitAt (length xs `div` 2) xs
-- write better split
merge :: (a -> a-> Bool) -> [a] -> [a] -> [a]
merge pred left [] = left
@akorobov
akorobov / eclipse-4.2-tab-font-customization.txt
Created July 2, 2012 22:10
fixing tab font sizes for eclipse 4.2 juno
Eclipse 4.2(juno) is using CSS to decorate/render widgets. Default tab font size is quite large wasting screen space. To change it edit eclipse42//plugins/org.eclipse.platform_4.2.0.v201206081400/css/e4_default_mac.css (or pick css file that corresponds to your specific os) and change following section:
.MPartStack {
font-size: 12;
swt-simple: false;
swt-mru-visible: false;
}
to something like:
.MPartStack {
@akorobov
akorobov / qs.py
Created July 2, 2012 22:11
quick sort with counting comparisons
import sys
import logging
global log
log = logging.getLogger('qs')
log.addHandler(logging.StreamHandler())
def readFromFile(fname):
print "reading " + fname
txt = open(fname)
@akorobov
akorobov / getToDoListFromOmniFocus.applescript
Last active October 11, 2015 20:28
Pomodoro script to get current active omnifocus tasks
# this goes into Pomodoro.app/Contents/Resources/getToDoListFromOmniFocus.applescript
on sort(_list)
set text item delimiters to {ASCII character 10}
set _list to _list as string
set _list to paragraphs of (do shell script "echo " & quoted form of (_list) & " | sort -f")
set text item delimiters to ""
return _list
end sort
@akorobov
akorobov / ssl_receive.py
Created October 19, 2012 17:33
test/demo code to receive messages from given rabbitmq's queue
# ***** BEGIN LICENSE BLOCK *****
#
# For copyright and licensing please refer to COPYING.
#
# ***** END LICENSE BLOCK *****
"""
Example of simple consumer using SSL. Acks each message as it arrives.
"""
from ssl import CERT_REQUIRED, PROTOCOL_SSLv3
@akorobov
akorobov / ssl_receive.log
Created October 19, 2012 21:26
ssl_receive log
DEBUG 2012-10-19 14:29:51,873 pika.connection _send_frame 1309: Added 21 bytes to the outbound buffer
DEBUG 2012-10-19 14:29:51,873 pika.adapters.select_connection poll 349 : Calling <bound method SelectConnection._handle_events of <pika.adapters.select_connection.SelectConnection object at 0x101045d50>>(1)
DEBUG 2012-10-19 14:29:51,873 pika.callback wrapper 49 : Args: (<pika.callback.CallbackManager object at 0x101045e10>, 1, <Basic.Deliver(['consumer_tag=ctag1.0', 'redelivered=False', 'routing_key=test100', 'delivery_tag=17853', 'exchange='])>), kwargs: {}
DEBUG 2012-10-19 14:29:51,873 pika.channel _on_basic_deliver 789 : Called with <METHOD(['frame_type=1', 'channel_number=1', "method=<Basic.Deliver(['consumer_tag=ctag1.0', 'redelivered=False', 'routing_key=test100', 'delivery_tag=17853', 'exchange='])>"])>, <Header(['frame_type=2', '
@akorobov
akorobov / ut.sml
Last active December 12, 2015 04:59
Unittesting in SML
fun toStr (xs:int list) = List.foldl (fn (i,s) => Int.toString(i) ^ " " ^ s) "" xs;
(* returns true if all test cases were successful, false otherwise *)
fun test name (results:bool list) : bool =
let fun checkT (t, (failed, total)) =
if t then (failed, total + 1) else ([total+1] @ failed, total + 1)
val (failed, total) = List.foldl checkT ([], 0) results
in case (failed, total) of
(x::xs, t) => (print ("> Failed " ^ name ^ " [" ^ toStr(failed) ^ "] (total " ^ Int.toString(t) ^")\n") ; false)
| (nil, t) => (print ("> Success " ^ name ^ " (total " ^ Int.toString(t) ^")\n"); true)
@akorobov
akorobov / mono-light-theme.el
Last active December 14, 2015 03:59
emacs 24 monochrome theme based/inspired by https://github.com/fxn/monochrome-theme.el
(deftheme mono-light
"Light monochrome theme")
(let ((class '((class color) (min-colors 10)))
(black "#080808") ; black
(white "#fafafa") ; "white"
(lgray "#b3b3b3")
(dgray "#303030")
(sgray "#606060")
(sgray+1 "#707070")
@akorobov
akorobov / gist:5259538
Created March 28, 2013 00:42
c++ - statically typed language
#include <map>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
// map of int -> string
// note that string is not included
map<int, std::string> m;
// assigning integer instead of string
// compiles just fine, sigh...