Skip to content

Instantly share code, notes, and snippets.

Avatar

najeira

View GitHub Profile
@najeira
najeira / test.py
Created Oct 3, 2011
Check mediawiki responses for Tuningathon#2
View test.py
# -*- coding: utf-8 -*-
import urllib
import urllib2
import time
MASTER_SERVER = '127.0.0.1'
PAGE_FORMAT = 'http://%s/mediawiki/index.php/%s'
TARGETS = [
@najeira
najeira / gist:1341295
Created Nov 5, 2011
encode and decode between int,long and string by Python
View gist:1341295
import struct, base64
def long_to_str(value):
value = struct.pack('q', value)
value = base64.urlsafe_b64encode(value)
value = value.rstrip('=')
value = value.rstrip('A')
return value
@najeira
najeira / gist:1341622
Created Nov 5, 2011
QueryIterator for async - Google App Engine / Python
View gist:1341622
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)
@najeira
najeira / gist:1372274
Created Nov 17, 2011
Create snapshot of Amazon RDS by Python
View gist:1372274
# -*- coding: utf-8 -*-
import datetime
from boto import rds
#設定
AccessKey = '****'
AccessSecret = '****'
DbinstanceId = '****'
Region = 'ap-northeast-1'
@najeira
najeira / gist:1769576
Created Feb 8, 2012
Get Key trough ReferenceProperty
View gist:1769576
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:3135184
Created Jul 18, 2012
nginx.conf example
View gist:3135184
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:5682804
Created May 31, 2013
verify Amazon SNS message
View gist:5682804
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 / memo.md
Last active Aug 29, 2015
Growthforecast setting up
View memo.md
View gist:451ebaeef0d9451d715b
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
)
View gist:26e6e788fa7a6943ebec
# -*- 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)
You can’t perform that action at this time.