Skip to content

Instantly share code, notes, and snippets.

View walfie's full-sized avatar

walfie

  • New York City
  • 18:07 (UTC -04:00)
View GitHub Profile
@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 November 20, 2024 14:14
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 March 15, 2025 20:15
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);
@walfie
walfie / README.md
Last active October 18, 2016 02:50
Bookmarklet to translate Granblue boss
  1. Create a bookmark with the following "URL" (bookmarklet):

    javascript:!function(){var a=[].slice.call(document.querySelectorAll('.enemy-info>.name')).map(function(a){return a.innerHTML}).filter(function(a){return a.length>0});jQuery.ajax({dataType:'json',url:'http://gbf-raidfinder.aikats.us/api/bosses.json',data:{name:a},traditional:!0,success:function(a){var b=a.raidBosses.map(function(a){return(a.translatedName||{}).value}).filter(function(a){return a});document.querySelector('#frm-post-tweet').value=b.join(' ')}})}();

  2. Go to a raid and open the "Post to Twitter" menu (via "Request Backup" -> "Tweet")

  3. Click the bookmarklet

  4. If a translation is found, it will be inserted into the input box

Note: Translations might not be found for new event bosses that don't have images yet.

Here's a demo video.

Keybase proof

I hereby claim:

  • I am walfie on github.
  • I am walfie (https://keybase.io/walfie) on keybase.
  • I have a public key whose fingerprint is 5601 632B 2B37 CE71 C060 BEA0 5B97 3FD2 6105 0838

To claim this, I am signing this object: