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
do $$ | |
declare | |
r record; | |
lMaxId bigint; | |
dbName text := 'devel'; | |
begin | |
for r in with seq as ( | |
select | |
table_name, | |
column_name, |
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
std::string json = "{\"msg\":\"There is a json in New Orleans...\"}"; | |
unsigned long n = json.length(); | |
unsigned long total = n + 5; | |
char *msg = (char *)malloc((total + 1) * sizeof(char)); | |
if (!msg || total < 6) | |
{ | |
if (msg) | |
free(msg); | |
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
unsigned long n = 12121212; | |
unsigned long len = 0; | |
char msg[5]; | |
msg[0] = (n >> 24) & 0xFF; | |
msg[1] = (n >> 16) & 0xFF; | |
msg[2] = (n >> 8) & 0xFF; | |
msg[3] = n & 0xFF; | |
msg[4] = 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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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
-- First, create a full backup | |
sqlcmd -d devel | |
use devel | |
go | |
select name,recovery_model_desc from sys.databases | |
go | |
ALTER DATABASE devel SET RECOVERY simple | |
go |
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
psql -d devel | |
-- delete duplicate rss - postgresql | |
DELETE FROM rss T1 | |
USING rss T2 | |
WHERE T1.ctid < T2.ctid | |
AND T1.rss_source_id = T2.rss_source_id | |
AND T1.title = T2.title | |
AND T1.link = T2.link; |
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
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md | |
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192 | |
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB. | |
------------ | |
-- Basics -- | |
------------ | |
-- Get indexes of tables |
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
mkdir -p $HOME/.dotfiles | |
git init --bare $HOME/.dotfiles | |
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' | |
(add this alias to .bashrc) | |
bash config config --local status.showUntrackedFiles no | |
Basic usage example: |
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 <time.h> | |
time_t rawtime; | |
struct tm * timeinfo; | |
time(&rawtime); | |
timeinfo = localtime(&rawtime); | |
setlocale(LC_ALL, "C"); | |
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", now); |
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
[mysqld] | |
datadir=D:/MariaDB 10.3/data | |
port=3306 | |
innodb_buffer_pool_size=2045M | |
log-bin=binlog | |
max-binlog-size=500M | |
server-id=1 | |
[client] | |
port=3306 | |
plugin-dir=D:/MariaDB 10.3/lib/plugin |
NewerOlder