This file contains 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
1. Grab the DB dump | |
curl -L "https://www.dropbox.com/s/k1ai0765gc2k98f/bug5.sql?dl=1" -o bug5.sql | |
2. Create an empty database and restore the dump and wait a bit: | |
createdb bug5 && psql -d bug5 -f bug5.sql && psql -d bug5 -c "ANALYZE" | |
3. Run queries: |
This file contains 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
WITH relations AS (SELECT | |
a.attname, | |
pg_catalog.format_type(a.atttypid, a.atttypmod) AS type, | |
t.relname | |
FROM | |
pg_attribute a | |
JOIN pg_class t ON a.attrelid = t.oid | |
JOIN pg_namespace s ON t.relnamespace = s.oid | |
WHERE | |
a.attnum > 0 |
This file contains 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
#!/bin/bash | |
set -e | |
set -o pipefail | |
for dev in /dev/sd? | |
do | |
if findmnt "${dev}1" | |
then | |
umount "${dev}1" |
This file contains 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
class Auth0Token | |
def request_token | |
connection = Faraday.new(url: "https://rubyfriend.auth0.com/oauth/token") | |
response = connection.post do |request| | |
request.headers['Content-Type'] = 'application/json' | |
request.body = payload.to_json | |
end | |
JSON.parse(response.body) | |
end |
This file contains 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
[ | |
{time: 201201, x: 2, y: 7, z: 2}, | |
{time: 201202, a: 3, b: 4, c: 0}, | |
] |
This file contains 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
log = [ | |
{time: 201201, x: 2}, | |
{time: 201201, y: 7}, | |
{time: 201201, z: 2}, | |
{time: 201202, a: 3}, | |
{time: 201202, b: 4}, | |
{time: 201202, c: 0} | |
] |
This file contains 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
git log --pretty="%ad|%an|%s" --date=short | | |
while IFS='|' read date author message | |
do | |
printf '%s %-20s %s\n' "$date" "$author" "$message" | |
done |
This file contains 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
christmas_present.price #=> "123.0" |
This file contains 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
christmas_present.price #=> #<BigDecimal:7ff71b93df40,'0.123E3',9(18)> |
This file contains 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
class BigDecimal | |
def inspect | |
to_s | |
end | |
end |
NewerOlder