Skip to content

Instantly share code, notes, and snippets.

@rsky
rsky / index.ts
Created May 14, 2020
RxJSでthrottlingの練習。ついでにTsyringeも。
View index.ts
import "reflect-metadata";
import { EventEmitter } from "events";
import { fromEvent, interval, Observable, Subject, Subscription } from "rxjs";
import { take, throttle } from "rxjs/operators";
import { container, instanceCachingFactory } from "tsyringe";
class Throttling<T> {
private subscription: Subscription;
private subject: Subject<T>;
@rsky
rsky / japanese-era.php
Created Apr 1, 2019
新元号(令和)のために予約されているコードポイントからの変換ルールはまだない。
View japanese-era.php
<?php
$s = "\u{337E} \u{337D} \u{337C} \u{337B} \u{32FF}\n";
echo $s;
echo Normalizer::normalize($s, Normalizer::FORM_KC);
@rsky
rsky / clock.go
Created Mar 15, 2019
clock for testing
View clock.go
package clock
import (
"flag"
"time"
)
type NowFunc func() time.Time
var nowFunc NowFunc
@rsky
rsky / manifest.json
Last active Nov 9, 2020
Tiny Proxy Configurator
View manifest.json
{
"name": "Tiny Proxy Configurator",
"version": "1.0",
"description": "A tiny and simple proxy configurator.",
"permissions": [
"proxy"
],
"background": {
"scripts": [
"pac.js"
@rsky
rsky / Calculator.java
Last active Sep 20, 2017
戦果係数を自動で検出する試み
View Calculator.java
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
public class Calculator {
private static final int[] RANKING_RATE_MAGIC_NUMBERS =
{8931, 1201, 1156, 5061, 4569, 4732, 3779, 4568, 5695, 4619, 4912, 5669, 6586};
public static int detectRateCoefficient(Map<Integer, Long> source) {
Set<BigInteger> set = new HashSet<>();
@rsky
rsky / memo.md
Created May 14, 2017
OSX+航海日誌で動画キャプチャする設定
View memo.md
  • {path} はダブルクォートしてはいけない。
  • -i 0:none0(ビデオデバイスのインデックス)は環境によって1等に変更する
  • Retinaディスプレイのキャプチャはうまくいかない(キャプチャ全体に倍率設定が必要?)
View gist:afd839620eb907096d56f901202f9c01
The following ports are currently installed:
apache-ant @1.9.7_0 (active)
autoconf @2.69_5 (active)
automake @1.15_1 (active)
bison @3.0.4_1 (active)
bison-runtime @3.0.4_0 (active)
bzip2 @1.0.6_0 (active)
cctools @886_6+llvm38 (active)
cmake @3.7.1_0 (active)
colordiff @1.0.16_0 (active)
@rsky
rsky / aggr.php
Created Sep 29, 2016
航海日誌 (logbook/logbook-kai) の資材ログを日付ごとにまとめるスクリプト
View aggr.php
#!/usr/bin/env php
<?php
/**
* Usage:
* php aggr.php < 資材ログ.csv > out.csv
* nkf -Ws -Lw out.csv > 資材ログ.csv
*/
$src = 'php://filter/read=convert.iconv.cp932%2Futf-8/resource=php://stdin';
$file = new SplFileObject($src);
@rsky
rsky / change_fill_color.php
Last active Jun 6, 2016
透明チャンネルをそのままに塗り潰し色を変える
View change_fill_color.php
<?php
// usage: php change_fill_color.php '#cafe00' < in.png > out.png
$color = $_SERVER['argv'][1];
$in = new Imagick();
$in->readImageFile(STDIN);
$size = $in->getImageGeometry();
$out = new Imagick();
$out->newImage($size['width'], $size['height'], $color);
@rsky
rsky / file0.java
Last active May 2, 2016
RetrofitでMediaStoreから取得したオブジェクトをアップロードする ref: http://qiita.com/rsky/items/fbe0b5fdfa955b8026a9
View file0.java
public interface UploadService {
@Multipart
@POST("/upload")
Observable<Response> upload(@Part("file") TypedFile file);
}