Skip to content

Instantly share code, notes, and snippets.

@yangminzhu
yangminzhu / egress-mtls-authz.yaml
Created September 18, 2020 06:28
Example policies to enforce mTLS between sidecar and egress gateway
# Example policies to enforce mTLS between sidecar and egress gateway, the connection between sidecar
# and egress gateway could be:
# 1. plaintext in (Istio) mTLS or
# 2. TLS in (Istio) mTLS;
# An AuthorizationPolicy is applied on egress gateway to enforce egress access control.
---
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
name: httpbin-org-ext
@nealfennimore
nealfennimore / wireguard.conf
Last active April 3, 2024 09:49
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@lmakarov
lmakarov / lambda-basic-auth.js
Created August 30, 2017 19:15
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@sharu725
sharu725 / subscribe-form.html
Last active December 7, 2023 20:36
Jekyll Subscribe Form using Mailchimp
<!--
Before implementing this jekyll snippet make sure
1. you have signed up with Mailchimp.
2. you have created a list in Mailchimp.
3. you have defined the list in _config.yml,
for ex: "mailchimp-list: //redgadgets.us10.list-manage.com/subscribe/post?u=210acce5db69d3d4a04b0e25d&amp;id=08c6708f40"
-->
<form action="{{site.mailchimp-list}}" method="post" name="mc-embedded-subscribe-form" class="wj-contact-form validate" target="_blank" novalidate>
<div class="mc-field-group">
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active May 3, 2024 11:43
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@thomasfinch
thomasfinch / nightShiftControl.sh
Created April 3, 2017 18:40
Bash script to enable/disable night shift on Mac OS
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 [enable|disable]"
exit 1
fi
plistLoc="/private/var/root/Library/Preferences/com.apple.CoreBrightness.plist"
currentUserUID=$(dscl . -read /Users/$(whoami)/ GeneratedUID) # Get the GeneratedUID for the current user
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active April 19, 2024 12:30
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@trestletech
trestletech / instance-types.sh
Created June 15, 2016 16:41
Get all EC2 Instance Types in All Availability Zones
#!/bin/bash
echo "Getting list of Availability Zones"
all_regions=$(aws ec2 describe-regions --output text --query 'Regions[*].[RegionName]' | sort)
all_az=()
while read -r region; do
az_per_region=$(aws ec2 describe-availability-zones --region $region --query 'AvailabilityZones[*].[ZoneName]' --output text | sort)
while read -r az; do
@engelmarkus
engelmarkus / gtkmm-example.cpp
Created May 18, 2016 22:31
Creating a window with gtkmm 3 and a glade description.
// g++ -std=c++14 -o gtkmm-example gtkmm-example.cpp `pkg-config --cflags --libs gtkmm-3.0`
#include <memory>
#include <gtkmm.h>
class MainWindow : public Gtk::ApplicationWindow {
public:
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
: Gtk::ApplicationWindow(obj)
, builder{builder}
@lalibi
lalibi / Set-WindowState.ps1
Last active August 26, 2023 04:25 — forked from Nora-Ballard/Set-WindowState.ps1
Hide, Show, Minimize, Maximize, etc window from Powershell.
function Set-WindowState {
<#
.LINK
https://gist.github.com/Nora-Ballard/11240204
#>
[CmdletBinding(DefaultParameterSetName = 'InputObject')]
param(
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[Object[]] $InputObject,