Skip to content

Instantly share code, notes, and snippets.

View walfie's full-sized avatar

walfie

  • New York City
  • 20:42 (UTC -04:00)
View GitHub Profile
@walfie
walfie / Cargo.toml
Last active February 16, 2018 02:42
h2 with tokio-rustls
[package]
name = "http2-example"
version = "0.1.0"
authors = ["Walfie"]
[dependencies]
futures = "0.1.18"
h2 = "0.1.0"
http = "0.1.4"
rustls = "0.12.0"
@walfie
walfie / yew_hashchange.rs
Created February 6, 2018 04:52
yew - Trigger message on HashChangeEvent
// Valid as of yew commit a6c87e48b42e4977b008ce31281242e2b8684f9f and stdweb 0.3.0
extern crate stdweb;
#[macro_use]
extern crate yew;
use yew::prelude::*;
type Context = ();
@walfie
walfie / textarea.js
Created January 30, 2018 19:29
Basic HTML edit/preview bookmarklet
(function(d) {
d.open();
d.write('<textarea id="input" spellcheck="false" style="flex:1;height:100%;resize:none;outline:none;font:15px monospace;color:#fff;background:#111;padding:10px;"><html>\n<head></head>\n<body>\nClick here to render\n</body>\n</html></textarea>');
d.write('<iframe id="iframe" style="flex:1;height:100%;"></iframe>');
d.close();
var s = d.body.style;
s.display = 'flex';
s.margin = 0;
var i = d.getElementById('input');
i.onkeydown = function(e) {
@walfie
walfie / wanikani-levels.js
Created October 1, 2017 00:54
Extract kanji from text and group by their WaniKani level
function isKanji(char) {
return /^[\u4e00-\u9faf]+$/.test(char);
}
function getKanji(string) {
var chars = string.split('');
var map = chars.reduce(function(acc, char) {
if (isKanji(char)) { acc[char] = true; };
return acc;
@walfie
walfie / nginx-s3-proxy-cache.conf
Last active May 5, 2023 15:16
nginx S3 proxy cache
# configure cache directory with 20G and holding old objects for max 31 days
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=s3:500m max_size=30g inactive=31d;
server {
server_name files.example.com;
gzip off;
# need to setup external DNS resolver
resolver 8.8.8.8 valid=300s;
@walfie
walfie / granblue-reroll-bookmarklets.md
Last active March 8, 2017 05:51
Granblue reroll bookmarks and bookmarklets

Granblue reroll bookmarks and bookmarklets

Some useful bookmarklets which may or may not still work.

GBF Wiki Guide

https://gbf.wiki/Rerolling

Register

Visit page in device emulation mode (Chrome dev tools)

010000 ARTIST_NAME
020000 SONG_NAME
// ジャンル>新曲
030100 NEW_SONG_ALL_SONG // 全曲
// ジャンル>新曲>映像
030201 NEW_SONG_LIVE_KARAOKE // LIVEカラオケ
030202 NEW_SONG_CAST_PICTURE // 本人出演映像
030203 NEW_SONG_CLIP_JUST_NOW // 今だけクリップ
@walfie
walfie / clubdam-api.md
Last active August 5, 2025 00:10
ClubDAM API docs
@walfie
walfie / -twitter-archive-search-webworker.md
Last active November 6, 2016 22:39
Search twitter archive in a web worker

Twitter Archive Search in Web Worker

Twitter's default offline archive search is slow as heck. If you do it in a web worker, the search itself is actually pretty fast.

Instructions

  • Download search.html and worker.js to the root directory of your twitter archive (the same directory as index.html)
  • Open search.html in browser
  • Open JS console (probably ctrl shift j)
  • Type search("insert some regex here") and press enter
@walfie
walfie / local-webworker.html
Last active November 8, 2025 21:27
Run webworker from `file://`, with working `importScripts`
<script>
function createWebWorkerFromFunction(f) {
var blobContents = ['(', f.toString(), ')();'];
var blob = new Blob(blobContents, { type: 'application/javascript'});
var blobUrl = URL.createObjectURL(blob);
var worker = new Worker(blobUrl);
URL.revokeObjectURL(blobUrl);