Skip to content

Instantly share code, notes, and snippets.

View julesfern's full-sized avatar

Jules Glegg julesfern

View GitHub Profile
module Tzatziki
module Parsable
attr_accessor :raw
attr_accessor :data, :post_parse
def parse!(path_to_source_file)
read(path_to_source_file)
self.data, self.post_parse = extract_yaml(self.raw)
end
>> access_token
=> #<OAuth::Token id=7 user_id=16 consumer_id=10 expires=#<DateTime: 2121368281/864,1/24,2299161> created_at=#<DateTime: 2121053569/864,1/24,2299161> permissions=\"read-user\" token_key=\"hFNfbULwG6dPQS0y1KtizBWpJmEgAw\" activated=true secret=\"MujA1uCYwsUMvXYnyCa9QTs2pKdsex\">,
>> access_token.consumer
=> nil
>> OAuth::Consumer.first(:id=>access_token.consumer_id)
=>#<OAuth::Consumer id=10 user_id=nil created_at=#<DateTime: 2121053569/864,1/24,2299161> name=\"hamfatter\" web_url=#<Addressable::URI:0x1a90e42 URI:http://www.gerontogeous.com/client/> consumer_key=\"Ribbonism\" secret=\"tuberculatoradiate\" kind=\"mobile\" permissions=\"write-master\">
>> OAuth::Token.first('consumer.consumer_key'=>(OAuth::Consumer.first(:id=>access_token.consumer_id)).consumer_key)
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
puts "WELCOME TO RTWIGGY™"
puts "Enter your search term, sponsored by Framework Du Jour™"
term = gets
puts "---------"
def beneficiary_relationships=(arg)
raise ArgumentError, "beneficiaries must be set as a hash keyed with relationship id's, with values as booleans" unless arg.is_a?(Hash)
if new_record?
@relationships_to_associate = arg
else
enable_ids = arg.select {|key, value| ["true","1"].include?(value.to_s) }.map {|k,v| k.to_i }
relationship_list = Relationship.all(:origin_user_id=>user_id, :id=>enable_ids)
self.relationships.clear
self.relationships = relationship_list
save
class Application < Merb::Controller
Merb.add_mime_type(:smil, :to_smil, %w[application/smil+xml] )
# Set the seed repository if the controller expects seed_key
# TODO: define API patterns in router.rb
def _call_action(*args)
if @seed
@seed.inside { super }
else
super
# Public API
# ---------------------------------------------------------------------------------
# The following methods are intended to be a stable, repository-safe frontend
# that place restrictions upon you in exchange for you not having to put repository
# blocks absolutely fucking everywhere in the application.
# Override the finder methods to always use the :garden repository regardless of the
# contents of DataMapper's repository context stack.
def self.first(*args)
DataMapper.repository(:garden) { super }
module DataMapper::RepositoryLock
# Places a repository_lock method on the including class, which can
# be executed given a repository name as an argument.
def self.append_features(base)
super
base.extend(ClassMethods)
end
module ClassMethods

Good news everyone!

We at Videojuicer are currently working on our next-generation API product, and we have a vacancy for a Ruby application developer to join our small team.

Our product is an API-led platform for generating leads from online video. It's designed to work in any situation where you have a video, and want it to drive traffic back to your product. That means it's good for screencasts, movie trailers, music videos, product commercials - you name it.

Our environment is a distributed team in the UK, US and Canada. We communicate mainly with Skype. Your working hours will be flexible, and you'll be able to work from your home, our London office or from a Brighton coworking venue if you so choose.

We work with Merb/Rails/Rack, DataMapper, Flex, Git, and jQuery. We use a series of futuristic moon-standards including HTML5, OAuth, OEmbed and SMIL3.

Attributable is a videojuicer-specific module for handling
attribution of objects to their original uploaders.
The Videojuicer API allows authentication with one of two kinds of
authorised token:
1. A User token, which has permissions of either 'read-user' or 'write-user'.
Objects created with a User token are automatically *attributed* to the
authenticated user. Requests made with User tokens cannot reassign
objects to other users or manually specify the user_id of an object.
# Model
class Donor
#.... a bunch of stuff
def self.find_for_params(params={})
find :all, :order=>sort_statement_for_param(params[:sort])
end
def self.sort_statement_for_param(sort)