Some CoffeeScript (verbosely commented for clarity)
# Override Rails handling of confirmation
$.rails.allowAction = (element) ->
# The message is something like "Are you sure?"
message = element.data('confirm')| macro := { | |
| rule infix { $obj $([ $key ] ...) | $rval:expr } => { | |
| $obj = mori.assoc_in($obj, [$key (,) ...].reverse(), $rval) | |
| } | |
| } | |
| macro hash_map { | |
| rule {{ $($key : $value) (,) ... }} => { | |
| mori.hash_map($($key, $value) (,) ...) | |
| } |
| class @GoogleAnalytics | |
| @load: -> | |
| # Google Analytics depends on a global _gaq array. window is the global scope. | |
| window._gaq = [] | |
| window._gaq.push ["_setAccount", GoogleAnalytics.analyticsId()] | |
| # Create a script element and insert it in the DOM | |
| ga = document.createElement("script") | |
| ga.type = "text/javascript" |
| #!/bin/bash | |
| set -exo pipefail | |
| BUILD_ENV=$1 | |
| if [ `uname` == 'Darwin' ]; then | |
| OSX=1 | |
| JSCOMPRESSOR="yuicompressor --type js" | |
| else | |
| OSX= |
| # The fact that YAML.load will instantiate arbitrary ruby objects | |
| # means that calling `YAML.load` on untrusted data is virtually always | |
| # equivalent to executing arbitrary code in a complex app. | |
| # This code fragment globally neuters YAML to disable this behavior, | |
| # which should (hopefully) cut off all such attacks from the start. | |
| # I don't promise this closes all possible attacks, but this closes | |
| # off the trivial case. You should audit and upgrade all your | |
| # dependencies, as well. |
| # Gemfile | |
| gem "puma" | |
| # Procfile | |
| web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb | |
| # add to config block config/environments/production.rb | |
| config.threadsafe! | |
| # get rid of NewRelic after_fork code, if you were doing this: |
| ###################### | |
| # | |
| # ActiveRecord's ConnectionPool in Rails 3.2.3 allows threads to 'steal' | |
| # connections from each other, so some threads get starved out. | |
| # | |
| # This monkey patch uses an implementation from https://github.com/rails/rails/pull/6492 | |
| # that ensures 'fair' queue in ConnectionPool. | |
| # | |
| # It's actually a weird hybrid which ALSO maintains the clear_stale_cached_connections! | |
| # behavior to reclaim leaked orphaned connections, and calls that method |
| -- PostgreSQL 9.2 beta (for the new JSON datatype) | |
| -- You can actually use an earlier version and a TEXT type too | |
| -- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
| -- Inspired by | |
| -- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html | |
| -- http://ssql-pgaustin.herokuapp.com/#1 | |
| -- JSON Types need to be mapped into corresponding PG types | |
| -- |
| # coding: utf-8 | |
| # | |
| # Encode any codepoint outside the ASCII printable range to an HTML character | |
| # reference (https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_reference_overview). | |
| def encode(string) | |
| string.each_codepoint.inject("") do |buffer, cp| | |
| cp = "&#x#{cp.to_s(16)};" unless cp >= 0x20 && cp <= 0x7E | |
| buffer << cp | |
| end | |
| end |
| .ui-autocomplete { | |
| position: absolute; | |
| top: 100%; | |
| left: 0; | |
| z-index: 1000; | |
| float: left; | |
| display: none; | |
| min-width: 160px; | |
| _width: 160px; | |
| padding: 4px 0; |