Skip to content

Instantly share code, notes, and snippets.

View bmcculley's full-sized avatar

bmcculley

View GitHub Profile
@bmcculley
bmcculley / slice_example.go
Last active September 4, 2018 17:38
Example of a golang string slice and element removal by index (https://play.golang.org/p/Kw20T6apfLP)
package main
import (
"fmt"
"sort"
)
func remove(slice []string, s int) []string {
return append(slice[:s], slice[s+1:]...)
}
@bmcculley
bmcculley / install_firefox.sh
Last active March 4, 2020 12:49
A script to automate the installation of the latest Firefox on Crostini.
#!/bin/bash
# script that will install the latest firefox and create a shelf icon
# Run:
# curl -sL https://git.io/fNbqF | bash -
if [ $(dpkg-query -W -f='${Status}' bzip2 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
sudo apt-get install -y bzip2;
fi
@bmcculley
bmcculley / index.html
Created July 27, 2018 12:25
The digitalocean placeholder page, tweaked a bit.
<!DOCTYPE html>
<html>
<head>
<title>Hello, world</title>
<style type="text/css">
body {
background: #1c6ba0;
height: 100%;
border:0px;
@bmcculley
bmcculley / argp.h
Created July 26, 2018 03:48
the gnu argp header file
/* Hierarchial argument parsing, layered over getopt.
Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[email protected]>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
@bmcculley
bmcculley / snippet.md
Last active June 26, 2018 16:22
An example wrapper for passing command-line flags to app.run()

Wrapper for passing command-line flags to app.run()

Wrapper that allows you to pass options to app.run() on the command line. Example invocations:

$ ./server.py --host 0.0.0.0
$ ./server.py --host 127.0.1.1 --port 8000
$ ./server.py --debug
@bmcculley
bmcculley / README.md
Created April 27, 2018 05:42 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@bmcculley
bmcculley / index.html
Last active April 5, 2018 03:19
An example of using localStorage to store page form data that also has a simple auto save function.
<!DOCTYPE html>
<html>
<head>
<title>LocalStorage example</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style type="text/css">
.container {
width: auto;
max-width: 780px;
padding: 0 15px;
@bmcculley
bmcculley / tricks.sh
Last active July 20, 2018 16:28
Silly command line tricks
# run multiple scripts from a directory
ls example{1..2}.sh|xargs -n 1 -P 0 bash
# run the previous command as sudo
sudo !!
# a function to create a directory and move into it
function mkcd() { mkdir -p "$1" && cd "$_"; }
# remove lines that begin with '#'
@bmcculley
bmcculley / conftest.c
Created March 28, 2018 04:10
Python configuration test for openssl support
/**
* Python configuration test for openssl support
* Compile with:
* cc -pthread -o conftest conftest.c -lssl -lcrypto -lpthread -lutil
*/
/* confdefs.h */
#define _GNU_SOURCE 1
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _DARWIN_C_SOURCE 1
@bmcculley
bmcculley / notes.txt
Created March 27, 2018 03:35
apt-get build-dep python3
The following NEW packages will be installed:
autotools-dev bsdmainutils debhelper debiandoc-sgml dh-python
dh-strip-nondeterminism distro-info-data docutils-common file gettext
gettext-base groff-base intltool-debian libarchive-zip-perl libasprintf0v5
libcroco3 libexpat1 libffi6 libfile-stripnondeterminism-perl libglib2.0-0
libhtml-parser-perl libhtml-tagset-perl libicu55 libmagic1 libmpdec2 libosp5
libpipeline1 libpython3-stdlib libpython3.5-minimal libpython3.5-stdlib
libroman-perl libsgmls-perl libsqlite3-0 libtext-format-perl
libtimedate-perl libunistring0 liburi-perl libxml2 lsb-release man-db
mime-support opensp po-debconf python3 python3-docutils python3-minimal