Skip to content

Instantly share code, notes, and snippets.

Masafumi Oyamada mooz

Block or report user

Report or block mooz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View unfill-paragraph.js
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);
View script.js
(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 Apr 29, 2018
latex-strip-comments
View latex-strip-comments.sh
#!/bin/sh
# Usage: latex-strip-comments.sh some_tex_file.tex
cat $1 | latexpand --empty-comments - | sed '/^\s*%/d' | cat -s
View surfingkeys.js
settings.aceKeybindings = "emacs";
map("<Ctrl-Alt-j>", "R"); // right tab
map("<Ctrl-Alt-k>", "E"); // left tab
map("l", "R"); // right tab
map("h", "E"); // left tab
mapkey("e", "#10Open a linkb", function () {
Hints.create("", Hints.dispatchMouseClick);
});
@mooz
mooz / extract_slide.py
Last active May 11, 2018
Extract a slide image from a photo
View extract_slide.py
# -*- coding: utf-8 -*-
# ============================================================ #
# 写真からスライド領域を切り出して保存。透視変換もおこなう
#
# Usage: python extract_slide.py YOUR_PHOTO
#
# ============================================================ #
import cv2
@mooz
mooz / .rbindkeys.rb
Created Nov 1, 2014
rbindkeys helper
View .rbindkeys.rb
# Load rbindkeys-helper
require "path-to-rbindkeys-helper"
# Emacs-like settings
def define_emacs_keys()
bind "C-g", "ESC"
# cursor move
bind "C-f", "<right>"
bind "C-b", "<left>"
@mooz
mooz / byte-in-various-units.el
Created Oct 6, 2014
Display `size-byte' in various units
View byte-in-various-units.el
(defun my:byte-to-various-units (size-byte)
"Display `size-byte' in various units."
(interactive "nBytes: ")
(let ((size size-byte)
(size-kib size-byte))
(with-output-to-temp-buffer "*unit*"
(princ (format "%d B\n-----------\n" size-byte))
(dolist (unit '("K" "M" "G" "T" "P"))
(setq size (/ size 1000.0))
(setq size-kib (/ size-kib 1024.0))
@mooz
mooz / perf.rb
Created Feb 18, 2014
perf made easy
View perf.rb
#!/usr/bin/env ruby
require "rios/easy"
# http://ascii-table.com/ansi-escape-sequences.php
key_remaps = {
"j" => "\e[B", # down
"k" => "\e[A", # up
"o" => "\r\n", # enter
"u" => "\e[D", # left
@mooz
mooz / parse-mozilla-ast.js
Created Feb 1, 2013
Use Reflect API from xpcshell
View parse-mozilla-ast.js
// Reflect API from xpcshell
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
function openFile(aPath) {
var file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile);
file.initWithPath(aPath);
@mooz
mooz / fix-japanese-number-usages.el
Last active Dec 10, 2015
Fix improper Japanese number usages
View fix-japanese-number-usages.el
(defun fix-japanese-number-usages ()
"Fix improper japanese number usages like 1つ and 2つ."
(interactive)
(require 'japan-util)
(require 'cl)
(let ((from-regexp "\\([1-9123456789]+\\)[ \n\r\t]*つ")
(to-regexp "\\,(replace-digit-to-japanese \\1)つ")
(japanese-numbers (list "" "" "" "" "" "" "" "" "" "" "")))
(flet ((query-replace-read-from
(prompt regexp-flag)
You can’t perform that action at this time.