Skip to content

Instantly share code, notes, and snippets.


Alfred Rowe nukturnal

View GitHub Profile
nukturnal / audio_length.rb
Created Jan 18, 2010
Extracting audio length with Rails and ffmpeg
View audio_length.rb
def self.get_audio_length(filepath)
pipe = "ffmpeg -i "+ filepath.to_s+" 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//"
command = `#{pipe}`
if command =~ /([\d][\d]):([\d][\d]):([\d][\d]).([\d]+)/
#convert the result to only secs
duration = ($2.to_i * 60) + $3.to_i
#return and array containing the seconds and the human readable time length, ["6453","03:54"]
return "#{duration.to_s},#{$2}:#{$3}".split(",")
nukturnal / simple_deploy.rb
Created Sep 18, 2012
Simple script to help with Rails deployment tasks. Requires "Rye Gem"
View simple_deploy.rb
require 'rubygems'
require 'rye'
HOST = "yourserver"
USER = "username"
PASS = "password"
app_path = "/path/to/rails_app_root"
production_env = "RAILS_ENV=production"
nukturnal / api_conf.php
Last active Oct 12, 2015
MPower PHP API Keys Configuration
View api_conf.php
nukturnal / store_conf.php
Last active Oct 12, 2015
MPower PHP Checkout Store Configuration
View store_conf.php
//Setup your Store information
MPower_Checkout_Store::setName("My Awesome Online Store");
MPower_Checkout_Store::setTagline("My awesome store's awesome tagline");
MPower_Checkout_Store::setPostalAddress("Post office Box AN 10604");
nukturnal / library.php
Created Nov 6, 2012
MPower PHP Library Setup
View library.php
nukturnal / building_checkout_invoice.php
Last active Oct 12, 2015
MPower PHP Checkout Invoice setup
View building_checkout_invoice.php
/* Adding items to your invoice is very basic, the parameters expected are
name_of_item, quantity, unit_price, total_price and optional item
description. */
$invoice->addItem("13' Apple Retina 500 HDD",1,10.99,10.99);
$invoice->addItem("Case Logic laptop Bag",2,100.50,201,"Optional description");
$invoice->addItem("Philips electric shaver",2,50.50,101.00);
/* You can optionally set a general invoice description text which can
be used in cases where your invoice does not need an items list or in cases
nukturnal / total_amount.php
Last active Oct 12, 2015
MPower PHP Checkout Total Amount Set
View total_amount.php
nukturnal / add_tax.php
Last active Oct 12, 2015
MPower PHP Checkout Invoice Adding Tax
View add_tax.php
// The parameters for setting add tax are title_of_the_tax, tax_amount
$invoice->addTax('VAT (15%)',50);
$invoice->addTax('NHIL (5%)',50);
nukturnal / cancel_url.php
Last active Oct 12, 2015
MPower PHP Checkout Invoice Cancel URL
View cancel_url.php
// Globally setting cancel URL, the piece of code below
// should be included with the checkout shop setup code
// Setting the cancel URL on an invoice instance.
// This will overwrite any global settings for cancel URL
nukturnal / create_redirect_checkout.php
Last active Oct 12, 2015
MPower PHP Library Checkout Invoice Creation & Redirection
View create_redirect_checkout.php
// The code below depicts how to create the checkout invoice on our servers
// and redirect to the checkout page.
if($invoice->create()) {
header("Location: ".$invoice->getInvoiceUrl());
echo $invoice->response_text;