Skip to content

Instantly share code, notes, and snippets.

View bigfolio's full-sized avatar

BIG Folio bigfolio

View GitHub Profile
[Thu Nov 08 19:01:37 2012] [notice] caught SIGTERM, shutting down
@bigfolio
bigfolio / gist:1508133
Created December 21, 2011 23:09
My first lua program
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> print "hello world"
hello world
>
Counting objects: 17, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1005 bytes, done.
Total 9 (delta 7), reused 0 (delta 0)
-----> Heroku receiving push
-----> Removing .DS_Store files
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.pre.10
require 'hominid'
mc = Hominid::Base.new({:api_key => 'you-api-key-goes-here'})
list = mc.find_list_by_name('Name of Your Subscriber List')
users = User.all
users.each {|u| mc.subscribe(list['id'], u.email, {:FNAME => u.first, :LNAME => u.last}) }
>> require 'aws/s3'
=> true
>> include AWS::S3
=> Object
>> AWS::S3::Base.establish_connection!(:access_key_id => 'REDACTED', :secret_access_key => 'REDACTED')
=> #<AWS::S3::Connection:0x1016de910 ... :port=>80}>
>> file = S3Object.find 'tv/BF-TV-Episode-001.ogv', 'cloud.bigfolio.com'
=> #<AWS::S3::S3Object:0x2159355220 '/cloud.bigfolio.com/tv/BF-TV-Episode-001.ogv'>
>> file.content_type
=> "binary/octet-stream"
# Request from an iPhone or iPod touch? (Mobile Safari user agent)
def iphone_user_agent?
request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile\/.+Safari)/]
end
#!/usr/bin/env ruby
####################################
# How to get and parse query string
# data in Ruby
####################################
require 'rubygems'
require 'open-uri'
require 'cgi'
#!/usr/bin/env ruby
require 'net/http'
require 'open-uri'
site = 'http://somedomain.com'
file = 'index2.php'
begin
html = open(File.join(site,'index2.php')).read
rescue OpenURI::HTTPError