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 <iostream> | |
#include <vector> | |
#include <cassert> | |
#include <string> | |
using std::vector; | |
using std::cout; | |
using std::endl; | |
using std::string; |
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 <stdio.h> | |
#include <assert.h> | |
#define DEBUG | |
#include "smartasspointer.h" | |
struct spaceship_t { /* extends */ smartass_t _; | |
const char* name; | |
}; |
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
#!/usr/bin/python | |
# coding: utf-8 | |
import socket | |
import time | |
s = socket.socket() | |
#host = '195.50.209.244' | |
host = '127.0.0.1' | |
#port = 80 |
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
class Restartable(object): | |
@classmethod | |
def __new__(cls, *args, **kwargs): | |
ret = super(Restartable, cls).__new__(*args, **kwargs) | |
ret.__initargs__ = (args[1:], kwargs) | |
return ret | |
# this is something like a clone with __getinitargs__ but let's not call | |
# it a clone because it's semantically different--i.e. explicitly discards | |
# any state other than the initial one. |
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
print "importing problematic_module through other_module:" | |
try: | |
import other_module | |
except Exception as e: | |
print "...got", e | |
print "importing problematic_module directly:" | |
try: | |
import problematic_module | |
except Exception as e: |
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
class Traceback(object): | |
@classmethod | |
def parse(cls, tb_str): | |
tb_lines = tb_str.strip().split('\n') | |
firstline = tb_lines.pop(0) | |
step_lines = [] | |
while True: | |
if tb_lines[0].startswith(' '): | |
step_lines.append(tb_lines.pop(0)) |
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
# ... snip | |
class Cell(_BaseCell): # TODO: inherit from Greenlet? | |
uri = None | |
hub = None | |
impl = None | |
proc = None | |
stash = None | |
stopped = False |
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
trait Extractor[T, U] { def unapply(x: T): Option[U] } | |
object Extractor { | |
def apply[T, U](f: PartialFunction[T, U]) = new Extractor[T, U] { | |
def unapply(x: T) = f.lift(x) | |
} | |
} | |
val EmployedAt = Extractor[Person, Company] { | |
case Person(_, _, Some(Position(_, Some(c)))) => c | |
} |
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
$ rm -f *.class; fsc -shutdown | |
[Compile server exited] | |
$ time scala test.scala | |
real 0m5.779s <-------- | |
user 0m0.375s | |
sys 0m0.069s | |
-------------------------- | |
~/code/scala/testtask$ fsc # käivitab fsc daemoni |
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
##################### | |
# git | |
##################### | |
alias g=git | |
alias s='g status' | |
alias gs='g status' | |
alias a='g add' | |
alias ga='g add' | |
alias gap='ga -p' | |
alias gf='g fetch' |