Skip to content

Instantly share code, notes, and snippets.

View niclaslindstedt's full-sized avatar

Niclas Lindstedt niclaslindstedt

View GitHub Profile
@niclaslindstedt
niclaslindstedt / block-non-vpn-traffic.sh
Last active August 14, 2017 07:25
Block all non-VPN traffic in iptables. Replace "192.168.100.0" with your home network.
#!/bin/sh
HOMENETWORK="192.168.100.0/24"
HOMENETIF="eth0"
HOMEVPNIF="tun0"
iptables --flush
# default policy
iptables -P INPUT DROP
@niclaslindstedt
niclaslindstedt / resize-vbox-virtual-drive
Last active September 11, 2017 08:58
Resize virtual drive in VirtualBox
cd "C:\Program Files\Oracle\VirtualBox"
VBoxManage modifyhd <path to vdi image> --resize <new size in mb>
@niclaslindstedt
niclaslindstedt / sshd_config
Last active October 18, 2018 19:49
safe sshd configuration (add to bottom of config)
ClientAliveInterval 360
ClientAliveCountMax 0
PermitEmptyPasswords no
PermitRootLogin no
Protocol 2
Port 3089
PasswordAuthentication no
AuthenticationMethods publickey
PubkeyAuthentication yes
IgnoreRhosts yes
@niclaslindstedt
niclaslindstedt / interfaces
Created October 17, 2018 05:42
Static ip in Linux
#/etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.100.101
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
gateway 192.168.100.1
dns-nameservers 1.1.1.1 1.0.0.1
@niclaslindstedt
niclaslindstedt / cifs_ubuntu.txt
Created October 17, 2018 06:46
Cifs on Ubuntu
# Install needed packages
sudo apt install cifs-utils
# Add a mount line to /etc/fstab
//<ip>/<share> <mount point> cifs credentials=<credentials file>,uid=<user id>,gid=<group id>,vers=2.0 0 0
@niclaslindstedt
niclaslindstedt / kodi.ahk
Last active October 25, 2018 07:12
Useful Kodi AutoHotKey Binds
; Start Program
; If Program is already started, maximize and focus its window.
; If Program is started but minimized, maximize it.
; If Program is not started, start it.
ActivateProgram(name, executable, path)
{
Process,Exist,%executable%
If Errorlevel != 0 ;Errorlevel returns pid of process
{
@niclaslindstedt
niclaslindstedt / commands.ps1
Last active October 27, 2018 10:37
Useful PowerShell commands
# Set IP-address
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.1.200" -AddressFamily IPv4 -PrefixLength 24 -DefaultGateway 192.168.1.1
# Set DNS server
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 1.1.1.1,1.0.0.1
# Allow remote connections
Set-Item WSMAN:\localhost\Client\TrustedHosts -value RemoteComputerName -force
# Create AD forest
@niclaslindstedt
niclaslindstedt / Replace-Tokens.ps1
Last active October 11, 2023 08:12
PowerShell script to replace tokens in a file. Useful for DevOps when you have a template config file that you wish to insert real values into.
<#
.SYNOPSIS
Replace tokens in a file with values.
.DESCRIPTION
Finds tokens in a given file and replace them with values. It is best used to replace configuration values in a release pipeline.
.PARAMETER InputFile
The file containing the tokens.
@niclaslindstedt
niclaslindstedt / .gitattributes
Created January 28, 2021 09:02
.gitattributes for JavaScript projects
# Auto-detect text files
* text=auto eol=lf
# Whitespace exclusions
*.txt whitespace=-blank-at-eof,-space-before-tab,-tab-in-indent,trailing-space,tabwidth=2
*.md whitespace=-blank-at-eof,-space-before-tab,-tab-in-indent,trailing-space,tabwidth=2
*.js whitespace=-blank-at-eof,-space-before-tab,-tab-in-indent,trailing-space,tabwidth=2
*.ts whitespace=-blank-at-eof,-space-before-tab,-tab-in-indent,trailing-space,tabwidth=2
*.json whitespace=-blank-at-eof,-space-before-tab,-tab-in-indent,trailing-space,tabwidth=2
@niclaslindstedt
niclaslindstedt / package.json
Last active May 19, 2021 10:57
Husky with commitlint
{
"scripts": {
"postinstall": "husky install"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"husky": "^4.3.5"
},
"commitlint": {