Skip to content

Instantly share code, notes, and snippets.

View key's full-sized avatar

Mitsukuni Sato key

View GitHub Profile
@key
key / drive.py
Last active December 31, 2021 07:59 — forked from basuke/drive.py
Python3 support! Create the GPX file from origin and destination using the GoogleMap Direction API. You can use this output for simulate the location apps in Xcode.
#
# python drive.py 'origin' ['waypoint' ... ] 'destination' --apikey=GOOGLE_MAPS_APIKEY
#
# i.e. python drive.py 'Union Square, San Francisco' 'Ferry Building, San Francisco' 'Bay Bridge' SFO
import hashlib
import json
import sys
import urllib
import os
from urllib.parse import quote_plus
@key
key / quadkey.ino
Last active June 13, 2019 17:03
Arduino implementation of quadkey
#include <math.h>
/**
以下を参考に実装
https://cttr.jp/2019/04/10/post-453/
https://github.com/buckhx/QuadKey/blob/master/quadkey/tile_system.py
*/
struct PixelXY {
int x;
int y;
@key
key / m5stack-env-sensor.ino
Last active June 3, 2019 13:13
m5stack env sensor
/*
* This code is example to get environment variable and upload to google spreadsheet.
*
* Requirements:
* - M5STACK (I tested this code on M5STACK FIRE)
* - Adafruit_BMP280 library
* - DHT12 library
*
* Usage:
* - Connect env unit to M5Stack port A.
@key
key / gist:814427ce19fa41bc42ba52a3c60704d1
Last active August 30, 2018 13:15
Encoding / Decoding JSON in python
import json
# JSON文字列をPythonオブジェクトにする
print(json.loads('{"key":"value"}'))
# PythonオブジェクトをJSON文字列にする
print(json.dumps({"key":"value"}))
@key
key / gist:6ab80db7dd277d61f271aeb0f698381f
Created July 6, 2017 07:49
sakuraio: some values into single channel
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <SakuraIO.h>
#include <string.h>
/*
This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
@key
key / hash_speed_test.py
Last active April 28, 2017 02:36
hash algorithm speed comparison ref: http://qiita.com/key/items/f614e90ef9ec5c4c839b
#!/usr/bin/env python
import timeit
def mmh3_test():
import mmh3
for i in range(0, 100000):
mmh3.hash(str(i))
@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"
@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 / 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 / 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