This file contains 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 connect(addr, family=socket.AF_INET, bind=None): | |
"""Convenience function for opening client sockets. | |
:param addr: Address of the server to connect to. For TCP sockets, | |
this is a (host, port) tuple. | |
:param family: Socket family, optional. See :mod:`socket` | |
documentation for available families. | |
:param bind: Local address to bind to, optional. | |
""" | |
sock = green_socket.socket(family) |
This file contains 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
# chunkify_list( list(xrange(1, 11), 2 ) -> ([1,2], [3,4], [5,6], [7,8], [9,10]) | |
def chunkify_list(L, size): | |
while L: | |
chunk, L = L[:size], L[size:] | |
yield chunk |
This file contains 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
; Copied from http://newos.org/txt/context_switch.txt | |
BITS 32 | |
global HalSwitchContext | |
section .text | |
; void i386_context_switch(void **from_esp, void *esp) | |
HalSwitchContext: | |
pusha ; save all 8 general purpose regs on the stack |
This file contains 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
# Muhs3 in Go. | |
include $(GOROOT)/src/Make.inc | |
TARG := muhs3 | |
GOFMT := gofmt -spaces=true -tabindent=false -tabwidth=4 | |
GOFILES := \ | |
main.go \ | |
muh.go \ |
This file contains 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
# Except it would not work, because TypeError: can't set attributes of built-in/extension type 'datetime.datetime' | |
@contextmanager | |
def time_machine(now=None, utcnow=None, today=None): | |
if now is None and utcnow is None and today is None: | |
raise ValueError(u"At least one of `now`, `utcnow` or `today` must be specified.") | |
real_now = datetime.now() | |
real_utcnow = datetime.utcnow() | |
tz_delta = real_now - real_utcnow |
This file contains 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 <pcrecpp.h> | |
#include <iostream> | |
int main(int argc, char *argv[]) { | |
// Don't sync C++ and C I/O | |
std::ios_base::sync_with_stdio(false); | |
if (argc < 2) { | |
std::cerr << "Usage: re_remove REGEX <input" << std::endl; |
This file contains 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
#!/usr/bin/env python | |
# coding: utf-8 | |
import os | |
import time | |
import zmq | |
name = "main" | |
#endpoint = "ipc://test-pub-sub-double-bind.ipc" | |
endpoint = "tcp://127.0.0.1:5004" |
This file contains 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
ZeroMQ -> file writer |
This file contains 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
-- Types: ticket_query, ticket_result | |
-- Functions: ticket_search_1, ticket_unique_sellers | |
drop type ticket_query cascade; | |
create type ticket_query as ( | |
cities_from text[], | |
cities_to text[], | |
date_direct date, | |
date_back_min date, | |
date_back_max date, |
This file contains 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
$ xmonad --recompile | |
Error detected while loading xmonad configuration file: /home/temoto/.xmonad/xmonad.hs | |
xmonad.hs:81:54: | |
Couldn't match expected type `Data.Monoid.Endo WindowSet' | |
with actual type `()' | |
Expected type: X (Data.Monoid.Endo WindowSet) | |
Actual type: X () | |
In the first argument of `liftX', namely | |
`(withDisplay $ \ d -> io (lowerWindow d w))' |