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
''' | |
Dirty and ugly hack to duplicate stdout stream to a file | |
Be careful as this only overwrites several file functions | |
This thing sort of acts like unix's tee program | |
Ang Way Chuang <wcang@sfc.wide.ad.jp> | |
Feel free to use, modify and distribute. No warranty and no restriction | |
''' | |
import sys |
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
import os | |
class cd: | |
def __init__(self, path): | |
print "constructor" | |
self.dest = path | |
self.origin = os.getcwd() | |
def __enter__(self): | |
os.chdir(self.dest) |
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
import os | |
import sys | |
import shutil | |
class chroot: | |
def __init__(self, root_dir): | |
self.root_dir = root_dir | |
def __enter__(self): | |
self.real_root = os.open("/",os.O_RDONLY) |
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
#implementation of state design pattern for MLD router state transition | |
#(RFC2710) | |
import time | |
class NonQuerier: | |
def __init__(self, ctx): | |
print "In non-querier" | |
print "Start other querier timeout" | |
self.ctx = ctx | |
self.timeout = time.time() |
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
/* Implementation of state design pattern for MLD router state transition | |
* (RFC 2710) using C | |
*/ | |
#include <stdio.h> | |
#include <stdbool.h> | |
struct mld_state { | |
struct mld_ctx * ctx; | |
void (*init)(struct mld_state *, struct mld_ctx *); | |
void (*recv_query)(struct mld_state *, bool lower); |
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 <sys/types.h> | |
#include <sys/socket.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <netinet/in.h> /* this is needed for struct sockaddr_in (IPv4 address) */ | |
#include <unistd.h> /* close syscall */ | |
#include <arpa/inet.h> /* for inet_ntop */ |
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 <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <errno.h> | |
static void child_process(int fd) |
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
function deepEqual(obj1, obj2) | |
{ | |
if (obj1 === obj2) { | |
return true; | |
} | |
if (typeof(obj1) == typeof(obj2)) { | |
if (typeof(obj1) == 'object') { | |
var obj1Prop = 0; | |
var obj2Prop = 0; |
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
// Your code here. | |
function Vector(x, y) { | |
this.x = x; | |
this.y = y; | |
this.plus = function(v) { | |
var res = new Vector(this.x, this.y); | |
res.x += v.x; | |
res.y += v.y; | |
return res; |
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
<style> | |
/* Defines a cleaner look for tables */ | |
table { border-collapse: collapse; } | |
td, th { border: 1px solid black; padding: 3px 8px; } | |
th { text-align: left; } | |
</style> | |
<script> | |
var MOUNTAINS = [ | |
{name: "Kilimanjaro", height: 5895, country: "Tanzania"}, |
OlderNewer