Skip to content

Instantly share code, notes, and snippets.

Avatar

takeshy takeshy

View GitHub Profile
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){
View calc_month.rb
def calc_month(t,n)
y = t.year
m = t.month + n
if m < 1
y += ((m-1)/12).floor
m = 12 + (m % -12)
elsif m > 12
y += (m/12).floor
m = ((m-1) % 12) + 1
end
@takeshy
takeshy / index.html
Created Dec 18, 2013
socket.io-reqev用demo index.html
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/underscore.js"></script>
<script type="text/javascript" src="js/backbone.js"></script>
<script type="text/javascript" src="js/socket.io.min.js"></script>
<script type="text/javascript" src="js/io-reqev-client.js"></script>
<title>sample</title>
</head>
@takeshy
takeshy / timer.js
Last active Dec 31, 2015
socket.io-reqev用demo timer.js
View timer.js
var events = require('events');
var Timer = function(){
this.events = ["five","ten","thirty"];
var that = this;
setInterval(function (){
var now = new Date();
if(now.getSeconds() % 5 == 0){
that.emit("five", {time: now.toString()});
}
if(now.getSeconds() % 10 == 0){
@takeshy
takeshy / app.js
Created Dec 18, 2013
socket.io-reqev デモアプリ サーバー側 app.js
View app.js
var IOReqEv = require('socket.io-reqev');
var ioReqEv = new IOReqEv(require('socket.io').listen(50000));
var Timer = require('./timer');
ioReqEv.register("/timer",new Timer());
//temporary web server
var static = require('node-static');
var file = new static.Server('.');
require('http').createServer(function (request, response) {
request.addListener('end', function () {
file.serve(request, response);
You can’t perform that action at this time.