Skip to content

Instantly share code, notes, and snippets.

import java.util.*;
import java.net.*;
public class ShowEth0PrimaryIp {
public static final String ETH0 = "eth0";
public static void main(String[] args) throws Exception {
System.out.println(new ShowEth0PrimaryIp().getEth0PrimaryIp());
}
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Redirecting...</title>
<link rel=canonical href="http://www.kehlet.cx/subnetting-is-fun/index.html">
<meta http-equiv=refresh content="0; url=http://www.kehlet.cx/subnetting-is-fun/index.html">
<h1>Redirecting...</h1>
<a href="http://www.kehlet.cx/subnetting-is-fun/index.html">Click here if you are not redirected.</a>
<script>location='http://www.kehlet.cx/subnetting-is-fun/index.html'</script>
function my_explode($delimiter, $string, $limit = null) {
$array = call_user_func_array('explode', func_get_args());
if (count($array) === 1 && strlen($array[0]) === 0) {
return array();
}
return $array;
}
@skehlet
skehlet / gist:36aad599171b25826e82
Created May 6, 2015 17:45
Show autovacuum and analyze data, including if the next autovacuum will be a freeze; and how close the table is to being force-freezed
WITH table_opts AS (
SELECT
pg_class.oid, relname, nspname, array_to_string(reloptions, '') AS relopts
FROM
pg_class INNER JOIN pg_namespace ns ON relnamespace = ns.oid
), storage_settings AS (
SELECT
oid, relname, nspname,
CASE
WHEN relopts LIKE '%autovacuum_vacuum_threshold%'
schema | table | rowcount | dead_rowcount | autovacuum_threshold | expect_autovacuum | relfrozenxid_age | autovacuum_freeze_table_age | next_autovacuum_will_be_a_freeze | autovacuum_freeze_max_age | % til forced vacuum freeze
---------+---------+----------------+----------------+----------------------+-------------------+------------------+-----------------------------+----------------------------------+---------------------------+----------------------------
public | table01 | 1,336,112,512 | 4,641,856 | 267,222,552 | | 165311956 | 1.5e+08 | yes | 2e+08 | 82.7%
public | table02 | 777,657,088 | 20,662,775 | 155,531,468 | | 165311956 | 1.5e+08 | yes | 2e+08 | 82.7%
public | table03 | 642,018,368 | 9 | 128,403,724 | | 165311956 |
mydb=> SELECT name, current_setting(name), source
mydb-> FROM pg_settings
mydb-> WHERE source NOT IN ('default', 'override');
name | current_setting | source
---------------------------------+------------------+--------------------
application_name | psql | client
archive_command | exit 0 | configuration file
archive_mode | on | configuration file
autovacuum | on | configuration file
autovacuum_analyze_scale_factor | 0.1 | configuration file
listen_addresses = '*'
port = 5432
max_connections = 300
shared_buffers = 2GB
work_mem = 10MB
maintenance_work_mem = 256MB
max_stack_depth = 8MB
wal_buffers = 16MB
checkpoint_segments = 32
checkpoint_completion_target = .9
@skehlet
skehlet / gist:fd4945f9c9ce6ed075f1
Created August 28, 2015 16:53
my non-default postgres config
psql (9.4.4)
Type "help" for help.
postgres=#
postgres=# SELECT name, current_setting(name), source
postgres-# FROM pg_settings
postgres-# WHERE source NOT IN ('default', 'override');
name | current_setting | source
---------------------------------+----------------------------------+--------------------
application_name | psql | client
SELECT
COALESCE(blockingl.relation::regclass::text,blockingl.locktype) as locked_item,
blockeda.procpid AS blocked_pid,
blockeda.current_query as blocked_query,
blockedl.mode as blocked_mode,
blockinga.procpid AS blocking_pid,
blockinga.current_query as blocking_query,
blockingl.mode as blocking_mode
FROM pg_catalog.pg_locks blockedl
JOIN pg_stat_activity blockeda ON blockedl.pid = blockeda.procpid
@skehlet
skehlet / gist:08aeed3d06f1c35bc780
Created March 17, 2016 18:58
my custom postgres settings
postgres=# SELECT version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44), 64-bit
(1 row)
postgres=# SELECT name, current_setting(name), SOURCE
postgres-# FROM pg_settings
postgres-# WHERE SOURCE NOT IN ('default', 'override');
name | current_setting | source