Skip to content

Instantly share code, notes, and snippets.

View eagletmt's full-sized avatar

Kohei Suzuki eagletmt

View GitHub Profile
#!/usr/bin/ruby
# depends: nokogiri, term-ansicolor, pit
require 'time'
require 'net/https'
require 'nokogiri'
require 'term/ansicolor'
require 'pit'
class String
include Term::ANSIColor
@eagletmt
eagletmt / BrowseType.hs
Created August 8, 2010 00:01
export されている名前とその型を表示
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Maybe (mapMaybe)
import Data.List (sort)
import Control.Applicative ((<$>))
import Control.Monad (unless)
import Control.Exception (SomeException)
import System.Environment (getArgs)
import GHC
import GHC.Paths (libdir)
import Outputable (ppr, defaultUserStyle)
vnoremap <buffer> zf :call <SID>fold_haskell()<CR>
function! s:fold_haskell() range
let str = getline(a:firstline)
if empty(str) || str =~# '\s$'
call setline(a:firstline, str . '-- {{{')
else
call setline(a:firstline, str . ' -- {{{')
endif
let str = getline(a:lastline)
commands.addUserCommand(['pixivFullNovel'], 'show full novel',
function(args) {
let doc = content.document.wrappedJSObject;
let win = content.window.wrappedJSObject;
Array.forEach(doc.querySelectorAll('.novel_article'),
function(e) {
e.style.display = 'block';
e.innerHTML = win.parse_page(e.innerHTML);
}
@eagletmt
eagletmt / ghc_complete.vim
Created July 25, 2010 03:25
This plugin is currently maintained here: https://github.com/ujihisa/neco-ghc
" plugin for neocomplcache <http://github.com/Shougo/neocomplcache>
"
" This plugin requires ghc-mod <http://www.mew.org/~kazu/proj/ghc-mod/>
let s:source = {
\ 'name' : 'ghc_complete',
\ 'kind' : 'ftplugin',
\ 'filetypes': { 'haskell': 1 },
\ }
-- http://projecteuler.net/index.php?section=problems&id=14
{-# OPTIONS_GHC -O2 #-}
import Data.List (maximumBy)
import Data.Ord (comparing)
import Control.Applicative ((<$>))
import Control.Monad (forM_)
import Data.Array.Unboxed (UArray, assocs)
import Data.Array.ST (runSTUArray, newArray, readArray, writeArray)
collatz :: Integer -> Integer
{-# LANGUAGE ExistentialQuantification #-}
import System
class Hi_ a where
hi :: a -> String
data Hi = forall a. Hi_ a => Hi a
instance Hi_ Hi where
hi (Hi x) = hi x
data Ujihisa = Ujihisa
" For test (Do quickrun on the target character!):
" aiu
" あいう
function! s:get_current_character()
if mode() ==# 'c'
let str = getcmdline()
let cur_idx = getcmdpos() - 1
return matchstr(str, '.', cur_idx)
function! ParseJSON(str)
let obj = { 'str': a:str, 'pos': 0, 'len': len(a:str) }
function! obj.skip_space() dict
let self.pos = matchend(self.str, '^\s*', self.pos)
endfunction
function! obj.parse_string() dict
if self.str[self.pos] != '"'
throw 'not a string'
-- original: http://d.hatena.ne.jp/kazu-yamamoto/20100528/1275008906
import Control.Applicative
import Control.Monad
import Data.Array.ST
import Data.Array.Unboxed
import Random
----------------------------------------------------------------
type Value = Int