Parse any date time string into a date object
08/13/20 Public, Ruby General
Use Ruby's Date
#strptime method to take any date or date time object that has been created with the [#strftime](https://ruby-doc.org/stdlib-2.5.0/libdoc/date/rdoc...
1 vote - harrylevine
Create a Rails path helper link to a specific anchor tag section of a page
06/13/20 Public, Rails Errors
admin_company_settings_path(anchor: 'autopilot-mode')
#=> /admin/company_settings#autopilot-mode
Links to that page, scrolled to the DOM element containing id="autopilot-mode"
1 vote - harrylevine
03/06/20 Public, Rails Errors
In a separate tab run:
$ tail -f log/test.log
1 vote - harrylevine
03/04/20 Public, Ruby General
for each in `ps -eo pid,command | grep ruby | grep -v grep | awk '{print $1}' `; do kill -9 $each;done
killall −9 ruby
pkill -9 ruby
pidof ruby | xargs kill -9
ps aux | grep sidekiq | awk '{print $2}' | xargs kill
...
1 vote - harrylevine
Find and extract a recurring pattern from a string
01/09/20 Public, Ruby General
For example, let's say that you have a string containing any number of Slack user ids (i.e. <@W012A3CDE>
), and you need to extract out just the user ids.
Here is the string you are startin...
1 vote - harrylevine
Rails scope with and without arguments
12/11/19 Public, Rails General
Model scope
with argument:
scope :for_company, ->(company_id) { where(company_id: company_id) }
Model scope
without arguments:
scope :admins, -> { where(role: 'Admin') }
1 vote - harrylevine
01/31/20 Public, Rails Errors, Ruby General
re: @redis
In general for getters and setters in our classes. Can we:
@redis
), i.e. where we are assigning things, and1 vote - harrylevine
02/17/19 Public, Ruby General
This is a simple implementation that uses Ruby's CSV class to:
.csv
file1 vote - harrylevine
Using Nokogiri to parse an XML page
02/16/19 Public, Ruby General, Gems
My solution for Upcase's Analyzing Shakespeare challenge where we:
...
1 vote - harrylevine
In Jest run one specific test in a file using npm test
02/08/19 Public, Testing / TDD
package.json
for test
set to jest
"scripts": {
"test": "jest"
}
/__test__/td.tes...
1 vote - harrylevine