Hack hack hack...

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

KCA 2

Heroku

  • git push staging develop:master

FB

  • target ‘_top’ will put the new window on top
  • http://app.facebook.com/name-space
  • make sure to disable secure browsing in FB
  • change fields from address state to state_loc to avoid collisions with state machine gems like transitions

  • can simulate mobile with overrides in the inspector

  • heroku run rake db:migrate --remote staging

  • heroku config:add <env variable> <env variable>
  • heroku log --remote staging

  • .shuffle method

  • .floor returns an integer
  • if diving two integers you need to th make sure one of them is a float

  • In routes, member do block adds a resource on a specific record, while collect do

  • in config/application.rb in order to load libs automatically need to change config to config.autoload_paths += %W(#{config.root}/lib)

  • has_mobile_fu false in appcontroller, need false

  • decent exposure

      • expose(:articles) { current_user.articles } scopes articles belonging to that user
  • output the boards on board show page, new board page, and how to play

  • content tag

    • need to use .html_safe
  • to start memcache /usr/local/opt/memcached/bin/memcached

  • deploy to heroku staging with git push staging develop:master

  • creating a table with content tags in a helper

  • .update_attribute! versus .update_attribute -> raise an exception rahter than false.

Tests

HAML

1
2
.shuffle.hidden
.delete.hidden

Makes divs with classes above

Ajax with coffeescript

Used the call below to make a friend request.

1
2
3
4
5
getFriends: (callback) ->
    FB.api '/me/friends', (response) => 
      $.each response.data, (k, v) =>
        @friends.push({ label: v.name, value: v.id })
      callback()

The callback is to ensure that other function do not proceed before the friends are loaded asynchronously.

Auto-complete with JQuery UI

  • Got it from here
  • also loaded the js and css minified versions in the lib directory.
  • there was a small change to be made, documented here

Javascript to coffee

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  sendMessage: (fb_uid, details = {}) ->
    obj =
      to: fb_uid
      method: "feed"
      redirect_uri: "http://kca.dev"
      link: "http://google.com"
      picture: "http://fbrell.com/f8.jpg"
      name: "Facebook Dialogs"
      caption: "Reference Documentation"
      description: "Using Dialogs to interact with users."

    obj = $.extend obj, details

    FB.ui obj, ->
      alert 'posted'
  • = link_to "Something", some_path, :method => :post

  • Need to remember to add () after a method call

  • defaults to auth user if no to: method
  • discussion on lexical scope

Counter_cache

  • In the model -> belongs_to :project, :counter_cache => true
  • railscast #23

Jquery

  • $("div,p,span") this works as a multiple selector
  • hidden divs

Selecting a winner

Migrate test db

  • ake db:migrate RAILS_ENV=test

No merge message for a no-ff flag

  • --no-edit

FB app auto-grow

Gem from a git url

  • gem 'redcarpet', :git => 'git://github.com/tanoku/redcarpet.git'

With an options hash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def facepile(*options)
opts = {:href => ENV['FACEBOOK_APP_URL'],
        :max_rows => 1,
        :width => 300,
        :show_count => true }
opts.merge!(options.first) unless options.empty?

raise "Must provide a :url option parameter or ENV['FACEBOOK_APP_URL']" unless opts[:href]

%Q{
<div class="fb-facepile" 
data-href="#{opts[:href]}" 
data-max-rows="#{opts[:max_rows]}"
data-show-count="#{opts[:show_count]}"
data-width="#{opts[:width]}">
</div>
}.html_safe
  end

FB invite friends

in coffeescript
1
2
3
4
5
6
7
inviteFriend: ->
  obj =
    method: 'apprequests',
    message: 'Come check this out'

  FB.ui obj, ->
    alert 'invited'

Delpoy

  • rake deploy:staging and rake deploy:production

Comments