Skip to content

Instantly share code, notes, and snippets.

@jiMuBao
jiMuBao / resize.js
Created November 7, 2012 00:42
jquery: resize image
<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){
@jiMuBao
jiMuBao / tmux.conf
Created November 28, 2013 22:38 — forked from spicycode/tmux.conf
tmux: configuration
# 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 / key binding
Last active August 29, 2015 13:58
sublime: 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 / moveCursor.py
Last active August 29, 2015 13:58
sublime: move cursor plugin
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 / index.html
Last active August 29, 2015 14:08 — forked from jonnyreeves/index.html
javascript: Require JS construct object
<!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 / git-zsh-checkout-autocomplete-local-only.md
Created October 18, 2017 02:44 — forked from mmrko/git-zsh-checkout-autocomplete-local-only.md
List only local branches when autocompleting git checkout (Zsh)
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 / hastebin.sh
Created December 11, 2017 00:12
haste bin sh tool
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."