Skip to content

Instantly share code, notes, and snippets.

Avatar

George Hawkins george-hawkins

View GitHub Profile
View 00-pi-hole.md

Setting up an Odroid C2 as a Pi-hole

Note that a Pi-hole can't currently block ads in YouTube as these ads come from the same DNS addresses as the content (the Pi-hole forum has numerous questions relating to this).

Install Armbian on the C2

Download Etcher. Download the server version of Armbian for Ordoid C2. Install the image on the C2's eMMC card and attach it to the C2.

View pyproject.toml
[tool.poetry]
name = "foo-bar-cb3da32"
version = "0.1.1"
description = "Foo bar library with alpha for beta."
authors = ["George Hawkins"]
license = "MIT"
packages = [
{ include = "foo_bar_cb3da32", format = "sdist" }
]
View pyenv-install.txt
$ PYENV_DEBUG=1 pyenv install -v micropython-1.12
+ [pyenv:22] enable -f /Users/georgehawkins/.pyenv/bin/../libexec/pyenv-realpath.dylib realpath
+ [pyenv:29] '[' -z '' ']'
++ [pyenv:31] type -p greadlink readlink
++ [pyenv:31] head -1
+ [pyenv:31] READLINK=/usr/bin/readlink
+ [pyenv:32] '[' -n /usr/bin/readlink ']'
+ [pyenv:57] '[' -z '' ']'
+ [pyenv:58] PYENV_ROOT=/Users/georgehawkins/.pyenv
+ [pyenv:62] export PYENV_ROOT
View user-local-pip.md

Pip basics with Python 3 on Ubuntu 16.04

It seems impossible to upgrade pip, even locally, without also breaking the system pip:

$ sudo apt install python3-pip
$ pip3 --version
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
$ python3 -m pip install --user --upgrade pip
$ python3 -m pip --version
View serialization.md

Serialization and loops in Kotlin

First we found there were loops in the things we were trying to serialize and so you have to tell things that are going to walk these structures (like Jackson or even plain old equals) how to handle these to avoid recursing infinitely. Fair enough.

For Jackson you do this by telling it has to generate references like so:

@JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator::class, property="@id")
class Type ...
View vagrant-fixed-ip.md

Vagrant walkthru

Assuming you've already got VirtualBox and Vagrant already installed, let's create a Vagrant box on which to run some of these nodes and get its IP address:

$ cd
$ mkdir foo-vagrant
$ cd foo-vagrant
$ vagrant init bento/ubuntu-18.04
$ vagrant up
View WebSecurityPublicConfiguration.kt
import org.springframework.context.annotation.Configuration
import org.springframework.core.annotation.Order
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
@Order(2)
@Configuration
class WebSecurityPublicConfiguration : WebSecurityConfigurerAdapter() {
// ResourceServerConfiguration invokes OAuth2ResourceServerConfiguration.ResourceSecurityConfigurer.configure
// which turns on authorization for all paths.
View SwaggerConfig.kt
package bookmarks
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.bind.annotation.RequestMethod
import springfox.documentation.builders.ApiInfoBuilder
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.builders.ResponseMessageBuilder
@george-hawkins
george-hawkins / FooBar.kt
Last active Jun 11, 2018
Generic logic to walk both jar and filesystem isn't simple...
View FooBar.kt
package com.example
import org.junit.Test
import java.net.URI
import java.net.URL
import java.nio.file.FileSystem
import java.nio.file.FileSystemNotFoundException
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Paths
You can’t perform that action at this time.