Skip to content

Instantly share code, notes, and snippets.

View ichiban's full-sized avatar

Yutaka Ichibangase ichiban

View GitHub Profile
@ichiban
ichiban / gist:1833038
Created February 15, 2012 03:50
こんなので.ssh/config切り替えると便利な気がする
#!/usr/bin/env ruby
require 'thor'
class SSHEnv < Thor
SSH_DIR = "~/.ssh"
desc 'use PRESET', 'Switch SSH config preset to PRESET'
method_option :dry, :type => :boolean, :aliases => '-d'
def use(name="default")
@ichiban
ichiban / base64tweet.el
Created June 11, 2012 09:24
おおっぴらに言いにくい事でも難読化すればどこにだって書ける。
(defun base64 (&optional b e)
"base64 encode/decode"
(interactive "r")
(shell-command-on-region b e "ruby -rbase64 -e 's = $stdin.gets; print Base64.send(/^[A-Za-z0-9\\+\\/=]+$/ =~ s ? :decode64 : :encode64, s).split($/).join'" nil t))
@ichiban
ichiban / tsv-to-sexp.el
Created July 6, 2012 08:01
TSV to S-exp
(require 'cl)
(defun tsv-to-sexp (&optional b e)
"TSV to S-exp"
(interactive "r")
(lexical-let ((str (buffer-substring b e)))
(delete-region b e)
(insert (pprint (mapcar (lambda (line) (split-string line "\t"))
(split-string str "\n"))))))
@ichiban
ichiban / tsv-to-ruby.el
Created July 6, 2012 08:02
TSV to ruby
(require 'cl)
(defun tsv-to-ruby (&optional b e)
"TSV to ruby"
(interactive "r")
(lexical-let ((str (buffer-substring b e)))
(delete-region b e)
(insert (mapconcat #'identity
(list "["
(mapconcat #'tsv-to-ruby-line (split-string str "\n") ",\n ")
@ichiban
ichiban / gist:3192730
Created July 28, 2012 10:03
Installing ocaml4.0.0 with ocamlbrew
export OCAML_MAJOR_VERSION=4
export OCAML_MINOR_VERSION=00
export OCAML_PATCH_VERSION=0
curl -kL https://raw.github.com/hcarty/ocamlbrew/master/ocamlbrew-install | bash

test

てすとてすと

テスト

てすてす

@ichiban
ichiban / crawler.ml
Created January 13, 2013 07:48
たった20行のコードでひたすらアイドル水着画像を集める(OCamlだよ)
#!/usr/bin/env ocamlscript
Ocaml.packs := ["batteries"; "netclient"]
--
open BatPervasives
open Str
open Http_client.Convenience
let url = "http://matome.naver.jp/odai/2135350364969742801"
let pattern = regexp "<img src=\".+\".*class=\"MTMItemThumb\".*/>"
chmod +x crawler.ml
./crawler.ml > photos.html
open photos.html
@ichiban
ichiban / dashboard_controller.rb
Last active December 14, 2015 06:09
Rubyの暗黒面が見えてきた
class DashboardController < ApplicationController
include TabsHelper
set_tab :dashboard
def index
end
end
@ichiban
ichiban / dtpicker.js
Created May 27, 2013 18:11
jquery-simple-datetimepickerを無理矢理Angular.jsのdirectiveにしちゃう
// a Angular.js directive that activates jquery-simple-datetimepicker
//
// jquery-simple-datetimepicker:
//
// https://github.com/mugifly/jquery-simple-datetimepicker
//
// usage:
//
// <input type="text" ng-model="datetime" ng-dtpicker ng-change="doSomething(datetime)" />
//