Skip to content

Instantly share code, notes, and snippets.

View maurcs's full-sized avatar

Marcus Rosentrater maurcs

View GitHub Profile
@maurcs
maurcs / trim_frame_subtitle.rb
Created September 14, 2016 06:33
cleans up timecodes on subtitle text files to trim one frame from the in-point of each line. Adobe Encore was giving me PGC errors on my timeline. Putting a frame of space between each subtitle was the only fix that worked for me.
new_file_path = "path/to/subtitle_fixed_file.txt"
File.truncate(new_file_path, 0)
new_file = File.open(new_file_path, "w")
file = File.open("path/to/subtitle_file.txt", "r").readlines.each do |line|
reg = /;(\d{2}) \d{2};/
match = line.match(reg)
if match.class == MatchData
m = match[1]
@maurcs
maurcs / adapter.rb
Created June 24, 2010 12:46
What I did to get mongo_mapper and machinist to work with pickle.
# spec/pickle/adapter.rb
module Pickle
class Adapter
class MongoMapper < Adapter
def self.factories
factories = []
model_classes.each do |klass|
require 'rubygems'
require 'flatbed'
ROOT_DIR = File.dirname(__FILE__) + "/.."
IMAGE_DIR = File.expand_path(File.join(ROOT_DIR,"pngs"))
CLIP_DIR = File.expand_path(File.join(ROOT_DIR,"clips"))
FileUtils.mkdir_p(CLIP_DIR)
still_clips = {
no such file to load -- grip/url_helper
Given I am on create account
...
When I attach the file "features/support/assets/test_profile_image.jpg" to "user[image]"
When I press "Save Changes"
Then my account should be created
And the "last" "User" should have a "image" attachment
...
class Post
include MongoMapper::Document
timestamps!
end
# rake task
namespace :tumblr do
require 'test_helper'
class CardinalizeTest < Test::Unit::TestCase
def test_a_floats_cardinality
assert_equal 10.0.cardinalize, "North"
assert_equal 310.5.cardinalize, "Northwest"
assert_equal 175.2.cardinalize, "South"
assert_equal 40.0.cardinalize, "Northeast"
assert_equal -40.0.cardinalize, "Northwest"
assert_equal 600.5.cardinalize, "Southwest"
require 'rubygems'
require 'oauth'
require 'oauth/consumer'
require 'ruby-debug'
require 'json'
API_KEY = "#####"
API_KEY_PRIVATE = "####"
USERNAME = "####"
@maurcs
maurcs / gist:108198
Created May 7, 2009 16:38 — forked from digitalscientists/gist:108159
Uses ruby's built in CSV Reader which will find " escaped columns
require 'csv'
file = "db/commission_junction/2087028_18584_20080827.csv"
rows = CSV::Reader.parse(File.open(file)).to_a
cols = rows.shift
collection = rows.collect do |row|
Hash[*cols.zip(row).flatten]
end
puts collection.first.inspect