Skip to content

Instantly share code, notes, and snippets.

@michaelfox
michaelfox / Plist_parser.php
Created March 26, 2011 19:30
A PHP Class for Parsing OS X Plist files
<?php
/**
* Plist Parser Class
*
* Usage:
* ======
* $plist = Plist::from_file("~/Music/iTunes/iTunes Music Library.xml");
* print_r($plist->as_array());
*/
@ghedo
ghedo / sound_playback.c
Last active May 26, 2024 13:44
Simple sound playback using ALSA API and libasound
/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples:
@a-chernykh
a-chernykh / carrierwave.rb
Created July 1, 2011 12:50
Change image quality with carrierwave and mini_magick
# put this in config/initializers/carrierwave.rb
module CarrierWave
module MiniMagick
def quality(percentage)
manipulate! do |img|
img.quality(percentage)
img = yield(img) if block_given?
img
end
end
@jamiew
jamiew / tumblr-photo-ripper.rb
Created July 13, 2011 17:46
Download all the images from a Tumblr blog
# Usage:
# [sudo] gem install mechanize
# ruby tumblr-photo-ripper.rb
require 'rubygems'
require 'mechanize'
# Your Tumblr subdomain, e.g. "jamiew" for "jamiew.tumblr.com"
site = "doctorwho"
@scottmac
scottmac / serial.cpp
Created September 16, 2011 07:17
Find serial number of USB device on OS X.
#include <stdio.h>
#include <stdlib.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/usb/IOUSBLib.h>
#include <IOKit/hid/IOHIDKeys.h>
CFStringRef find_serial(int idVendor, int idProduct) {
CFMutableDictionaryRef matchingDictionary = IOServiceMatching(kIOUSBDeviceClassName);
@worldeggplant
worldeggplant / transcode-convert-wav-mp3-ogg.sh
Created October 10, 2011 16:10
transcode/convert wav mp3 ogg
# convert all .wav files to ogg/vorbis
for x in *.wav; do ffmpeg -i "$x" "`basename "$x" .wav`.ogg" -acodec vorbis; done
# convert all .mp3 files to ogg/vorbis
for x in *.mp3; do ffmpeg -i "$x" "`basename "$x" .mp3`.ogg" -acodec vorbis; done
#convert all .wav files to .mp3
for x in *.wav; do ffmpeg -i "$x" "`basename "$x" .wav`.mp3"; done
#convert all .mp3 files to .wav
@Jaybles
Jaybles / UIDeviceHardware.h
Created October 28, 2011 19:33
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@refractalize
refractalize / decrypt.rb
Created January 4, 2012 20:11
Decrypt HTTP Live Streaming TS files
def read_m3u8(m3u8)
File.open(m3u8, 'r') do |file|
keyfile = nil
iv = 0
file.each_line do |line|
line.chomp!
if line =~ /^#EXT-X-KEY:METHOD=AES-128,URI="(.*?)"(,IV=0x(.*))?/
keyfile = $1
if $2
iv = $3
@oumu
oumu / soundcloud-mp3.js
Created March 31, 2012 00:49 — forked from rsvp/soundcloud-mp3.js
SoundCloud bookmarklet that generates link to download MP3
/**
2012-03-26 Forked from duncanbeevers' sc-dl.js : https://gist.github.com/2157987
**/
(function(document) {
var link = document.createElement("a"),
span = document.createElement("span"),
slug = document.querySelector("#main-content-inner img[class=waveform]").src.match(/\.com\/(.+)\_/)[1],
mp3 = document.querySelector("em").innerText + ".mp3";
@nrk
nrk / command.txt
Created April 2, 2012 19:19
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"