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

Code review comments

01/31/20  Public, Rails Errors, Ruby General

instance variables / getters / setters

re: @redis

In general for getters and setters in our classes. Can we:

  1. limit the usage of instance variables to setters (@redis), i.e. where we are assigning things, and
  2. use an `attr_...

1 vote - harrylevine

Import a CSV file

02/17/19  Public, Ruby General

This is a simple implementation that uses Ruby's CSV class to:

  • import a local .csv file
  • account for the first line of the file being the headers
  • converting these headers in...

1 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:

  • take a given URL to an XML-encoded page
  • download and parse the page at runtime

Solution

...

1 vote - harrylevine

In Jest run one specific test in a file using npm test

02/08/19  Public, Testing / TDD

Circumstances

  • using Jest JavaScript framework
  • have an npm script in package.json for test set to jest
  "scripts": {
    "test": "jest"
  }
  • have a test file in the following location:
/__test__/td.tes...

1 vote - harrylevine

Open and edit Rails 5.2 credentials file

10/12/18  Public, Rails General

Here is an example of how to open and edit the new credentials file that came out in Rails 5.2. This example is using Sublime as the editor.

1. From the root of the project run:

➜  EDITOR="subl --wait" rails credentials:edit

...

1 vote - harrylevine

How to add a new path to my PATH

06/20/18  Public, Command Line

http://osxdaily.com/2014/08/14/add-new-path-to-path-command-line/

Here was my use case.

My starting PATH

➜  echo $PATH
/Users/harrylevine/.rbenv/shims:/usr/local/heroku/bin:/Users/harrylevine/.rbenv/shims:/Users/harrylevine/.rbe...

1 vote - harrylevine

Explanation of the Singleton Pattern in ruby

06/18/18  Public, Ruby General

https://ieftimov.com/singleton-pattern

1 vote - harrylevine

How to look at an older version of the rails API docs

05/07/18  Public, Rails General

You add in /v4.2.1/ into the URL, for the version in question. For example:

Before URL:

After URL:

1 vote - harrylevine