Skip to content

Instantly share code, notes, and snippets.

View nkoneko's full-sized avatar

Nekomura, Koneko nkoneko

  • Tokyo
View GitHub Profile
@nkoneko
nkoneko / .gitignore
Last active December 22, 2015 19:29
To help beginners
.python-version
__pycache__/
@nkoneko
nkoneko / httpmessage.py
Created September 18, 2013 17:32
I started to write a HTTP-message parser. It'll take me forever to implement the parser due to lack of my understanding on ParserCombinator.
from pyparsing import ParseException, _PositionToken, ParserElement
from pyparsing import (
Or, Group, Word, Literal, Optional, Regex, Empty, LineEnd,
Combine, ZeroOrMore, OneOrMore, Forward)
# FIXME: need to know how pyparsing handles whitespaces
class CarriageReturn(_PositionToken):
def __init__(self):
super(CarriageReturn, self).__init__()
self.setWhitespaceChars(ParserElement.DEFAULT_WHITE_CHARS.replace('\r', ''))
@nkoneko
nkoneko / fnptr.c
Created December 26, 2013 14:29
Function Pointer. Not a good example.
#include <stdio.h>
#define USE_BINARY_FUNC typedef struct { \
T (*fn)(T, T); \
} T##_binfn;
USE_BINARY_FUNC(int)
USE_BINARY_FUNC(float)
int add(int x, int y) { return x + y; }
#!/bin/sh
usage() {
cat 1>&2 <<EOS
SYNOPSIS
${SCRIPT_NAME} TARGET VERSION
TARGET either of the followings:
gmp, mpfr, mpc, isl, cloog, lzip, gcc, binutils
EOS
#!/bin/sh
usage() {
cat 1>&2 <<EOS
SYNOPSIS
${SCRIPT_NAME} TARGET VERSION
TARGET either of the followings:
lzip, curl, gcc
EOS
CXX = g++
CFLAGS = -std=c++0x -Wall
LDFLAGS = -Llib -lboost_system -lboost_filesystem
LIBS =
INCLUDE = -Iinclude
TARGET = ./bin/$(shell basename `readlink -f .`)
SRCDIR = ./src
OBJDIR = ./build
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
OBJECTS = $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(SOURCES))
import itertools as I
import functools as F
import operator as O
FROM=3
TO=117
_=lambda m,f,g:I.cycle(I.chain(I.repeat(g,m-1),[f]))
_id=lambda x:x
_th=lambda x:x+2
import itertools as I
import functools as F
FROM=1
TO=32
_=lambda m,f,g:I.cycle(I.chain(I.repeat(g,m-1),[f]))
_id=lambda x:x
_fizz=lambda x:x+'Fizz'
#!/usr/bin/python
if __name__=='__main__':
import itertools as _;import sys as __;
____=lambda ____,__,___:_.cycle(_.chain(_.repeat(___,____-1),[__]))
_____=lambda __,_:_ if _ else str(__)
print(' '.join(list(_.islice((_____(_,__(___(''))) for _,___,__ in _.izip(_.count(1),____(3,lambda _:_+'Fizz',lambda _:_),____(5,lambda _:_+'Bazz',lambda _:_))),int(__.argv[1])-1,int(__.argv[2])))))
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <iostream>
#include <string>
#include <complex>
namespace
{