Skip to content

Instantly share code, notes, and snippets.

View tai-sho's full-sized avatar
🏠
Working from home

ShoheiTai tai-sho

🏠
Working from home
View GitHub Profile
@tai-sho
tai-sho / carbon_tracking.gs
Created April 24, 2024 05:19
webサイトのCO2消費量をスプレッドシート出力する。 API Doc: https://api.websitecarbon.com/
const TARGET_URL = 'https://example.com';
const CARBON_API_URL = `https://api.websitecarbon.com/site?url=${TARGET_URL}`;
/**
* APIからデータを取得し、スプレッドシートに記録する
*/
function main() {
const response = callApi(CARBON_API_URL);
if (response !== null) {
writeToSpreadsheet(response);
@tai-sho
tai-sho / index.gs
Last active April 15, 2024 04:03
Google Apps Scriptを使用し1ヶ月分のバイオリズムをGoogleカレンダーに登録します。トリガーで毎月月初で登録をする想定で実装。冪等性があり、複数回実行した場合も重複は有りません。 This script calculates biorhythms based on a given birthday and adds them as events to a specified Google Calendar. Each event's title includes the biorhythm type and its value. It is designed to run on the 1st of every month and is idempotent, me…
/**
* This script calculates biorhythms based on a given birthday and adds them as events
* to a specified Google Calendar. Each event's title includes the biorhythm type and its value.
* It is designed to run on the 1st of every month and is idempotent, meaning it can run
* multiple times a month without causing duplicate entries. It deletes any existing biorhythm
* events for the month before adding new ones.
*
* Cycles:
* - Physical: 23 days
* - Emotional: 28 days
@tai-sho
tai-sho / main.gs
Last active July 16, 2023 03:46
Using GoogleAppsScript to link OuraRing's sleep score to the calendar
/**
* Refer to https://tech.affordigitalife.com/oura-api-sleep-log/
*/
function main() {
const days = 10;
for (let i = 0; i < days; i++) {
let today = new Date()
today.setDate(today.getDate() - i)
let yesterday = new Date()
yesterday.setDate(yesterday.getDate() - (i + 1))
@tai-sho
tai-sho / gitlab-ci.yml
Created December 19, 2020 16:53
Automate deployment to Shopify with Gitlab-CI.
image: python:2
stages:
- deploy
before_script:
- curl -s https://shopify.github.io/themekit/scripts/install.py | python
deploy_staging:
stage: deploy
@tai-sho
tai-sho / GenerationGapModelTask.php
Created December 8, 2019 17:22
bake with generation gap pattern
<?php
namespace App\Shell\Task;
use Bake\Shell\Task\ModelTask;
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\ORM\TableRegistry;
/**
* Class GenerationGapModelTask
@tai-sho
tai-sho / DatabaseMigrateResetCommand.php
Created March 12, 2019 04:04
CakePHP3.6でデータベース初期化+マイグレーションを行う。 rails db:migrate:resetと同様
<?php
namespace App\Command;
use Cake\Console\Arguments;
use Cake\Console\Command;
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Datasource\ConnectionManager;
/**
@tai-sho
tai-sho / map.js
Last active July 11, 2017 17:23
GoogleMapを扱うjs
/**
* Map表示を行う
* @class Map
*/
;var Map = (function(window, $) {
/**
* コンストラクタ
* @class Map
*/
@tai-sho
tai-sho / GoogleMapAPIComponent.php
Created July 11, 2017 16:40
GoogleMapAPIのgeocodingAPI #cakephp
<?php
/**
* GoogleMapAPIコンポーネント
*/
class GoogleMapAPIComponent extends Component {
/**
* APIベースURL
* @var string
*/
@tai-sho
tai-sho / LazyLoadHelper.php
Created July 11, 2017 16:34
jQueryLazyloadを扱うHelper #cakephp
<?php
/**
* jquery.lazyloadの制御を行うHelper
*/
class LazyLoadHelper extends AppHelper {
/**
* 使用するヘルパーの宣言
* @var array
*/
@tai-sho
tai-sho / QRHelper.php
Created July 11, 2017 16:30
QRコードを出力するHelper #cakephp
<?php
/**
* QRコード出力
*/
class QRHelper extends AppHelper {
/**
* QRコードを扱うAPIのURL
* @var string
*/