Moved: https://notes.wilspi.com/wiki/dev/technologies/database/postgres/cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir="$1" | |
for f in "$dir"/*; do | |
#filename="${cat '$f'}" | |
filename=${f:13:10} # string of length 10 from index 13 | |
arrIN=(${filename//-/ }) # split by "-" | |
reversefilename="${arrIN[2]}-${arrIN[1]}-${arrIN[0]}" | |
reversef="journal/2021/${reversefilename}.md" | |
mv $f $reversef | |
#echo $reversefilename | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Middleware to log `*/api/*` requests and responses. | |
""" | |
import socket | |
import time | |
import json | |
import logging | |
request_logger = logging.getLogger(__name__) |
Tested using PyCharm PyCharm 2018.3.7 (Professional Edition).
Note: Commands that are being run, need to be run in nix shell
-
Python:
- Run
which python
and update this in Preferences -> Project:project_name
-> Project Interpreter -> Gear Icon -> Add -> Virtual Environment -> Existing Environment ->...
-> Add.
- Run
-
Rust:
If using Catalina
sudo mkdir -p /System/Volumes/Data/nix
sudo chown -R `whoami` /System/Volumes/Data/nix
echo "nix\t/System/Volumes/Data/nix" | sudo tee /etc/synthetic.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sudo apt-get install libfontenc1 xfonts-75dpi xfonts-base xfonts-encodings xfonts-utils openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y | |
# https://github.com/wkhtmltopdf/wkhtmltopdf/releases | |
if [ "$(uname -s)" = "Darwin" ]; then | |
# For Mac | |
cd ~ | |
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.macos-cocoa.pkg | |
sudo installer -verbose -pkg wkhtmltox-0.12.5-1.macos-cocoa.pkg -target / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install nix via yay (AUR helper) | |
yay -S archlinux-nix | |
# Read: https://nixos.org/nix/manual/#ssec-multi-user | |
# Add nix builder groups | |
sudo groupadd -r nixbld | |
for n in $(seq 1 10); do sudo useradd -c "Nix build user $n" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
pub enum Superheroes { | |
Superman(Superman), | |
Batman(Batman) | |
} | |
#[derive(Debug)] | |
pub struct Superman { | |
id: i32, | |
name: String, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Script to run UDP Server on 127.0.0.1:8126 | |
# This mocks statsd server for testing | |
import socket | |
UDP_IP_ADDRESS = "127.0.0.1" | |
UDP_PORT_NO = 8126 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from selenium import webdriver | |
from bs4 import BeautifulSoup | |
def getPage(url): | |
# open with chromedriver | |
browser = webdriver.Chrome() | |
browser.get(url) |
NewerOlder