Skip to content

Instantly share code, notes, and snippets.

View niclaslindstedt's full-sized avatar

Niclas Lindstedt niclaslindstedt

View GitHub Profile
@niclaslindstedt
niclaslindstedt / install_docker_ubuntu.sh
Created July 6, 2021 11:19
Install Docker Engine on Ubuntu 20.04 systems
#!/bin/bash
main() {
sudo apt-get update \
&& sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release \
@niclaslindstedt
niclaslindstedt / generate_ssh_key.sh
Last active September 25, 2021 11:51
Generate SSH Key
#!/bin/bash
# Run this remotely:
# curl -fsSL https://gist.githubusercontent.com/niclaslindstedt/cc22b56774475f4345dc9c6f129136a0/raw/7f19198ca1970f9168ea29cb9cb4035793b5a09b/generate_ssh_key.sh | bash -
main() {
local gh_email ssh_key_path answer
ssh_key_path="$HOME/.ssh/id_ed25519"
@niclaslindstedt
niclaslindstedt / sshd_config
Last active November 8, 2022 07:34
SSH Server Hardening
# Add this in /etc/ssh/sshd_config.d/00-hardening.conf
# Then type sudo service sshd reload
Protocol 2
Port 2222
PermitRootLogin no
MaxAuthTries 3
LoginGraceTime 20
PasswordAuthentication no
@niclaslindstedt
niclaslindstedt / .editorconfig
Created January 28, 2021 10:24
ReSharper-compatible editorconfig for C# projects
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
[*.yml]
indent_size = 2
@niclaslindstedt
niclaslindstedt / release.yml
Created January 28, 2021 10:20
Automatic release+changelog
name: Release
on:
push:
branches: [ master ]
jobs:
create_release:
name: create release
runs-on: ubuntu-latest
@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": {
@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 / 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 / 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 / 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
{