Skip to content

Instantly share code, notes, and snippets.

@niyando
niyando / create_work_queue_items.rb
Last active December 3, 2019 21:34
create_work_queue_items
tallies = Tally.discharge.where(organization_id: [64,8,1]).where('started_at > (?)', DateTime.now - 30.hours).not_closed
tallies.each do |tally|
wq = tally.voyage.work_queue
next if wq.blank?
tally.tallied_cargos.each do |tallied_cargo|
next if tallied_cargo.work_queue_item.present?
tallied_cargo.organization.work_queue_items.create(
work_queue: tallied_cargo.tally.voyage.work_queue,
@niyando
niyando / shark_tank_data.csv
Created August 15, 2018 06:19
Shark Tank Data
Row Season No. in series Company Deal Industry Entrepreneur Gender Amount Equity Valuation Corcoran Cuban Greiner Herjavec John O'Leary Harrington Guest # Sharks $ per shark Details / Notes
2 1 1 Ava the Elephant Yes Healthcare Female $50,000 55% $90,909 1 1 $50,000
3 1 1 Mr. Tod's Pie Factory Yes Food and Beverage Male $460,000 50% $920,000 1 1 2 $230,000
4 1 1 Wispots No Business Services Male 0
5 1 1 College Foxes Packing Boxes No Lifestyle / Home Male 0
6 1 1 Ionic Ear No Uncertain / Other Male 0
7 1 2 A Perfect Pear Yes Food and Beverage Female $500,000 50% $1,000,000 1 1 2 $250,000
8 1 2 Classroom Jams Yes Children / Education Male $250,000 10% $2,500,000 1 1 1 1 1 5 $50,000
9 1 2 Lifebelt No Consumer Products Male 0
@niyando
niyando / array.rb
Created July 15, 2017 12:28
Custom instance method of Array class in Ruby to flatten it
class Array
def flatten_it(result = [])
self.each do |value|
value.is_a?(Array) ? value.flatten_it(result) : (result << value)
end
result
end
end
@niyando
niyando / email.css
Created November 7, 2015 12:01
Style your emails for responsiveness using Zurb Ink framework. I have customized it to some extent to wrap things in a container. I am also using premailer rails gem to inline my external styles.
/**********************************************
* Ink v1.0.5 - Copyright 2013 ZURB Inc *
**********************************************/
/* Client-specific Styles & Reset */
#outlook a {
padding:0;
@niyando
niyando / rails_admin.rb
Last active August 29, 2015 14:17
rails_admin gem config to see original fields encrypted in db using attr_encrypted gem
RailsAdmin.config do |config|
# include required models
required_models = ["Blog", "Comment", "User", "Other"]
required_models.each do |act_model|
model_class = Object.const_get(act_model)
config.model act_model do
# find all attrs that start with encrpted_ (default attr_encrypted convention; change as required)
encrypted_attrs = model_class.column_names.select{|k| k.match("encrypted_")}
list do
include_all_fields