Skip to content

Instantly share code, notes, and snippets.

View bingxie's full-sized avatar

Bing Xie bingxie

View GitHub Profile
@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"
}
@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 / .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 / 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 / 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 / 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 / vim-heroku.sh
Created January 11, 2018 00:40 — forked from dvdbng/vim-heroku.sh
Run vim in heroku updated 2017
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 March 20, 2017 04:03 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
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 November 21, 2016 23:47 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#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 August 11, 2016 06:42
Generate a list of fonts for ImageMagick
#!/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