Skip to content

Instantly share code, notes, and snippets.

View mandrean's full-sized avatar

Sebastian Mandrean mandrean

  • Stockholm, Sweden
View GitHub Profile
@nsbingham
nsbingham / local-dnsserver.md
Last active June 5, 2023 21:44
Testing a CNAME

Setting up a local DNS server with bind on OSX Mavericks

This is really just an approach for locally testing DNS changes, which can easily be done with a HOSTS file if the change involves an IP address, but gets a bit trickier when things like CNAMEs are involved. This is only meant to test locally off a single machine.

  1. Install bind using homebrew

    brew install bind

  2. Follow the installation steps to start up bind

@mandrean
mandrean / fix_csv_encoding_mac.md
Created September 1, 2015 14:15
Fix broken CSV encoding in Excel for Mac

Fix broken CSV encoding in Excel for Mac

Problem

Excel for Mac can't handle UTF-8 encoded CSV files. Official statement by Microsoft:

Excel for Mac does not currently support UTF-8. If this is a feature you’d like to see in future versions of Office for Mac, be sure to send your feedback by clicking “Help” > “Send Feedback” [...]

Solution

Convert the UTF-8 file to UTF-16 Little Endian by running this one-liner in Terminal:

( printf "\xff\xfe" ; iconv -f utf-8 -t utf-16le INPUT_UTF8_FILE.csv ) > OUTPUT_UTF16_FILE.csv
@gr4y
gr4y / wemo.go
Last active September 25, 2017 17:58
Toggle all WeMo switches. If it is on, it will turn off. If it is off, it will turn on. Just a quick little thing.
package main
import (
"fmt"
"github.com/huin/goupnp"
"github.com/huin/goupnp/soap"
)
func main() {
devices, err := goupnp.DiscoverDevices("urn:Belkin:device:controllee")
@mandrean
mandrean / cloud-config-controller
Created October 28, 2016 13:09
kube-aws fluentd/elastic search/kibana logging for kubernetes
# ...
write_files:
- path: /opt/bin/install-kube-system
permissions: 0700
owner: root:root
content: |
#!/bin/bash -e
# ...
# Custom replication controllers
@lg
lg / paperspace-gaming.ps1
Last active October 31, 2023 17:24
A script to provision a new Paperspace machine for gaming
# init stuff
Install-PackageProvider -Name NuGet -Force
mkdir c:\cloudygamer\downloads
Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" "DontUsePowerShellOnWinX" -Value 0
################
# install steam first since windows updates will take forever (and you can install games)
(New-Object System.Net.WebClient).DownloadFile("https://steamcdn-a.akamaihd.net/client/installer/SteamSetup.exe", "c:\cloudygamer\downloads\steamsetup.exe")
@thbkrkr
thbkrkr / gcloud-ssh-sysctl-vmmaxmapcount.sh
Created November 7, 2019 19:42
Set vm.max_map_count=262144 on the nodes of a GKE cluster #k8s
#!/bin/bash -eu
# Increase Virtual Memory for Elasticsearch on GKE
# https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
# Dependencies: kubectl, gcloud, jq
nodes() {
kubectl get nodes -o custom-columns=n:.metadata.name --no-headers
}
# Instructions for fresh install
$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
# reboot
$ source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
$ echo 'export NIX_PATH=darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH' | tee -a ~/.zshrc
$ echo 'source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh' | tee -a ~/.zshrc
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
$ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
@mandrean
mandrean / Install Arm Embedded GCC toolchain on Apple M1 Silicon (aarch64, arm64)
Last active March 31, 2024 14:29
Install xPack GNU Arm Embedded GCC toolchain on Apple M1 Silicon (aarch64 / arm64)
# Install xpm using npm
$ npm install --global xpm@latest
# Install xPack distribution of Arm toolchain with Apple M1 Silicon support
$ xpm install @xpack-dev-tools/arm-none-eabi-gcc@10.3.1-2.3.1
# Add Arm toolchain binaries to PATH in your .bashrc or .zshrc
$ echo 'export PATH="$HOME/Library/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/10.3.1-2.3.1/.content/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
@mandrean
mandrean / Install Apple Clang 12 next to Apple Clang 13
Created January 23, 2022 02:15
Install Apple Clang 12 next to Apple Clang 13
# download 'Command_Line_Tools_for_Xcode_12.5.1.dmg' from Apple's developer portal:
# https://developer.apple.com/download/all/?q=xcode
# mount 'Command_Line_Tools_for_Xcode_12.5.1.dmg', then unpack it
❯ pkgutil --expand-full /Volumes/Command\ Line\ Developer\ Tools/Command\ Line\ Tools.pkg /tmp/CLTools
# rename existing CLTools v13
❯ sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools@13
# move CLTools v12 into place