SQL for INSERT:
INSERT INTO geographies (type, name, geometry)
VALUES (
'Location',
'Vintage Heart Coffee',
ST_GeomFromGeoJSON('{"type": "Point", "coordinates": [30.2642, -97.7277]}')
);
-- INSERT 0 1
module Attrlist | |
def /(attrlist) | |
attrlist.map { |a| send(a) } | |
end | |
end | |
class Time | |
include Attrlist | |
end |
Rails.application.routes.set. | |
map { |r| r.optimized_path[1..-1].split('/').first }. | |
uniq. | |
compact. | |
reject { |s| s.include?('*') || s.include?(':') } |
SQL for INSERT:
INSERT INTO geographies (type, name, geometry)
VALUES (
'Location',
'Vintage Heart Coffee',
ST_GeomFromGeoJSON('{"type": "Point", "coordinates": [30.2642, -97.7277]}')
);
-- INSERT 0 1
def random_plausible_html_tags(num=5) | |
num.times.map { [*('a'..'z')].sample(rand(6) + 1).join } | |
end |
# Utility converter to make a circular enumerator, wrapping around to the | |
# beginning of a list after it has exhausted all entries. | |
# | |
# Example: | |
# | |
# >> e = CircularEnumerator([1,2,3,4,5]) | |
# => #<Enumerator: [1, 2, 3, 4, 5]:each> | |
# | |
# >> 10.times.map { e.next } | |
# => [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] |
require 'active_support/core_ext/time' | |
require 'active_support/values/time_zone' | |
module TimeUtilities | |
# Parses an ISO-8601 time string with a time zone and keeps the time zone in | |
# the Time object returned, unlike Ruby Core. | |
# | |
# Examples: | |
# |
# Automatic Per-field Background Validation for Forms | |
# | |
# Usage: | |
# | |
# 1. Add a 'bg-validatible' class to your <form> | |
# 2. Add data-bg-validation-url-template="/validation/{field_id}" to your <form> | |
# 3. Add data-bg-validation-success-message="Looks good!" to your <form> or each validatible element | |
# 4. Add data-bg-validation-output="relative_selector_to_field" to the <form> or each validatable element | |
# 5. Add data-bg-validation-field="some_field_id" to each validatable field | |
# 6. (Optionally) Add a data-bg-validation-include="other_id,other2_id" attribute to the validatable field to send |
#!/bin/bash -e | |
number_of_cores=`sysctl -n hw.ncpu` | |
brew update && \ | |
brew upgrade ruby-build libxml2 libxslt libiconv | |
brew link --force libiconv && \ | |
bundle config --global build.nokogiri "--with-xml2-include=/usr/local/include --with-xml2-lib=/usr/local/lib --with-xslt-dir=/usr/local/opt/libxslt --with-iconv-include=/usr/local/include --with-iconv-lib=/usr/local/lib" && \ | |
bundle config --global jobs `expr $number_of_cores - 1` && \ | |
rbenv install 2.1.5 && \ |
Congress (House & Senate) just passed (amidst the release of the torture report and the Gruber hearing) an amendment to the annual intelligence agencies’ budget bill (HR 4681, Section 309) that makes it legal to:
class Time | |
def within?(time_period) | |
self >= Time.now && self <= Time.now + time_period | |
end | |
end | |
# >> (Time.now + 55.hours).within? 2.days | |
# false | |
# >> (Time.now + 45.hours).within? 2.days | |
# true |