Skip to content

Instantly share code, notes, and snippets.

View hadrienblanc's full-sized avatar

Hadrien Blanc hadrienblanc

  • Paris, France
View GitHub Profile
my_string.chars do |c|
  puts "%s %3d %02X" % [ c, c.ord, c.ord ]
end
# How to use sqlite3
```
sqlite3 db/development.sqlite3
```
```
sqlite3 db/development.sqlite3

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'.

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" 
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
SELECT table_schema AS "Database",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
echo "[test 200]"
echo "Script that tests we receive a 200 http code response from an array of urls."
echo ""
urls=(
https://www.google.fr
https://www.google.com
)
for url in "${urls[@]}"
dw = Delayed::Worker.new
dj = Delayed::Job.last # assuming that the last job is the failed one, otherwise use a proper query to
# locate it
dw.run dj
Post.where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day)
# mac OS 10.14
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder