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
# -*- python -*- | |
env = Environment() | |
env.Append(CPPFLAGS='-g -Wall -Wextra') | |
env.Program(target='resolver', | |
source=['resolver.cc'], | |
LIBS=['event']) |
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 <stdio.h> | |
int main(void) | |
{ | |
int i, j, l[4]= {0x48617070, 0x79204269, 0x72746864, 0x61792021}; | |
for (i=0; i<4; i++) | |
for (j=3; j>=0; j--) |
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
void x() { | |
SomeClass blah; | |
asyncthread(y(blah)); | |
} | |
// Note if you pass shit by reference, it should be a const reference. Otherwise just use a pointer | |
void y(const SomeClass &blah) { | |
Blah blah_copy(blah); // <-- assuming the constructor does not do a shallow copy | |
} |
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
finally { | |
if(source != null) { | |
try { | |
source.close(); | |
} finally { | |
if(dest != null) { | |
dest.close(); | |
} | |
} | |
} |
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 Control.Monad | |
import System.IO | |
import Data.List | |
import qualified Data.Map as Map | |
countWords :: [String] -> Map.Map String Integer | |
countWords = foldl updateMap Map.empty | |
where | |
updateMap m word = | |
Map.insert word (1 + (Map.findWithDefault 0 word m)) m |
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
// -*-c++-*- | |
#ifndef AF_ALLOC_ALLOC_H_ | |
#define AF_ALLOC_ALLOC_H_ | |
#include <cstdlib> | |
#include <memory> | |
namespace af { |
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 <cstdlib> | |
#include <cstring> | |
#include <netdb.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <iostream> | |
#include <string> |
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
/* | |
* tlook.c - [email protected] based on mlook.c | |
* threaded mass resolver | |
* | |
* ./tlook <file> Accepts stdin if no arguments are given resolves both hostname | |
* and IPs | |
* | |
* grep new.cgi access.log | awk '{print $1}' | sort |uniq |tlook > resolved | |
* | |
*/ |
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
(defvar *default-font-size* 13) | |
(defvar *default-font-name* "Menlo") | |
(defun increase-default-font-size () | |
"Increase font size" | |
(interactive) | |
(incf *default-font-size*)) | |
(defun decrease-default-font-size () | |
"Decrease default font size" |
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 <stdio.h> | |
#include <sys/mman.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <signal.h> | |
#include <unistd.h> | |
static volatile int done = 0; |