Skip to content

Instantly share code, notes, and snippets.

@bndw
bndw / import_photos.sh
Last active July 22, 2018 22:05
A script for importing photos from an SD card to a local directory
#!/bin/bash
#
# This script is used to copy images files from a connected volume to a local
# directory.
#
# - Creates a folder with today's date in $PHOTO_DIR
# - Moves RAW files into the root $PHOTO_DIR
# - Creates a folder for JPEG images
# - Creates a folder for edits/exports
# - Creates a README file
@bndw
bndw / readme.md
Last active May 20, 2023 02:32
go 1.10 encoding/json Decoder.DisallowUnknownFields

Go 1.10 was released today and an addition to the core library encoding/json package caught my eye

func (dec *Decoder) DisallowUnknownFields()

DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.

Godoc

Keybase proof

I hereby claim:

  • I am bndw on github.
  • I am bndw (https://keybase.io/bndw) on keybase.
  • I have a public key whose fingerprint is 82D0 479F 230B 9590 41E8 616F E333 623C BDB5 D958

To claim this, I am signing this object:

#!/bin/bash
#
# Reloads HAProxy and kills the old instances kept alive by open connections.
#
# Old HAProxy instances will only be killed if they're:
# * bound to ports in CHOPPABLE_PORTS
# * not the active HAProxy process, as defined by PID_FILE
CONF=/etc/haproxy/haproxy.cfg
PID_FILE=/run/haproxy.pid
@bndw
bndw / convert_old_safe.go
Created September 4, 2016 05:50
Converts an old format pick safe to the new format
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"github.com/bndw/pick/backends"
"github.com/bndw/pick/safe"
@bndw
bndw / docker_debian.md
Last active November 9, 2023 13:40
How to install an older version of Docker on Debian
@bndw
bndw / component.js
Created October 29, 2015 22:07
ember select-box component
import Ember from "ember";
export default Ember.Component.extend({
content: null,
selectedValue: null,
didInitAttrs(attrs) {
this._super(...arguments);
if (!this.get('content')) {
" run :help <command> for more information
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

Create a new key

  • gpg --gen-key
  • gpg --export --armor <email for new key> > ~/Desktop/my-pubkey.asc

Import a friend's key

gpg --recv-key <key id>

Encrpyt a message with a friend's key

<?php
/*
* Takes a credit card number and ensures
* it contains the proper number of digits
* for the given card type.
*/
function isValidCreditCardNumber($cardNumber)
{
// First check that the card number