Skip to content

Instantly share code, notes, and snippets.

View ChasManRors's full-sized avatar

Charles Magid ChasManRors

View GitHub Profile
@ChasManRors
ChasManRors / luke.rb
Created June 27, 2021 20:54
Secrete agent observes a PIN, but may not have it right. So where are the arrays of arrays of arrays ...?
# Here is a slightly earlier version of the code with added variables for clarity (I hope)
def pins(str)
variations = str.split('').map { |c| @board[c] }
return variations.first if str.length <= 1
position, *positions = *(-str.length..-1).to_a
nested_arrays = positions.inject(variations[position]) do |result, index|
result.product(variations[index])
end
nested_arrays.map(&:flatten).map(&:join)
end
first_name,last_name,phone,van_id
Joleen,Tamsin,205-296-8267,1000
Pen,Sabryna,206-986-8493,648017
Trish,Alyssia,210-270-1802,829734
Paulie,Geneva,215-424-6951,894155
@ChasManRors
ChasManRors / cmdline.html
Last active March 4, 2019 18:14
[Simple javascript function] A few examples of html with javascript #html #js #ex #from_tutorial
// Simple javascript function print to console example
<!DOCTYPE HTML>
<html>
<head>
<title>Practical JavaScript</title>
</head>
<body>
<script type="text/javascript">
// Square the given number x
campaign_ids = []
planogram_counts = []
photo_compliance_counts = []
compliance_div_planograms = []
ActiveRecord::Base.logger.level = 5
campaigns = Campaign.where(:launched_at => 12.month.ago..Time.now)
# campaigns = campaigns[2..255]
puts "campaigns.count = #{campaigns.count}"
batch_idx is increasing by batch_size. In this example 250
Count in the number of locations in this case 5440
Eventually batch_idx will be equal to of less then by < 250 (in_groups_of(batch_size, false)) RE: the false here
I have no idea how this reached 101. Empirically seems like this code would not do it.
num = 0
count = Location.count
(0..count).step(250) do |index|
num += 1
puts "#{num}) percent = #{(count > 0 ? index.to_f/count.to_f : 0)}"
From: /Users/cmagid/projects/vmm/app/services/users/mass_upload.rb @ line 59 Users::MassUpload#process_line:
57: def process_line(index, header, row, allow_admins)
58: binding.pry
=> 59: row = MassUpload::Row.new({
60: :index => index,
61: :header => header,
62: :row => row,
63: :replace_existing_values => @replace_existing_values,
AspectDefinition.all.pluck
(:aspected_type , :column , :code , :position , :start_campaign_id).group_by{ |x| x.first }
=> {"Location"=>
[["Location" , "cid" , "store_number" , 1 , 6] ,
["Location" , "name" , "name" , 2 , 6] ,
["Location" , "attr001" , "finance_store_number" , 3 , 6] ,
["Location" , "phone" , "phone" , 4 , 6] ,
["Location" , "address1" , "address_1" , 5 , 6] ,
["Location" , "address2" , "address_2" , 6 , 6] ,
["Location" , "city"
MESSAGE
undefined method `+' for nil:NilClass
STACK TRACE
warden::saml::Gatekeeper#login_url
lib/warden/saml/gatekeeper.rb, line 19
Warden::OnedoorSaml.sso_login_url
config/initializers/warden/onedoor_saml.rb, line 5
@ChasManRors
ChasManRors / gist:b7fabb66a77c5a06a246ef9f451d58a3
Created March 8, 2018 16:00
steps taken to get back to cleaner ember free environment
cd /Users/cmagid/projects/compliance-visualization-dashboard
=> ok
brew unlink node
=> Error: No such keg: /Users/cmagid/brew/Cellar/node
brew uninstall --force node
=> ok
brew prune
=> ok
brew uninstall --ignore-dependencies python@2
=> ok
compliance-visualization-dashboard (FR92-47)$ type npm
-bash: type: npm: not found
compliance-visualization-dashboard (FR92-47)$ type node
-bash: type: node: not found
compliance-visualization-dashboard (FR92-47)$ type npm
-bash: type: npm: not found
compliance-visualization-dashboard (FR92-47)$ type ember
-bash: type: ember: not found
compliance-visualization-dashboard (FR92-47)$ type brew
brew is /Users/cmagid/brew/bin/brew