Skip to content

Instantly share code, notes, and snippets.

View kayode-adechinan's full-sized avatar

Kayode Adechinan kayode-adechinan

  • Dakar, Senegal
View GitHub Profile
@kayode-adechinan
kayode-adechinan / psql-error-fix.md
Created April 17, 2020 12:51 — forked from AtulKsol/psql-error-fix.md
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

input, textarea {
outline: none;
border:1px solid #ccc !important;
box-shadow:none !important;
}
@kayode-adechinan
kayode-adechinan / java8-one-liners-for-statistical-properties.md
Created October 26, 2019 23:58 — forked from asela38/java8-one-liners-for-statistical-properties.md
Java 8 One liners for statistical properties : Mean, Mode, Median(Q2), Q1, Q2, Variance, Standard Deviation

While working on a Hacker Rank Problem I wrote few one lines using java stream to find mean, median, mode, Q1, Q3, variance and standard deviation. Thought to share since it's quite interesting.

        // mean
        double mean = list.stream().mapToInt(Integer::intValue).average().getAsDouble();
        System.out.println(mean);
        
        // mode - create count map using group by and sorted with custom comparator to give minimum from competing probable mode values
        Integer mode = list.stream()
                .collect(Collectors.groupingBy(i -> i, () -> new TreeMap<Integer, Long>(), Collectors.counting()))
@kayode-adechinan
kayode-adechinan / upload-a-file.MD
Created August 21, 2019 10:04 — forked from ahmadawais/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@kayode-adechinan
kayode-adechinan / geo.js
Created August 5, 2019 10:28 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@kayode-adechinan
kayode-adechinan / IntelliJ_IDEA__Perf_Tuning.txt
Created July 24, 2019 21:37 — forked from P7h/IntelliJ_IDEA__Perf_Tuning.txt
Performance tuning parameters for IntelliJ IDEA. Add these params in idea64.exe.vmoptions or idea.exe.vmoptions file in IntelliJ IDEA. If you are using JDK 8.x, please knock off PermSize and MaxPermSize parameters from the tuning configuration.
-server
-Xms2048m
-Xmx2048m
-XX:NewSize=512m
-XX:MaxNewSize=512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1
# Create appservice plan named DjangoServicePlan
$ az appservice plan create -g DjangoAppRG -n DjangoServicePlan --is-linux --number-of-workers 1 --sku S1 -l westeurope
# Create App Service named DjangoDemoAZ
$ az webapp create --resource-group DjangoAppRG --plan DjangoServicePlan --name DjangoDemoAZ --runtime "PYTHON|3.7" --deployment-local-git
# (optional) Disable ARR DjangoDemoAZ & force HTTPs
$ az webapp update --name DjangoDemoAZ --resource-group DjangoAppRG --client-affinity-enabled false --https-only true
# (optional) Enable HTTP 2.0, Disable FTP(s) deployment capability and "Always On" mode
# Create resource group named DjangoAppRG
$ az group create --name DjangoAppRG --location "West Europe"
# Create Azure Database for PostgreSQL server named pgdemoserver
$ az postgres server create --resource-group DjangoAppRG --name pgdemoserver --location westeurope --admin-user myadmin --admin-password ThisIs4P4ssw0rd!=1 --sku-name B_Gen5_1
# Allow access to Azure services
$ az postgres server firewall-rule create -g DjangoAppRG -s pgdemoserver -n allowall --start-ip-address 0.0.0.0 --end-ip-address 255.255.255.255
# not recommended
#!/bin/bash
#######################################################################
#
# Solus OS system setup
#
#######################################################################
# Go into a temp work directory
mkdir ~/tmp-installer

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream