Skip to content

Instantly share code, notes, and snippets.

Avatar

Bing Xie bingxie

View GitHub Profile
@bingxie
bingxie / ruby.json
Created Aug 19, 2020
ruby binding.pry snippet
View ruby.json
"Debug with pry": {
"prefix": "pry",
"body": [
"binding.pry"
],
"description": "Debug with pry"
}
View job_worker.rb
# 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 / .inputrc
Last active May 8, 2019 — 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 /".
View .inputrc
## 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 / GitHub-Forking.md
Created Apr 3, 2019 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow
View GitHub-Forking.md

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 / source_for.rb
Last active Jun 12, 2020
Quickly find ruby method and open the file
View source_for.rb
# 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 / custom_formatter.rb
Created Jan 15, 2018
Simplified rspec formatter, good for VS code terminal integration
View custom_formatter.rb
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
@bingxie
bingxie / vim-heroku.sh
Created Jan 11, 2018 — forked from dvdbng/vim-heroku.sh
Run vim in heroku updated 2017
View vim-heroku.sh
mkdir ~/vim
cd ~/vim
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
# Compiled on Jul 20 2017
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
export VIMRUNTIME="$HOME/vim/runtime"
export PATH="$HOME/vim:$PATH"
cd -
@bingxie
bingxie / gist:4c26678bce5a52396c4901bf9395456e
Created Mar 20, 2017 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
View gist:4c26678bce5a52396c4901bf9395456e
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@bingxie
bingxie / rspec_rails_cheetsheet.rb
Last active Nov 21, 2016 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
View rspec_rails_cheetsheet.rb
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@bingxie
bingxie / imagick_type_gen.pl
Created Aug 11, 2016
Generate a list of fonts for ImageMagick
View imagick_type_gen.pl
#!/usr/bin/perl -w
#
(my $prog = $0) =~ s/^.*\///;
sub Usage {
die @_, &herefile( qq{
| Usage: $prog > ~/.magick/type.xml
| $prog [-d] font1.ttf font2.ttf ... > type.xml
| $prog -f ttf_font_file_list > type.xml
|
| Generate an ImageMagick font list "type.xml" file for ALL fonts
You can’t perform that action at this time.