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
def gen(init, ret, next): | |
while True: | |
yield ret(init) | |
init = next(init) | |
def myfor(iter, n): | |
a = [] | |
for i, x in enumerate(iter): | |
if i == n: | |
break |
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 pyNotificationCenter as nc | |
import sys | |
def runtimer(objective): | |
nc.notify('25 min timer started', None, objective, delay=0, sound=False) | |
nc.notify('25 min timer timeup', None, objective, delay=10, sound=True) | |
def makelogtemplate(objective): | |
import datetime | |
import locale |
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
def str_collection(obj): | |
if isinstance(obj, list): | |
if len(obj) > 0: | |
result = ['[', str(obj[0])] | |
for o in obj[1:]: | |
result.append(', ') | |
result.append(o.__str__()) | |
result.append(']') | |
return ''.join(result) | |
return obj.__str__() |
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
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()) |
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
# -*- 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() |
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
OUTPUT_FORMAT("binary") | |
ENTRY(KernelMain) | |
HEAP_SIZE = 0; | |
MMAREA_SIZE = 0; | |
__ctors = ADDR(.ctors); | |
__ctors_count = SIZEOF(.ctors) / 4; | |
SECTIONS |
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
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; |
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> | |
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> |
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 <utility> | |
#include <string> | |
using namespace std; | |
// {{{ | |
struct ListTerminator | |
{ | |
}; | |
const ListTerminator NIL {}; |
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 <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <netdb.h> | |
#include <unistd.h> | |
using namespace std; |
OlderNewer