As configured in my dotfiles.
start new:
tmux
start new with session name:
| git stash # Stash changes if any | |
| git symbolic-ref HEAD refs/heads/${NEW_BRANCH} # Change head to a new, non-existing ref | |
| git rm -rf . # Delete files from version control and working directory | |
| rm -r . # Delete files from file system | |
| git commit --allow-empty -m "Created new branch ${NEW_BRANCH}" # Commit changes in the new branch |
| # UPDATE: The ability to call Proc.new without a block was removed in Ruby 3.0.0 | |
| # See https://bugs.ruby-lang.org/issues/10499 for more information. | |
| # So you might have heard that this is slow: | |
| # | |
| # def some_method(&block) | |
| # block.call | |
| # end | |
| # | |
| # Compared to: |
As configured in my dotfiles.
start new:
tmux
start new with session name:
| 1. Close Firefox | |
| 2. Execute this: | |
| find ~/.mozilla/firefox/ -type f -name '*.sqlite' -exec sqlite3 {} 'VACUUM;' \; |
| desc 'List defined routes' | |
| task 'routes' do | |
| App::routes.each_pair do |method, list| | |
| puts ":: #{method} ::" | |
| routes = [] | |
| list.each do |item| | |
| source = item[0].source | |
| item[1].each do |s| | |
| source.sub!(/\(.+?\)/, ':'+s) |
| t = 236 # seconds | |
| Time.at(t).utc.strftime("%H:%M:%S") | |
| => "00:03:56" | |
| # Reference | |
| # http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time |
| def snake_case | |
| return downcase if match(/\A[A-Z]+\z/) | |
| gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). | |
| gsub(/([a-z])([A-Z])/, '\1_\2'). | |
| downcase | |
| end | |
| "FooBar".snake_case #=> "foo_bar" | |
| "HeadlineCNNNews".snake_case #=> "headline_cnn_news" | |
| "CNN".snake_case #=> "cnn" |
| hash = { 'foo' => 'bar' } | |
| # Version 1 | |
| hash = Hash[hash.map { |k, v| [k.to_sym, v] }] | |
| # Version 2 | |
| hash = hash.reduce({}) do |memo, (k, v)| | |
| memo.tap { |m| m[k.to_sym] = v } | |
| end |
| require 'base64' | |
| require 'openssl' | |
| # Parse SSH keys to be used by OpenSSL lib | |
| # Taken from Zerg Support project. | |
| # See: https://github.com/pwnall/zerg_support/blob/faaa5dd140c95588a1db2a25f6c9d9cacb4f9b0a/lib/zerg_support/open_ssh.rb | |
| module OpenSSHKeyConverter | |
| # The components in a openssh .pub / known_host RSA public key. | |
| RSA_COMPONENTS = ['ssh-rsa', :e, :n] | |
| # The components in a openssh .pub / known_host DSA public key. |
| [Unit] | |
| Description=Unbound is a validating, recursive, and caching DNS resolver. | |
| After=network.target networking.service | |
| [Service] | |
| Type=simple | |
| ExecStartPre=/usr/local/sbin/unbound-anchor -a /var/unbound/root.key | |
| ExecStartPre=/usr/local/sbin/unbound-checkconf | |
| ExecStart=/usr/local/sbin/unbound -d | |
| LimitNOFILE=102400 |