Skip to content

Instantly share code, notes, and snippets.

View bradkarels's full-sized avatar

Brad Karels bradkarels

View GitHub Profile
@bradkarels
bradkarels / main.go
Created December 21, 2023 16:04
Simple example of using channels to listen for and act on SIGINT/SIGTERM signals.
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
// This program will run until interupted (e.g. ctrl+c).
@bradkarels
bradkarels / pi_psql.md
Created January 1, 2020 01:44
Making my Pi Postgresql DB available on my network

From: https://opensource.com/article/17/10/set-postgres-database-your-raspberry-pi

'''

  1. Edit the PostgreSQL config file /etc/postgresql/9.6/main/postgresql.conf to uncomment the listen_addresses line and change its value from localhost to *. Save and exit.

  2. Edit the pg_hba config file /etc/postgresql/9.6/main/pg_hba.conf to change 127.0.0.1/32 to 0.0.0.0/0 for IPv4 and ::1/128 to ::/0 for IPv6. Save and exit.

  3. Restart the PostgreSQL service: sudo service postgresql restart.

@bradkarels
bradkarels / .bashrc
Created June 9, 2017 17:15
Yet another bashrc file I want some stuff from...
#export PS1="\u@\w \\$ "
export PS1="bk@\w \\$ "
# JAVA
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
#JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:bin/javac::")
#export JAVA_OPTS="-Xms1G -Xmx2G -XX:PermSize=512m -XX:MaxPermSize=1G -server"
export SCALA_HOME=/usr/local/share/scala/current
export PATH=$SCALA_HOME/bin:$PATH
@bradkarels
bradkarels / cmd.sh
Created April 10, 2017 13:52
Cmd to get studio display camera to work
sudo killall VDCAssistant
@bradkarels
bradkarels / docker_stop_rm_all.sh
Created March 20, 2017 14:58
Quickly stop and remove all docker containers. Careful!
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
$ terminator
$ which python-support
$ wget http://launchpadlibrarian.net/109052632/python-support_1.0.15_all.deb
$ sudo dpkg -i python-support_1.0.15_all.deb
@bradkarels
bradkarels / scalaTraitInstanitationViaAnonClass.scala
Created May 11, 2016 13:15
When you see a trait being "instantiated", be mindful that what is actually happening is that an anonymous class is being instantiated for you.
// Given a simple trait
trait NiceTrait {
def isNice(s: String): Boolean = s match {
case "nice" => true
case _ => false
}
}
//It is possible to "instantiate" this trait two ways, manually create a class and instantiate that:
class MyClass extends NiceTrait
@bradkarels
bradkarels / java8.sh
Created April 22, 2016 13:17
Setting up Java8 on fresh Ubuntu 14.04 - (won't be relevant long with 16.04 in beta2)
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
@bradkarels
bradkarels / ServerITSpec.js
Created March 15, 2016 16:03 — forked from BoyCook/ServerITSpec.js
Integration testing a node.js web app with Mocha
var should = require('should');
var request = require('request');
var url = 'http://localhost:8080';
var HttpServer = require('./server').HttpServer;
var server;
describe('HttpServer', function () {
before(function (done) {
server = new HttpServer({port: 8080}).start(done);
@bradkarels
bradkarels / removeExitedContain.sh
Last active May 27, 2021 15:05
Sweet command to remove all exited container from a Docker host. Obvious, be careful, not for prod...etc.
docker ps -a | grep Exited | awk '{print $1}' | xargs -r docker rm
docker ps -a | grep Exited | awk '{print $1}' | xargs --no-run-if-empty docker rm