I hereby claim:
- I am tansengming on github.
- I am sengming (https://keybase.io/sengming) on keybase.
- I have a public key ASC-G2ogHeeBKrtTPbtyJ2tbgv60i6iRlo2mW_ijPCdWnAo
To claim this, I am signing this object:
| # TODO: Fix this to work with addition and deletion distances | |
| def edit_distance(word_1, word_2) | |
| # transforms 'str' to ['s', 't', 'r'] | |
| to_array = -> (word) { word.each_char.map{|c| c} } | |
| # xor(['s', 't', 'r'], ['s', 't', 'r']) = 0 | |
| # xor(['s', 't', 'r'], ['a', 't', 'r']) = 1 | |
| # xor(['s', 't', 'r'], ['a', 'b', 'c']) = 3 | |
| substitution_distance = -> (top, bottom) { top.zip(bottom).map{|top_node, bottom_node| top_node == bottom_node ? 0 : 1 }.inject(:+) } |
| #! /usr/bin/env ruby | |
| sum = ->(top, bottom) { top.zip(bottom).map{|array| array.inject('', :+) } } | |
| mask = ->(top, bottom) { top.zip(bottom).map{|mask_layer, bottom_layer| mask_layer.empty? ? bottom_layer : mask_layer } } | |
| list = (1..100).to_a | |
| crackles = list.map{|num| (num % 3) == 0 ? 'Crackle' : '' } | |
| pops = list.map{|num| (num % 5) == 0 ? 'Pop' : '' } | |
| # ['', '', 'Crackle', '', '' , ...] |
I hereby claim:
To claim this, I am signing this object:
| <snippet> | |
| <content><![CDATA[ | |
| binding.pry | |
| ]]></content> | |
| <tabTrigger>pry</tabTrigger> | |
| <scope>source.ruby</scope> | |
| </snippet> | |
| <!-- save in ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/ --> |
| ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}[" | |
| ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" | |
| ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" | |
| ZSH_THEME_GIT_PROMPT_CLEAN="" | |
| #Customized git status, oh-my-zsh currently does not allow render dirty status before branch | |
| git_custom_status() { | |
| local cb=$(current_branch) | |
| if [ -n "$cb" ]; then | |
| echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX" |
| // Packages/User/rspec.sublime-build | |
| { | |
| "cmd": ["spring", "rspec", "--format", "Fuubar", "$file"], | |
| "working_dir": "$project_path", | |
| "selector": "source_spec.rb" | |
| } |
| require 'rubygems' | |
| require 'active_support' | |
| require 'pathname' | |
| # require 'tapp' | |
| class ToParams | |
| attr_reader :pathname | |
| def initialize(path) | |
| @pathname = Pathname.new path |
| ZSH=$HOME/.oh-my-zsh | |
| ZSH_THEME="gallois" | |
| setopt HIST_FIND_NO_DUPS | |
| setopt histignorealldups | |
| alias x='exit' | |
| alias desk='cd ~/Desktop' | |
| alias rm='grm -v' |
| function gup | |
| if git diff-index --quiet HEAD | |
| gup_base | |
| else | |
| echo 'your index is dirty' | |
| echo 'please git stash or commit, then rerun gup' | |
| end | |
| end | |
| function gup_base |