Skip to content

Instantly share code, notes, and snippets.

View zbjdonald's full-sized avatar
🤣

Baiju Zhang zbjdonald

🤣
View GitHub Profile
@vanlooverenkoen
vanlooverenkoen / Synology CI.md
Last active October 19, 2024 13:09
Synology CI

How to set up CI with Synology

Before you start

Install packages on your Synology with the Package Manager

  • Docker
  • Git

Configure Git

@jerodg
jerodg / windows_and_office_kms_setup.adoc
Last active August 8, 2025 11:42
Activate Windows and Office Using KMS Server

Microsoft Windows and Office KMS Setup

@alimanfoo
alimanfoo / find_runs.py
Created November 5, 2017 23:53
Find runs of consecutive items in a numpy array.
import numpy as np
def find_runs(x):
"""Find runs of consecutive items in an array."""
# ensure array
x = np.asanyarray(x)
if x.ndim != 1:
raise ValueError('only 1D array supported')
#!/bin/shell
set -euo pipefail
HERE="$(pwd)"
RELEASE=${1:-"lts"}
usage() {
cat <<EOF
Usage: $1 [lts | weekly]
EOF
@mdriesch
mdriesch / fifo_bond_accounting.py
Last active November 6, 2022 13:55
Python Class for LiFo, FiFo and AVCO Accounting of bonds
"""
Copyright (C) 2017 Michael von den Driesch
This file is just a simple implementation of a python class allowing for various
*booking* types (LIFO, FIFO, AVCO)
This *GIST* is free software: you can redistribute it and/or modify it
under the terms of the BSD-2-Clause (https://opensource.org/licenses/bsd-license.html).
This program is distributed in the hope that it will be useful, but WITHOUT
@hewerthomn
hewerthomn / install-oh-my-zsh.sh
Created January 26, 2017 11:30
Offline install of oh-my-zsh on Ubuntu
main() {
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
@AtulKsol
AtulKsol / psql-error-fix.md
Last active November 13, 2024 12:43
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

@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active August 7, 2025 10:30
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@a-s-o
a-s-o / Caddyfile
Last active January 6, 2021 10:28
Single page app rewriting with Caddy server
localhost:80
gzip
ext .html
root /home/deploy/current/build/www
proxy /graphql localhost:3000
rewrite /login {
to {path} /login
}
@nicholastjohnson
nicholastjohnson / deleteFilesBySize.py
Created October 10, 2014 15:33
Python script to delete all files less than a certain size in a directory and subdirectories
import os, os.path
for root, _, files in os.walk("C:/some/dir"):
for f in files:
fullpath = os.path.join(root, f)
try:
if os.path.getsize(fullpath) < 10 * 1024: #set file size in kb
print fullpath
os.remove(fullpath)
except WindowsError: