Skip to content

Instantly share code, notes, and snippets.

// switch record
var jsonName = 'sleeprec.settings.json';
var settings = require("Storage").readJSON(jsonName,1)||{};
function init() {
if (settings.isRecording == undefined)
settings.isRecording = false;
if (settings.lastAverage == undefined)
settings.lastAverage = -1;
// record heart beat while sleeping
var MEASURE_PERIOD = 15*60*1000; // 15 min
var SAMPLE_TIME = 3*60*1000; // 3 min
var DISPOSE_TIME = 30*1000; // 30 sec
var sumBPM;
var sumCount;
var csvFile;
@deltam
deltam / swimrec.app.js
Last active December 15, 2020 10:12
Bangle.jsで水泳の記録を取るやつ
// record accel while swimming
const WRITE_INTERVAL = 5*1000; // msec
const AVG1_MSEC = 1000; // last 1sec
const MAX_INDEX = 200;
const SCALE = 1000;
const STROKE_THRESHOLD = 1.5*SCALE;
var COLUMNS = [
'period_msec',
'accel_mag',
@deltam
deltam / sourdough.el
Created August 29, 2020 04:09
サワードウブレッドの分量計算
(defun my/sourdough (flour hydra)
(let* ((flour-rate (/ flour 100.0))
(hydra-rate (/ hydra 100.0))
(dough (* 40 flour-rate))
(water (* flour-rate (- (* hydra-rate 120) 20)))
(salt (* 2.4 flour-rate)))
(list dough water salt)))
(defun my/sourdough-recipe (flour hydra)
(interactive "n小麦粉(g):\nn加水率(%):\n")
@deltam
deltam / plots.py
Created April 10, 2019 15:09
「ゼロから作るDeep Learning2」図1-33 決定境界の描画コード
# -*- coding: utf-8
# 参考
# scikit-learn - matplotlib を使って分類問題の決定境界を描画する - Pynote
# http://pynote.hatenablog.com/entry/sklearn-plot-decision-boundary
# 機械学習の分類結果を可視化!決定境界 - 見習いデータサイエンティストの隠れ家
# http://www.dskomei.com/entry/2018/03/04/125249
import numpy as np
import matplotlib.pyplot as plt
@deltam
deltam / trampoline.php
Created January 16, 2019 08:47
trampoline.php
<?php
// JavaScript・再帰・トランポリン - Qiita
// https://qiita.com/41semicolon/items/985bdd2f551d9392463c
function countDown($num) {
if ($num == 1) return 1;
if ($num%10000 == 0) echo $num."\n";
return countDown($num-1);
}
//countDown(650000);
@deltam
deltam / hoge
Last active February 4, 2021 05:03
test
034 898b9418ec135df4dde0fc0ca2aa90c2e327a101
033 0b8d8d7e0e6245f16612d3f5920becdf6baf8007
032 584733d3a39c7b7a7f04519a76838187820216ca
031 d0669f2acc9022c9ad9ba2554ee2b02f2e9153e7
030 275fe432e327301f17b5db8a02aef80de1830336
029 7dd4050fedf8849a4b4387b2cd065d9478e921e2
028 717725b4d56a19047d7c33edc4139831a26b8741
027 0458a9e1637efaa2b0977e8113ef3266e6ffc674
026 a1a6c5c7f1d431c02442f183050337130570b56e
025 f3eba146e2fe0510b6cf13f25b07a3ebc4c10732
@deltam
deltam / changelog.clj
Created July 1, 2018 11:20
Convert changelog memo to JSON in clojure.
(ns sandbox.changelog
(:require [clojure.string :refer [split blank? includes?]]
[clojure.java.io :refer [reader]]))
(def df (java.text.SimpleDateFormat. "yyyy-MM-dd"))
(defn header? [line]
(not (nil? (re-find #"^\d{4}-\d{2}-\d{2}" line))))
(defn parse-header [line]
@deltam
deltam / main.go
Last active June 15, 2018 03:09
汎用データ構造っぽいやつ
// どんな型の配列だろうが添字はintという発想から汎用データ構造みたいなのが作れないか試してみた
// 配列は削除が面倒なのでmapで任意の構造体を持つ
// intキー:任意の型でintキーだけデータ構造で管理しとく
// とりあえずStack
package main
import "fmt"
func main() {
@deltam
deltam / pomodoro.sh
Created June 6, 2018 13:01
ポモドーロ用のシェルスクリプト
#!/bin/sh
# for mac
function message() {
m=$1" "`date "+%H:%M"`
osascript -e "display notification \"$m\" with title \"pomodoro notice\""
echo $m
say $m
}