Skip to content

Instantly share code, notes, and snippets.

Avatar

Kanshi TANAIKE tanaikech

View GitHub Profile
@tanaikech
tanaikech / file0.txt
Last active Oct 14, 2016
Google Apps Scriptで配列要素の総和処理を高速で行いたい ref: http://qiita.com/tanaike/items/17c88c69a0aa0b8b18d7
View file0.txt
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 Oct 14, 2016
ピラミッド方式の他言語への適応性 ref: http://qiita.com/tanaike/items/64ff01fad8d5958a56d5
View file0.txt
N_{l} = \sum_{k=1}^{\omega - 1} \frac{\theta}{\phi^{k}} \tag{1}
@tanaikech
tanaikech / file0.txt
Created Oct 21, 2016
Pythonでリスト内要素を要素、重複数として重複数でソートして出力 ref: http://qiita.com/tanaike/items/5a94e9bb1154d1caefca
View file0.txt
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 Oct 30, 2016
PythonでのCSVファイル出力の速度評価 ref: http://qiita.com/tanaike/items/f1a986a34e03dcbb7729
View file0.txt
#!/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 Oct 31, 2016
Google Apps Scriptで指定したフォルダへ直接スプレッドシートを作成する ref: http://qiita.com/tanaike/items/8c82392ef2749892061c
View file0.txt
Drive.Files.insert({
"title": ファイル名,
"mimeType": "application/vnd.google-apps.spreadsheet",
"parents": [{"id": フォルダID}]
});
@tanaikech
tanaikech / file0.txt
Created Nov 20, 2016
Googleスプレッドシートで空白のみのセルを削除する ref: http://qiita.com/tanaike/items/1e93a0355aaef8355035
View file0.txt
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 Dec 31, 2016
OmniMarkupPreviewerでプレビューできない場合の対処法 ref: http://qiita.com/tanaike/items/816d3096cb7978e3452d
View file0.txt
def makeExtension(configs=None):
return StrikeoutExtension(configs=configs)
@tanaikech
tanaikech / file0.bat
Created Jan 11, 2017
ワンライナーコードでNetatmoからデータを取得, 表示する ref: http://qiita.com/tanaike/items/539dd06a1ffd7b7451e9
View file0.bat
> 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 Jan 15, 2017
Google Apps Scriptでファイル名、フォルダ名からファイルへアクセスしたい ref: http://qiita.com/tanaike/items/94c263d3906ee23ad522
View sample.s
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 Jan 20, 2017
コマンドラインからローカルPCまたはweb上の画像データを使ってGoogleの類似画像検索を行う ref: http://qiita.com/tanaike/items/dd89e41bf77bc3d96f51
View file0.txt
$ python スクリプト.py -f ファイル名