Skip to content

Instantly share code, notes, and snippets.

View huaweigu's full-sized avatar

Huawei huaweigu

  • Circle Internet Financial
  • Boston
  • 00:35 (UTC -05:00)
View GitHub Profile
@huaweigu
huaweigu / repo-rinse.sh
Created May 17, 2023 19:12 — forked from nicktoumpelis/repo-rinse.sh
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@huaweigu
huaweigu / ssl-certs.md
Created July 8, 2018 17:24 — forked from Eng-Fouad/ssl-certs.md
Generate self-signed PKCS#12 SSL certificate and export its keys using Java keytool and openssl.

Steps to generate self-signed PKCS#12 SSL certificate and export its keys:

1- Create PKCS#12 keystore (.p12 or .pfx file)

keytool -genkeypair -keystore myKeystore.p12 -storetype PKCS12 -storepass MY_PASSWORD -alias KEYSTORE_ENTRY -keyalg RSA -keysize 2048 -validity 99999 -dname "CN=My SSL Certificate, OU=My Team, O=My Company, L=My City, ST=My State, C=SA" -ext san=dns:mydomain.com,dns:localhost,ip:127.0.0.1
  • myKeystore.p12 = keystore filename. It can with .pfx extension as well.
  • MY_PASSWORD = password used for the keystore and the private key as well.
  • CN = commonName, it will be shown as certiciate name in certificates list.
  • OU = organizationUnit, department name for example.
@huaweigu
huaweigu / safe.md
Last active September 14, 2017 12:18 — forked from bryanrite/safe.md
Safe Postgres Operations on High Volume Tables

Safe Operations For High Volume PostgreSQL

Safe

  • Add a new column
  • Drop a column
  • Rename a column
  • Add an index concurrently (Example), Note: it will still take a long time to run the migration, but it won't write-lock the table.
  • Drop a constraint (for example, non-nullable)
  • Add a default value to an existing column
@huaweigu
huaweigu / gist:8298b3df1d80b4e6c2b1
Created December 8, 2015 20:15 — forked from petetronic/gist:c6274f33ffea1c7d1956
PostgreSQL conditional anonymous code block
DO $$
DECLARE updated_rows INT;
BEGIN
UPDATE some_table
SET some_column = 'new'
WHERE some_column = 'old';
GET DIAGNOSTICS updated_rows = ROW_COUNT;