Skip to content

Instantly share code, notes, and snippets.

View draftcode's full-sized avatar

Masaya Suzuki draftcode

View GitHub Profile
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string s("abc\0abc");
cout << s.length() << endl; // 3
cout << distance(s.begin(), s.end()) << endl; // 3
string t("abcdabc");
@draftcode
draftcode / gist:1357281
Created November 11, 2011 05:35
構文解析 Howto

構文解析 Howto

Author: draftcode
Date: 2011-11-11T13:18:07+09:00
ID:289a0136-0c1c-11e1-a06b-040ccee352e6

こうぶん、かいせきー

.class public A
.super java/lang/Object
.method static method()F
fconst_1
freturn
.end method
.method static method()I
iconst_1
.class public hello
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 2
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Hello, World"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
return
.end method
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import threading
class Segment(object):
version_count = 0
def __init__(self, parent):
"""
Args:
class Property(object):
def __init__(self):
self.name = None
def setup_name(self, obj, cls):
for k, v in cls.__dict__.iteritems():
if v is self:
self.name = k
obj.__dict__[k] = None
#include <iostream>
using namespace std;
typedef unsigned long long ull;
ull pow(ull p, ull n) {
ull w = 1;
for (ull i = 1ULL << (sizeof(ull)*8-1); i != 0; i >>= 1) {
if ((n & i) == 0) {
w *= w;
#!/usr/bin/env python
class Application(object):
def __init__(self, lhs, rhs):
self.lhs = lhs
self.rhs = rhs
def __repr__(self):
if isinstance(self.rhs, Variable):
return str(self.lhs) + str(self.rhs)
#!/usr/bin/env python
import urllib
import re
import logging
def extract_booklist(user_id, category="", kininaru="0"):
page = 1
while(True):
url = "http://book.akahoshitakuya.com/u/%s/booklist%s&p=%s" % \
(user_id, category, page)
import os, re, datetime
class CST_tzinfo(datetime.tzinfo):
def utcoffset(self, dt):
return datetime.timedelta(hours=+8) + self.dst(dt)
def dst(self, dt):
return datetime.timedelta(0)
def tzname(self, dt):