Skip to content

Instantly share code, notes, and snippets.

@NaotoKumagai
NaotoKumagai / web_server
Last active November 19, 2016 10:29
ESP-WROOM-02 でローカルのWebサーバ
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#define WIFI_SSID "接続したいSSID"
#define WIFI_PWD "接続したいSSIDのパスワード"
// HTML
#define HTML_HEADER "<!doctype html>"\
"<html><head><meta charset=\"UTF-8\"/>"\
"<meta name=\"viewport\" content=\"width=device-width\"/>"\
@NaotoKumagai
NaotoKumagai / gist:1966ef3ae90d85c7268c2373af68b3bf
Created October 10, 2016 21:40
ブログ用レスポンスデータ
2016/10/11 06:17:13 GET /customsearch/v1/?cx=【検索エンジンID】&key=【APIキー】&num=3&q=google&searchType=image HTTP/1.1
Host: www.googleapis.com
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"
},
@NaotoKumagai
NaotoKumagai / gist:7d247b4d8fe86f41d9d0363130786b0e
Last active October 10, 2016 21:18
GoogleCustomSearchを適当に叩く(エラーガン無視...)
package main
import (
"fmt"
"github.com/franela/goreq"
)
type Parameter struct {
Key string
Q string
@NaotoKumagai
NaotoKumagai / goreqのサンプル
Created October 10, 2016 18:28
goreqのサンプル
package main
import (
"fmt"
"github.com/franela/goreq"
)
func main() {
res, _ := goreq.Request{ Uri: "https://www.googleapis.com/customsearch/v1" }.Do()
body, _ := res.Body.ToString()
@NaotoKumagai
NaotoKumagai / make_schema.pl
Last active November 19, 2016 10:39
Embulkのinputとoutput時のスキーマ作成補助
#!/usr/bin/perl
for(@ARGV) {
open(IN, $_) || die "$!";
for(<IN>) {
# 通常のjsonだと m/"(\w*?)":["|\d]/g
for my $match ( m/"(\$?\w*?)":["|\d|true|false]/g ) {
$is_match = 0;
for my $_ (@list) {
if($_ eq $match) {
@NaotoKumagai
NaotoKumagai / jsonkey.pl
Last active November 19, 2016 10:39
【Perl】Jsonのkey名抽出
#!/usr/bin/perl
for(@ARGV) {
open(IN, $_) || die "$!";
for(<IN>) {
# 通常のjsonだと m/"(\w*?)":["|\d]/g
for my $match ( m/"(\$?\w*?)":["|\d|true|false]/g ) {
$is_match = 0;
for my $_ (@list) {
if($_ eq $match) {
@NaotoKumagai
NaotoKumagai / tmp
Created September 28, 2015 15:25
Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=111, too big.
`EmbulkのBigquerryのプラグインを利用していて以下のエラーが出た。
`Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=111, too big.
`間違えて秘密鍵を適当なエディタで開いてしまい、のエンコード形式が変わっていたのが原因。
public class SampleFragment extends Fragment {
/** Fragmentで保持しておくデータ */
private int mData;
/**
* Fragmentインスタンスを生成した返却.
*
* コンストラクタに引数を渡すのはダメ。
* Fragmentがメモリ不足で破棄され、そこから復帰する時に空のコンストラクタ呼ばれる。