Skip to content

Instantly share code, notes, and snippets.

@sillage
sillage / gist:1336681
Last active April 10, 2024 22:10
Save a file in UTF-8 encoding with Vim
:wq! ++enc=utf-8
@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 / 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 / gist:1944623
Created February 29, 2012 21:37
piratebay magnet scrape
use warnings;
use strict;
use Parallel::ForkManager;
use 5.010;
my $pm=new Parallel::ForkManager(50);
use Fcntl qw(:flock SEEK_END);
$pm->run_on_finish(sub{
my (undef, undef, undef, undef, undef, $res_ref) = @_;
@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 / 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 / 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

Creating a two way sync between a Github repository and Subversion

Another git <> svn post?

As many of you know I have been on a quest to get Jetpack core development moved from the WordPress.org Subversion (svn) repository to Github (git). As part of this process I setup an experimental Jetpack repository to see how synchronization works between git and svn. Lets just clear the air right now and say not well, not well at all. This is due to how git and svn each store their respective histories. But! I think I finally have it figure out.

Backfill

I wrote an article a couple months ago entitled Creating a synchronized Github fork of a WordPress.org Subversion plugin repository. This article is great (and still a recommended read) if you are only doing synchronization b

@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)