Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

Coil

Git Workflow

Powder

  • pow
  • binding.remote_pry in the code to drop into pry. Also need to have pry-remote open in a terminal window.
  • powder applog -> is like trace for pow
  • to output notices to the log logger.debug "message"

Hooks

Redis

To access the Reds cli and flushall these are the commands…

1
2
♕ redis-cli
redis> flushall

Reg-ex

reg expressions can kick out multiple match groups. These are accessible with array notion. [0] is always the matching string, [1] would be the first match, and [2] would be the second and so on. Rubular throws off the match groups for you to access.

e.g. of URL parse
1
2
p.slug = "#{github_url.match(/https:\/\/github\.com\/.*\/(.*)\.git/)[1]}"
p.repo_owner = "#{github_url.match(/https:\/\/github\.com\/(.*)\/.*\.git/)[1]}"

Disable CSRF

  • disabled the CSRF verifcation with skip_before_filter :verify_authenticity_token found at

Pubsubhubbub

  • think about subscribe or unsubscribe on pubsubhubbub
    • when to trigger the subscription? in an asynch worker? in the clone method
    • because you have have access to the process and the user?
  • this can be easily called with Octokit (See below)

cURL

We really shouldn’t be invoke cURL methods in the model or background job. Octokit allows users to easily subscribe to pubsubhubbub. It’s all here.

I was going to do this… but it wasn’t neccessary with octokit

Pubsubhubbub and cURL
1
2
3
4
curl -u "#{user.nickname}:#{user.password}" -i https://api.github.com/hub
  -F "hub.mode=subscribe"
  -F "hub.topic=https://github.com/#{project.repo_owner}/#{project.slug}/events/push"
  -F "hub.callback=http://coil.io/hook/#{project.key}"

Sidekiq best practices

Parsing a yaml file of quotes

1
2
thing = YAML.load_file('some.yml')
puts thing.inspect

See here

Formatted array of strings in YAML:

1
2
3
4
5
6
7
8
9
- "“We build but to tear down. Most of our work and resource is squandered. Our onward march 
is marked by devastation. Everywhere there is an appalling loss of time, effort and life. A 
cheerless view, but true”
\n - Nikola Tesla, 1910"
- "“If the genius of invention were to reveal to-morrow the secret of immortality, of eternal 
beauty and youth, for which all humanity is aching, the same inexorable agents which prevent a 
mass from changing suddenly its velocity would likewise resist the force of the new knowledge 
until time gradually modifies human thought.”
\n - Nikola Tesla, 1907"

Yaml is white space sensitive, but not new-line sensitive for strings as long as the new-line is within the the quotes.

I then selected a random element with the .sample method. Very cool.

Slim

Had to look in the Slim docs. I was looking for output, which is controlled by the = sign. Figured it out after that…

Testing

Factory Girl

  • A factory generates test data to pass to the controller method; note the use of Factory Girl’s attributes_for option, which generates a hash of values as opposed to a Ruby object.
  • Rewatched the RailsCasts no. 158

Refactoring lessons

  • Don’t pass in more params than you need. It makes the unit testing harder and it isn’t neccessary.
    • refer to Sandi Metz’s comments about passing in a params hash if you are accessing multiple attributes of an object

Random

Comments