my_string.chars do |c|
puts "%s %3d %02X" % [ c, c.ord, c.ord ]
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to use sqlite3 | |
``` | |
sqlite3 db/development.sqlite3 | |
``` | |
``` | |
sqlite3 db/development.sqlite3 |
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'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Post.where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mac OS 10.14 | |
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder |