Skip to content

Instantly share code, notes, and snippets.

View uchan-nos's full-sized avatar

Kota UCHIDA uchan-nos

View GitHub Profile
class Base;
class Sub;
shared_ptr<Base> create(Kind k) {
switch (k) {
case kHoge:
return shared_ptr<Base>(new Sub());
}
return shared_ptr<Base>();
}
int main() {
char b = -1;
cout << static_cast<int>(b) << endl;
cout << static_cast<uint32_t>(b) << endl;
cout << static_cast<uint32_t>(static_cast<unsigned char>(b)) << endl;
}
uint32_t Read32(const char* data) {
return static_cast<unsigned char>(data[0])
| (static_cast<unsigned char>(data[1]) << 8u)
| (static_cast<unsigned char>(data[2]) << 16u)
| (static_cast<unsigned char>(data[3]) << 24u);
}
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
using namespace std;
#include <iostream>
#include <utility>
#include <string>
using namespace std;
// {{{
struct ListTerminator
{
};
const ListTerminator NIL {};
#include <iostream>
using namespace std;
// {{{
constexpr int get_hash(int hash, const char* p)
{
return *p == '\0' ? hash : get_hash(*p * 137, p + 1);
}
template <typename T, int N>
template <typename T, typename U, typename ... ApiArgs, typename ... Args>
T ExitOnWrongValue0(const U& expected, const char* api_name, T (api_exp)(ApiArgs...), Args... args)
{
T x = api_exp(args...);
if (x != expected)
{
std::cout << api_name << " Error: " << std::endl;
exit(1);
}
return x;
@uchan-nos
uchan-nos / bootpack.ld
Created January 2, 2014 08:21
GNU LD linker script for BitNOS (HariboteOS-like operating system)
OUTPUT_FORMAT("binary")
ENTRY(KernelMain)
HEAP_SIZE = 0;
MMAREA_SIZE = 0;
__ctors = ADDR(.ctors);
__ctors_count = SIZEOF(.ctors) / 4;
SECTIONS
# -*- coding: utf-8 -*-
import time
def separate_variations2(lst):
n = len(lst)
assert n >= 2
for bitpattern in xrange(1, 2 ** (n - 1)):
x = list()
url = 'http://toi.kuronekoyamato.co.jp/cgi-bin/tneko'
data = {
'number00' : '1',
'number01' : '000000000000'
}
data_e = urllib.parse.urlencode(data)
req = urllib.request.Request(url, data_e.encode('sjis'))
res = urllib.request.urlopen(req)
soup = BeautifulSoup(res.read())