Embeds SQL syntax highlighting inside Ruby heredocs labeled SQL
. This will also work to embed other syntaxen, e.g., HTML.
(requires https://github.com/exu/pgsql.vim)
syntax include @SQL syntax/pgsql.vim
require "active_support" | |
require "active_support/key_generator" | |
require "json" | |
# Based on https://gist.github.com/mattetti/7624413 | |
module JsonSessionSerializer | |
def self.load(value) | |
begin | |
JSON.parse(value) | |
rescue JSON::ParserError |
Embeds SQL syntax highlighting inside Ruby heredocs labeled SQL
. This will also work to embed other syntaxen, e.g., HTML.
(requires https://github.com/exu/pgsql.vim)
syntax include @SQL syntax/pgsql.vim
# In your code, right at the top of any source code file. | |
trap 'PROF' do | |
File.open("/tmp/profile-#{Time.current.to_f}", 'w') {|f| f.write caller(2).join("\n") } | |
pid = $$ | |
Thread.new { sleep 0.5; `kill -PROF #{pid}` } | |
end | |
# in a terminal | |
while true; do | |
sleep 0.1 |
# config/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
end |
This is a compiled list of falsehoods programmers tend to believe about working with time.
Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.