This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
An OSA script to replace disc numbers in album names with the disc number attribute. | |
Accepts album names in any of these formats: | |
LCD Soundsystem (Disc 1) | |
Mellon Collie and the Infinite Sadness (Disc 1: Dawn to Dusk) | |
The Wall: Live in Berlin (Disc 2) [Live] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PREFIX_LENGTH = 3; | |
var itunes = Application('iTunes'), | |
selection = itunes.selection(); | |
for (var i=0; i<selection.length; i++) { | |
var song = selection[i], | |
trackNumber = parseInt(song.name().slice(0, PREFIX_LENGTH), 10), | |
name = song.name().slice(PREFIX_LENGTH); | |
if (!isNaN(trackNumber)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; nasm -f macho64 mkdir.asm && ld -o mkdir mkdir.o && ./mkdir | |
%define SYSCALL_MKDIR 0x2000088 | |
%define SYSCALL_EXIT 0x2000001 | |
global start | |
section .text | |
start: | |
call mkdir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SimpleHTTPServer, SocketServer | |
import subprocess, sys, os | |
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
subprocess.call('screencapture -x -t jpg /tmp/screen.jpg', shell=True) | |
self.send_response(200) | |
self.send_header('Content-type', 'image/jpeg') | |
imgfile = open('/tmp/screen.jpg', 'rb').read() | |
self.send_header('Content-length', sys.getsizeof(imgfile)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hachoir_core.cmd_line import unicodeFilename | |
from hachoir_parser import createParser | |
import sys | |
def find_atoms(filename): | |
parser = createParser(unicodeFilename(filename)) | |
atoms = [] | |
for field in parser: | |
print '%s: %s %s + %s' % (field.description, field.name, field.absolute_address, field.size) | |
if 'mdat' in field.description: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
printf "You are about to push, have you run ...? [y]\n" | |
read -s -n1 KEY < /dev/tty | |
if [ $KEY = 'y' ]; then | |
exit 0 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILES=`find . -type f` | |
for F in $FILES | |
do | |
OUTPUT=`uniq -d $F 2> /dev/null` | |
LEN=${#OUTPUT} | |
if [ $LEN -ge 3 ]; then | |
echo $F | |
echo $OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Hacker News Article Highlighter | |
// @version 0.1 | |
// @author You | |
// @include https://news.ycombinator.com/* | |
// @grant none | |
// @noframes | |
// ==/UserScript== | |
// Requires Hacker News Enhancement Suite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Safari no longer allows choosing default browsers from a list | |
from LaunchServices import LSSetDefaultHandlerForURLScheme | |
from LaunchServices import LSSetDefaultRoleHandlerForContentType | |
LSSetDefaultRoleHandlerForContentType("public.html", 0x00000002, "com.google.chrome.canary") | |
LSSetDefaultRoleHandlerForContentType("public.xhtml", 0x00000002, "com.google.chrome.canary") | |
LSSetDefaultRoleHandlerForContentType("public.url", 0x00000002, "com.google.chrome.canary") | |
LSSetDefaultHandlerForURLScheme("http", "com.google.chrome.canary") | |
LSSetDefaultHandlerForURLScheme("https", "com.google.chrome.canary") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
exit_if_pushing_database() { | |
if [ -f .git_push_lock ]; then | |
exit 0 | |
fi | |
} | |
dump_and_push_database() { | |
mysqldump --skip-comments --skip-dump-date -h localhost -u root db_name > db.sql |