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
#!/usr/bin/env python3 | |
""" | |
formatting with double width characters | |
""" | |
import unicodedata | |
def shorten_string_cjk(intput_string, width, placeholder='..'): |
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 btree_index_atts AS ( | |
SELECT nspname, relname, reltuples, relpages, indrelid, relam, | |
regexp_split_to_table(indkey::text, ' ')::smallint AS attnum, | |
indexrelid as index_oid | |
FROM pg_index | |
JOIN pg_class ON pg_class.oid=pg_index.indexrelid | |
JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace | |
JOIN pg_am ON pg_class.relam = pg_am.oid | |
WHERE pg_am.amname = 'btree' | |
), |
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
/** | |
* Convert a string with B/K/M/etc into a byte number | |
* @param {String|Number} bytes Any string with B/K/M/etc | |
* @return {String|Number} A byte number, or original string as is | |
*/ | |
function stringByteFormat(bytes) | |
{ | |
// if anything not string return | |
if (!(typeof bytes === 'string' || bytes instanceof String)) { | |
return bytes; |
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
#!/usr/bin/perl | |
# AUTHOR: Clemens Schwaighofer | |
# DATE: 2015/8/6 | |
# DSCRIPTION: | |
# Runs a query from a file or command line and outputs the data to a CSV file | |
# Runs query async/and CURSOR | |
use strict; | |
use warnings; |
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 | |
folder=${1}; | |
diff=1; | |
sleeptime=5; | |
if [ ! -d "${folder}" ]; then | |
echo "Folder: ${folder} not found"; | |
exit; | |
fi; |
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
{ | |
"php_log": { | |
"title": "PHP error log format", | |
"description": "Error Log format used by PHP (and PHP-FPM)", | |
"url": "http://www.php.net/", | |
"regex": { | |
"general": { | |
"pattern": "^\\[(?<date>\\d{2}-\\w{3}-\\d{4}) (?<timestamp>\\d{2}:\\d{2}:\\d{2}) (?<timezone>\\w+(\\/\\w+)?)\\] (?<level>PHP [\\w ]+): (?<body>.*)" | |
}, | |
"dump": { |
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
{ | |
"web_dev": { | |
"title": "Web Development Log", | |
"description": "Development log from CoreLibs\\Basic Class", | |
"url": "http://www.egplusww.jp/", | |
"regex": { | |
"general": { | |
"pattern": "^\\[(?<date>\\d{4}-\\d{2}-\\d{2}) (?<timestamp>\\d{2}:\\d{2}:\\d{2}\\.\\d{8})\\] \\[(?<server>[\\w.]+)\\] \\[(?<sourcefile>\\/([A-Za-z0-9-_.]+\\/)+([A-Za-z0-9-_. ]+\\.(inc|php)))\\] \\[(?<puid>[\\w]+)\\] \\{(?<namespaceclass>[\\w]+(\\\\[\\w]+)*)\\} <(?<muid>[\\w ]+)> - (?<body>.*)" | |
} | |
}, |
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
{ | |
"rsync": { | |
"title": "rsync log", | |
"description": "rsync transfer and progress logs", | |
"url": "http://www.egplusww.jp/", | |
"regex": { | |
"rsync": { | |
"pattern": "^(?<date>\\d{4}/\\d{2}/\\d{2}) (?<timestamp>\\d{2}:\\d{2}:\\d{2}) \\[(?<opid>\\d+)\\] (?<body>.*)" | |
}, | |
"progress": { |
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
find ./ -type f -print0 | xargs -0 stat -f '%Sm %z' -t "%Y" | awk 'function human(x) {s=" B KB MB GB TB EB PB YB ZB"; while (x>=1024 && length(s)>1){x/=1024; s=substr(s,4)} s=substr(s,1,4); xf=(s==" B ")?"%d ":"%.2f"; return sprintf( xf"%s", x, s);}{sum[$1]+= $2;}END{for (date in sum){printf ("%s %s\n", date, human(sum[date]));}}' | sort |
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 OR REPLACE FUNCTION copy_progress(from_date DATE, to_date DATE, p_precision INT DEFAULT 1) RETURNS "varchar" | |
AS $$ | |
DECLARE | |
status VARCHAR; -- return status | |
my_rec RECORD; -- transfer record | |
-- progress info | |
pos INT := 1; -- current position | |
row_count INT := 0; -- overall row count (max) | |
percent NUMERIC; -- output percent | |
old_percent NUMERIC := 0.0; -- previous percent |
NewerOlder