Skip to content

Instantly share code, notes, and snippets.

@lmas
lmas / unbound_blocklist.sh
Last active June 25, 2023 15:45
Script to generate a blocklist zone file for unbound DNS server
#!/bin/sh
# Inspired by:
# https://old.reddit.com/r/PFSENSE/comments/9mipe0/unboundbased_dnsblacklisting/
# https://news.ycombinator.com/item?id=22854209
#
# With lotsa code stolen from:
# https://www.tumfatig.net/20190405/blocking-ads-using-unbound8-on-openbsd/
#
# Comment filter syntax from:
@lmas
lmas / decrapifier.ps1
Created January 25, 2020 13:17
Windows 10 Decrapifier
# SOURCE AND AUTHOR:
# https://community.spiceworks.com/scripts/show/4378-windows-10-decrapifier-18xx-19xx
#
#Windows 10 Decrapifier 1803/1809
#By CSAND
#June 21 2019
#
#
#PURPOSE: Eliminate much of the bloat that comes with Windows 10. Change many privacy settings to be off by default. Remove built-in advertising, Cortana, OneDrive, Cortana stuff (all optional). Disable some data collection.
# Clean up the start menu for new user accounts. Remove a bunch of pre-installed apps, or all of them (including the store). Create a more professional looking W10 experience. Changes some settings no longer
@lmas
lmas / generate_token.go
Last active November 14, 2019 16:06
Generate random, hex encoded tokens
package main
import (
"crypto/rand"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"fmt"
"time"
)
@lmas
lmas / Dockerfile
Created April 2, 2019 21:01
Minimalist dockerfile for running standalone binaries
FROM alpine:3.9 AS builder
RUN apk add --no-cache ca-certificates && \
mkdir -p /build/etc/ssl/certs && \
cp /etc/ssl/certs/ca-certificates.crt /build/etc/ssl/certs/ && \
echo 'app:x:2000:2000::/:' > /build/etc/passwd && \
echo 'app:x:2000:' > /build/etc/group && \
mkdir /data
################################################################################
@lmas
lmas / crt.css
Created March 24, 2019 18:45
Add CRT scanlines, screen flicker and color separation effects
/*Stolen from http://aleclownes.com/2017/02/01/crt-display.html*/
/*This adds a "crt scanlines" effect to the screen*/
.crt-scanlines::before {
content: " ";
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
@lmas
lmas / http_utils.go
Created November 28, 2018 21:18
Some simple http utils (http handlers with errors, secure cookies)
import (
"net/http"
"time"
"github.com/gorilla/securecookie"
)
type WebError struct {
Code int
Err error
@lmas
lmas / api_client.go
Created January 1, 2018 13:17
Simple API client with json parsing, gzip compression, ratelimit and oauth tokens
package main
import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@lmas
lmas / summarize.go
Created September 28, 2017 18:23
Summarizes text
import (
"strings"
"github.com/JesusIslam/tldr"
)
func Summarize(text string) (string, float64, error) {
sum := tldr.New()
tmp, err := sum.Summarize(text, 6)
if err != nil {
@lmas
lmas / rng_imager.go
Created September 8, 2017 16:29
Simple attempt at visual analysis of RNG sources
package main
// Inspiration: https://www.random.org/analysis/
import (
"image"
"image/color"
"image/png"
"math/big"
"os"
@lmas
lmas / closing_channels_sends_zero_vals.go
Created July 12, 2017 20:41
Reading values from a closed channel only returns zero values
package main
import (
"log"
)
func main() {
// Also works with other channel types, like: chan string, chan int etc.
// NOTE: The zero value for "bool" types is == false
ch := make(chan bool)