Skip to content

Instantly share code, notes, and snippets.

View tyru's full-sized avatar
🏠
Working from home

Fujiwara Takuya tyru

🏠
Working from home
View GitHub Profile
@tyru
tyru / remap-alt-to-ctrl.ahk
Last active April 2, 2020 02:28
[AutoHotkey] Remap Alt + [A-Z] to Ctrl + [A-Z]
!a::Send, ^a
!b::Send, ^b
!c::Send, ^c
!d::Send, ^d
!e::Send, ^e
!f::Send, ^f
!g::Send, ^g
!h::Send, ^h
!i::Send, ^i
!j::Send, ^j
@tyru
tyru / windows-like-word.json
Created March 25, 2020 01:50
[Karabiner Elements][macOS] Windows-like word movement/selection/deletion
{
"title": "[macOS] Windows-like word movement/selection/deletion",
"rules": [
{
"description": "Ctrl + Arrow Keys to Option + Arrow Keys",
"manipulators": [
{
"from": {
"key_code": "up_arrow",
"modifiers": {
@tyru
tyru / fun.sh
Created December 31, 2019 21:18
clear
echo -n -e "\x1b7"
while :; do
# 2>/dev/null: hide python stacktrace when Ctrl-C
output=$(echo -n -e "あけましておめでとうこざいます。\n本年も日経Linuxとラズパイマガジンをご愛読のほど、\n何卒よろしくお願いいたします。" | boxes -d mouse | lolcat -F 1 -f 2>/dev/null)
echo -n -e "\x1b8$output"
sleep 0.5s
done
@tyru
tyru / bench.vim
Created November 19, 2019 07:16
Benchmark for parsing SKK dictionary
function! s:run() abort
let skkdict = expand('~/Dropbox/config/skkdict/system-dict')
" for memory cache
call readfile(skkdict)
let start = reltime()
call readfile(skkdict)
let b1 = reltimestr(reltime(start, reltime()))
@tyru
tyru / main.rs
Last active August 25, 2019 09:24
JSON Parser in Rust
#![feature(slice_patterns)]
use std::io;
use std::fmt;
use std::str;
use std::result;
use std::iter::Iterator;
// TODO: take deparse option from command-line arguments
fn main() {
function! HasKey(dict, key)
return has_key(a:dict, a:key)
endfunction
function! s:has_key(dict, key)
return has_key(a:dict, a:key)
endfunction
function! Fold(list, init, f)
let l:V = a:init
for l:Elem in a:list
@tyru
tyru / profile.txt
Created August 1, 2019 19:42
Add readable name to numbered-function (and vim-jp/vim-vimlparser profiling result)
SCRIPT /Users/tyru/config/home/volt/repos/github.com/vim-jp/vim-vimlparser/autoload/vimlparser.vim
Sourced 1 time
Total time: 0.011356
Self time: 0.011356
count total (s) self (s)
" vim:set ts=8 sts=2 sw=2 tw=0 et:
"
" VimL parser - Vim Script Parser
"
@tyru
tyru / require.vim
Last active July 2, 2019 17:02
require() function for deeply nested very loooooooooong named autoload function
let s:L = vital#of('vital').import('Data.List')
function! s:require(ns, ...) abort
let ns = strtrans(a:ns)
let fnlist = map(
\ split(execute('function /' . ns), '\n'),
\ {_,l -> matchstr(l, '^function ' . ns . '#\zs\w\+\ze(')}
\)
call filter(fnlist, '!empty(v:val)')
if a:0
@tyru
tyru / search-decl-php-ftplugin-2.patch
Last active June 6, 2019 11:25
Searching declaration in PHP ftplugin (Fix [[, ]] mappings problems, added [], ][ mappings)
--- php.vim.bak 2018-10-10 14:08:25.875669800 +0900
+++ php.vim 2018-10-10 14:04:30.777334700 +0900
@@ -61,15 +61,107 @@
setlocal omnifunc=phpcomplete#CompletePHP
endif
-" Section jumping: [[ and ]] provided by Antony Scriven <adscriven at gmail dot com>
-let s:function = '\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function'
-let s:class = '\(abstract\s\+\|final\s\+\)*class'
+" Section jumping: [[ and ]] provided by:
@tyru
tyru / run.gs
Last active March 21, 2019 05:34
Google Apps Script で Gmail の添付ファイルを Google Drive に保存
// Google Drive でフォルダに移動した時のURLで分かる
// https://drive.google.com/drive/u/1/folders/{フォルダのID}
var SAVE_FOLDER_ID = 'フォルダのID';
var READ_LABEL_NAME = '添付ファイル保存済み';
var SEARCH_CONDITION = 'has:attachment -label:' + READ_LABEL_NAME;
var THREADS_PER_PAGE = 100;
function saveAttachments() {
Logger.clear();
Logger.log('start');