Skip to content

Instantly share code, notes, and snippets.

View AAlvarez90's full-sized avatar
🏠
Working from home

Abraham Alvarez AAlvarez90

🏠
Working from home
  • Miami, FL
View GitHub Profile
@AAlvarez90
AAlvarez90 / psha1.rb
Last active April 21, 2016 20:43
P_SHA1 for Ruby
#Testing function PHA1:
require 'base64'
require 'openssl'
#Sample Data:
secret = Base64.decode64("kAIthWJeZ3UoS4k6qLIbfA==")
label = "WS-SecureConversationWS-SecureConversation"
seed = Base64.decode64("yP9lu4OUF1ah534Re/ZfcQ==")
new_seed = label + seed
@AAlvarez90
AAlvarez90 / create_element.rb
Last active April 28, 2016 19:31
Helper function for REXML to create an element and pass in text and attribute at once.
#Method
def create_element(name, content, attributes = {})
element = Element.new name
if content.is_a? Array
content.each { |e|
element.elements << e
}
else
(element.text = content) unless(content.nil?)
end
@AAlvarez90
AAlvarez90 / array_flatten.rb
Created September 19, 2016 16:37
A method to flatten an array of integers
def array_flatten(array, result = [])
array.each do |element|
if element.is_a? Integer
result.push element
else
array_flatten(element, result)
end
end
result
end
@AAlvarez90
AAlvarez90 / email_advice_importer.md
Last active July 13, 2017 20:17
Using the EmailAdviceImporter
  1. Load the branch: xpo_improvement
  2. Open Rails console
  3. Run the command: Resque.inline = true
  4. Grab the biller: biller = Biller.find <id>
  5. Create a new importer object: importer = Dade::EmailAdviceImporter.new
  6. Run the perform method on it: importer.perform('/Users/Abraham/Desktop/potential_advices', biller.id, '[email protected]')

Notes: The first parameter is the absolute path to that folder. The third parameter is the recipient used for the inbound addresses, you can put there an XPO email address