Skip to content

Instantly share code, notes, and snippets.

View ochilab's full-sized avatar

おちラボ ochilab

View GitHub Profile
@ochilab
ochilab / todoistGetCompleteItems.gs
Created June 26, 2023 05:04
GAS: Todoistから完了したタスクを取ってくる
/**
sinceから現在まですべてのタスクをとってくる
since: 取得開始する日時 (2023-06-26 というフォーマットの文字列)
**/
function todoistGetCompleteItems(since) {
const token = PropertiesService.getScriptProperties().getProperty('TODOIST_TOKEN');
const url = 'https://api.todoist.com/sync/v9/completed/get_all?since='+since+'T00:00:00';
const params = {
headers: { 'Authorization': `Bearer ${token}` }
};
@ochilab
ochilab / assignScriptsToImages.gs
Created June 14, 2023 11:42
GAS: GoogleSheet上の画像にスクリプトを動的に割り当てる(複数の画像を配置した場合)
function assignScriptsToImages() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var images =sheet.getImages();
for(var i=0;i<images.length;i++){
switch(images[i].getAltTextTitle()){
case "risu":
images[i].assignScript("risuSay");
break;
case "momo":
images[i].assignScript("momoSay");
@ochilab
ochilab / getJointData.py
Created May 31, 2023 03:47
pyKinectAzureで関節(joint)の情報をとってくる
import numpy as np
import cv2
import pykinect_azure as pykinect
if __name__ == “__main__“:
# Initialize the library, if the library is not found, add the library path as argument
pykinect.initialize_libraries(track_body=True)
# Modify camera configuration
device_config = pykinect.default_configuration
device_config.color_resolution = pykinect.K4A_COLOR_RESOLUTION_OFF
device_config.depth_mode = pykinect.K4A_DEPTH_MODE_WFOV_2X2BINNED
@ochilab
ochilab / setValue.gs
Created May 30, 2023 05:34
講義資料:GASでHTTPでデータを受け取り、シートに書き込む例(戻り値のjsonは暫定)
function doPost(e){
var params = JSON.parse(e.postData.getDataAsString());
var data = params.data;
//// 以下の範囲独自処理を書く
//シートへの書き込み
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName('シート1');
@ochilab
ochilab / getValue.gs
Last active May 30, 2023 05:35
講義資料:GASでシートを読み込んで、JSONで返す例(HTTPのパラメータの受け取り処理はなくても良い)
function doPost(e){
var params = JSON.parse(e.postData.getDataAsString());
var data = params.data;
//// 以下の範囲独自処理を書く
//シートへの書き込み
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName('シート1');
// A2セルを選択
@ochilab
ochilab / urllibRequest.py
Last active May 17, 2023 09:57
Python:リダイレクトされるURLに対応したhttpリクエスト(urllib.requestを利用)
import urllib.request
def urllibRequest():
url="https://xxxxxxxxxxxx"
response = urllib.request.urlopen(url)
content = response.read()
if content is not None:
response = {
'statusCode': 200,
'body': content
@ochilab
ochilab / CameraImageToMovieFile.py
Created May 1, 2023 07:43
Python: OpenCVでカメラの映像を動画ファイルとして保存する
import cv2
cap = cv2.VideoCapture(0)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
# フォーマット指定
fmt = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
writer = cv2.VideoWriter('output.mp4', fmt, 25, (width, height))
@ochilab
ochilab / searchSheet.gs
Created April 26, 2023 14:57
GAS:特定の列のデータを探して、その行のデータを返す
/**
* keyword: 検索したいキーワード
* keywordColumn:検索する列
* outputColumn: 出力する列
*/
function searchSheet(keyword,keywordColumn,outputColumn) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("シート1");
var data = sheet.getRange(1,keywordColumn,3).getValues();
var result = "";
console.log("data="+data);
@ochilab
ochilab / BGSubtractor.py
Created December 16, 2022 10:30
OpenCVで背景差分を取得する(Python編)
cap = cv2.VideoCapture("sample.avi")
subtractor = cv2.bgsegm.createBackgroundSubtractorMOG()
while True:
# 画像を取得
ret, frame = cap.read()
if not ret:
break
detect_mask = subtractor.apply(frame, learningRate=0)
#差分表示
cv2.imshow("detect_mask", detect_mask)
@ochilab
ochilab / getGcStudentList.py
Last active September 17, 2022 09:41
Pythonで、Google Classroomの受講生のメールアドレスを取得する
SCOPES = ['https://www.googleapis.com/auth/classroom.courses.readonly'
,'https://www.googleapis.com/auth/classroom.rosters'
,'https://www.googleapis.com/auth/classroom.rosters.readonly'
,"https://www.googleapis.com/auth/classroom.profile.emails",
"https://www.googleapis.com/auth/classroom.profile.photos"]
def getGcStudentList():
creds = None
if os.path.exists('token.json'):