Skip to content

Instantly share code, notes, and snippets.

View inossidabile's full-sized avatar

Boris Staal inossidabile

View GitHub Profile
Joosy.namespace 'Urls', ->
class @NewPage extends ApplicationPage
@layout ApplicationLayout
@view 'new'
@mapElements
'form': '#new_url'
@mapEvents
module ActiveAdmin
class ResourceController < BaseController
def clean_search_params(search_params)
super.delete_if do |key, value|
value == [""]
end
end
end
end
<script type="text/javascript">
if (localStorage['data/categories'][0] === '{') {
localStorage['data/categories'] = "[" + localStorage['data/categories'] + "]";
}
if (localStorage['data/session'][0] === '{') {
localStorage['data/session'] = "[" + localStorage['data/session'] + "]";
}
if (localStorage['data/counters'][0] === '{') {
grunt.initConfig
testem:
'core-jquery':
src: [
'bower_components/jquery/jquery.js',
'core/*.coffee'
],
options:
launch_in_dev: ['PhantomJS'],
launch_in_ci: ['PhantomJS', 'Chrome', 'Firefox', 'Safari', 'IE7', 'IE8', 'IE9']
@inossidabile
inossidabile / form_builder_fix.rb
Created February 25, 2013 21:09
Sortable ActiveAdmin forms
ActiveAdmin::FormBuilder.class_eval do
def has_many(association, options = {}, &block)
options = { :for => association }.merge(options)
options[:class] ||= ""
options[:class] << "inputs has_many_fields"
# Add Delete Links
form_block = proc do |has_many_form|
# @see https://github.com/justinfrench/formtastic/blob/2.2.1/lib/formtastic/helpers/inputs_helper.rb#L373
contents = if block.arity == 1 # for backwards compatibility with REE & Ruby 1.8.x
for value in @values
sum = 0
costs.push []
for pair in value
costs.last().push pair[0]
sum += pair[0]
totalHeights.push sum
require "rubygems"
require "bundler/setup"
require "eventmachine"
require "thin"
require "sinatra/base"
EventMachine.run do
class App < Sinatra::Base
get '/' do
// Example of HTTP API documentation format based on Apiary blueprint
== transport | Transport system
Markdown description of an entity goes here.
== transport/cards | Customers' cards
@keyword [string] Keyword of a card
create_shortage = ->
shortage = 0
percents.each (x, i) ->
if x < 15
percents[i] = 15
shortage += 15 - x
shortage
# match 'api/wsdl', ...
Rails.application.routes.routes.named_routes['api_wsdl'].app.instance_variable_get("@controllers")['api'].try(:'clear!')