Hack hack hack...

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

Rum Fun

Asset Trouble

  • Rails 3.1.3 legacy app The images were coming through, but the JS and css wasn’t compiling.
  • This inspired us to roll back to 1.9.3, which worked.

Coffeescript hashes

  • this one took me a hot second -> delete obj[key]

  • counting the keys in an object was pretty close to javascript Object.keys(obj).length from.

Thought process on adding a friend

  • page loads
    • checks to see if local storage has values

      • if not it assigns empty array
      • if so it assigns to local array which contains a hash of both the name, the uid, and its input position
        • names are loaded into the input field
        • names and uid(pic) are loaded with the appropriate number of beach passes
    • if when a name is removed from the input field, it is removed from the local array

      • a listener on the array updates the proper number of beach passes
    • when a name is selected by the autocomplete, it assigns pushes the new record of name, uid and position into the array

      • a listener on the array updates the proper number of beach passes
    • a validator prevents the user from continuing without having at least one friend OR checking the ‘alone’ checkbox

    • upon hitting the continue btn, the local array is assigned to local storage

Devise sign out

  • In the devise.rb initializer -> The default HTTP method used to sign out a resource. Default is :delete.
    • config.sign_out_via = :get will allow me to use a regular link

PG setup

IP Spoof

  • had a client on a plane that triggered a ActionDispatch::RemoteIp::IpSpoofAttackError: IP spoofing attack?! error.
To turn off ip spoof
1
2
3
4
5
6
7
8
9
10
11
12
13
class IpSpoof
  def initialize(app)
    @app = app
  end

  def call(env)
    @app.call(_strip_ip_spoofable_headers(env))
  end

  def _strip_ip_spoofable_headers(env)
    env.reject { |key, value| key.upcase == 'HTTP_CLIENT_IP' }
  end
end

  • this needed to be inserted before the rack middleware ActionDispatch::RemoteIp so used config.middleware.insert_before ActionDispatch::RemoteIp, IpSpoof as suggested in rails guide. Pretty cool.

Location Tracking

  • after many protests, I was forced to include a tracking script that pilled down users’ lat and long coordinates. Not sure I believe it is right to pull down location info without providing the user with some benefit.

Comments