This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import zmq | |
def result_collector(): | |
context = zmq.Context() | |
results_receiver = context.socket(zmq.PULL) | |
results_receiver.bind("tcp://127.0.0.1:1234") | |
while True: | |
print results_receiver.recv() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <zmq.h> | |
#include <stdlib.h> | |
#include "assert.h" | |
int main() { | |
void *c = zmq_ctx_new(); | |
assert(c); | |
void *s = zmq_socket(c, ZMQ_PUSH); | |
assert(s); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <zmq.h> | |
#include <stdlib.h> | |
#include "assert.h" | |
int main() { | |
void *c = zmq_ctx_new(); | |
assert(c); | |
void *s = zmq_socket(c, ZMQ_PUSH); | |
assert(s); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fu Select_c_style() | |
set tabstop=8 "A tab is 8 spaces | |
set expandtab "Always uses spaces instead of tabs | |
set softtabstop=8 "Insert 4 spaces when tab is pressed | |
set shiftwidth=8 "An indent is 4 spaces | |
set smarttab "Indent instead of tab at start of line | |
set shiftround "Round spaces to nearest shiftwidth multiple | |
set foldmethod=syntax | |
" set nojoinspaces "Don't convert spaces to tabs | |
endf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import System.Random | |
shuffle :: [a] -> IO [a] | |
shuffle ss = do | |
i <- getStdRandom $ randomR (0, length ps) | |
return $ ps !! i | |
where ps = permutations ss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set textwidth=79 | |
set formatoptions=cqro | |
set autoindent | |
if has('gui_running') | |
set guifont=Terminus | |
endif | |
filetype indent plugin on | |
syntax on | |
call pathogen#infect() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s=->l{(p=l.pop)?s[l.select{|i|i<=p}]+[p]+s[l.select{|i|i>p}]:[]} | |
puts s["the quick brown fox jumps over the lazy dog".chars.to_a].join |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
random_string = -> length, radix=36 { rand(radix ** length).to_s(radix) } | |
# Random string of length 42, maybe 41. | |
random_string.call(42) | |
# Four random digits | |
random_string.call(4, 10) | |
# Four random hex digits | |
random_string.call(4, 16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def progress p | |
t=p;p=[p.to_i,100].min;p>>=1 | |
print("[#{'*'*p}#{' '*(50-p)}] #{t.round}%\r") | |
STDOUT.flush | |
end | |
1.upto(100){|i| progress(i); sleep 0.1} |
NewerOlder