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
#include <stdio.h> | |
#include <strings.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <unistd.h> | |
char * ameba(char * s1, char * s2); | |
int main(void) { | |
time_t rawtime; |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"os/exec" | |
"os" | |
"strings" | |
"github.com/jroimartin/gocui" | |
"time" |
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
-- Upgrading old partitioning with ALTER TABLEs and PLPGSQL. | |
-- IN: _orig_table - master table which should be upgraded | |
-- IN: _partkey - column which used as partition key | |
-- IN: _seq_col - sequence column | |
CREATE OR REPLACE FUNCTION fn_upgrade_partitioning(_orig_table text, _partkey text, _seq_col text) RETURNS void AS | |
$function$ | |
DECLARE | |
_new_table text = _orig_table ||'_new'; -- parent relation's name | |
_child_table text; -- child relation's name | |
_v_from timestamp without time zone; |
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
-- Function used for upgrading old (inheritance) partitioning to new (declarative). | |
-- Partitions have names like partition_XX_YY. | |
create or replace function fn_upgrade_partitioning(_oname text, _partkey text) returns void as | |
$$ | |
declare | |
_nname text = _oname ||'_new'; -- name of the new parent relation | |
_cname text; -- name of the child relation | |
_min_border bigint; | |
_max_border bigint; | |
begin |
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 table_opts AS ( | |
SELECT | |
c.oid, c.relname, c.relfrozenxid, c.relminmxid, n.nspname, array_to_string(c.reloptions, '') AS relopts | |
FROM pg_class c | |
INNER JOIN pg_namespace n ON c.relnamespace = n.oid | |
WHERE c.relkind IN ('r', 't') AND n.nspname NOT IN ('pg_catalog', 'information_schema') AND n.nspname !~ '^pg_temp' | |
), | |
vacuum_settings AS ( | |
SELECT | |
oid, relname, nspname, relfrozenxid, relminmxid, |
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
SELECT | |
now()-pg_postmaster_start_time() "Uptime", now()-stats_reset "Since stats reset", | |
round(100.0*checkpoints_req/total_checkpoints,1) "Forced checkpoint ratio (%)", | |
round(np.min_since_reset/total_checkpoints,2) "Minutes between checkpoints", | |
round(checkpoint_write_time::numeric/(total_checkpoints*1000),2) "Average write time per checkpoint (s)", | |
round(checkpoint_sync_time::numeric/(total_checkpoints*1000),2) "Average sync time per checkpoint (s)", | |
round(total_buffers/np.mp,1) "Total MB written", | |
round(buffers_checkpoint/(np.mp*total_checkpoints),2) "MB per checkpoint", | |
round(buffers_checkpoint/(np.mp*np.min_since_reset*60),2) "Checkpoint MBps", | |
round(buffers_clean/(np.mp*np.min_since_reset*60),2) "Bgwriter MBps", |
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
/* This example used in the following scenario: | |
* 1. there are several sets of files. | |
* 2. we need to choose specific set. | |
* 3. handle files from this set in the loop. | |
*/ | |
#include<stdio.h> | |
int main() | |
{ |
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
CREATE SCHEMA IF NOT EXISTS pgcenter; | |
CREATE OR REPLACE FUNCTION pgcenter.get_netdev_link_settings(INOUT iface VARCHAR, OUT speed INT, OUT duplex INT) AS $$ | |
use Linux::Ethtool::Settings; | |
if (my $settings = Linux::Ethtool::Settings->new($_[0])) { | |
my $if_speed = $settings->speed(); | |
my $if_duplex = $settings->duplex() ? 1 : 0; | |
return {iface => $_[0], speed => $if_speed, duplex => $if_duplex}; | |
} else { | |
return {iface => $_[0], speed => 0, duplex => -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
# Terminate long transactions | |
*/10 * * * * psql -d postgres -tx -c "SELECT pg_terminate_backend(pid),now(),now()-xact_start as duration,* from pg_stat_activity where (now() - pg_stat_activity.xact_start) > '1 hour'::interval and usename NOT IN ('postgres', 'backuper') and state<>'idle'" | grep -vE '^(|\(No rows\))$' | |
* * * * * psql -d postgres -tx -c "SELECT pg_terminate_backend(pid),now(),now()-xact_start as duration,* from pg_stat_activity where (now() - pg_stat_activity.xact_start) > '1 min'::interval and usename NOT IN ('postgres', 'backuper', 'cron_user') and state<>'idle'" | grep -vE '^(|\(No rows\))$' |
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
#include <stdio.h> | |
#include <ncurses.h> | |
#include <limits.h> /* INT_MAX */ | |
#include <unistd.h> /* sleep */ | |
int main (void) | |
{ | |
int i = 0; | |
WINDOW * w1, * w2; | |
initscr(); |