Skip to content

Instantly share code, notes, and snippets.

View tanaikech's full-sized avatar

Kanshi TANAIKE tanaikech

View GitHub Profile
@tanaikech
tanaikech / file0.txt
Last active October 14, 2016 05:07
Google Apps Scriptで配列要素の総和処理を高速で行いたい ref: http://qiita.com/tanaike/items/17c88c69a0aa0b8b18d7
Declare a string variable arr, sum
Declare an integer variable loopcounter
Set arr to size n
for loopcounter = 0 to (size of arr) - 1
sum = sum + arr[loopcounter]
loopcounter = loopcounter + 1
endfor
@tanaikech
tanaikech / file0.txt
Created October 14, 2016 05:13
ピラミッド方式の他言語への適応性 ref: http://qiita.com/tanaike/items/64ff01fad8d5958a56d5
N_{l} = \sum_{k=1}^{\omega - 1} \frac{\theta}{\phi^{k}} \tag{1}
@tanaikech
tanaikech / file0.txt
Created October 21, 2016 03:35
Pythonでリスト内要素を要素、重複数として重複数でソートして出力 ref: http://qiita.com/tanaike/items/5a94e9bb1154d1caefca
data = ['a', 'b', 'c', 'd', 'b', 'c', 'd', 'b', 'c', 'b']
result = sorted({i: data.count(i) for i in set(data)}.items(), key=lambda x: x[1], reverse=True)
print(result)
>>> [('b', 4), ('c', 3), ('d', 2), ('a', 1)]
@tanaikech
tanaikech / file0.txt
Created October 30, 2016 05:03
PythonでのCSVファイル出力の速度評価 ref: http://qiita.com/tanaike/items/f1a986a34e03dcbb7729
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import csv
import pandas as pd
import SOUWA
def measure_csv(ar):
start = time.time()
@tanaikech
tanaikech / file0.txt
Last active October 31, 2016 08:46
Google Apps Scriptで指定したフォルダへ直接スプレッドシートを作成する ref: http://qiita.com/tanaike/items/8c82392ef2749892061c
Drive.Files.insert({
"title": ファイル名,
"mimeType": "application/vnd.google-apps.spreadsheet",
"parents": [{"id": フォルダID}]
});
@tanaikech
tanaikech / file0.txt
Created November 20, 2016 02:50
Googleスプレッドシートで空白のみのセルを削除する ref: http://qiita.com/tanaike/items/1e93a0355aaef8355035
var ss = SpreadsheetApp.getActiveSheet();
var data = ss.getDataRange().getValues();
for (var i in data){
for (var j in data[i]){
if (data[i][j].length > 0 && !/^[a-zA-Z0-9]+$/.test(data[i][j])){
data[i][j] = null;
}
}
}
ss.getRange("A1").offset(0,0, data.length, data[0].length).setValues(data);
@tanaikech
tanaikech / file0.txt
Last active December 31, 2016 01:44
OmniMarkupPreviewerでプレビューできない場合の対処法 ref: http://qiita.com/tanaike/items/816d3096cb7978e3452d
def makeExtension(configs=None):
return StrikeoutExtension(configs=configs)
@tanaikech
tanaikech / file0.bat
Created January 11, 2017 05:15
ワンライナーコードでNetatmoからデータを取得, 表示する ref: http://qiita.com/tanaike/items/539dd06a1ffd7b7451e9
> setlocal & curl -s -d "grant_type=password&client_id='#####'&client_secret='#####'&username='#####'&password='#####'&scope=read_station" "https://api.netatmo.net/oauth2/token" | for /f "usebackq tokens=*" %a in (`jq -r ".access_token"`) do @set a="%a" | curl -s -d "access_token=%a&device_id='#####'" "https://api.netatmo.net/api/getstationsdata" > dat.txt & for /f "usebackq tokens=*" %b in (`jq -r ".body.devices[0].dashboard_data.Temperature" dat.txt`) do @set b="%b" | echo: & set /p nb=Indoor: Temperature %b [degree C],<nul & for /f "usebackq tokens=*" %b in (`jq -r ".body.devices[0].dashboard_data.Humidity" dat.txt`) do @set b="%b" | set /p nb=Humidity %b [%],<nul & for /f "usebackq tokens=*" %b in (`jq -r ".body.devices[0].dashboard_data.Pressure" dat.txt`) do @set b="%b" | set /p nb=Pressure %b [hPa]<nul & for /f "usebackq tokens=*" %b in (`jq -r ".body.devices[0].modules[0].dashboard_data.Temperature" dat.txt`) do @set b="%b" | echo: & set /p nb=Outdoor: Temperature %b [degree C],<nul & for /f "usebackq
@tanaikech
tanaikech / sample.s
Last active January 15, 2017 22:30
Google Apps Scriptでファイル名、フォルダ名からファイルへアクセスしたい ref: http://qiita.com/tanaike/items/94c263d3906ee23ad522
function F_number(file_name, folder_name) {
var Array_files = [];
var Array_folders = [];
var fileIT = DriveApp.getFilesByName(file_name);
while (fileIT.hasNext()) {
Array_files.push(fileIT.next().getId());
};
var folderIT = DriveApp.getFoldersByName(folder_name);
@tanaikech
tanaikech / file0.txt
Last active January 20, 2017 08:24
コマンドラインからローカルPCまたはweb上の画像データを使ってGoogleの類似画像検索を行う ref: http://qiita.com/tanaike/items/dd89e41bf77bc3d96f51
$ python スクリプト.py -f ファイル名