Skip to content

Instantly share code, notes, and snippets.

View key's full-sized avatar

Mitsukuni Sato key

View GitHub Profile
@key
key / geocoding.py
Created November 2, 2011 04:30
python geocoding (using Google Maps API service)
def geocoding(address):
from httplib2 import Http
import simplejson
url_prefix = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address='
(header, response) = Http().request(url_prefix + address)
decoder = simplejson.JSONDecoder()
dict_ = decoder.decode(response)
@key
key / gist:1650808
Created January 21, 2012 02:16
How to use Google Maps API geocoder
var address = "Shinagawa station"
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var location = results[0].geometry.location;
} else {
alert("Unable to find address: " + status);
}
}
@key
key / swfrect.py
Created March 14, 2012 04:52 — forked from moriyoshi/swfrect.py
to get rectangle of swf object.
import struct
import zlib
import itertools
class bitstream(object):
def __init__(self, buf):
self.buf = buf
self.i = 0
self.rem = 0
self.n = 0
@key
key / fetch_feeds_from_googlereader.py
Created July 4, 2012 11:48
Fetch all feeds from Google Reader
# coding:utf-8
# please install gdata module from pypi
import gdata.service
FEED_URL = 'http://example.com/feed'
# google account
CONFIG = {
'Email': '[email protected]',
@key
key / python_if_statement.py
Created April 26, 2013 07:15
python if statement test
>>> def a(): print 'a'; return False
>>> def b(): print 'b'; return True
>>> if a() and b():
... print 'hogehoge'
...
a
@key
key / file0.txt
Created November 28, 2013 06:02
Background App Refreshについて ref: http://qiita.com/key/items/3cc7f631393149bac567
UIApplication *app = [UIApplication sharedApplication];
if (app.backgroundRefreshStatus == UIBackgroundRefreshStatusAvailable) {
NSLog(@"バックグラウンド更新が可能");
} else if(app.backgroundRefreshStatus == UIBackgroundRefreshStatusDenied) {
NSLog(@"バックグラウンド更新はユーザによって禁止されている。");
} else if(app.backgroundRefreshStatus == UIBackgroundRefreshStatusRestricted) {
NSLog(@"デバイス設定により無効にされている(ユーザが有効にすることは出来ない)。");
}
@key
key / file0.txt
Created December 3, 2013 05:47
iPhone5sの位置情報水平精度を取得してみた ref: http://qiita.com/key/items/1d196c4ec477f8773cd1
- (id)init
{
self = [super init];
if (self) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
[_locationManager startUpdatingLocation];
[Flurry startSession:@"YOUR_FLURRY_API_KEY"];
}
@key
key / tests.py
Created April 8, 2015 12:54
django test sample
from django.test import TestCase
class SomeAPITestCase(TestCase):
fixtures = [
'fixtures/someapi/user.yaml',
]
def setUp(self):
super(SomeAPITestCase, self).setUp()
{
"status": "ok",
"message": "test response"
}
@key
key / convert_double_to_nsdata.swift
Last active December 21, 2016 22:48
Convert `Double` value to `NSData` in Swift
var x: Double = 0.99043125417
var length = sizeof(Double) // -> 8
var x_data = NSData(bytes: &x, length: length)
var buffer = [UInt8](count: sizeof(Double), repeatedValue: 0x00)
x_data.getBytes(&buffer, length: buffer.count)
print(buffer) // -> "[210, 21, 179, 226, 156, 177, 239, 63]\n"