This file contains hidden or 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
module Fluent | |
class GStoreOutput < Fluent::TimeSlicedOutput | |
Fluent::Plugin.register_output('gstore', self) | |
def initialize | |
super | |
require 'gstore' | |
require 'kconv' |
This file contains hidden or 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
<match pattern> | |
type gstore | |
gstore_key_id API_ACCESS_KEY | |
gstore_sec_key API_SECRET_KEY | |
gstore_bucket BUCKET_NAME |
This file contains hidden or 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
$ gem install gstore |
This file contains hidden or 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 sys | |
import decimal | |
import ply.lex as lex | |
class AssignLexer(object): | |
t_ignore = ' \t\r\f\v' | |
t_ignore_comment = r'\#.*' |
This file contains hidden or 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
a1 = 1 + 2 + 3 # a1 = 6 | |
a2 = 5 + 2 - 6 # a2 = 1 | |
a3 = "name" # a3 = "name" | |
a4 = "(`Д´)ノ" # a4 = "(`Д´)ノ" |
This file contains hidden or 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
$ 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) | |
------------------------------------------ | |
------------------------------------------ |
This file contains hidden or 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 sys | |
import ply.yacc as yacc | |
from lexer import AssignLexer | |
import core | |
_quiet = True | |
class AssignLogger(yacc.PlyLogger): |
This file contains hidden or 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
$ 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')) |
This file contains hidden or 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 -*- | |
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: |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from PySide.QtGui import QUndoCommand, QUndoStack | |
class MyDocument(object): | |
def __init__(self): | |
self.document = [] |