Skip to content

Instantly share code, notes, and snippets.

View ikeikeikeike's full-sized avatar
🈵
Working

ikedat / Tatsuo Ikeda ikeikeikeike

🈵
Working
  • 3C
  • Tokyo, Japan
  • 01:30 (UTC +09:00)
View GitHub Profile
@ikeikeikeike
ikeikeikeike / gist:2045506
Created March 15, 2012 17:34
out_gstore.rb
module Fluent
class GStoreOutput < Fluent::TimeSlicedOutput
Fluent::Plugin.register_output('gstore', self)
def initialize
super
require 'gstore'
require 'kconv'
@ikeikeikeike
ikeikeikeike / gist:2045536
Created March 15, 2012 17:39
fluent.conf
<match pattern>
type gstore
gstore_key_id API_ACCESS_KEY
gstore_sec_key API_SECRET_KEY
gstore_bucket BUCKET_NAME
@ikeikeikeike
ikeikeikeike / gist:2093308
Created March 19, 2012 03:36
gem install gstore
$ gem install gstore
@ikeikeikeike
ikeikeikeike / gist:2115601
Created March 19, 2012 15:07
Assign Lexer
# -*- coding: utf-8 -*-
import sys
import decimal
import ply.lex as lex
class AssignLexer(object):
t_ignore = ' \t\r\f\v'
t_ignore_comment = r'\#.*'
@ikeikeikeike
ikeikeikeike / gist:2115772
Created March 19, 2012 15:12
calc and assign
a1 = 1 + 2 + 3 # a1 = 6
a2 = 5 + 2 - 6 # a2 = 1
a3 = "name" # a3 = "name"
a4 = "(`Д´)ノ" # a4 = "(`Д´)ノ"
@ikeikeikeike
ikeikeikeike / gist:2160659
Created March 22, 2012 17:40
run lexer.py
$ py lexer.py
LexToken(NUMBER,Decimal('3'),2,5)
LexToken(PLUS,'+',2,7)
LexToken(NUMBER,Decimal('2'),2,9)
LexToken(MULT,'*',2,11)
LexToken(NUMBER,Decimal('4'),2,13)
LexToken(DIV,'/',2,15)
LexToken(NUMBER,Decimal('2'),2,17)
------------------------------------------
------------------------------------------
# -*- coding: utf-8 -*-
import sys
import ply.yacc as yacc
from lexer import AssignLexer
import core
_quiet = True
class AssignLogger(yacc.PlyLogger):
@ikeikeikeike
ikeikeikeike / gist:2207148
Created March 26, 2012 17:35
run parser.py
$ py parser.py
Discard(Const('test'))
----------
Discard(Mul((Const(Decimal('1')), Sub((Const(Decimal('2')), Div((Const(Decimal('1')), Const(Decimal('3')))))))))
----------
Assign([AssName('name', 'OP_ASSIGN')], Add((Const(Decimal('1')), Add((Const(Decimal('2')), Const(Decimal('10')))))))
----------
Assign([AssName('name', 'OP_ASSIGN')], Const('name'))
----------
Assign([AssName('name', 'OP_ASSIGN')], Const('(`\xd0\x94\xc2\xb4)\xef\xbe\x89'))
# -*- coding: utf-8 -*-
def flatten(seq):
l = []
for elt in seq:
t = type(elt)
if t is tuple or t is list:
for elt2 in flatten(elt):
l.append(elt2)
else:
@ikeikeikeike
ikeikeikeike / gist:2260879
Created March 31, 2012 08:33
PySide UndoFramework
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PySide.QtGui import QUndoCommand, QUndoStack
class MyDocument(object):
def __init__(self):
self.document = []