This file contains 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
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) |
This file contains 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
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); | |
} | |
} |
This file contains 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
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 |
This file contains 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 | |
# please install gdata module from pypi | |
import gdata.service | |
FEED_URL = 'http://example.com/feed' | |
# google account | |
CONFIG = { | |
'Email': '[email protected]', |
This file contains 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
>>> def a(): print 'a'; return False | |
>>> def b(): print 'b'; return True | |
>>> if a() and b(): | |
... print 'hogehoge' | |
... | |
a |
This file contains 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
UIApplication *app = [UIApplication sharedApplication]; | |
if (app.backgroundRefreshStatus == UIBackgroundRefreshStatusAvailable) { | |
NSLog(@"バックグラウンド更新が可能"); | |
} else if(app.backgroundRefreshStatus == UIBackgroundRefreshStatusDenied) { | |
NSLog(@"バックグラウンド更新はユーザによって禁止されている。"); | |
} else if(app.backgroundRefreshStatus == UIBackgroundRefreshStatusRestricted) { | |
NSLog(@"デバイス設定により無効にされている(ユーザが有効にすることは出来ない)。"); | |
} |
This file contains 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
- (id)init | |
{ | |
self = [super init]; | |
if (self) { | |
_locationManager = [[CLLocationManager alloc] init]; | |
_locationManager.delegate = self; | |
[_locationManager startUpdatingLocation]; | |
[Flurry startSession:@"YOUR_FLURRY_API_KEY"]; | |
} |
This file contains 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
from django.test import TestCase | |
class SomeAPITestCase(TestCase): | |
fixtures = [ | |
'fixtures/someapi/user.yaml', | |
] | |
def setUp(self): | |
super(SomeAPITestCase, self).setUp() |
This file contains 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
{ | |
"status": "ok", | |
"message": "test response" | |
} |
This file contains 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
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" |
OlderNewer