Skip to content

Instantly share code, notes, and snippets.

View najeira's full-sized avatar

najeira

View GitHub Profile
@najeira
najeira / gist:b8c9d438d30b242643bc
Last active August 29, 2015 14:20
Kinesisメモ

GoでKinesis用ライブラリを作るメモ

Writer

Kinesisにデータを送るクラス。

コネクションは呼び出し側で作成してもらう。 それを引数にしてWriterを生成する。

Addメソッドで行を追加していく。

@najeira
najeira / gist:280c347ecb6bd9f2e680
Created August 15, 2014 03:20
Golang BigQuery example
package main
import (
bigquery "code.google.com/p/google-api-go-client/bigquery/v2"
"code.google.com/p/goauth2/oauth/jwt"
"encoding/json"
"fmt"
)
func main() {
# -*- coding: utf-8 -*-
import os
import datetime
import jinja2
import webapp2
from google.appengine.api import users
from google.appengine.ext import ndb
class Page(ndb.Model):
title = ndb.StringProperty(indexed=False)
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
)
@najeira
najeira / memo.md
Last active August 29, 2015 13:57
Growthforecast setting up
@najeira
najeira / gist:5682804
Created May 31, 2013 03:36
verify Amazon SNS message
def verify(message):
# the string to sign
sign_str = []
for key in ("Message", "MessageId", "Subject", "Timestamp", "TopicArn", "Type"):
if key == "Subject" and key not in message:
continue
sign_str.append(key)
sign_str.append(message[key])
sign_str.append("")
sign_str = "¥n".join(sign_str)
@najeira
najeira / gist:3135184
Created July 18, 2012 09:13
nginx.conf example
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$request_time"';
sendfile on;
keepalive_timeout 65;
@najeira
najeira / gist:1769576
Created February 8, 2012 13:39
Get Key trough ReferenceProperty
from google.appengine.ext import db
class Foo(db.Model):
pass
class Bar(db.Model):
foo = db.ReferenceProperty(Foo)
Bar.foo.get_value_for_datastore(bar_obj) #=> Key of Foo
@najeira
najeira / gist:1372274
Created November 17, 2011 03:16
Create snapshot of Amazon RDS by Python
# -*- coding: utf-8 -*-
import datetime
from boto import rds
#設定
AccessKey = '****'
AccessSecret = '****'
DbinstanceId = '****'
Region = 'ap-northeast-1'
@najeira
najeira / gist:1341622
Created November 5, 2011 14:55
QueryIterator for async - Google App Engine / Python
class QueryIterator(object):
def __init__(self, query, limit=None):
self.limit = limit
self.count = 0
if limit:
config = datastore_query.QueryOptions(limit=limit, prefetch_size=limit)
else:
config = None
self.iterator = query.run(config=config)