Skip to content

Instantly share code, notes, and snippets.

Avatar
🎸
hard as a rock

Christian Castelli chrisvoo

🎸
hard as a rock
View GitHub Profile
@chrisvoo
chrisvoo / jsoup_examples.java
Last active Jan 12, 2021
GET/POST HTTP request and HTML parsing with Jsoup library
View jsoup_examples.java
import java.io.IOException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@chrisvoo
chrisvoo / pgsql_administration.sh
Last active Oct 6, 2016
psql/pg_dump administration commands
View pgsql_administration.sh
# dump of your database in plain text. It creates tables, views, etc
# for exporting multiple tables only, you can repeat parameter -t
pg_dump --host <IP> --port 5432 --username "myuser" \
--format plain --create --encoding UTF8 -v \
--file "/my/path/file.sql" "db_name"
# or, with short opts and wrapping all SQL statements inside a transaction with automatic ROLLBACK
psql -U postgres -p 5433 --single-transaction -f /my/path/file.sql db_name
# Import of a SQL dump. Be sure to have write permissions in the current directory
@chrisvoo
chrisvoo / pgsql_cheatsheet.sql
Last active Apr 22, 2017
PostgreSQL cheat sheet
View pgsql_cheatsheet.sql
-- QUERIES OPERATIONS
----------------------------------------------------------------------------------
-- KILL ALL sessions FOR A DATABASE
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();
-- GETTING RUNNING QUERIES, version: 9.2+
You can’t perform that action at this time.