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
// SFINAE structure that tests if a given | |
// type contains the iterator typedef | |
template<typename T> | |
struct has_iterator { | |
template<class C> | |
static char test(typename C::iterator*); | |
static long test(...); | |
enum { | |
value = 1 == sizeof test<T>(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
#include <iostream> | |
#include <fstream> | |
class Twister { | |
private: | |
uint32_t data[624], | |
index = 0; | |
uint32_t read_device() { | |
std::ifstream ifs("/dev/urandom"); | |
uint32_t r(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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
typedef struct { | |
int64_t user, nice, system, | |
idle, iowait, irq, | |
softirq, steal, guest, |
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
/* Tested on Linux running apache 2.4.10-1 CGI module | |
and bash-4.3.018-1 */ | |
#include <stdio.h> | |
#include <assert.h> | |
#include <unistd.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
#define HOST "127.0.0.1" |
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/python2 | |
from threading import Thread | |
import socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect(('localhost', 9999,)) | |
class ReplyHandler(Thread): |
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
var fs = require('fs'); | |
function BufferWriter(initialSize) { | |
initialSize = initialSize || 1024; | |
this.data = new Buffer(initialSize); | |
this.clear(this.data); | |
this.capacity = initialSize; | |
this.offset = 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
#include <stdio.h> | |
#include <stdlib.h> | |
static char * | |
read_stdin (void) | |
{ | |
size_t cap = 4096, /* Initial capacity for the char buffer */ | |
len = 0; /* Current offset of the buffer */ | |
char *buffer = malloc(cap * sizeof (char)); | |
int c; |
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 <stdlib.h> | |
static struct { | |
size_t buffer_size; | |
char *buffer, *ptr; | |
} bf; | |
void bf_init(size_t initial_cap) { | |
bf.buffer_size = initial_cap; |
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
.intel_syntax noprefix | |
.globl fib | |
fib: | |
sub rsp, 24 | |
xor eax, eax | |
mov ecx, 1 | |
0: | |
xadd rax, rcx |
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 <string> | |
#include <iostream> | |
#include <time.h> | |
using namespace std; | |
/***************************** Person Class **********************************/ | |
class Person | |
{ |