Helpful site for writing Regular Expressions

05/02/16  Public, Other Languages

Rubular

Rubular is a Ruby-based regular expression editor. It's a handy way to test regular expressions as you write them.

1 vote - harrylevine

Creating a scaffold migration in Rails

08/21/16  Public, Rails General

1 - Make sure you have already created your rails app
2 - $ rails generate scaffold topic title:string description:text

This generate scaffold tells Rails to create everything necessary to get up and running with topics model.
- `topi...

1 vote - harrylevine

Rescue in failing controller spec

04/01/16  Public, Testing / TDD

I was getting a failing controller spec, and the failure message was not helpful at all, nor were any of the debugging approaches. A coworker recommended that I check the controller method itself to see if there is a rescue block in there. Low...

1 vote - harrylevine

Shortcut for pretty printing Active Record data in the rails console

03/28/16  Public, Command Line, Shortcuts, Tricks

In the rails console, when you run something like Post.all it returns all of the posts in one big continuous paragraph. A quick, low-rent shortcut to get these records to pretty print is to:

  • lead with a y

For example:

$...

1 vote - harrylevine

Test one specific file or spec with spring, without running guard

03/21/16  Public, Shortcuts, Command Line, Testing / TDD

This syntax will allow you to take advantage of the speed that spring offers, when running just one spec file, or just one spec within the file (or context), without running [guard](https://github.com/guard/g...

1 vote - harrylevine

Find all the available instance methods for a given class

03/07/16  Public, Ruby General

To see all the instance methods available on a given class

1 - from a class object call .instance_methods on the class (i.e. User.instance_methods)
or

2 - from ...

1 vote - harrylevine

Create browser bookmark in Alfred

03/02/16  Public, Shortcuts

https://youtu.be/O2i_w-57_XA?t=7m54s

To create a new bookmark:

  1. Open the Alfred search window
  2. Paste in the URL of the bookmark
  3. Once you can tell it has been recognized as a website, hit enter

To use...

1 vote - harrylevine

Passing a block into a method, as a parameter - Using Proc and &block

02/23/16  Public, Ruby General

In order to pass a block into a method, as a parameter:

  1. Create a Proc and put the block's contents inside of it
  2. Pass the Proc in as parameter, placing an & in front of the variable's name
  3. In the method, the block parameter will...

1 vote - harrylevine

Link one JavaScript file to another in Rails - Use function in one.js inside of two.js

01/20/16  Public, Other Languages

In Rails, this is to place your JS code in more than one file, based on functionality, to keep things DRY, and to prevent one file from becoming large and complicated.

If you want to call a function from one.js in files two.js and `three.js...

1 vote - harrylevine

JavaScript - Remove all non-alphanumeric characters, new lines, and multiple white space from string

12/27/15  Public, Other Languages

Here is the Regular Expression: /[\W_]+/g

For example:

var str = "234&^%,Me,2 2013 1080p x264 5 1 BluRay!@#$%&*()_-+=";

var filtered = str.replace(/[\W_]+/g, '');

console.log(filtered);
==>  "234Me220131080px26451BluR...

1 vote - harrylevine