Skip to content

Instantly share code, notes, and snippets.

View amscotti's full-sized avatar
😀

Anthony Scotti amscotti

😀
View GitHub Profile
@amscotti
amscotti / capmon.rb
Created August 27, 2011 02:50 — forked from rgrove/capmon.rb
Ruby script to retrieve and display Comcast data usage. See http://www.128bitstudios.com/2011/08/27/comcast-data-usage-put-a-fork-in-it/
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
URL_PRELOADER = 'https://customer.comcast.com/Secure/Preload.aspx?backTo=%2fSecure%2fUsers.aspx&preload=true'
URL_USERS = 'https://customer.comcast.com/Secure/Users.aspx'
abort "Usage: #{$0} <username> <password>" unless ARGV.length == 2
@amscotti
amscotti / wowapi.coffee
Last active September 27, 2015 07:57
Code to use battle.net's RESTful API for pulling World of Warcraft guild rosters - http://www.128bitstudios.com/2011/09/22/updated-world-of-warcraft-armory-code/
http = require 'http'
rest = require 'restler'
realm = escape "Staghelm"
guild = escape "Controlled Chaos"
type = {
1: "Warrior", 2: "Paladin", 3: "Hunter",
4: "Rogue", 5: "Priest", 6: "Death Knight",
7: "Shaman", 8: "Mage", 9: "Warlock",
@amscotti
amscotti / publish.rb
Created November 11, 2011 01:19
This is a sample file for AWS-SDK gem that uses the Amazon Simple Notification Service. - http://www.128bitstudios.com/2011/11/10/playing-around-with-amazon-sns-in-ruby/
require File.expand_path(File.dirname(__FILE__) + '/../samples_config')
# Topic's arn can be found in AWS Management, under Topic Details.
(topic_arn, message) = ARGV
unless topic_arn && message
puts "Usage: upload.rb <TOPIC_ARN> <MESSAGE>"
exit 1
end
# Get an instance of the SNS interface using the default configuration
@amscotti
amscotti / login.rb
Created November 22, 2011 00:45
Sample of Sinatra authentication
require 'rubygems'
require 'bcrypt'
require 'haml'
require 'sinatra'
enable :sessions
userTable = {}
helpers do
@amscotti
amscotti / sinatra_linkedin.rb
Created November 26, 2011 04:42
LinkedIn authentication with Sinatra
require "rubygems"
require "haml"
require "sinatra"
require "linkedin"
enable :sessions
helpers do
def login?
if session[:atoken].nil?
@amscotti
amscotti / wowapi_mongodb.rb
Created January 21, 2012 00:35
Pulling a World of Warcraft guild roster in to a MongoDB
require 'rubygems'
require 'nestful'
require 'mongo'
db = Mongo::Connection.new.db("wowstats")
coll = db.collection("character")
coll.drop
type = {
1 => "Warrior", 2 => "Paladin", 3 => "Hunter",
@amscotti
amscotti / wowapi_auction.rb
Created April 1, 2012 20:01
Using Redis to sort World of Warcraft's Auction House data. bit.ly/Hyxkq9
require 'rubygems'
require 'open-uri'
require 'yajl'
require 'redis'
realm = "Lothar"
filePath = Yajl::Parser.parse(open("http://us.battle.net/api/wow/auction/data/#{realm}"))["files"].first['url']
puts filePath
redis = Redis.new
@amscotti
amscotti / mongo_urlshortener.rb
Created April 2, 2012 20:04
Example of using MongoMapper and Sinatra to make an url shortener - http://bit.ly/wZw0TO
require "rubygems"
require "sinatra"
require "haml"
require "mongo_mapper"
class Shorten
include MongoMapper::Document
key :url, String
key :shorten_id, String
@amscotti
amscotti / md5.coffee
Last active January 18, 2021 12:54
MD5 hashing
crypto = require('crypto');
#Quick MD5 of text
text = "MD5 this text!"
md5hash1 = crypto.createHash('md5').update(text).digest("hex")
#MD5 of text with updates
m = crypto.createHash('md5')
m.update("MD5 ")
m.update("this ")
@amscotti
amscotti / node_send.coffee
Created June 3, 2012 17:24
Amazon's Simple Queue Service with Node.js and Ruby - http://bit.ly/Nwn0Q1
aws = require ('aws-lib')
access_key_id = "<Your access key id>"
secret_access_key = "<Your secret access key>"
options = {
"path" : "<Your queue URL, just the /accountid/queue_name is needed>"
}
sqs = aws.createSQSClient(access_key_id, secret_access_key, options)