Skip to content

Instantly share code, notes, and snippets.

@ksexton
ksexton / README
Last active November 18, 2023 16:01 — forked from jmatsushita/README
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
# Inspired by https://github.com/malob/nixpkgs I highly recommend looking at malob's repo for a more thorough configuration
#
# Some people are coming directly to this Gist from search results and not the original post[1]. If that sounds like you, you should also know there is a video[2] that accompanies this.
#
# [1] https://discourse.nixos.org/t/simple-workable-config-for-m1-macbook-pro-monterey-12-0-1-with-nix-flakes-nix-darwin-and-home-manager/16834
# [2] https://www.youtube.com/watch?v=KJgN0lnA5mk
#
# Let's get started
@ksexton
ksexton / _aws_golang_examples.md
Created November 1, 2018 19:21 — forked from eferro/_aws_golang_examples.md
golang aws: examples

AWS Golang SDK examples

@ksexton
ksexton / main.go
Created April 12, 2018 19:21
2018-04-12 daily problem
//
// Given a list of numbers, return whether any two sums to k.
//
// For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
//
// Bonus: Can you do this in one pass?
package main
import "fmt"
@ksexton
ksexton / sample.yaml
Created March 22, 2018 21:36
Sample YAML
apiVersion: v1
kind: Pod
metadata:
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ""
creationTimestamp: null
labels:
component: kube-scheduler
tier: control-plane
name: kube-scheduler
root@kubernetes:~# kubectl get nodes -o json | jq '.items[].metadata.annotations'
{
"flannel.alpha.coreos.com/backend-data": "null",
"flannel.alpha.coreos.com/backend-type": "host-gw",
"flannel.alpha.coreos.com/kube-subnet-manager": "true",
"flannel.alpha.coreos.com/public-ip": "192.168.1.20",
"node.alpha.kubernetes.io/ttl": "0",
"volumes.kubernetes.io/controller-managed-attach-detach": "true"
}
{
@ksexton
ksexton / install-emacs.sh
Created August 30, 2017 15:10
Install Emacs
#!/bin/bash
[ -z "$EMACS_VERSION" ] && echo "Usage: EMACS_VERSION=25.2 install-emacs.sh" && exit 1
[ -z "$EMACS_URL" ] && EMACS_URL="http://mirror.aarnet.edu.au/pub/gnu/emacs/"
# I've assign 12G memory to /tmp as ramdisk
[ -z "$EMACS_TMP" ] && EMACS_TMP="/tmp"
# configure: WARNING: unrecognized options: --without-gtk3, --without-aqua, --without-alsa, --without-aqua
echo "curl $EMACS_URL/emacs-$EMACS_VERSION.tar.gz"
curl $EMACS_URL/emacs-$EMACS_VERSION.tar.gz | tar xvz -C $EMACS_TMP
# @see http://wiki.gentoo.org/wiki/Project:Emacs/GNU_Emacs_developer_guide
@ksexton
ksexton / main.go
Created April 17, 2017 16:23
Go Project Euler exercise
// Find a problem at projecteuler.net then create the solution. Add a
// comment beneath your solution that includes a description of the
// problem. Upload your solution to github. Tweet me a link to your
// solution.
//
// https://projecteuler.net/problem=4
// A palindromic number reads the same both ways. The largest palindrome
// made from the product of two 2-digit numbers is 9009 = 91 × 99.
//
// Find the largest palindrome made from the product of two 3-digit
@ksexton
ksexton / altnetworking.sh
Created April 14, 2017 23:04 — forked from level323/altnetworking.sh
Run a command inside a customised networking environment (using cgroups)
#!/bin/bash
# === INFO ===
# altnetworking.sh
# Description: Run the specified application in a custom networking environment.
# Uses cgroups to run process(es) in a network environment of your own choosing (within limits!)
VERSION="0.1.0"
# Author: John Clark
# Requirements: Debian 8 Jessie (plus iptables 1.6 from unstable)
#
@ksexton
ksexton / cleanup.sh
Created March 16, 2017 19:44
cleanup centos
yum -y update && \
yum -y install yum-utils && \
service rsyslog stop && \
service auditd stop && \
package-cleanup --oldkernels -y –count=1 && \
yum clean all && \
logrotate -f /etc/logrotate.conf
rm -f /var/log/*-???????? /var/log/*.gz
rm -f /var/log/dmesg.old
@ksexton
ksexton / chefdk-rvm.sh
Created January 31, 2017 17:21 — forked from asnodgrass/chefdk-rvm.sh
Making ChefDK work with RVM
# Assumption: Mac OS X
CHEFDK="/opt/chefdk/embedded"
CHEFDK_USER="$HOME/.chefdk/gem/ruby/2.1.0"
RVM_GEMS="$HOME/.rvm/gems"
RVM_RUBIES="$HOME/.rvm/rubies"
RUBY_NAME="ext-chefdk-ruby"
mkdir -p $RVM_RUBIES/$RUBY_NAME
ln -s $CHEFDK/bin $RVM_RUBIES/$RUBY_NAME