Skip to content

Instantly share code, notes, and snippets.

@Perlence
Perlence / fixcsv.py
Last active December 15, 2015 13:08
Set column number of CSV file to column number of first row moving latter items
import sys
import itertools
import csv
def grouper(n, iterable, fillvalue=None):
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return itertools.izip_longest(fillvalue=fillvalue, *args)
def chainfix(lines):
@Perlence
Perlence / autorun.inf.bat
Created December 17, 2015 17:15
Protect autorun.inf
:: Copy this file to the root of the flash memory and then run it
md autorun.inf
cd autorun.inf
md -..\
:: Now, to delete the folder autorun.inf format the flash memory
@Perlence
Perlence / imgren.py
Last active December 22, 2015 04:29
Rename JPEG images with EXIF data according to date
import sys
import os
from datetime import datetime
from PIL import Image
# Keys of items that may contain date
items = [36868, 36867, 306]
# Output date format
@Perlence
Perlence / mrename.py
Created September 2, 2013 22:02
Open filenames in the text editor for further changes
import sys
import os
import glob
import subprocess
import tempfile
EDITOR = 'c:/Program Files/Sublime Text 2/sublime_text.exe'
files = sys.argv[1:]
@Perlence
Perlence / jsonconfig.py
Created September 3, 2013 07:37
Acquire access to JSON configs via ConfigParser interface
import json
import ConfigParser
class JSONConfig(ConfigParser.RawConfigParser):
def write(self, fp):
output = self._dict()
if self._defaults:
for (key, value) in self._defaults.items():
output[key] = value
for section in self._sections:
@Perlence
Perlence / byobu.txt
Last active December 23, 2015 20:09
Byobu help
┌────────────────────────────┤ Byobu Help ├─────────────────────────────┐
│ │
│ Byobu is a suite of enhancements to tmux, as a command line │
│ tool providing live system status, dynamic window management, │
│ and some convenient keybindings: │
│ │
│ F1 * Used by X11 * │
│ Shift-F1 Display this help │
│ F2 Create a new window │
│ Shift-F2 Create a horizontal split │
@Perlence
Perlence / concurrent-youtube-dl.fish
Last active December 24, 2015 09:13
Download a batch of YouTube videos concurrently
youtube-dl -a - -i -o ' out=%(uploader)s/%(id)s %(title)s.%(ext)s' -g --get-filename --cookies .cookies \
< all-bookmarks.txt \
^ youtube-dl.log \
| aria2c -c -j 6 -x 6 -s 6 -k 1M --load-cookies=.cookies -i - --deferred-input=true \
^ aria2c.log
@Perlence
Perlence / GuitarProMouse.ahk
Created November 29, 2013 20:07
Useful mouse button binds for Guitar Pro 5
MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}
#If WinActive("Guitar Pro 5") and MouseIsOver("Guitar Pro 5")
RButton::
Send {LButton}
Send {Del}
Return
@Perlence
Perlence / getclip.py
Created December 29, 2015 20:49
Print contents of the clipboard
from Tkinter import Tk
r = Tk()
r.withdraw()
print r.clipboard_get()
r.destroy()
@Perlence
Perlence / mrename.py
Created January 1, 2016 12:51
Rename multiple files
#!/usr/bin/env python2
import glob
from itertools import takewhile
import os
import subprocess
import sys
import tempfile
EDITOR = 'c:\\Program Files\\Sublime Text 3\\sublime_text.exe'