Skip to content

Instantly share code, notes, and snippets.

View knoguchi's full-sized avatar

Kenji Noguchi knoguchi

View GitHub Profile
@knoguchi
knoguchi / gist:6952087
Last active May 29, 2019 17:08
get financial report from Google Finance. [UPDATE] The days of good old static html is long gone. This script no longer works.
#!/usr/bin/env python
"""
Get financial data from Google Finance.
Requirment:
pyquery 1.2.6. (1.2.1 did not work)
Report types:
inc - income statement
bal - balance sheet
@knoguchi
knoguchi / file0.txt
Last active August 19, 2019 15:25
PythonとDB: DBIのcursorを理解する ref: https://qiita.com/knoguchi/items/3d5631505b3f08fa37cc
DECLARE カーソル名 CURSOR FOR SELECT文
@knoguchi
knoguchi / file1.html
Last active August 29, 2015 14:14
Python+PyQueryでスクレイピング ref: http://qiita.com/knoguchi/items/cd51a00de026ef92080a
<ul>
<li x="123" class="red"> item 1 </li>
<li x="123" class="red"> item 2 </li>
<li x="123" class="red"> item 3 </li>
</ul>
@knoguchi
knoguchi / ex1.pl0
Last active August 29, 2015 14:15
Pythonでコンパイラ: PL/0パーサー ref: http://qiita.com/knoguchi/items/ee949989d0a9f04bee6f
VAR x, squ;
PROCEDURE square;
BEGIN
squ := x * x
END;
BEGIN
x := 1;
WHILE x <= 10 DO
@knoguchi
knoguchi / file0.txt
Last active August 29, 2015 14:15
Pythonでコンパイラ: PL/0構文木 ref: http://qiita.com/knoguchi/items/6f9b7383b7252a9ebdad
['VAR', 'x', ',', 'squ', ';', 'PROCEDURE', 'square', ';', 'BEGIN', 'squ', ':=', 'x', '*', 'x', 'END', ';', 'BEGIN', 'x', ':=', '1', ';', 'WHILE', 'x', '<=', '10', 'DO', 'BEGIN', 'CALL', 'square', ';', 'x', ':=', 'x', '+', '1', ';', 'END', 'END', '.']
@knoguchi
knoguchi / ex2.pl0
Last active August 29, 2015 14:15
Pythonでコンパイラ: PL/0抽象構文木(AST) ref: http://qiita.com/knoguchi/items/96fa352ff0db60ee2eee
CONST
m = 7,
n = 85;
VAR
x, y, z, q, r;
PROCEDURE multiply;
VAR a, b;
@knoguchi
knoguchi / file0.diff
Last active December 27, 2016 17:53
Pythonで作ったデーモンにREST APIをつける話 ref: http://qiita.com/knoguchi/items/385fe91038760c856530
$ diff -u example.py example_threaded.py
--- example.py 2016-12-20 16:19:19.000000000 -0800
+++ example_threaded.py 2016-12-20 16:23:43.000000000 -0800
@@ -1,6 +1,13 @@
+import logging
+import threading
+
from flask import request, url_for
from flask.ext.api import FlaskAPI, status, exceptions
{
"type": "kafka",
"dataSchema": {
"dataSource": "metrics-kafka",
"parser": {
"type": "protobuf",
"descriptor": "file:///tmp/metricskafka.desc",
"protoMessageType": "MetricsKafka",
"parseSpec": {
"format": "json",
@knoguchi
knoguchi / x.java
Created April 11, 2017 00:14
Packed field test
public void testPacked() throws Exception
{
byte[] protobufData;
final String SCHEMA_STR =
"package mypackage;\n"
+ "message t1 {\n"
+ " repeated uint32 report_code = 1 [packed=true];\n"
+ "}";
@knoguchi
knoguchi / DynamicSchemaUtil.java
Last active April 12, 2017 20:46
Create ProtobufSchema object from .descriptor file
package com.example.jackson.protobuf;
import com.fasterxml.jackson.dataformat.protobuf.schema.FieldType;
import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufEnum;
import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField;
import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage;
import com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchema;
import com.github.os72.protobuf.dynamic.DynamicSchema;
import com.google.protobuf.Descriptors;
import com.squareup.protoparser.DataType;