Skip to content

Instantly share code, notes, and snippets.

@remear
remear / ajax-form.js
Created February 25, 2013 02:20 — forked from havvg/ajax-form.js
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@norman
norman / character_reference.rb
Last active September 9, 2021 20:48
HTML entities? We don't need no stinkin' HTML entities.
# 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
@remear
remear / eunic
Created February 9, 2012 23:10 — forked from pjammer/eunic
i put this into /usr/local/bin/eunic and you can your server using eunic -s && eunic -N
#!/bin/bash
set -u
set -e
#change this below to your actual path. If you another environemnt like staging, fucking change N to -e staging instead.
APP_PATH=/youpath/to/app/root
PID=$APP_PATH/tmp/pids/unicorn.pid
OLD_PID=$APP_PATH/tmp/pids/unicorn.pid.oldbin
UNICORN_COMMAND="unicorn_rails -c $APP_PATH/config/unicorn.rb -D"
while getopts ":nsNr" opt; do
@joshsusser
joshsusser / gist:998055
Created May 29, 2011 19:20
turn off 255 limit for string fields in postgresql
# in rails application.rb
initializer "postgresql.no_default_string_limit" do
ActiveSupport.on_load(:active_record) do
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:string].delete(:limit)
end
end