Skip to content

Instantly share code, notes, and snippets.

@lrvick
lrvick / github-troll.md
Last active April 1, 2025 08:14
Trolling Github's DMCA repo with their own security flaws.
@ScribbleGhost
ScribbleGhost / Privacy links you might want to check out.md
Last active August 13, 2024 16:50
👀 Privacy links you might want to check out...
@3isenHeiM
3isenHeiM / MDNS_jail_FreeNAS
Last active July 27, 2022 21:26
Enable MDNS on a FreeNAS/BSD jail. That will allow a Avahi name resolution of the jail in the local network.
freenas# jls
JID IP Address Hostname Path
...
5 - etherpad /mnt/basin/jails/etherpad
...
freenas# ./mdns.sh 5
Updating FreeBSD repository catalogue...
[etherpad] Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
[etherpad] Fetching packagesite.txz: 100% 6 MiB 5.9MB/s 00:01
@eugene-babichenko
eugene-babichenko / Makefile
Created September 28, 2019 13:33
Makefile for building version strings from Git data and including that version numbers into go programs
TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d")
VERSION := $(TAG:v%=%)
ifneq ($(COMMIT), $(TAG_COMMIT))
VERSION := $(VERSION)-next-$(COMMIT)-$(DATE)
endif
ifeq $(VERSION,)
VERSION := $(COMMIT)-$(DATA)
@pjeby
pjeby / shelldown-demo
Last active March 14, 2025 19:26
"You got your markdown in my shell script!" "No, you got your shell script in my markdown!"

Mixed Markdown and Shell Scripting

: By the power of this magic string: ex: set ft=markdown ;:<<'```shell' #, this file is now both a markdown document and an executable shell script. chmod +x it and try running it!

The above line does just what it says. More specifically, when placed within in the first 5 lines and preceded only by blank lines or #-prefixed markdown headers:

  1. The first part of the magic string makes github and various editors (e.g. atom with the vim-modeline packge) treat the file as having markdown syntax (even if the file doesn't have an extension)
  2. The second part (if run in a shell), makes the shell skip execution until it encounters the next ```shell block.

(The line also has to start with a : so that it's valid shell code.)

@mratsim
mratsim / extract-ff-cookies.sh
Created November 27, 2016 12:21
Extract cookies from Firefox
#!/bin/bash
#extract_cookies.sh $HOME/.mozilla/firefox/*/cookies.sqlite > /tmp/cookies.txt
#wget --load-cookies=/tmp/cookies.txt http://mysite.com
# OR
#curl --cookie /tmp/cookies.txt http://mysite.com
function cleanup {
rm -f $TMPFILE
@EnigmaCurry
EnigmaCurry / vpn_namespace.md
Created April 7, 2016 02:28
OpenVPN and browser specific network routing with ip netns

OpenVPN and browser specific network routing with ip netns

Create network bridge

A network bridge allows us to have a virtual router that we can plug multiple network interfaces into. The IP address is assigned to the bridge rather than the individual network interface.

Create the bridge device, br0 :

@Potherca
Potherca / debug-bash-scripts.md
Last active January 10, 2024 21:29
Sometimes you want to be able to debug a bash script. This gist gives an example of how to do this.

Introduction

Sometimes you want to be able to debug a bash script. Usually the -x option will suffice but sometimes something more sophisticated is needed.

In such instances using the DEBUG trap is often a good choice.

Attached to this gist is a example script to demonstrate how such a thing would work.

@andrewgross
andrewgross / Makefile
Created August 13, 2015 15:22
Git Tagging in Makefile
tag:
@if [ $$(git rev-list $$(git describe --abbrev=0 --tags)..HEAD --count) -gt 0 ]; then \
if [ $$(git log -n 1 --oneline $$(git describe --abbrev=0 --tags)..HEAD CHANGELOG.md | wc -l) -gt 0 ]; then \
git tag $$(python setup.py --version) && git push --tags || echo 'Version already released, update your version!'
else \
echo "CHANGELOG not updated since last release!"; \
exit 1; \
fi; \
else \
echo "No commits since last release!"; \
@tvlooy
tvlooy / unit.sh
Last active May 4, 2025 03:31
Bash test: get the directory of a script
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else