Skip to content

Instantly share code, notes, and snippets.

@desbo
desbo / headphones.md
Last active February 17, 2021 12:26
disconnect/reconnect bluetooth headphones on mac sleep/wake
  1. install blueutil (cli app to control bluetooth) and sleepwatcher (run commands on sleep and wake)
brew install blueutil sleepwatcher
  1. find the address of your headphones with blueutil
> blueutil --paired
@desbo
desbo / quake-3-arena-macos-quickstart-guide.md
Last active August 22, 2022 23:14
Quake 3 Arena macOS quick start guide
  1. Install Q3 fork ioquake3 along with original game patch files (baseq3/pak{1-8}.pk3, missionpack/pak{1-3}.pk3)

    brew cask reinstall ioquake3
    
  2. Build ioquake3 master branch

    git clone https://github.com/ioquake/ioq3
    
@desbo
desbo / cdk-notes.md
Last active July 18, 2019 10:25
CDK notes

CDK notes

Notes on building a small application (two lambdas and a step function state machine) with the CDK (TypeScript).

directory structure

cdk init can only be run in an empty directory. The name of this directory is used throughout the generated code, notably as the name of the generated stack. It seems like the intention is to use the root directory of the project for the CDK code as well as any other source code. I preferred to separate the CDK code from Scala, so I put it into its own subdirectory that was ultimately named cdk, but when running cdk init I temporarily gave it the same name as my project so the generated stack name made sense (e.g. MyProjectStack instead of CdkStack).

constructs

CDK applications are made by composing constructs. A construct is a representation of an AWS Resource at varying levels of abstraction. Some are auto-generated and therefore as low-level as CloudFormation itself, others provide a

package com.gu.emr.util
import java.util.concurrent.{Future => JavaFuture}
import com.amazonaws.services.elasticmapreduce.model._
import com.amazonaws.{AmazonWebServiceRequest, AmazonWebServiceResult}
import scala.concurrent.{ExecutionContext, Future}
trait Marking[Request, Result] {
@desbo
desbo / master-restart.sh
Created January 8, 2018 15:15
master restart
# run as root
initctl list | grep -E 'hadoop|hive|spark|yarn' | cut -d' ' -f1 | xargs -L1 restart
@desbo
desbo / x.scala
Created July 9, 2017 21:14
random donations
import scala.util.Random
// http://www.decisionsciencenews.com/2017/06/19/counterintuitive-problem-everyone-room-keeps-giving-dollars-random-others-youll-never-guess-happens-next/
case class Person(var balance: Int) {
def receive(amount: Int): Unit = {
balance = balance + 1
}
def give(amount: Int, other: Person): Unit = {
@desbo
desbo / steady-on.js
Last active July 13, 2016 14:31
steady on
function Queue() {
this.queue = [];
}
/**
* Add an item to the queue
*
* @param {Anything} item item to add
* @return {Number} queue length
@desbo
desbo / ansi.sh
Created March 29, 2016 12:42
ansi-script npm-shrinkwrap fix
grep -nHC1 "2\.2\.0" npm-shrinkwrap.json \
| grep -A1 ansi-styles \
| grep npm-shrinkwrap.json: \
| cut -d: -f2 \
| xargs -I"{}" -n1 sed -i {}s/\.0/\.1/ npm-shrinkwrap.json
@desbo
desbo / websecurity_uninstall.sh
Created March 9, 2016 16:35
websecurity_uninstall.sh
#!/bin/sh
INSTPREFIX="/opt/cisco/anyconnect"
BINDIR="${INSTPREFIX}/bin"
PLUGINSDIR="${BINDIR}/plugins"
LIBDIR="${INSTPREFIX}/lib"
PROFILESDIR="${INSTPREFIX}/websecurity"
ACMANIFESTDAT="${INSTPREFIX}/VPNManifest.dat"
WEBSECMANIFEST="ACManifestWebSecurity.xml"
UNINSTALLLOG="/tmp/websecurity-uninstall.log"
@desbo
desbo / codewars.clj
Last active December 28, 2015 12:33
codewars
;; 559e3224324a2b6e66000046
(defn cart [n]
(let [n (+ n 1)]
(for [x (range 1 n) y (range 1 n)] [x y])))
(defn xf [f] (map (fn [[x y]] (f x y))))
(defn sumin [n]
(transduce (xf min) + (cart n)))