Skip to content

Instantly share code, notes, and snippets.

takeshy takeshy

View GitHub Profile
@takeshy
takeshy / .vimrc
Created Nov 15, 2018
remove trailing space on save
View .vimrc
function! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre *.ts,*.rb,*.tsx,*.js,*.erb :call <SID>StripTrailingWhitespaces()
View eijiro_to_dicwin.rb
#!/usr/bin/env ruby
require 'nkf'
raw = File.read("#{ENV['HOME']}/Downloads/EIJIRO-1445.TXT")
data = NKF.nkf("-w -d", raw)
results = {}
first_flg = false
data.each_line do |raw_line|
next if !first_flg && !raw_line.match(/a\s+{不-1}/)
View table_info.rb
#!/usr/bin/ruby
require 'rubygems'
require 'mysql'
require 'optparse'
options = {
:database => '',
:host=> 'localhost',
:create=> false,
:count=> false,
:index=> false,
@takeshy
takeshy / read_ts.vim
Last active Jul 11, 2018
typescriptのimport先のファイルの読み込み
View read_ts.vim
function! ReadFile() abort
let s:currentPos = col('.')
let s:colNum = s:currentPos - 1
let s:lastPos = len(getline('.'))
let s:fileName = ''
let s:ext = '.' . expand("%:e")
while s:colNum > -1
if getline('.')[s:colNum] =~ "\['\"\]"
break
end
View confirm_git_branch_D.rb
#!/usr/bin/env ruby
branches = `git branch`
branches.each_line do|line|
branch = line.gsub(/\s/,"")
next if branch[0] == "*"
puts "################"
puts "#{branch}\n"
puts "################"
puts `git branch -d #{branch}`
@takeshy
takeshy / readfile.vim
Last active Sep 3, 2016
javascriptでimport先のファイルやejsファイルをsplitで開く
View readfile.vim
function! ReadJSFile() abort
let s:currentPos = col('.')
let s:colNum = s:currentPos - 1
let s:lastPos = len(getline('.'))
let s:fileName = ''
while s:colNum > -1
if getline('.')[s:colNum] =~ "\['\"\]"
break
end
View vimrc
execute pathogen#infect()
syntax on
ab conlog <script>console.log("<%= %>")</script>
ab vimed sp ~/.vimrc<CR>
nmap ! :execute ":lcd " . expand("%:p:h")<CR>
map <C-f> :let @* = expand("%:p")<CR>
let g:skk_auto_save_jisyo=1
let g:skk_large_jisyo='~/.vim/SKK-JISYO.L'
set ts=2
set sw=2
@takeshy
takeshy / hex2bin.rb
Created Apr 22, 2015
HEX文字列をbinaryに変換する
View hex2bin.rb
#!/bin/env ruby
$HEX = false
if ARGV[0] == "-x"
$HEX = true
ARGV.shift
end
if ARGV.length != 1
puts "#{$0} outputfile"
exit -1
@takeshy
takeshy / js_loader.js
Created Jan 1, 2015
on demand loading js
View js_loader.js
JsLoader = function(srcMap){
this.srcMap = {};
for(key in srcMap){
this.srcMap[key] = {state: "unload",src: srcMap[key],cb: []}
}
};
JsLoader.prototype = {
load: function(m,cb){
var that = this;
if(!this.srcMap[m]){
@takeshy
takeshy / app.js
Last active Aug 29, 2015
socket.ioでiPhone,Androidでローディングが続く問題
View app.js
var static = require('node-static');
var file = new static.Server('.');
server = require('http').createServer(function (request, response) {
request.addListener('end', function () {
file.serve(request, response);
}).resume();
})
server.listen(60000);
var io = require('socket.io').listen(60001);
io.sockets.on('connection', function(socket){
You can’t perform that action at this time.