Skip to content

Instantly share code, notes, and snippets.

@jiMuBao
jiMuBao / hastebin.sh
Created Dec 11, 2017
haste bin sh tool
View hastebin.sh
haste () {
local output returnfile contents
if (( $# == 0 )) && [[ $(printf "%s" "$0" | wc -c) > 0 ]]
then
contents=$0
elif (( $# != 1 )) || [[ $1 =~ ^(-h|--help)$ ]]
then
echo "Usage: $0 FILE"
echo "Upload contents of plaintext document to hastebin."
echo "\nInvocation with no arguments takes input from stdin or pipe."
@jiMuBao
jiMuBao / git-zsh-checkout-autocomplete-local-only.md
Created Oct 18, 2017 — forked from mmrko/git-zsh-checkout-autocomplete-local-only.md
List only local branches when autocompleting git checkout (Zsh)
View git-zsh-checkout-autocomplete-local-only.md
git config --global alias.checkoutr checkout
$EDITOR /usr/local/share/zsh/site-functions/git-completion.bash

...and then modify the file as follows...

-__gitcomp_nl "$(__git_refs '' $track)"
+if [ "$command" = "checkoutr" ]; then
+    __gitcomp_nl "$(__git_refs '' $track)"
+else
@jiMuBao
jiMuBao / index.html
Last active Aug 29, 2015 — forked from jonnyreeves/index.html
javascript: Require JS construct object
View index.html
<!DOCTYPE html>
<html>
<head>
<script data-main="usage" src="http://requirejs.org/docs/release/1.0.8/comments/require.js"></script>
</head>
<body>
<p>Check your JavaScript console for output!</p>
</body>
</head>
@jiMuBao
jiMuBao / moveCursor.py
Last active Aug 29, 2015
sublime: move cursor plugin
View moveCursor.py
import sublime, sublime_plugin
class Move_caret_topCommand(sublime_plugin.TextCommand):
def run(self, edit):
screenful = self.view.visible_region()
col = self.view.rowcol(self.view.sel()[0].begin())[1]
row = self.view.rowcol(screenful.a)[0] + 1
target = self.view.text_point(row, col)
@jiMuBao
jiMuBao / key binding
Last active Aug 29, 2015
sublime: Key binding
View key binding
How do I skip the cursor past the end of autofilled parens and braces in Sublime Text 2?
This is a small modification to Naor Ami's answer so that the autocomplete also includes curly braces and single quotes.
[
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)'}\"\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
}
@jiMuBao
jiMuBao / tmux.conf
Created Nov 28, 2013 — forked from spicycode/tmux.conf
tmux: configuration
View tmux.conf
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@jiMuBao
jiMuBao / resize.js
Created Nov 7, 2012
jquery: resize image
View resize.js
<script type="text/javascript">
$('.imgClass').each(function() {
var maxWidth = 640; // Max width for the image
var maxHeight = 100; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max
if(width > maxWidth){
You can’t perform that action at this time.