Skip to content

Instantly share code, notes, and snippets.

@yaegaki
yaegaki / main.go
Last active June 4, 2020 11:45
notification sample
package main
import (
"context"
"log"
firebase "firebase.google.com/go"
"firebase.google.com/go/messaging"
)
@yaegaki
yaegaki / starttimestamp.js
Created January 12, 2020 11:44
Youtubeのアーカイブから開始時間を調べるスクリプト
(async () => {
const f = await fetch(location.href);
const html = await f.text();
const index = html.indexOf('"startTimestamp');
if (index < 0) {
console.log('not found startTimestamp');
return;
}
const count = html.indexOf(',', index) - index;
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System.Threading;
using UniRx.Async;
namespace UniRx
{
public static class UniTaskCancellationTokenExtensions
{
@yaegaki
yaegaki / temp.go
Created February 18, 2016 19:51
forをchanを使って途中で止める(スレッドセーフ)
package main
import (
"log"
"time"
)
func temp(quitChan chan bool) {
for i := 0; i <= 1000000; i++ {
select {
@yaegaki
yaegaki / railsinstaller_3.1.1_rails.bat
Created February 16, 2016 15:18
rails.bat(in RailsInstaller)
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "C:/Users/emachnic/GitRepos/railsinstaller-windows/stage/Ruby2.1.0/bin/rails" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
@yaegaki
yaegaki / app.go
Created February 14, 2016 19:35
golangでiTunes内の曲情報を取得する(Windows)
package main
import (
ole "github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil"
"log"
"fmt"
)
func main() {
# split windows like vim
# vim's definition of a horizontal/vertical split is reversed from tmux's
bind s split-window -v
bind v split-window -h
# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
@yaegaki
yaegaki / promise.js
Last active January 3, 2016 18:46
simple promise
function Promise(callback, immudiate) {
// Promiseとcallbackを関連付ける
this.callback = callback;
// immudiateにfalse以外のものが渡されたとき(引数を一つしか渡さなかった場合も)はすぐにinvokeを呼び出す
if (immudiate !== false) {
this.invoke();
}
}
require "yaml"
require "pp"
h = []
hash = {}
File.read("unitychan_dynamic.prefab").each_line do |line|
match = line.match(/--- !u!\d+ &(\d+)/)
if match.nil?
h << line
else
/** Packet format
* 4 bytes data size (x)
* x bytes data
*/
var sb = new StreamBuffer();
var requireLength = 0;
var state = 0;
client.on('data', function (data) {