Skip to content

Instantly share code, notes, and snippets.

@apuignav
apuignav / rename-mp3.py
Last active February 27, 2018 19:15
MP3 renamer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# =============================================================================
# @file rename-mp3.py
# @author Albert Puig (albert.puig@cern.ch)
# @date 27.02.2018
# =============================================================================
"""MP3 file renamer"""
import os
$ brew config
HOMEBREW_VERSION: 1.2.1
ORIGIN: https://github.com/Homebrew/brew
HEAD: ea8be174f6009bc9bdec67b13ca501b5b83fc4b8
Last commit: 11 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 2856b9e1e89fba013da875f7c7486379569fca46
Core tap last commit: 24 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
@apuignav
apuignav / curl-timing.cfg
Created March 8, 2015 15:45
Debug slow connection (from http://askubuntu.com/questions/147377/how-to-debug-slow-browsing-speed), use in the following way: curl -w "@curl-timing.cfg" -o /dev/null -s http://www.google.com/
\n
DNS lookup : %{time_namelookup}\n
Connect to server (TCP) : %{time_connect}\n
Connect to server (HTTP/S) : %{time_appconnect}\n
Time from start until transfer began: %{time_pretransfer}\n
Time for redirection (if any) : %{time_redirect}\n
Total time before transfer started : %{time_starttransfer}\n
\n
Total time : %{time_total}\n
Size of download (bytes) : %{size_download}\n
@apuignav
apuignav / f.pl
Last active August 29, 2015 14:09
Useful scripts from Christian Neukirchen's Summer of Scripts (http://chneukirchen.org/blog/)
#!/usr/bin/perl
# From http://chneukirchen.org/blog/archive/2013/07/summer-of-scripts-f.html
my $field = shift or usage();
$field -= 1 if $field > 0;
while (<>) {
chomp;
my @f = split;
print $f[$field], "\n";
}
#!/bin/sh
#
# Find and replace by a given list of files.
#
# replace foo bar **/*.rb
#
# From: https://github.com/thoughtbot/dotfiles/blob/master/bin/replace
find_this=$1
shift
@apuignav
apuignav / temp_shell.zsh
Last active August 29, 2015 14:07
Create a temp directory and open a shell in it. When finished, delete the temp directory.
#!/usr/bin/env zsh --login
# Create temp dir
tmp=${1-$TMPDIR}
tmp=$tmp/tmp.$RANDOM.$RANDOM.$RANDOM.$$
(umask 077 && mkdir $tmp) || {
echo "Could not create temporary directory! Exiting." 1>&2
exit 1
}
# Go to it and start a new shell
@apuignav
apuignav / torrent.py
Last active August 29, 2015 14:03
Torrent file analyzer
#!/usr/bin/env python
# =============================================================================
# @file torrent.py
# @author Albert Puig (albert.puig@epfl.ch)
# @date 05.07.2014
# =============================================================================
"""Torrent file-info decoder, extracted from
http://effbot.org/zone/bencode.htm
@apuignav
apuignav / pyp_beta
Last active September 11, 2017 15:10
#!/usr/bin/env python
#version 2.13
#author tobyrosen@gmail.com
#Copyright (c) 2011-2015 Toby Rosen
#Distributed under the New BSD License.
#All rights reserved.
#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes:
@apuignav
apuignav / lphe-ja.py
Last active December 15, 2015 20:40
LPHE ninja utilities
#!/usr/bin/env python
# @file lphe-ja.py
# @author Albert Puig (albert.puig@epfl.ch)
# @date 05.04.2013
import os
import sys
import re
from sh import git, svn