Skip to content

Instantly share code, notes, and snippets.

@hyperqube
hyperqube / extract_audio.sh
Created September 9, 2012 22:04
Extract audio from mp4 files
fmpeg -i Chapter3.mp4 -vn -acodec copy Chapter3.m4a
@hyperqube
hyperqube / AssembleAudioBook.rb
Created September 9, 2012 02:34
Assemble m4a files into audio books
require 'pp'
require 'fileutils'
require 'escape'
@TARGET = ARGV[0]
File.delete(@TARGET) if File.exists?(@TARGET)
def formatTime(dur)
ms = ((dur.round(3) - dur.truncate())*1000).to_i
@hyperqube
hyperqube / handbrake_he-aac
Created September 9, 2012 01:41
HandBrake CLI HE-AAC
HandBrakeCLI -e x264 --vb 300 --aencoder ca_haac -B 32 -i input -o output
find . -name "*avi" -print \
-exec ffmpeg -vn -acodec pcm_s16le -i {} /tmp/ffmpeg.wav \; \
-exec afconvert -d aacp -b 32000 -f m4af -v -c 2 {} \; \
-exec rm /tmp/ffmpeg.wav \; \
ffmpeg -vn -acodec pcm_s16le -i /tmp/ffmpeg.wav
#/bin/bash
find . -name "*mp3" -print -exec afconvert -d aacp -b 32000 -f m4af -v -c 1 {} \;
@hyperqube
hyperqube / emberjs_object.js
Created July 24, 2012 15:31
#emberjs #object
var tom = Person.create({
name: "Tom Dale",
helloWorld: function() {
this.say("Hi my name is " + this.get('name'));
}
});
tom.helloWorld() // alerts "Hi my name is Tom Dale"
var yehuda = Person.create({
var tom = Person.create({
name: "Tom Dale",
helloWorld: function() {
this.say("Hi my name is " + this.get('name'));
}
});
tom.helloWorld() // alerts "Hi my name is Tom Dale"
var yehuda = Person.create({
MyApp.president = Ember.Object.create({
firstName: "Barack",
lastName: "Obama",
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
// Tell Ember that this computed property depends on firstName
// and lastName
}.property('firstName', 'lastName')
});
@hyperqube
hyperqube / emberjs_binding.js
Created July 23, 2012 18:53
Emberjs Binding
MyApp.president = Ember.Object.create({
name: "Barack Obama"
});
MyApp.country = Ember.Object.create({
// Ending a property with 'Binding' tells Ember to
// create a binding to the presidentName property.
presidentNameBinding: 'MyApp.president.name'
});
// Later, after Ember has resolved bindings...
MyApp.country.get('presidentName');
DECLARE @TASKS TABLE ( TASK_ID INT IDENTITY PRIMARY KEY , TASK_NAME VARCHAR(256), TASK_COST FLOAT , PARTITION_ID INT DEFAULT 0)
DECLARE @MAX_PARTITION INT = 4
WITH INIT_TASKS AS
(SELECT TOP @MAX_PARTITION
ROW_NUMBER(OVER() ORDER BY TASK_COST DESC) AS INIT_PARTITION
,PARTITION_ID
FROM @TASKS
ORDER BY TASK_COST DESC)
@hyperqube
hyperqube / get_partition.ps1
Created June 7, 2012 16:49
Split files into roughly equal partitions
function Add-Prop([string]$name,$value){
$input |add-member -memberType Noteproperty -name $name -value $value -passThru
}
function Get-Partitions($no_partitions=4){
$sums = @()
$indexes = (0..($no_partitions-1))
$indexes |% { $sums+= 0 }
$sortedBySize = $input | Sort Length -Descending
foreach($file in $sortedBySize){