Skip to content

Instantly share code, notes, and snippets.

View eagletmt's full-sized avatar

Kohei Suzuki eagletmt

View GitHub Profile
@eagletmt
eagletmt / ambiwidth.rb
Last active December 18, 2015 21:38
East Asian ambiguous character width が2である charmap を生成するスクリプト
#!/usr/bin/env ruby
# Usage
# % ./ambiwidth.rb
# % sudo cp UTF-8-CJK.gz /usr/share/i18n/charmaps/
# % sudo vim /etc/locale.gen # Add "ja_JP.UTF-8 UTF-8-CJK"
# % sudo locale-gen
require 'open-uri'
require 'zlib'
@eagletmt
eagletmt / sd-hd.rb
Last active December 18, 2015 16:19
SD -> HD または HD -> SD の切り替えがあるときに、HD または SD の先頭オフセットを見つける
#!/usr/bin/env ruby
# coding: utf-8
require 'open3'
require 'tempfile'
class Avconv
def initialize(path, bin = 'avconv')
@path = path
@bin = bin
@tempfile = Tempfile.new ['sd-hd', '.ts']
nnoremap <C-g> :<C-u>call <SID>ruby_gf()<CR>
function! s:ruby_gf()
let l:saved_isfname = &l:isfname
setlocal isfname+=:
let l:cfile = expand('<cfile>')
let &l:isfname = l:saved_isfname
let l:match = matchlist(l:cfile, '\(\f\+\):\(\d\+\)')
normal! gf
if !empty(l:match)
@eagletmt
eagletmt / ideslave.rb
Last active December 16, 2015 22:29
coqtop -ideslave
#!/usr/bin/env ruby
require 'nokogiri'
module FromXml
class MappingError < StandardError
attr_reader :node
def initialize(node, msg = nil)
super msg
@node = node
end
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int f(int E, int R, const vector<int>& v, const vector<int>& x, int idx)
{
const int N = v.size();
int e1 = E;
for (int i = 0; i < idx; i++) {
@eagletmt
eagletmt / _cabal-dev
Last active December 15, 2015 01:48
zsh completion definition for cabal-dev
#compdef cabal-dev
_cabal-dev() {
local curcontext="$curcontext" state
_arguments -C \
{-h,-?,--help}'[Show help text]' \
{-s,--sandbox}'[The location of the development cabal sandbox (default: ./cabal-dev)]:directory:_directories' \
{-c,--config}'[The location of the cabal-install config file (default: use included)]:file:_files' \
{-v,--verbose}'[Verbosity level]:verbosity:_cabal-dev_verbosity' \
--version'[Show the version of this program]' \
{-# LANGUAGE TemplateHaskell #-}
module Bar (bar) where
import Foo (foo)
bar = $foo ++ "bar"
diff --git a/autoload/necoghc.vim b/autoload/necoghc.vim
index 9b43ec8..d1d35e6 100644
--- a/autoload/necoghc.vim
+++ b/autoload/necoghc.vim
@@ -202,9 +202,17 @@ function! s:get_modules() "{{{
endfunction "}}}
function! s:ghc_mod(cmd) "{{{
+ let l:cmd = 'ghc-mod -g -package -g ghc ' . a:cmd
lcd `=expand('%:p:h')`
diff -ur xmonad-contrib-0.11.orig/XMonad/Hooks/DebugEvents.hs xmonad-contrib-0.11/XMonad/Hooks/DebugEvents.hs
--- xmonad-contrib-0.11.orig/XMonad/Hooks/DebugEvents.hs 2013-02-27 00:30:37.840686030 +0900
+++ xmonad-contrib-0.11/XMonad/Hooks/DebugEvents.hs 2013-02-27 00:48:45.208871862 +0900
@@ -42,13 +42,15 @@
import Data.Maybe (fromMaybe)
import Data.Monoid
import Foreign
-import Foreign.C.String
import Foreign.C.Types
import Numeric (showHex)
@eagletmt
eagletmt / purchased.rb
Created February 9, 2013 15:15
List purchased songs on iPhone. ifuse is a part of libimobiledevice.
#!/usr/bin/ruby
# USAGE:
# % ifuse ~/mnt
# % ./purchased.rb ~/mnt
require 'pathname'
require 'sqlite3'
iphone = Pathname.new ARGV[0]