Skip to content

Instantly share code, notes, and snippets.

@sarthology
sarthology / regexCheatsheet.js
Created January 10, 2019 07:54
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@chrisswanda
chrisswanda / WireGuard_Setup.txt
Last active April 16, 2024 12:18
Stupid simple setting up WireGuard - Server and multiple peers
Install WireGuard via whatever package manager you use. For me, I use apt.
$ sudo add-apt-repository ppa:wireguard/wireguard
$ sudo apt-get update
$ sudo apt-get install wireguard
MacOS
$ brew install wireguard-tools
Generate key your key pairs. The key pairs are just that, key pairs. They can be
@rasschaert
rasschaert / !renew-certificate.sh
Last active April 11, 2024 23:38
Automatic renewal of let's encrypt certificates using docker containers and luadns
#!/bin/bash
# Set PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Run the certbot container to renew the certs
docker-compose -f /opt/docker/certbot/docker-compose.yml run --rm certbot
# Concatenate the resulting certificate chain and the private key and write it to HAProxy's certificate file.
cat /opt/docker/certbot/certbot/etc/letsencrypt/live/example.org/{fullchain,privkey}.pem > /opt/docker/haproxy/ssl/example_org.pem
#!/usr/bin/env node
const
express = require( 'express' ),
app = express(),
passport = require( 'passport' ),
LocalStrategy = require( 'passport-local' ).Strategy,
bodyParser = require( 'body-parser' );
app.use( bodyParser.urlencoded( { extended: true } ) );
@Firsh
Firsh / lwp-cloudflare-dyndns.sh
Last active January 6, 2024 15:38
Cloudflare as Dynamic DNS
#!/bin/bash
# Cloudflare as Dynamic DNS
# From: https://letswp.io/cloudflare-as-dynamic-dns-raspberry-pi/
# Based on: https://gist.github.com/benkulbertis/fff10759c2391b6618dd/
# Original non-RPi article: https://phillymesh.net/2016/02/23/setting-up-dynamic-dns-for-your-registered-domain-through-cloudflare/
# Update these with real values
auth_email="email@example.com"
auth_key="global_api_key_goes_here"
zone_name="example.com"
@chrisstubbs93
chrisstubbs93 / ffmpeg.sh
Last active January 11, 2024 22:40
auto-restart FFMPEG when it stops sending frames to youtube
#!/bin/sh
sleep 5
ffmpeg -re -f mjpeg -r 10 -i "http://localhost/?action=stream" -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -acodec aac -ab 1k -strict experimental -s 640x360 -vcodec h264 -pix_fmt yuv420p -g 20 -vb 500k -preset ultrafast -crf 31 -r 10 -f flv "rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx" 2> /home/pi/ffmpeg.log
@jaytaylor
jaytaylor / ._README.md
Last active March 4, 2024 23:39
URL Encoding in pure bash / sed.
@tdr2d
tdr2d / docker_cleanup.sh
Last active March 10, 2021 01:37
Remove all unused docker containers, remove all docker volumes, cleanup networks
#!/usr/bin/env bash
removevolumes() {
sudo docker volume rm $(sudo docker volume ls -qf dangling=true)
sudo docker volume ls -qf dangling=true | xargs -r sudo docker volume rm
}
removenetwork() {
sudo docker network ls
sudo docker network ls | grep "bridge"
@carlos22
carlos22 / install-syncthing-smartos.md
Last active November 10, 2018 16:38
install syncthing on smartos
pkgin update
pkgin in syncthing
groupadd users
useradd -d /srv/syncthing -c "syncthing user" -s /usr/bin/false -g users synctg
mkdir -p /srv/syncthing
chown synctg:users /srv/syncthing
svccfg import syncthing.xml
svcadm enable syncthing
@julianpoy
julianpoy / .Xresources
Created May 17, 2018 06:05
X1C6 DPI Linux
Xft.dpi: 160
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb