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_bytes_to_uint8.swift
Created November 24, 2015 09:51
Convert `Byte Array` to `UInt8` in Swift
// bytes
var buffer: [UInt8] = [0b11111111, 0b11111100, 0b0101, 0b00001]
// get part of bytes
var data = NSData(bytes: [UInt8(buffer[0])], length: sizeof(UInt8))
var target: UInt8 = 0
data.getBytes(&target, length: sizeofValue(data))
print(target) // 255
@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"
{
"status": "ok",
"message": "test response"
}
@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()