Skip to content

Instantly share code, notes, and snippets.

View ochilab's full-sized avatar

おちラボ ochilab

View GitHub Profile
@ochilab
ochilab / ListAllStudentWork.gs
Created March 8, 2022 16:26
全学生の課題提出状況(Google Classroom API)
function ListAllStudentWork(courseId,courseWorkId){
var listStudentWork = function (pageToken){
if (pageToken){
var newResponse = Classroom.Courses.CourseWork.StudentSubmissions.list(courseId,courseWorkId,{pageToken: pageToken});
if(newResponse.nextPageToken){
return newResponse.studentSubmissions.concat(listStudentWork(newResponse.nextPageToken));
} else{
return newResponse.studentSubmissions;
}
}
@ochilab
ochilab / getAllWorkList.gs
Created March 8, 2022 16:21
あるクラスの全ての課題IDをリストにして取ってくるプログラム(Google Classroom API)
function getAllWorkList(courseId){
var response = Classroom.Courses.CourseWork.list(courseId);
var result= new Array();
response.courseWork.forEach(function(e){
var w= new workInfo(e.id, e.title);
result.push(w);
//Logger.log('%s (%s)', e.title, e.id);
});
return result;
@ochilab
ochilab / AzureSpeechRecognizer.py
Created December 16, 2021 07:28
Azure音声認識を利用して、wavファイルの文字起こしをする
import azure.cognitiveservices.speech as speechsdk
import time
import json
#シークレットキー、サービスリージョン、言語の設定など
speech_key, service_region,language = "xxxxxxxxxxxxxxxxxxxxxxx", "westus2","ja-jp"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region, speech_recognition_language=language)
speech_config.request_word_level_timestamps()
#音声ファイルの設定
@ochilab
ochilab / firstPySimpleGUI.py
Created November 21, 2021 14:47
はじめてのPySImpleGUI
import PySimpleGUI as sg
textlbl = sg.Text('何か入力', size=(10,1))
textBox = sg.InputText('', size=(30,1),key='textBox')
submitButton = sg.Button('入力')
layout = [[textBox], [submitButton]]
# 画面レイアウトを指定
layout = [
[textlbl,textBox],
@ochilab
ochilab / createGDriveFile.dart
Created October 31, 2021 09:28
FlutterでGoogle Driveのファイルを作成する
Future createFile(GoogleAuthClient authenticateClient) async {
// 引数の authenticateClientは Goolge Driveのスコープを設定しているという前提です
final driveApi = drive.DriveApi(authenticateClient);
var driveFile = new drive.File();
driveFile.name = "xxxxxx";
driveFile.mimeType = 'xxxxxxxxxxx';
final result = await driveApi.files.create(driveFile);
return result.id;
}
@ochilab
ochilab / glogin.dart
Created October 24, 2021 05:54
Firebaseを用いてGoogle認証をする(Flutter,Dart編)
//ログインボタンを押した場合
onPressed: () async {
GoogleSignInAccount? signinAccount = await GoogleSignIn().signIn();
if (signinAccount == null) return;
GoogleSignInAuthentication auth = await signinAccount.authentication;
final OAuthCredential credential = GoogleAuthProvider.credential(
idToken: auth.idToken,
accessToken: auth.accessToken,
);
User? user =
@ochilab
ochilab / dynamodbdocumentmodel.cs
Created July 11, 2021 03:57
DocumentModelを利用してDynamoDBを操作する
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DocumentModel;
AmazonDynamoDBClient client = null;
Table table = null;
client = new AmazonDynamoDBClient();
//目的のテーブルを取得
table = Table.LoadTable(client, tableName);
@ochilab
ochilab / discoverBleak.py
Created June 17, 2021 05:21
bleakライブラリでBLE端末を発見する
import asyncio
from bleak import discover
import time
async def run():
while True:
devices = await discover()
for d in devices:
print(d.address,d.metadata,d.name,d.rssi)
@ochilab
ochilab / DynamoDBWrapper.cs
Created April 14, 2021 01:35
DynamoDB: DynamoDBMapperでBatch処理をする
DynamoDBMapper mapper = new DynamoDBMapper(client);
List list = new ArrayList();
list.add(item);
list.add(item);
mapper.batchSave(list);
@ochilab
ochilab / heap.c
Last active December 9, 2020 16:34
ヒープ化をするプログラム(たぶん合ってるかな。。)
void heap (int array[], int left, int right) {
int target;
int parent;
for(parent=left;2*parent<=right;parent=target){
int cl = 2* parent; //左の子
int cr=cl+1;// 右の子
//比較対象の選定
if ((cl < right) && (array[cl] > array[cr])) {
target=cr;// 右の子の方が小さい
}