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();
}
}
@yaegaki
yaegaki / startThread.js
Created September 18, 2013 06:19
javascriptでworkerスレッドを関数から作成するサンプル. chromeでのみ動作確認.
function startThread(thread_callback, args, result_callback){
var script = new Blob(['onmessage = function(e){postMessage(('+thread_callback.toString()+').apply(null, e.data));}']);
var worker = new Worker(URL.createObjectURL(script));
worker.onmessage = function(e){
result_callback(e.data);
URL.revokeObjectURL(script);
}
worker.postMessage(args);
}
@yaegaki
yaegaki / c++11
Created August 21, 2013 00:28
c++11ってすげーわ Xcode5-DPで確認
#include <iostream>
#include <initializer_list>
class test{
public:
test(std::initializer_list<int> list){
for(auto it = list.begin();it != list.end();++it){
sum += *it;
}
}