This file contains hidden or 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
@http.resource.post('/foo') do |r| | |
r.content_type_header = 'app/xml' | |
r.accept_header = 'app.xml' | |
r.x_custom_header = 'foo' | |
r.body = "<my_elem />" | |
end |
This file contains hidden or 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
def expired? | |
# is the record's file_date over the specified number of days until expiration | |
if !self.identity_address.nil? && !self.identity_address.last_date_reported.blank? | |
last_date_reported = self.identity_address.last_date_reported.to_s | |
formatted_date = [ last_date_reported.slice(0,4), last_date_reported.slice(4,2), last_date_reported.slice(6,2) ].join("-") | |
begin | |
return true unless verified_date = Date.parse(formatted_date) | |
rescue Exception => e | |
raise "\"#{last_date_reported}\" is not a valid date" | |
end |
This file contains hidden or 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
(1..143671).step(100) do |n| | |
puts "working on block #{n}" | |
Subscriber.find(:all, :conditions => ["id between ? and ?", n, n+100], :limit => 100).each do |s| | |
next unless s.card_number | |
if ['8714', '0436', '0704', '4008'].include?(s.card_number[-4,4]) | |
puts "#{s.id} #{s.card_number}" | |
end | |
end |
This file contains hidden or 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
{ | |
"_type": "Metric", | |
"href": "http://data.v6.localhost/metrics/871ffeb6-6a35-4c35-a5bc-778d2cfd6456", | |
"name": "foo,bar,baz", | |
// By href | |
"datapoint_flavor": "numeric", | |
"numeric_datapoints_href": "http://data.v6.localhost/metrics/871ffeb6-6a35-4c35-a5bc-778d2cfd6456/datapoints", | |
"datapoints_href": "http://data.v6.localhost/metrics/871ffeb6-6a35-4c35-a5bc-778d2cfd6456/datapoints", | |
// | |
"account_href": "http://example.com/accounts/1234", |
This file contains hidden or 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 | |
$KCODE='UTF8' | |
require 'rubygems' | |
require 'aws/s3' | |
require 'main' | |
main do | |
argument('directory') { |
This file contains hidden or 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
{ | |
href: "http://example.com/databases/1", | |
_type: "Database", | |
name: "test_db", | |
server_hostname: "betabox.mongomachine.com", | |
server_port: 27017, | |
account_href: "http://example.com/accounts/1", | |
authorized_users_href: "http://example.com/authorized_users", | |
storage_stats_href: "http://example.com/database/1/storage_stats", | |
request_stats_href: "http://example.com/database/1/request_stats", |
This file contains hidden or 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 'ostruct' | |
class Keister::App | |
class DatabasesResource | |
include Spinal::Resource | |
resource '/databases' | |
def get | |
@databases = [OpenStruct.new(:created_at => Time.now.utc, :updated_at => Time.now.utc)] |
This file contains hidden or 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 'ostruct' | |
class Keister::App | |
class DatabasesResource | |
include Spinal::Resource | |
resource '/databases' | |
def get | |
@databases = [OpenStruct.new(:created_at => Time.now.utc, :updated_at => Time.now.utc)] |
This file contains hidden or 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 MyResource | |
include Spinal::Resource | |
representation :json, :direction => :in_and_out do |rep| | |
rep.attribute :foo | |
rep.attribute :bar, :required => true | |
end | |
representation :url_encoded_form_data, :direction => :in do |rep| | |
rep.attribute :foo |
This file contains hidden or 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 MyResource | |
include Spinal::Resource | |
representation :simple, :media_types => [:ufe, :ssj, :myxml] , :direction => :in_and_out do |rep| | |
rep.attribute :foo | |
rep.attribute :bar, :required => true | |
end | |
repesentation :html, :parent => :simple, :direction => :out do |rep| | |
rep.attribute :current_user |
OlderNewer