Skip to content

Instantly share code, notes, and snippets.

View hex2010's full-sized avatar
💀
Account abandoned

hex2010 hex2010

💀
Account abandoned
  • Beijing
View GitHub Profile
@hex2010
hex2010 / batch-rename-video-picture.sh
Created October 28, 2016 20:38
视频或图片文件用拍摄日期来命名
# 视频或图片文件用拍摄日期来命名
# 图片改名
exiv2 rename -F *.jpg
# 图片递归改名
find . -name "*" -type f -exec bash -c 'exiv2 rename -r %Y%m%d-$(basename $(dirname $0))-%H%M%S -F $0' {} \;
# 视频递归改名
find . -iname "*.mov" -exec bash -c 'echo mv $0 $(dirname $0)/$(exiftool -s2 -d %Y%m%d-%H%M%S -createdate $0 | awk -F " " "{print \$2}").mov' {} \;
@hex2010
hex2010 / hx-xcode.el
Created October 6, 2016 11:51
Open file/project/workspace/products with Xcode from within Emacs
;;; hx-xcode --- Utils work with Xcode.
;;; Commentary:
;; This is free and unencumbered software released into the public domain.
;; Anyone is free to copy, modify, publish, use, compile, sell, or
;; distribute this software, either in source code form or as a compiled
;; binary, for any purpose, commercial or non-commercial, and by any
;; means.
@hex2010
hex2010 / bgapp.sh
Last active October 6, 2016 07:22
Auto relaunch specific application when it crash. (MacOS)
#!/bin/bash
# you can setup crontab to run this script periodically
# require pidof install in /usr/local/bin
# read config from ~/.bgapp
ret=0
while read s; do
IFS="|"; cfg=($s) ; unset IFS;
if [ "${#cfg[@]}" = "2" ]; then
if [ -z "`/usr/local/bin/pidof ${cfg[0]}`" ]; then
@hex2010
hex2010 / autolaunch.crontab
Last active October 1, 2016 06:32
Auto relaunch specific application when it crash.(MacOS)
# run command "crontab -e" to edit crontab
# require pidof utils install in /usr/local/bin
* * * * * bash -c "[ -z \"`/usr/local/bin/pidof Spectacle`'\" ] && open -a Spectacle"
@hex2010
hex2010 / toggle-finder-show-all-files.sh
Created September 27, 2016 04:40
Mac OSX toggle show hidden files in Finder
#!/bin/bash
showAll=`defaults read com.apple.finder AppleShowAllFiles`
if [[ "$showAll" = "NO" ]]; then
defaults write com.apple.finder AppleShowAllFiles YES
else
defaults write com.apple.finder AppleShowAllFiles NO
fi
killall Finder /System/Library/CoreServices/Finder.app
@hex2010
hex2010 / start-screen-saver.sh
Created September 27, 2016 04:38
MacOS Sierra "start screen server" from command line, a way to Lock Screen
#!/bin/sh
/usr/bin/open -a /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
@hex2010
hex2010 / iterm.sh
Created September 27, 2016 04:33
Run command in new window of iTerm2
#!/bin/bash
read -r -d '' script <<'EOF'
on run argv
tell application "iTerm"
activate
set newWindow to (create window with default profile)
tell current session of newWindow
set args to ""
repeat with arg in argv
@hex2010
hex2010 / Terminal.workflow
Created September 27, 2016 04:31
Open iTerm2 at folder, Automator service script
on run {input, parameters}
set my_file to first item of input
set dir_path to quoted form of (POSIX path of my_file)
tell application "iTerm"
set newWindow to (create window with default profile)
tell current session of newWindow
write text "cd " & dir_path
end tell
end tell
end run
@hex2010
hex2010 / hx-golang.el
Last active October 5, 2016 20:08
Emacs scripts to work with golang, hard to make it generic thought.
;;; hx-golang.el --- Utils works with Golang
;;; Commentary:
;;; Code:
(defcustom hx-golang-build-flags "-gcflags='-l -N' -tags debug"
"Flags for build golang packages."
:type 'string
:options '(turn-on-auto-fill)