Skip to content

Instantly share code, notes, and snippets.

View rsim's full-sized avatar

Raimonds Simanovskis rsim

View GitHub Profile
@rsim
rsim / 01_thread.rb
Created March 26, 2013 21:15
Code examples from my "Using threads in Ruby applications" presentation in our local Ruby meetup http://www.meetup.com/ruby-on-rails-latvia/events/105142132/
Thread.new do
sleep 5
puts "finished"
end
thread = Thread.new do
sleep 5
puts "finished"
end
thread.join
@rsim
rsim / gist:d11652a8336137832df9
Created April 7, 2015 08:01
How to get the current Unix timestamp in SQL

Get the current Unix timestamp (seconds from 1970-01-01T00:00:00Z) in SQL.

  • MySQL: UNIX_TIMESTAMP()
  • PostgreSQL: CAST(EXTRACT(epoch FROM NOW()) AS INT)
  • MS SQL: DATEDIFF(s, '1970-01-01', GETUTCDATE())
  • Oracle: (CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS DATE) - DATE'1970-01-01') * 86400