Skip to content

Instantly share code, notes, and snippets.

View bingxie's full-sized avatar

Bing Xie bingxie

View GitHub Profile
@bingxie
bingxie / custom_formatter.rb
Created January 15, 2018 04:13
Simplified rspec formatter, good for VS code terminal integration
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
@bingxie
bingxie / source_for.rb
Last active June 12, 2020 03:53
Quickly find ruby method and open the file
# put this code into your .pryrc and .irbrc
def source_for(object, method_sym, from_super = nil)
if object.respond_to?(method_sym, true)
method = object.method(method_sym)
elsif object.is_a?(Module)
method = object.instance_method(method_sym)
end
if from_super
@bingxie
bingxie / GitHub-Forking.md
Created April 3, 2019 23:25 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@bingxie
bingxie / .inputrc
Last active May 8, 2019 00:45 — forked from shellexy/.inputrc
把这个文件保存为 ~/.inputrc 就能直接上下方向键搜索历史记录了。还能随时 cat ~/.inputrc 一下查看 shell 快捷键备忘,~/.inputrc for nice bash history up-arrows. This allows you to search through your history using the up and down arrows … i.e. type "cd /" and press the up arrow and you'll search through everything in your history that starts with "cd /".
## history search
"\e[A": history-search-backward
"\e[B": history-search-forward
## visible ring
set visible-stats on
## menu complete
"\C-n": menu-complete
## 快捷键备忘
## Ctrl + a : 光标移到行首。
@bingxie
bingxie / job_worker.rb
Created January 18, 2020 11:03
Test Ruby code
# this is a ruby file
def Hello
puts "Hello World"
end
class Job
def perform(*args)
args.each do |arg|
puts arg + "!"
end
@bingxie
bingxie / ruby.json
Created August 19, 2020 01:00
ruby binding.pry snippet
"Debug with pry": {
"prefix": "pry",
"body": [
"binding.pry"
],
"description": "Debug with pry"
}