Skip to content

Instantly share code, notes, and snippets.

@huytd
huytd / wordle.md
Last active May 2, 2024 12:13
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@m-radzikowski
m-radzikowski / script-template.sh
Last active April 25, 2024 18:43
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@ctron
ctron / tekton-cleanup.yaml
Last active March 17, 2024 02:20
Cleaning up Tekton pipeline runs
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: cleaner
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cleaner
@jaumef
jaumef / status.sh
Last active May 17, 2021 07:37
Check status of repo and reformat + check typing
#!/bin/bash
# Link/copy this file to your bin folder so you can run this easily
#
# ln -s $PWD/status.sh ~/.local/bin/status
pyfiles=$(git status -s | grep -vE '^ ?[DR] ' | awk {'print $2'} | grep '.py')
if [[ $pyfiles ]]
then
@abbaspour
abbaspour / nginx.conf
Last active February 4, 2024 19:20
Guide how to enable JWT validation on open source nginx server using ngx-http-auth-jwt-module
daemon off;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@ryanburnette
ryanburnette / Caddyfile
Last active May 3, 2024 06:36
Caddy v2.1+ CORS whitelist
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
@blaurt
blaurt / latLonToOffsets.js
Last active March 28, 2022 17:30
transformAndPoint.js
/**
* @param {number} latitude in degrees
* @param {number} longitude in degrees
* @param {number} mapWidth in pixels
* @param {number} mapHeight in pixels
*/
function latLonToOffsets(latitude, longitude, mapWidth, mapHeight) {
const FE = 180; // false easting
const radius = mapWidth / (2 * Math.PI);
@kevineinarsson
kevineinarsson / 91-pulseaudio-custom.rules
Last active February 10, 2022 01:38
MBP 16,1 System configuration files for the T2 audio driver (https://github.com/MCMrARM/mbp2018-bridge-drv/)
SUBSYSTEM!="sound", GOTO="pulseaudio_end"
ACTION!="change", GOTO="pulseaudio_end"
KERNEL!="card*", GOTO="pulseaudio_end"
SUBSYSTEMS=="pci", ATTRS{vendor}=="0x106b", ATTRS{device}=="0x1803", ENV{PULSE_PROFILE_SET}="apple-t2.conf"
LABEL="pulseaudio_end"
@nstarke
nstarke / netgear-private-key-disclosure.md
Last active April 30, 2024 06:02
Netgear TLS Private Key Disclosure through Device Firmware Images

Netgear Signed TLS Cert Private Key Disclosure

Overview

There are at least two valid, signed TLS certificates that are bundled with publicly available Netgear device firmware.

These certificates are trusted by browsers on all platforms, but will surely be added to revocation lists shortly.

The firmware images that contained these certificates along with their private keys were publicly available for download through Netgear's support website, without authentication; thus anyone in the world could have retrieved these keys.

@denis-ryzhkov
denis-ryzhkov / patch_graphene_django_JSONField_converter.py
Last active February 24, 2021 04:34
Ask `graphene_django` to convert `JSONField` to `GenericScalar` (JSON as is) instead of default `JSONString`
from django.contrib.postgres.fields import JSONField
from graphene.types.generic import GenericScalar
from graphene.utils.str_converters import to_camel_case, to_snake_case
from graphene_django.converter import convert_django_field
def patch_graphene_django_JSONField_converter(auto_camel_case=True):
"""
Ask `graphene_django` to convert `JSONField` to `GenericScalar` (JSON as is) instead of default `JSONString`