This file contains 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
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 |
This file contains 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
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}-" |
This file contains 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
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}-" |
This file contains 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
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}-" |
This file contains 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
<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: { |
This file contains 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
<?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); |
This file contains 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
/* | |
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); |
This file contains 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
#!/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") |
This file contains 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
#!/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) |
This file contains 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
# 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 |
OlderNewer