Skip to content

Instantly share code, notes, and snippets.

おちラボ ochilab

View GitHub Profile
@ochilab
ochilab / OJEncoder.py
Last active Jul 3, 2020
クラスに格納されているデータをJSON形式に変換する(日本語文字列対応)
View OJEncoder.py
def OJEncoder(obj):
class MyEncoder(JSONEncoder):
def default(self, o):
return o.__dict__
return MyEncoder(ensure_ascii=False).encode(obj)
@ochilab
ochilab / depth2multi-tiff.py
Last active Jul 1, 2020
RealsenseのDepthデータをMulti-Tiffに保存する
View depth2multi-tiff.py
# -*- coding: utf-8 -*-
# use tiffile library
# https://pypi.org/project/tifffile/
import pyrealsense2 as rs
import numpy as np
import tifffile
@ochilab
ochilab / getSelectedTextByMouse.gs
Last active Jun 4, 2020
Google Document内でマウス選択した箇所を取ってくる方法
View getSelectedTextByMouse.gs
var selection = DocumentApp.getActiveDocument().getSelection();
if (selection) {
var elements = selection.getRangeElements();
text= elements[0].getElement().asText().getText();
text = text.substring(elements[0].getStartOffset(),elements[0].getEndOffsetInclusive());
DocumentApp.getUi().alert(text);
}
@ochilab
ochilab / AddfirestoreSmaple.py
Last active May 19, 2020
firestoreにデータを保存する
View AddfirestoreSmaple.py
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
import os
#環境変数
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = './firebasekey.json'
cred = credentials.Certificate('firebasekey.json')
firebase_admin.initialize_app(cred)
db = firestore.Client()
@ochilab
ochilab / downloadFile.js
Created May 3, 2020
JavaScriptでデータをファイルとしてダウンロードさせる
View downloadFile.js
function downloadFile() {
var content="aaaa,bbbbb,ccccc";
var blob = new Blob([ content ], { "type" : "text/csv"});
var downLoadLink = document.createElement("a");
downLoadLink.download ="test.csv";
downLoadLink.href = window.URL.createObjectURL(blob);
downLoadLink.dataset.downloadurl = ["text/plain", downLoadLink.download, downLoadLink.href].join(":");
downLoadLink.click();
}
@ochilab
ochilab / css.html
Created May 3, 2020
GASでBootStrapを利用する際のテンプレート
View css.html
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
@ochilab
ochilab / assignScriptToImage.gs
Created May 2, 2020
GAS: Sheetのイメージにスクリプトを動的に割り当てる
View assignScriptToImage.gs
function assignScriptToImage() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var images =sheet.getImages();
images[0].assignScript("test");
}
function test(){
Browser.msgBox("aaa");
}
@ochilab
ochilab / getClassList.gs
Last active May 2, 2020
GAS:自分が参加しているクラスの情報を取得する(Google Classroom API)
View getClassList.gs
function getClassList(){
var optionalArgs = {
pageSize: 100 //クラスの数が多い場合はここを増やす
};
var response = Classroom.Courses.list(optionalArgs);
var courses = response.courses;
if (courses && courses.length > 0) {
for (i in courses) {
var course = courses[i];
Logger.log(course.name);
@ochilab
ochilab / firebaseClientCredential.py
Created Mar 30, 2020
PythonでFirebaseを用いる際のサービスアカウント情報の設定
View firebaseClientCredential.py
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
import os
#環境変数
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = './xxxxx-credentials.json'
#credentialsの読み込み
cred = credentials.Certificate('xxxxx-credentials.json')
@ochilab
ochilab / tkOpenCVCamera.py
Last active Mar 9, 2020
Tkinterでのカメラ映像表示
View tkOpenCVCamera.py
root=tk.Tk()
root.title("RGB Recorder")
root.geometry("800x600")
root.resizable(width=False, height=False)
canvas=tk.Canvas(root, width=640, height=480, bg="white")
canvas.pack()
def update():#update
global img
global camera
You can’t perform that action at this time.