Skip to content

Instantly share code, notes, and snippets.

@desbo
desbo / Puzzle.hs
Created October 13, 2015 15:14
puzzle parser
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.Aeson
import Data.Aeson.Types
import qualified Data.ByteString.Lazy as B (readFile)
import Data.Time
data CrosswordType = Quick | Cryptic
deriving Show
#!/bin/bash
machine=$1
[ -z "$machine" ] && machine="default"
docker-machine start $machine
eval "$(docker-machine env $machine)"
echo "VM $machine running: $DOCKER_HOST"
@desbo
desbo / samdash.js
Last active January 26, 2016 13:40
samdash
function head(xs) {
return xs[0];
}
function last(xs) {
return xs[xs.length - 1];
}
function init(xs) {
return xs.slice(0, xs.length - 1);

general

Keys Action Description
Cmd-Shift-A Search action by name search for any command/menu items
Alt-F1 Select target Open current file in project tree, finder, etc

opening files

Keys Action Description
Cmd-O Class search classes, traits, objects
@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)))
@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 / 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 / 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 / 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 / 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