I hereby claim:
- I am joshuagross on github.
- I am joshuagross (https://keybase.io/joshuagross) on keybase.
- I have a public key whose fingerprint is DC5B 28F6 29F9 D09B BFB9 7FC3 ABF0 5BA3 4B8D 6DFD
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Sometimes while running a command inside of a docker container, the container itself will run out of disk space and things can fail (sometimes in strange ways). This is not a guide on how to allocate resources, but a quick cookbook on how to free up disk space inside a container. See below for links to more resources and reading.
Recently I've experienced strange issues with networking inside of Docker containers - like being unable to ping google.com
from inside a container, and all of the common suggestions around DNS resolution
not helping.
It turns out that Docker will copy your computer's default DNS settings into a container. If you change your DNS settings at some point - either manually or because your machine accepts defaults from your router/provider - the settings inside your cached Docker layers may no longer match what's on your machine, and certain DNS resolutions will fail in unusual ways.
My fix: docker run -it {image} /bin/bash
manually (for example, docker run -it python:2.7 bash
) to find the root image that is unable to resolve the domain you're interested
in, and then remove the culprit with docker rmi {hash}
.
# Requires pg-datediff: https://gist.github.com/JoshuaGross/18b9bb1db8021efc88884cbd8dc8fddb | |
select datid, query, DateDiff('second', query_start::timestamp, NOW()::timestamp) from pg_stat_activity; |
CREATE OR REPLACE FUNCTION DateDiff (units VARCHAR(30), start_t TIMESTAMP, end_t TIMESTAMP) | |
RETURNS INT AS $$ | |
DECLARE | |
diff_interval INTERVAL; | |
diff INT = 0; | |
years_diff INT = 0; | |
BEGIN | |
IF units IN ('yy', 'yyyy', 'year', 'mm', 'm', 'month') THEN | |
years_diff = DATE_PART('year', end_t) - DATE_PART('year', start_t); | |
select * from pg_stat_activity; |
console.log('echo -e "' + buf.reduce((s, x) => s + '\\x' + x, '') + '"');
Shell:
echo -e "\x85\x0\x2\x68\x0\x32\x194\x41\x247\x13\x33\x183\x212\x148\x92\x165\x68\x193\x4\x214\x164\x10\x90\x65\x80\x193\x114\x14\x255\x164\x18\x165\x77\x65\x0\x0\x9\x0\x50\x55"
// Compiles with gcc -O0 sdiff_empty.c | |
// After running your sdiff function once, it will run | |
// a second time on canned data and compare your results with | |
// known outputs. | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <inttypes.h> |
-- none of this is terribly interesting, mostly here for reference | |
class Functor (f :: * -> *) where | |
fmap :: (a -> b) -> f a -> f b | |
(<$) :: a -> f b -> f a | |
-- The same as Functor! | |
-- http://stackoverflow.com/questions/34732571/why-there-is-no-cofunctor-typeclass-in-haskell/34732721 | |
class Cofunctor (f :: * -> *) where | |
fmap :: (b -> a) -> f b -> f a |
echo "{ \"param\": 234 }" | node -e 'var input = ""; process.stdin.on("data", function (d) { input += d.toString(); }); process.stdin.on("close", function () { console.log(JSON.parse(input).param); });' |