Skip to content

Instantly share code, notes, and snippets.

View halleyrv's full-sized avatar

Halley Rios Valenzuela halleyrv

View GitHub Profile
@halleyrv
halleyrv / gist:8d3ec99b92b51630f722b089f9153859
Created April 11, 2019 20:15 — forked from andrekandore/gist:3140554
AES128, AES256 encrypt/decrypt in Ruby
require "openssl"
require "digest"
def aes128_encrypt(key, data)
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize)
aes = OpenSSL::Cipher.new('AES-128-CBC')
aes.encrypt
aes.key = key
aes.update(data) + aes.final
end
@halleyrv
halleyrv / gist:ce4cd8ed65e92ecda19ff0fb75592dec
Created November 8, 2018 15:06 — forked from arjunvenkat/gist:1115bc41bf395a162084
Seeding a Rails database with a CSV file

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.

@halleyrv
halleyrv / rspec_model_testing_template.rb
Last active October 24, 2017 04:09 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: