Skip to content

Instantly share code, notes, and snippets.

View pier-oliviert's full-sized avatar

Pier-Olivier Thibault pier-oliviert

View GitHub Profile
NodeList.prototype.toArray = ->
array = []
for obj, i in this
array[i] = obj
return array
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script
$.morpheus = require("morpheus")
$.sugar = require("sugar")
class PHIntroList
setPageView: (pageviewEl) ->
@pageView = pageviewEl
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script
$.morpheus = require("morpheus")
$.sugar = require("sugar")
highlightedItem = null
intervalId = null
class PHIntroList
constructor: () ->
@pier-oliviert
pier-oliviert / hash.rb
Created December 19, 2011 03:25 — forked from cmer/hash.rb
Hash#value_at_path
class Hash
# Returns the value at the specified path.
# For example, [:foo, :bar, :baz] as a path would return the
# value at self[:foo][:bar][:baz]. If self doesn't contain one of
# the keys specified in path, nil is returned.
#
# This method is useful as it simplifies statements such as:
# value = h[:a][:b][:c][:d] if h[:a] && h[:a][:b] && h[:a][:b][:c]
# to
# value = h.value_at_path([:a, :b, :c, :d])
@pier-oliviert
pier-oliviert / hash.rb
Created December 19, 2011 14:00 — forked from cmer/hash.rb
Object#value_at_keypath
class Object
# Returns the value at the specified path.
# For example, "foo.bar.baz" as a path would return the
# value at self[:foo][:bar][:baz]. If self doesn't contain one of
# the keys specified in path, It will return the farthest object found (will return self if it couldn't find anything).
#
# @param String keypath A path composed of keys separated with "." specifying a deep-nested path
# @return Object the value object
class Object
route.do
resources :product do
acl :anonymous do //guest access level
get 'index', 'index.html.erb'
end
acl :user do
get 'product/:id', 'product.html.erb' // Product.find_by_id(:id), redirect to 404 if cannot find object. By default @product is the object found.
get 'product/:id/edit' do
<html>
<head>
<%= stylesheet_link_tag "application", controller_name, "template"%>
<%= javascript_include_tag "application" , controller_name %>
</head>
</html>
class @GroupActionMenuHandler
bind: ->
$(document).on 'click', '.group-action-menu a', this.selectMenuItem
selectMenuItem: (event) ->
id = $(e.target).data('id')
alert 'hello'
false
require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
include Devise::TestHelpers
def setup
@new_user = users(:new_user)
@active_user = users(:active_user)
end
undefined method `client_contacts_path' for #<#<Class:0x007fb9f2606658>:0x007fb9f260afa0>
rake routes:
POST /client/:client_id/contact(.:format) contact#create
Code:
<div id="contact-form-modal" class="contact-form" title="Ajouter un contact">
<%= form_for [client, Contact.new] do %>
<div class="row">