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
#ifndef __TESTING_HPP__ | |
#define __TESTING_HPP__ | |
/* | |
* Test this with something like: | |
* g++ -std=c++11 -x c++ -DTEST_TESTING testing.hpp -o testing_test | |
* ./testing_test | |
*/ | |
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 <fstream> | |
#include <string> | |
#include <iostream> | |
#include <cinttypes> | |
#include <utility> | |
#include <algorithm> | |
#include <unordered_map> | |
#include <unordered_set> | |
#include <list> |
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
/* | |
sudo apt-get install libkyotocabinet-dev | |
g++ kyotocabinet_hash_map_test.cpp -o kyotocabinet_hash_map_test -std=c++11 -O2 -lkyotocabinet | |
./kyotocabinet_hash_map_test 500000 | |
./kyotocabinet_hash_map_test 500000 threaded_read | |
*/ | |
#include <fstream> | |
#include <string> | |
#include <iostream> |
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
/* | |
* sudo apt-get install memcached libmemcached-dev libboost-all-dev | |
* have a look in /etc/memcached.conf and set some reasonable defaults | |
* changed the following: | |
* -m 4096m -I 10m | |
* | |
* sudo service memcached restart | |
* | |
* g++ memc.cpp -o memc -std=c++11 -g -O2 -lboost_system -lboost_filesystem -lmemcached | |
* memc /some/directory/with/files 2147483648 |
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
/* | |
* sudo apt-get install libboost-all-dev | |
* #if you want to mmap more files than what `sysctl vm.max_map_count` says | |
* sudo sysctl -w vm.max_map_count=some_larger_number | |
* g++ blob_cache.cpp -o blob_cache -std=c++11 -g -O2 -lboost_system -lboost_filesystem | |
* blob_cache /some/directory/with/files 1073741824 | |
* blob_cache /some/directory/with/files 1073741824 mm | |
*/ | |
#include <boost/filesystem.hpp> |
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
from BaseHTTPServer import BaseHTTPRequestHandler | |
from StringIO import StringIO | |
from cgi import urlparse | |
import json | |
import zmq | |
class HTTPRequest(BaseHTTPRequestHandler): | |
def __init__(self, request_text): | |
self.rfile = StringIO(request_text) | |
self.raw_requestline = self.rfile.readline() |
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 <list> | |
#include <vector> | |
//the guts that both specializations can use | |
template <class container_t> | |
void fill(container_t& c, int start, int end) { | |
for(;start <= end; ++start) | |
c.push_back(start); | |
} |
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> | |
template <class T> | |
struct iterable_t { | |
public: | |
using iterator = T*; | |
iterable_t(T* first, size_t size): head(first), tail(first + size), count(size){} | |
iterable_t(T* first, T* end): head(first), tail(end), count(end - first){} | |
T* begin() { return head; } |
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 <cinttypes> | |
#include <limits> | |
//combining a union with an anonymous bit field we can: | |
// get a summary value for the entire bit field | |
// reference bit field members directly from the union | |
// use an initializer list to set them | |
//TODO: how to initialize via the bit field members without un-anonymizing it | |
union bit_funion_t { |
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
#!/bin/bash | |
#run this like: DAYS=365 ./code_timeline.sh https://github.com/org/repo1.git https://github.com/org/repo2.git | |
#note that the types of files it checks for code are hardcoded below | |
code='\.cc$|\.h$|\.cpp$|\.hpp$|\.lua$|\.py$|\.js' | |
: ${DAYS:?Please set DAYS environment variable to a number of days in the past youd like to capture} | |
#setup each repo | |
echo -n "day," | |
for url in ${@}; do |
OlderNewer