Skip to content

Instantly share code, notes, and snippets.

View hadrienblanc's full-sized avatar

Hadrien Blanc hadrienblanc

  • Paris, France
View GitHub Profile

TimeZone (and Rails)

UTC : What is that ?

https://en.wikipedia.org/wiki/ISO_8601 ISO 8601 describes representation of dates and times as an international standard

Time zones in ISO 8601 are represented as local time (with the location unspecified), as UTC, or as an offset from UTC.

Z ?

Model.where('created_at >= ?', Time.zone.now.beginning_of_day)
class Test
def run
upload { puts "YIELD" }
end
def run2
upload do
puts "yield with do"
end
end
ALTER USER 'admin'@'%' IDENTIFIED BY 'NEW_PASSWORD';
class Person < ActiveRecord::Base
belongs_to :location
belongs_to :role
end
class Role < ActiveRecord::Base
has_many :people
end
class Location < ActiveRecord::Base
quote_style :single
ActiveModel::Type::Boolean.new.cast(ENV.fetch('MY_ENV_VARIABLE', false))
lsblk # show the volume size
sudo file -s /dev/xvdf # know your filesystem type
sudo xfs_growfs -d /home/ubuntu/data/ # increase your mount folder
require 'rest-client'
require 'json'
client_id = '42f5e************************'
client_secret = 'secret-b42-************************'
begin
response = RestClient.post('www.my_app.com/oauth/token', {
grant_type: 'client_credentials',
client_id: client_id,
{ "attribute_1": {$exists:true}, "attribute_2": "value_wanted"}