Skip to content

Instantly share code, notes, and snippets.

View kairyou's full-sized avatar

Leon Xu kairyou

View GitHub Profile
@kairyou
kairyou / alias.sh
Last active August 13, 2019 01:10
alias for git log, git branch log, git submodule log
# git -P lg -5 origin/master # --cherry --no-merges
git config --global alias.lg "\!f() { git log --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --graph \${@:q}; }; f"
# git -P sl submodulePath -5
git config --global alias.sl "\!f() { [[ -d \$1 ]] && cd \$1 && git log --pretty='%C(red)%h%C(reset) - %s %C(green)(%cr) %C(bold blue)<%an>%C(reset)' \${@:2}; }; f"
# git -P sul submodulePath -5
git config --global alias.sul "\!f(){ local IFS=\$'\n'; git submodule foreach -q '[[ \"\$name\" = \"'\$1'\" ]] && git log --pretty=\"%C(red)%h%C(reset) - %s %C(green)(%cr) %C(bold blue)<%an>%C(reset)\" '\${@:2}' || true'; };f"
@kairyou
kairyou / get-ip
Last active August 29, 2015 14:11
bash get ip
#!/bin/bash
# bash get ip
declare -a api=("ifcfg.me" "ident.me" "tnx.nl/ip" "ip.appspot.com" "ifconfig.me" "curlmyip.com");
IP=$(curl -s --retry 3 --retry-delay 10 ${api[0]});
while [ -z "$IP" ] # If no IP
do
sleep 0.5;
random=$(( RANDOM % ${#api[@]} ));
IP=$(curl -s --retry 3 --retry-delay 10 ${api[$random]});
done
@kairyou
kairyou / gist:4aaca43d1528d042fa4c
Last active June 17, 2020 09:57
jquery on show hide event
(function($) {
$.each(['show', 'hide'], function(i, ev) {
var el = $.fn[ev];
$.fn[ev] = function() {
this.trigger(ev);
return el.apply(this, arguments);
};
});
})(jQuery);
@kairyou
kairyou / git-post-merge-hook
Last active August 29, 2015 14:09
git hooks for .git/hooks/post-merge
<?php
// echo exec("pwd")."\n";
$id = exec("git log -1 --pretty=%h");
$msg = exec("git log -1 --pretty=%s");
$user = exec("git log -1 --pretty=%cn\(%ce\)"); #name+email
$time = exec("git log -1 --pretty=%ai");
exec("git diff-tree -p --no-commit-id $id", $diff);
$url = exec("git config --get remote.origin.url");
if(empty($url)) {
$url = exec("git config --get remote.origin.pushurl");
@kairyou
kairyou / index.html
Created June 25, 2013 13:27
A CodePen by Leon.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Scratchcard</title>
</head>
<body>
<div class="box">
<div class="content">
<img src="http://img2.pengfu.cn/big/138/140138.jpg">