Skip to content

Instantly share code, notes, and snippets.

class BaseCodec
def self.base_n_decode(s, alphabets)
n = alphabets.length
rv = pos = 0
charlist = s.split("").reverse
charlist.each do |char|
rv += alphabets.index(char) * n ** pos
pos += 1
end
return rv
require "rubygems"
require "hmac-sha1"
require "base64"
ankoder_access_key = ANKODER_ACCESS_KEY
private_key = ANKODER_PRIVATE_KEY
ankoder_date = Time.now.strftime("%a, %d %b %Y %X GMT")
ankoder_action = "GET"
ankoder_path = "/video.xml"
string = "-#{ankoder_date}-#{ankoder_action}-#{ankoder_path}-"
require "rubygems"
require "hmac-sha1"
require "base64"
ankoder_access_key = ANKODER_ACCESS_KEY
private_key = ANKODER_PRIVATE_KEY
ankoder_date = Time.now.strftime("%a, %d %b %Y %X GMT")
ankoder_action = "GET"
ankoder_path = "/video.xml"
string = "-#{ankoder_date}-#{ankoder_action}-#{ankoder_path}-"
require "rubygems"
require "hmac-sha1"
require "base64"
ankoder_access_key = ANKODER_ACCESS_KEY
private_key = ANKODER_PRIVATE_KEY
ankoder_date = Time.now.strftime("%a, %d %b %Y %X GMT")
ankoder_action = "GET"
ankoder_path = "/video.xml"
string = "-#{ankoder_date}-#{ankoder_action}-#{ankoder_path}-"
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 4,
interval: 6000,
width: 'auto',
height: 300,
theme: {
@rorcraft
rorcraft / Ankoder PHP library
Created November 14, 2009 09:13
PHP authentication example to Ankoder. (Thanks to GangOfCoders)
<?php
$ankoder_access_key = "GET YOUR ACCESS KEY FROM SETTINGS";
$private_key = "GET YOUR ACCESS KEY FROM SETTINGS";
$ankoder_date = date("r");
$ankoder_action = "GET";
$ankoder_path = "/video.xml";
$string = "-{$ankoder_date}-{$ankoder_action}-{$ankoder_path}-";
$salt = substr(sha1($string),0, 20);
@rorcraft
rorcraft / ankoder_sample.cs
Created November 16, 2009 07:16 — forked from goodwill/ankoder_sample.cs
c# .NET authentication to Ankoder API
/*
Sample Code for Ankoder API called via .NET C#
Written by William Yeung @ Gearbox Software (http://www.gearboxsoft.com)
*/
const string PrivateKey = "YOUR_ANKODER_KEY";
var ascii = Encoding.ASCII;
var date = DateTime.Now.ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss") + " GMT";
var action_url = "video.xml";
string token=string.Format("-{0}-GET-/{1}-", date, action_url);
#!/usr/bin/env ruby
require 'rubygems'
require 'roo'
pwd = File.dirname(__FILE__)
file = ARGV[0]
file_path = "#{pwd}/#{file}"
xls = Excel.new(file_path)
xls.to_csv("#{pwd}/#{file}.csv")
#!/usr/bin/env ruby
require 'rubygems'
require 'roo'
pwd = File.dirname(__FILE__)
Dir.glob("#{pwd}/*.xls") do |file|
file_path = "#{pwd}/#{file}"
file_basename = File.basename(file, ".xls")
xls = Excel.new(file_path)
@rorcraft
rorcraft / gist:1036930
Created June 21, 2011 00:08
Factory_girl singleton monkey patch
# I put this as spec/support/factory_girl_singleton.rb
# this get required from spec_helper.rb
# creates a class variable for factories that should be only created once
class Factory
@@singletons = {}
def self.singleton(factory_key)
begin
@@singletons[factory_key] = Factory.create factory_key
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
end