Skip to content

Instantly share code, notes, and snippets.

View hadrienblanc's full-sized avatar

Hadrien Blanc hadrienblanc

  • Paris, France
View GitHub Profile
begin
file = File.open("/tmp/some_file", "w")
file.write("your text")
rescue IOError => e
#some error occur, dir not writable etc.
ensure
file.close unless file.nil?
end

On a debian OS system

RUN apt-get update
RUN apt-get install libjemalloc-dev
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so" 

ORDER BY NULL

Explicitly ORDER BY After GROUP BY By default, the database sorts all 'GROUP BY col1, col2, ...' queries as if you specified 'ORDER BY col1, col2, ...' in the query as well. If a query includes a GROUP BY clause but you want to avoid the overhead of sorting the result, you can suppress sorting by specifying 'ORDER BY NULL'.

# How to use sqlite3
```
sqlite3 db/development.sqlite3
```
```
sqlite3 db/development.sqlite3
my_string.chars do |c|
  puts "%s %3d %02X" % [ c, c.ord, c.ord ]
end
docker stop $(docker ps -a -q) #stop all docker container
class User < ActiveRecord::Base
 def do_something!
   self.my_attr = 123
 end

 def do_another_thing!
   my_attr = 456
end

🇺🇸

:en:

@hadrienblanc
hadrienblanc / config.yml
Created April 29, 2019 09:20
classique circle_ci rails test config file
# classique circle_ci rails test config file
version: 2
jobs:
build:
environment:
working_directory: ~/circleci-myapp
docker:
- image: circleci/ruby:2.5.5-node-browsers
steps:
- checkout

Are you doing a array of hashes ? They merge. :/

Unless you as: :json on the test post

    post api_v1_stuff, params: params, as: :json