Skip to content

Instantly share code, notes, and snippets.

@sillage
sillage / 2utf8.sh
Last active August 29, 2015 14:07
Change encoding of file to UTF-8
!# /bin/sh
#source: https://wiki.gentoo.org/wiki/Vim#Change_file_encoding
vim -c ":wq! ++enc=utf8" *.srt
@sillage
sillage / jpg2pdf.sh
Last active August 29, 2015 14:19
Convert multiple files to one PDF
#! /bin/sh
brew install imagemagick
convert *.jpg output.pdf
@sillage
sillage / gist:492efe63c553fababa7d
Created April 25, 2015 18:13
curl multiple files with cookies
# "#1" and "#2"are like sed groups
curl url{foo,bar}_[1-42] --output "#1_#2.jpg" --cookie "NAME1=VALUE1;NAME2=VALUE2"
# or
curl url{foo,bar}_[1-42] -o "#1_#2.jpg" -b "NAME1=VALUE1;NAME2=VALUE2"
#!/bin/sh
while read file;
do
touch -r "${file}" "${file%.flac}.mp3";
done < <(ls *.flac)
@sillage
sillage / common.js
Created December 16, 2011 22:49
common.js
// *********************************************************************
// Add a new button in the toolbar which replaces `s' caracters by a
// `ſ' (long s, old style), but NOT at the end of a word.
// *********************************************************************
$(function() {
$.getScript('https://fr.wikisource.org/w/index.php?title=Utilisateur:FitzSai/xregexp.js&action=raw', // load XRegExp
function() {
$.getScript('https://fr.wikisource.org/w/index.php?title=Utilisateur:FitzSai/unicode-base.js&action=raw', // load Letter category only
function() {
@sillage
sillage / adb-backup.sh
Last active December 16, 2015 19:00
Backup MMS/SMS and Angry Birds through adb (Android Debug Bridge)
#!/bin/sh
# backup mms sms needs *root*
mkdir -p com.android.providers.telephony/databases
adb pull /data/data/com.android.providers.telephony/databases/mmssms.db com.android.providers.telephony/databases/mmssms.db
# backup Angry Birds highscores and settings
mkdir -p com.rovio.angrybirds/files
adb pull /data/data/com.rovio.angrybirds/files/highscores.lua com.rovio.angrybirds/files/highscores.lua
adb pull /data/data/com.rovio.angrybirds/files/settings.lua com.rovio.angrybirds/files/settings.lua
@sillage
sillage / get_magic.sh
Created May 24, 2013 23:35
Get all Magic card pictures from gatherer.wizards.com (format:number-title.jpg)
#!/bin/sh
for n in {1..4980}
do curl -s "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=${n}&type=card" > "${n}-$(hxextract title http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=$n | grep -v title | sed 's/^.\(.*\).\{35\}$/\1/').jpg"
done
@sillage
sillage / gist:cb3c101d8225753f9b43
Last active May 4, 2016 21:37
Git cheat sheet
# update and merge all remote submodules
# http://stackoverflow.com/questions/5828324/update-git-submodule-to-latest-commit-on-origin
git submodule update --remote --merge
# update repo from upstream
# https://help.github.com/articles/syncing-a-fork/
git fetch upstream && git checkout master && git merge upstream/master
# more help: https://github.com/blog/2104-working-with-submodules
@sillage
sillage / terminaltips.sh
Last active January 15, 2017 15:34
Terminal Tips
#!/bin/sh
# Terminal Tips: Make hidden Dock icons transparent
defaults write com.apple.dock showhidden -bool true && killall Dock
# Terminal Tips: Enable "path view" in Finder
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES && killall Finder
# How to prevent .DS_Store file creation over network connections
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
# Allow text selection in the Quick Look window
defaults write com.apple.finder QLEnableTextSelection -bool true && killall Finder
@sillage
sillage / exifdate.sh
Last active April 7, 2017 20:57
Rename pictures with Exif DateTimeOriginal prefix
#! /bin/sh
# Rename pictures with Exif DateTimeOriginal prefix
# format: YYYYmmdd_HHMMSS_:basename:
exiv2 -r '%Y%m%d_%H%M%S_:basename:' rename $(ls *.JPG *.jpg 2>/dev/null)
# format (Dropbox like): YYYY-mm-dd HH.MM.SS_:basename:
# exiv2 -r '%Y-%m-%d %H.%M.%S_:basename:' rename $(ls *.JPG *.jpg 2>/dev/null)