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 <assert.h> | |
#include <stdio.h> | |
#include <vector> | |
int buysell(const std::vector<int>& prices) | |
{ | |
assert(!prices.empty()); | |
size_t lowestBuy = 0; | |
size_t lowestBuySoFar = 0; | |
size_t highestSell = 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 <vector> | |
#include <assert.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
typedef int32_t Score; | |
typedef int32_t UserId; | |
typedef int32_t Rank; | |
const Score kInvalidScore = -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
#user nobody; | |
worker_processes 4; | |
events { | |
worker_connections 10240; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; |
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 <assert.h> | |
#include <list> | |
#include <boost/unordered_map.hpp> | |
#include <boost/noncopyable.hpp> | |
template<typename T> | |
class HashedList : boost::noncopyable | |
{ | |
typedef typename std::list<T>::iterator ListIterator; | |
typedef typename std::list<T>::reverse_iterator ReverseListIterator; |
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 <algorithm> | |
#include <string.h> | |
struct AreBothSpaces | |
{ | |
bool operator()(char x, char y) const | |
{ | |
return x == ' ' && y == ' '; | |
} | |
}; |
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
DEBUG = false | |
if ARGV.size < 2 | |
puts "Usage: #$0 pattern file_pattern" | |
puts "Example: #$0 '\\d+' '*.rb'" | |
exit | |
end | |
dirname = File.dirname(ARGV[1]) | |
file_pattern = File.basename(ARGV[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
#include <algorithm> | |
#include <vector> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
double getTime() | |
{ | |
struct timeval tv; | |
gettimeofday(&tv, NULL); |
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/python | |
import socket, os, hashlib, time | |
md5 = hashlib.md5() | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect(('server_address', 2021)) | |
start = time.time() | |
length = 0 | |
out = open('/tmp/download', 'wb') |
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 <map> | |
#include <set> | |
#include <stdio.h> | |
typedef std::pair<int64_t, uint32_t> Entry; | |
typedef std::set<Entry> TimerList; | |
TimerList timers; | |
void test(int64_t now) |
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> | |
template<typename CharT> | |
const CharT* ToString(const char* str, const wchar_t* wstr); | |
template<> | |
const char* ToString<char>(const char* str, const wchar_t* wstr) | |
{ | |
return str; | |
} |