Skip to content

Instantly share code, notes, and snippets.

@jennli
jennli / git.md
Last active February 10, 2016 00:12

#Merge

  • git branch
  • git checkout -b feature/uniform_hellos
  • git status On branch feature/uniform_hellos
  • git diff master feature/uniform_hellos
  • git merge --abort
  • gitx

Resources

  • generate model and controller in one command
bin/rails g resource support_request name email message:text department done:boolean
  • quickly reset data
bin/rake db:drop db:create db:migrate db:seed

USER AUTHENTICATION

password_digest

  • rails pre/append 'salt' before running through a hash algorithm
Digest::SHA1.digest("abcd1234")
"|\xE05\x9F\x12\x85\x7F*\x90\xC7\xDEF_@\xA9_\x01\xCB]\xA9"
2.2.3 :007 >
  • start by creating a user model
blog $ heroku create ldn-rails-blog

blog $ git remote -v

blog $ git push heroku master

blog $ heroku run rake db:migrate
  • to ensure migration runs for test environment
rake db:migrate RAILS_ENV=test

or

fundsy $ bin/rake db:test:prepare

Factory Girl

associate many to many through a third join model

  • generate the like model for awesome answers
rails g model like user:references question:references
rake db:migrate
  • go the question model to add in association:
  has_many :likes, dependent: :destroy
  has_many :users, through: :likes
  • config/initializers
  • create a file called setup_mail.rb
ActionMailer::Base.smtp_settings = {
  address:              "smtp.gmail.com",
  port:                 "587",
  enable_starttls_auto: true,
  authentication:       :plain,
  user_name:            ENV["email_user_name"],
  password:             ENV["email_password"]
@jennli
jennli / jade_.md
Last active February 23, 2016 19:06

Jade

  • allow to see logic behind HTML script
apm install atom-bootstrap3
apm install atom-jade
apm install preview-plus
  • index.jade
html
@jennli
jennli / JQuery.md
Last active February 25, 2016 23:12

JQuery

  • makes managing DOM easier
  1. select elements
  2. manipulate selected elements
  3. add even listeners to selected elements
$('img').hide();
$('a').on('click', function(){console.log('that tickles')});

CSS Positioning strategies

  • inherit: use position value of container
  • static: normal layout (top left? default)
  • relative: offests from normal layout position
  • fixed: fixed position
  • absolute: offsets from the nearest container with a position attribute other than static

CSS Attributes

  • more convenient to use css method rather than updating the style using attr