This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sublime, sublime_plugin, subprocess | |
| class GitLogPatchCommand(sublime_plugin.TextCommand): | |
| ''' | |
| Show result of `git log -p` current file | |
| # Installation | |
| 1. Save to Packages/User/git-log-p.py | |
| 2. Edit Packages/User/User.sublime-commands |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Usage: | |
| # preview path/to/pdf:123 # to open path/to/pdf in Preview.app and jump to specified page | |
| require "open3" | |
| require "json" | |
| OPEN_PAGE_SCRIPT = <<-JS | |
| function run(argv) { | |
| var options = JSON.parse(argv[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Kobito の JSON-LD を受け取って、#{timestamp}_#{title}.md のファイルを生成する | |
| # Example: cat ~/Dropbox/Kobito/Kobito\ Archive/*.json | jq -c . | kobito-export | |
| require "json" | |
| require "time" | |
| while line = gets | |
| json = JSON.parse(line) | |
| updated_at = Time.parse(json["updated_at"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # List all foreign key constraints for *_id columns. | |
| # Use --only-no-constraint to list *_id has no constraint. | |
| gem "activerecord", ">= 4.2.1" | |
| gem "mysql2" | |
| require "optparse" | |
| require "active_record" | |
| require "mysql2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # synvert --load convert_test_request_method_invocation.rb --run rails/convert_test_request_method_invocation . | |
| # convert `get @foo, @bar, @baz` to `get params: @foo, session: @bar, flash: @baz` etc. | |
| Synvert::Rewriter.new 'rails', 'convert_test_request_method_invocation' do | |
| %w(test/**/*.rb spec/**/*.rb features/**/*.rb).each do |file_pattern| | |
| within_files file_pattern do | |
| %w(get post put patch delete).each do |http_method| | |
| with_node type: 'send', receiver: nil, message: http_method do | |
| case current_node.arguments.size | |
| when 2 | |
| replace_with "#{http_method} {{arguments[0]}}, params: {{arguments[1]}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Usage: echo "東京都xxx\n大阪府xxx\n名古屋市" | ./split_pref.rb | |
| PREFECTURES = [ | |
| "北海道", "青森県", "岩手県", "宮城県", "秋田県", | |
| "山形県", "福島県", "茨城県", "栃木県", "群馬県", | |
| "埼玉県", "千葉県", "東京都", "神奈川県", "新潟県", | |
| "富山県", "石川県", "福井県", "山梨県", "長野県", | |
| "岐阜県", "静岡県", "愛知県", "三重県", "滋賀県", | |
| "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #compdef generator_spec | |
| local state | |
| _generator_spec() { | |
| __generator_spec | |
| } | |
| __generator_spec() { | |
| readonly local DEPTH=2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # synvert --load use_factory_girl_instead_of_machinist.rb --run factory_girl/use_factory_girl_instead_of_machinist . | |
| # convert `Foo::Bar.make` to `build(:foo_bar)` etc. | |
| require "active_support/core_ext/string" | |
| Synvert::Rewriter.new 'factory_girl', 'use_factory_girl_instead_of_machinist' do | |
| %w(test/**/*.rb spec/**/*.rb features/**/*.rb).each do |file_pattern| | |
| within_files file_pattern do | |
| with_node type: 'send', message: "make" do | |
| name = current_node.receiver.to_source.underscore.gsub("/", "_") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Thanks to: https://gist.github.com/kawaz/8bd7db8416f90c3cc168f12c8c75b6d3 | |
| # Usage: vpn (connect|disconnect) SERVICE_NAME [CONFIGURATION_NAME] | |
| require "json" | |
| SCRIPT = <<-JS | |
| function run(json) { | |
| var argv = JSON.parse(json); | |
| var sysev = Application("System Events"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Usage: ./kobito2html.rb Kobito.db ./export | |
| gem "activerecord", "~> 5.1.4" | |
| gem "nokogiri", "~> 1.8.1" | |
| gem "sqlite3", "~> 1.3.13" | |
| require "active_record" | |
| require "nokogiri" | |
| require "sqlite3" |