Skip to content

Instantly share code, notes, and snippets.

View julesfern's full-sized avatar

Jules Glegg julesfern

View GitHub Profile
before :ensure_signed, :only=>[:index]
# All other actions require that the user be authenticated directly, rather than through the api.
before :ensure_authenticated_personally, :exclude=>[:index]
# Main action used for starting the authorisation process (desktop clients) and finishing it (web clients)
def index
only_provides :js, :xml, :yaml
raise NotFound unless @authenticating_client = request.authenticating_client
if request.token
# If client and request key, give the activated token if it was activated.
~ Cannot load /Users/danski/Sites/beatthebanker.dev/app/controllers/cases.rb because of syntax error: /Users/danski/Sites/beatthebanker.dev/app/controllers/cases.rb:28: syntax error, unexpected kCASE, expecting ')'
def create(case)
^
/Users/danski/Sites/beatthebanker.dev/app/controllers/cases.rb:29: syntax error, unexpected ')', expecting kELSE or kWHEN
/Users/danski/Sites/beatthebanker.dev/app/controllers/cases.rb:38: syntax error, unexpected kCASE
def update(id, case)
^
/Users/danski/Sites/beatthebanker.dev/app/controllers/cases.rb:41: syntax error, unexpected ')', expecting kELSE or kWHEN
/Users/danski/Sites/beatthebanker.dev/app/controllers/cases.rb:43: syntax error, unexpected kELSE, expecting $end
<snip>
[5293792.396191] clocksource/0: Time went backwards: ret=3586769c09d0d3 delta=-2
6257874 shadow=35867684360ed0 offset=198c814b
[6068350.801481] clocksource/0: Time went backwards: ret=384b012c906988 delta=-1
5264277 shadow=384b0128679575 offset=5121dca
[6351083.335298] clocksource/1: Time went backwards: ret=394e0b2bdd283c delta=-2
6146072 shadow=394e0b178ebc51 offset=15e3f79f
[6465494.726422] clocksource/0: Time went backwards: ret=39b71912db4d79 delta=-2
4112539 shadow=39b719053726f5 offset=f1428ab
[6836455.853739] clocksource/1: Time went backwards: ret=3b0b16d8a8c945 delta=-2
def embed_player_for(object, options={})
fallback_label = "Watch #{h object.name} on #{h @context.name}"
fallback_url, js_url = if object.is_a? VideoConstruct
[ @context.canonical_host+url_for_video_construct(object),
@context.canonical_host+url_for_video_construct(object, {:from=>"embed", :format=>"js"})]
else
[ @context.canonical_host+url_for_channel(object),
@context.canonical_host+url_for_channel(object, {:from=>"embed", :format=>"js")]
end
return "<script src=\"#{@context.canonical_host}#{js_url}\"></script>"+
#!/usr/bin/env ruby
# Script to import tumblr posts into local markdown posts ready to be consumed by Jekyll.
# Inspired by New Bamboo's post http://blog.new-bamboo.co.uk/2009/2/20/migrating-from-mephisto-to-jekyll
require 'rubygems'
require 'open-uri'
require 'nokogiri'
# Configuration
# In Jekyll core...
module Jekyll
module Filters
class CustomFilter
cattr_accessor :extensions
@@extensions = []
def self.extended(base)
@@extensions << base
end
>> url = URI.parse("http://spreedly.com/api/v4/tails-test/subscribers/9/stop_auto_renew.xml")
=> #<URI::HTTP:0x10353c6 URL:http://spreedly.com/api/v4/tails-test/subscribers/9/stop_auto_renew.xml>
>> req = Net::HTTP::Post.new(url.path)
=> #<Net::HTTP::Post POST>
>> req.basic_auth 'sdfsdf', 'sdfsdf'
=> ["Basic MWJjMjlmNDc3NGRhZjYyZTJkN2E0MWQ4NzU4M2FiYjc4MmM4M2Q3MTptb2NoaW1vY2hp"]
>> res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
=> #<Net::HTTPFound 302 Found readbody=true>
>> res.body
=> "<html><body>You are being <a href=\"https://spreedly.com/api/v4/tails-test/subscribers/9/stop_auto_renew.xml\">redirected</a>.</body></html>"
#In order to generate a completely new test package:
tzatziki-gen api foldername/
#Generate a new header factory
tzatziki-gen headers shared/content-types
#Generate a new parameter factory
tzatziki-gen parameters shared/oauth
#Generate a new API call
shared/global.specification.markdown
====================================
---
title: Global request specification
parameters:
seed_key:
description: The Seed Key for the Seed you wish to target with your API call.
---
config.yml
==========
api_key: api_key_used_for_calls
_types/timestamp.markdown
===========================
---