Skip to content

Instantly share code, notes, and snippets.

@mooz
mooz / ar5iv-hash-attacher.user.js
Last active February 26, 2023 13:11
Ar5iv Hash Attacher: Attach a hash to the URL to create a permanent link when elements like sections and figures are clicked
// ==UserScript==
// @name Ar5iv Hash Attacher
// @namespace http://mooz.github.io/
// @version 0.1
// @description When elements like sections and figures are clicked, attach a hash to the URL to create a permanent link
// @author Masafumi Oyamada
// @match https://ar5iv.labs.arxiv.org/html/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=arxiv.org
// @grant none
// ==/UserScript==
config.TAB_VERTICAL = true;
@mooz
mooz / tiny_segmenter.js
Created May 9, 2020 12:25
TinySegmenter
(function (global) {
global.TinySegmenter = TinySegmenter;
var default_model = {BC1:{IH:-2384,II:3270,IK:-100,NH:2173,OH:-1008,OO:1343},BC2:{AA:-12150,HH:-4329,HI:-978,IH:1459,II:-6625,IO:4584,KI:1578,KK:-11956,KM:-2208,NH:1157,NN:-9390,OH:1131,OI:320,OO:-11227},BC3:{HH:906,IO:614,KK:170},BIAS:2252,BP1:{BB:302,OB:-231,OO:146,UB:282},BP2:{OB:1327,UB:49,UU:-146},BQ1:{BII:-100,OII:252},BQ2:{BHH:434,BHI:455,BIH:-1446,OHH:-802,OKK:-1977,UII:-661},BQ3:{BHH:-148,BHI:139,BIH:58,OHH:1008,UOH:-1190},BQ4:{BAA:-1264,BHH:-2820,BII:-3700,BOO:-353,OHI:-1024,OIH:-893,UHH:-712},BW1:{'、と':49,'いる':462,'うし':-2206,'から':1819,'こと':2372,'した':315,'して':1779,'しょ':1428,'そこ':1096,'そし':-1226,'たち':1283,'った':2355,'つい':-384,'てい':1550,'てき':250,'てく':-346,'てし':-784,'でも':589,'どこ':1229,'ない':6901,'なっ':505,'にし':1693,'ませ':1564,'まる':-3912,'よう':2051,'よっ':-317,'をし':457,'同時':-3330,'本当':-3421},BW2:{'——':-12400,'──':-6300,'いう':-4120,'いた':955,'いは':-3214,'から':-3546,'こと':-8616,'この':-4459,'させ':759,'され':9917,'しい':-642,'した':2787,'その':-5916,'たち':-3820,'
@mooz
mooz / change_video_playback_speed_ios.md
Last active October 15, 2021 04:19
Bookmarklet for changing video playback speed on iPad/iPhone

Installation

In your browser (e.g., Safari),

  1. Add a dummy bookmark and name it Change playback speed (1.5x)
  2. Change the URL of the bookmark to javascript:(function()%7Bvar%20video%20%3D%20document.querySelector(%22video%22)%3B%20if%20(video)%20%7B%20video.playbackRate%20%3D%201.5%3B%20%7D%7D)()

Usage

On website playing a video, click 1.5x in your bookmarks.

@mooz
mooz / jsbox-ctrl-space-swizzling.js
Created July 27, 2019 16:43
Capture ctlr-space in iPadOS public beta 3
let ctrlKey = false;
// Workaround for capturing Ctrl-Space
$define({
type: "WKWebView",
events: {
// Swizzling handleKeyUIEvent doesn't work. We need to swizzle the private one (_handleXXX).
"_handleKeyUIEvent:": evt => {
const CTRL = 224;
const SPACE = 44;
let keyCode = evt.$__keyCode();
@mooz
mooz / unfill-paragraph.js
Created June 4, 2019 02:42
unfill-paragraph
document.execCommand("selectAll");
var text = document.getSelection() + "";
text = text.replace(/[\n]{3,}/g, "#P@R@GR@PH#");
text = text.replace(/\n/g, " ");
text = text.replace(/[\t ]+/g, " ");
text = text.replace(/#P@R@GR@PH#/g, "\n\n");
document.execCommand("insertText", false, text);
(function (history) {
// 表示する履歴の数
const maxHistory = 5;
if ($('#history-box').length) { return; }
const $header = $(".quick-launch");
$header.append($(`<div class='flex-box'>
<div class='flex-item'>
<div class='left-box' id='history-box' />
@mooz
mooz / latex-strip-comments.sh
Last active April 29, 2018 09:09
latex-strip-comments
#!/bin/sh
# Usage: latex-strip-comments.sh some_tex_file.tex
cat $1 | latexpand --empty-comments - | sed '/^\s*%/d' | cat -s
@mooz
mooz / extract_slide.py
Last active October 5, 2023 16:00
Extract a slide image from a photo
# -*- coding: utf-8 -*-
# ============================================================ #
# 写真からスライド領域を切り出して保存。透視変換もおこなう
#
# Usage: python extract_slide.py YOUR_PHOTO
#
# ============================================================ #
import cv2