Skip to content

Instantly share code, notes, and snippets.

View KenshoFujisaki's full-sized avatar

藤崎 顕彰 KenshoFujisaki

View GitHub Profile
@KenshoFujisaki
KenshoFujisaki / printer.rb
Last active August 29, 2015 14:22 — forked from zakuroishikuro/printer.rb
Googleからダウンロードできる検索履歴のjsonを月ごとの検索単語でヒストグラム化
# https://history.google.com/history/
# 上のリンクのギアアイコンからダウンロードできる検索履歴のzipを全て表示するやつ
require 'kconv'
require 'json'
require 'cgi'
zip_path = ARGV[0]
raise "Googleからダウンロードした.zipファイルを指定してください。" unless /検索-20.*\.zip/ === zip_path
@KenshoFujisaki
KenshoFujisaki / get_modifying_file_with_method_beginning_linenumber.rb
Last active August 29, 2015 14:19
変更行を含むRSpecのメソッド開始行を取得する
#!/usr/bin/ruby
# require: diff-lines.sh: https://gist.github.com/KenshoFujisaki/169326eb2fdde5182153
# constants
MAX_FILE_LINES = 1000000
# get args
unless ARGV.length == 2
puts "usage: #{$0} [before_revision_hash] [after_revision_hash]"
puts "e.g.: #{$0} '212dfa0' '0bc3dc7'"
@KenshoFujisaki
KenshoFujisaki / diff-lines.sh
Last active January 24, 2020 03:14
git diffに対して行数出力
#!/bin/sh
# Ref: Using git diff, how can I get added and modified lines numbers? - Stack Overflow -
# http://stackoverflow.com/questions/8259851/using-git-diff-how-can-i-get-added-and-modified-lines-numbers
path=
line=
while read; do
esc=$'\033'
if [[ $REPLY =~ ---\ (a/)?.* ]]; then
continue
elif [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]]+).* ]]; then
@KenshoFujisaki
KenshoFujisaki / check_db_migration_condition.sh
Created April 20, 2015 14:47
DBマイグレーション状況確認(マイグレーション済/未のファイル取得)
# cd [RAILS_ROOT]
db_name="db_name"
db_user="db_user"
db_pass="db_pass"
diff -U10000 \
<(ls db/migrate/ | sort | ruby -nle 'print $_.split("_").first') \
<(mysql -u${db_user} -p${db_pass} -D${db_name} -e"select * from schema_migrations;")
@KenshoFujisaki
KenshoFujisaki / remove_vim_swap_files.sh
Created March 19, 2015 05:24
vimのスワップファイルを除去します。
# remove
$ find . -name '.*.sw*' -exec rm {} \;
# remove interactive
$ find . -name '.*.sw*' -ok rm {} \;
@KenshoFujisaki
KenshoFujisaki / hooks_commit-msg.rb
Last active August 29, 2015 14:17
ローカルフックスクリプト:トピックブランチのチケット番号とコミットログのチケット番号の一致チェック
#!/usr/bin/ruby
require "readline"
message_file = ARGV[0]
message = File.read(message_file)
# コミットメッセージ確認
regex_matches = /^#(\d+)/.match(message)
unless regex_matches
@KenshoFujisaki
KenshoFujisaki / hooks_update.rb
Created March 15, 2015 16:46
GitLab向けリモートフックスクリプト:トピックブランチ以外のpush禁止
#!/opt/gitlab/embedded/bin/ruby
# Fix the PATH so that gitlab-shell can find git-upload-pack and friends.
ENV['PATH'] = '/opt/gitlab/bin:/opt/gitlab/embedded/bin:' + ENV['PATH']
#!/usr/bin/env ruby
# This file was placed here by GitLab. It makes sure that your pushed commits
# will be processed properly.
# You can add your own hooks to this file, but be careful when updating gitlab-shell!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import sys
import os.path
import bz2
from gensim.corpora import WikiCorpus
from gensim.corpora.wikicorpus import filterWiki
@KenshoFujisaki
KenshoFujisaki / .zshrc
Last active August 29, 2015 14:13
svndiff (svn差分確認のための関数。コードレビュー効率化のためのショートカット)
# ------------------------------------------------------------------------
# svndiff
# ------------------------------------------------------------------------
function svndiff() {
help() {
echo "Usage: svndiff [option] [filename]"
echo "Customize: ~/.zshrc"
return
}
if [ $# -eq 0 ] ; then