Skip to content

Instantly share code, notes, and snippets.

View k-yamada's full-sized avatar

Kazuhiro Yamada k-yamada

  • japan
View GitHub Profile
@k-yamada
k-yamada / HogePage.vue
Last active May 29, 2018 11:03
electronのwebviewとipcで通信する方法 ref: https://qiita.com/k-yamada-github/items/31f87475b68d63badcfb
<template>
<webview
src="http://localhost:3000/"
partition="persist:hoge"
:preload="preload"
autosize
allowpopups
/>
</template>
@k-yamada
k-yamada / file0.swift
Last active May 23, 2018 06:39
カスタムUITableViewCellの選択時の背景色を変更する ref: https://qiita.com/k-yamada-github/items/a589fca3b68847bc3a99
// CustomCell.swift:
import UIKit
class CustomCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
backgroundColor = UIColor(named: "primary")
selectedBackgroundView = makeSelectedBackgroundView()
@k-yamada
k-yamada / file0.txt
Last active July 23, 2016 08:57
SwiftのCGRectMakeとCGPointMakeを新しい書き方に修正するスクリプト ref: http://qiita.com/k-yamada@github/items/59027c80be7be2644cc7
#! /usr/bin/ruby
#
# # usage
#
# chmod +x replace.rb
# ./replace.rb ./hoge.swift > out.swift
#
file_path = File.absolute_path(ARGV[0].to_s)
unless File.exists? file_path
abort "ファイルが存在しません. file_path = #{file_path}"
@k-yamada
k-yamada / .vimrc
Created January 7, 2014 07:21
vimrc
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <[email protected]>
" Last change: 2008 Jul 02
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'resque/tasks'
MyApp::Application.load_tasks
# Fix resque error.
# ref: https://gist.github.com/1316470
task "resque:setup" => :environment do
ENV['QUEUE'] ||= '*'
" =============== NeoBundle START ===============
set nocompatible " be iMproved
filetype off
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim
call neobundle#rc(expand('~/.vim/bundle/'))
endif
" originalrepos on github
@k-yamada
k-yamada / jsonparse
Created December 11, 2012 07:17
json parse
#!/usr/bin/env ruby
require 'json'
inp = ARGV[0]
jj(JSON.parse!("#{inp}"))
@k-yamada
k-yamada / to_snake_case.rb
Created November 12, 2012 02:03
Convert input text to snake_case
print ">>"
while line = STDIN.gets
if (/exit/ =~ line)
break;
end
STDOUT.puts line.downcase.gsub(/ /, "_")
print ">>"
end
@k-yamada
k-yamada / rspec.rb
Created October 22, 2012 10:48
simplecov hangs after all spec passed when running on jruby. the temporary solution is to add at_exit hook like this.
#!/usr/bin/env ruby
system("jruby -S bundle exec rspec spec")
exit 0
@k-yamada
k-yamada / 1. benchmark.rb
Created June 24, 2012 00:18
Benchmark of JRuby start-up time with arguments
require 'benchmark'
def test(args)
5.times do
`jruby test.rb #{args}`
end
end
Benchmark.bm(7) do |x|
x.report("default :") {test ""}