Skip to content

Instantly share code, notes, and snippets.

View Wendelstein7's full-sized avatar
❤️
Making the world a better place

Wendelstein7 Wendelstein7

❤️
Making the world a better place
  • The Netherlands
View GitHub Profile
@Wendelstein7
Wendelstein7 / cats.sh
Created November 30, 2021 15:07
Syntax highlighted cat -> cats
sudo apt-get install highlight
echo "alias cats='highlight -O ansi --force'" > ~/.bash_aliases && source ~/.bash_aliases
#Use: `cats <file>`, like `cats test.sh`
@Wendelstein7
Wendelstein7 / hosts
Created November 8, 2021 14:36
China Great Firewall hostfile
This file has been truncated, but you can view the full file.
# China Great Firewall hosts file
# This lists domains that are blocked by the 'Great Firewall' that is being used in China.
# Data is taken from the research conducted by https://gfwatch.org/overview
# Data is a snapshot of 2021-11-04 data taken from https://drive.google.com/drive/folders/1-l4o3c31BuWl6DoA2s7n3BWiEL5jN925
# Converted to hosts file format with regex: `/(^[^|]+).+/` replaced with `0.0.0.0 $1`
# Use with pi-hole for example to simulate your own Great Firewall.
# 537387 entries in this file.
0.0.0.0 ttwt.com.cn
0.0.0.0 54321zm.com
@Wendelstein7
Wendelstein7 / bitwise.h
Created September 30, 2021 07:52
Bitwise operation macros (Compatible with C, C++, C#, etc...)
#define isBitSet(byte, bit) ((byte) & (1 << (bit)))
#define setBit(byte, bit) ((byte) |= (1 << (bit)))
#define clearBit(byte, bit) ((byte) &= ~(1 << (bit)))
#define toggleBit(byte, bit) ((byte) ^= (1 << (bit)))
#define setBitTo(byte, bit, value) ((value) ? setBit(byte, bit) : clearBit(byte, bit))
@Wendelstein7
Wendelstein7 / setup.sh
Last active April 13, 2021 16:24
Wendelstein7 linux setup script
#!/bin/bash
# Wendelstein7's Setup Script
# https://askubuntu.com/questions/147241/execute-sudo-without-password
if [ ! -f /etc/sudoers.d/$(logname) ]; then
sudo sh -c 'echo "$(logname) ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$(logname)'
sudo chmod 440 /etc/sudoers.d/$(logname)
fi
sudo apt update
@Wendelstein7
Wendelstein7 / remove subdirectories.ps
Created January 29, 2021 10:08
Powershell script to delete all empty subdirectories
# Powershell script to delete all empty subdirectories
$rootPath = Get-Location
foreach($childItem in (Get-ChildItem $rootPath -Recurse))
{
# if it's a folder AND does not have child items of its own
if( ($childItem.PSIsContainer) -and (!(Get-ChildItem -Recurse -Path $childItem.FullName)))
{
# Delete it
Remove-Item $childItem.FullName -Confirm:$false

imagemagick batch convert .svg files to .png files with transperant background and higher resolution.

imagemagick: http://www.imagemagick.org/script/download.php#windows

svg files must be in a .\svg folder relative to executing path. output dir will be .\png

Powershell script:

mkdir .\png
@Wendelstein7
Wendelstein7 / characterbox.lua
Last active November 17, 2019 17:15
Generate a character box in lua
for x = 0, 15 do
for y = 0, 15 do
c = string.format("%q", string.char(16 * x + y)):gsub("\"", ""):gsub("\n", "n")
c = string.rep(" ", 4 - #c) .. c
io.stdout:write(c)
end
io.stdout:write("\n")
end
--[[ OUTPUT:
@Wendelstein7
Wendelstein7 / huemap.cs
Last active April 16, 2020 18:04
Generating an image to use as a hue value cheat sheet (hue in degrees, factor, bytes and hexadecimal)
// HSV to RGB code from http://www.splinter.com.au/converting-hsv-to-rgb-colour-using-c/
// Other code by me
#r "System.Drawing";
using System.Drawing;
void HsvToRgb(double h, double S, double V, out int r, out int g, out int b)
{
// T. Nathan Mundhenk mundhenk@usc.edu
double H = h;
@Wendelstein7
Wendelstein7 / README-Template.md
Created January 25, 2018 15:14 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites