Skip to content

Instantly share code, notes, and snippets.

View laminko's full-sized avatar
...

La Min Ko laminko

...
View GitHub Profile
@AtulKsol
AtulKsol / psql-error-fix.md
Last active September 30, 2025 18:28
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@revbucket
revbucket / psycopg_load.md
Created October 7, 2016 21:38
psycopg2 bulk loading

Bulk Loading from Python to Postgres

Here at MaestroIQ we deal with large amounts of user data as we need impression-level information to generate an accurate picture of our customer’s user’s paths to purchase. We store all this data in a postgres 9.3 instance. I’m hesitant to call it “big data,” but our largest tables have over 500M rows, occupying over 200GB of disk space (if you include the indices), so performance is a very real issue that we have to worry about. We are also a python shop on the backend. All of our production code that manages data analytics and machine learning is python, as well as the code that controls our ETL workflow. To interact with our Postgres instances, we use the psycopg2 package. It’s my hope through this post to share some tips, tricks, and best practices we’ve discovered by heavily using psycopg2.

Bulk loading

In dealing with large postgres tables, one has to first make them large. Bulk-loading is an extremely common task, and as we’ll see, there are good ways and

@oinopion
oinopion / read-access.sql
Created October 5, 2016 13:00
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@Edenhofer
Edenhofer / fix_compilation_errors_encountered_with_kernel_4.6.patch
Created July 26, 2016 13:26
mt7610u_sta-dkms-git: Fix compilation errors encountered with kernel 4.6
From 9738b5ebd677ec5fff3be4ba83e76488b66f076b Mon Sep 17 00:00:00 2001
From: Gordian Edenhofer <[email protected]>
Date: Tue, 26 Jul 2016 15:05:18 +0200
Subject: [PATCH] Fix compilation errors encountered with kernel 4.6
Inspired by Rene Ploetz's <[email protected]> patch for chenhaiq's repository.
Signed-off-by: Gordian Edenhofer <[email protected]>
---
chips/mt76x0.c | 2 +-
#!/bin/bash
echo 'Requires Ubuntu = 16.04 and installs Nginx + uWSGI + Web2py'
# Check if user has root privileges
if [[ $EUID -ne 0 ]]; then
echo "You must run the script as root or using sudo"
exit 1
fi
# parse env vars
WEB2PY_PASS="${WEB2PY_PASS:-0}"
NOPASSWORD="${NOPASSWORD:-0}"
@subfuzion
subfuzion / curl.md
Last active October 11, 2025 00:58
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@straker
straker / two-way-binding.js
Last active October 14, 2024 19:31
Simple and small two-way data binding between DOM and data
/**
* @param {object} scope - Object that all bound data will be attached to.
*/
function twoWayBind(scope) {
// a list of all bindings used in the DOM
// @example
// { 'person.name': [<input type="text" data-bind="person.name"/>] }
var bindings = {};
// each bindings old value to be compared for changes
@seinlin
seinlin / gist:f8fa3e10f46aaeede6f3
Last active October 5, 2016 05:46
Upgrade flame and install Myanmar keyboard.
1.
Enable developer menu.
Settings -> Device information -> More Information -> Developer Menu (enabled)
Settings -> Developer -> Debugging via USB (select ADB and DevTools)
(Note: adb can't access the device while it is in locked state.)
2.
Download and update base image (Base image v188.zip) from
https://developer.mozilla.org/en-US/Firefox_OS/Phone_guide/Flame/Updating_your_Flame
@andjc
andjc / myanmar.css
Last active November 16, 2020 02:13
Skeleton CSS file for languages written in the Myanmar script.
/* @import url(http://fonts.googleapis.com/earlyaccess/notosansmyanmar.css); */
/* @import url(http://fonts.googleapis.com/earlyaccess/padauk.css); */
@counter-style hyphen {
system: cyclic;
symbols: "-";
suffix: " ";
}
@counter-style myanmar-parens {