Skip to content

Instantly share code, notes, and snippets.

View amscotti's full-sized avatar
😀

Anthony Scotti amscotti

😀
View GitHub Profile
@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 / 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 ")
let firstUnique (word: string): char option =
word
|> Seq.countBy id
|> Seq.filter (snd >> (=) 1)
|> Seq.map fst
|> Seq.tryHead
[<EntryPoint>]
let main argv =
match argv |> Seq.tryHead |> Option.bind firstUnique with

Keybase proof

I hereby claim:

  • I am amscotti on github.
  • I am amscotti (https://keybase.io/amscotti) on keybase.
  • I have a public key whose fingerprint is B980 9D6D 9B8A 9322 8739 9BB9 6762 7C86 CC38 D6A7

To claim this, I am signing this object:

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)
# This is a sample build configuration for Ruby.
# Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: ruby:2.1.7
pipelines:
default:
- step:
input {
generator {
lines => [
"2017-02-12 14:50:98 DEBUG Main:12 - Test log file",
"2017-02-12 14:51:98 INFO Main:13 - Test log file",
"2017-02-12 14:52:98 WARN Main:14 - Test log file",
"2017-02-12 14:53:98 ERROR Main:15 - Test log file",
"2017-02-12 14:54:98 FATAL Main:16 - Test log file"
]
add_field => { "service" => "a" }
@amscotti
amscotti / client.rb
Created August 31, 2014 19:42
RPC using Redis
require 'redis'
require 'securerandom'
require 'msgpack'
class RedisRpcClient
def initialize(redis_url, list_name)
@client = Redis.connect(url: redis_url)
@list_name = list_name.to_s
end
def realm = URLEncoder.encode("Staghelm")
def guild = URLEncoder.encode("Controlled Chaos")
def url = "http://www.wowarmory.com/guild-info.xml?r=${realm}&amp;n=${guild}".toURL()
def types = [
"1": "Warrior", "2": "Paladin", "3": "Hunter",
"4": "Rogue", "5": "Priest", "6": "Death Knight",
"7": "Shaman", "8": "Mage", "9": "Warlock",
"11": "Druid"].withDefault { key -> "unknown" }
require 'net/http'
require 'rexml/document'
include REXML
def get_xml_page(strRealm, strGuildName)
oresp = Net::HTTP.start( "www.wowarmory.com") do |http|
http.get( "/guild-info.xml?r=#{strRealm}&amp;n=#{strGuildName}",
{ 'user-agent' =&gt; 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4'})
end