Skip to content

Instantly share code, notes, and snippets.

package week2
import java.util.Arrays
import common.ParallelConstructs._
import scala.util.Random
import org.scalameter._
object ParallelMergeSortLecture extends App {
package week2
object Lecture6 extends App {
def reduceSeg1[A](inp: Array[A], left: Int, right: Int, a0: A, f: (A, A) => A): A = {
var a = a0
var i = left
while (i < right) {
a = f(a, inp(i))
i += 1
}
sealed trait Conc[+T] {
def level: Int
def size: Int
def left: Conc[T] = throw new NoSuchElementException("no left subtree")
def right: Conc[T] = throw new NoSuchElementException("no right subtree")
def <>[U >: T](that: Conc[U]): Conc[U] = {
if (this == Empty) that
else if (that == Empty) this
else concat(this, that)
@george-hawkins
george-hawkins / arm64.md
Last active March 24, 2024 14:36
Running virtualized x86_64 and emulated arm64 Ubuntu cloud images using QEMU

QEMU arm64 cloud server emulation

This is basically a rehash of an original post on CNXSoft - all credit (particularly for the Virtio device arguments used below) belongs to the author of that piece.

Download the latest uefi1.img image. E.g. ubuntu-16.04-server-cloudimg-arm64-uefi1.img from https://cloud-images.ubuntu.com/releases/16.04/release/

Download the UEFI firmware image QEMU_EFI.fd from https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/

Determine your current username and get your current ssh public key:

@george-hawkins
george-hawkins / ResolveArgumentTest.java
Created February 1, 2017 15:59
ServletRequestMethodArgumentResolver issue
package com.example;
import java.lang.reflect.Method;
import java.security.Principal;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.core.MethodParameter;
import org.springframework.security.core.Authentication;
[Unit]
Description=Broadcast triggered shutdown
After=network.target
# To install:
# $ sudo apt-get install socat
# $ sudo chown root:root broadcast-shutdown.service
# $ sudo mv broadcast-shutdown.service /etc/systemd/system
# $ sudo systemctl daemon-reload
# $ sudo systemctl enable broadcast-shutdown

Accessing Okta accounts etc. in Java

If you've already followed the Getting Started With Okta document from Stormpath then you should already have a Spring Boot application where users can login.

However if you try to interogate the system e.g. for all accounts you'll quickly find out that most of the methods provided by Application, such as getAccounts(), throw UnsupportedOperationException.

Another way to get at this data is via the Okta Java SDK.

By default this SDK uses a different mechanism to pickup the Okta API token etc. to the one used by the Okta compatible version of the Stormpath Spring Boot SDK.

#!/bin/bash
DRIVERS_DIR=/sys/bus/pci/drivers
# George Hawkins Nov 18th, 2014
# I found various scripts that bind and unbind the USB devices to reset the whole USB system.
# All used hardcoded slots and drivers - slots aren't consistent across machines and driver names change with OS releases.
# This script attempts to discover all values.
# This awk script finds all PCI devices with class 'USB controller' that have a slot and a driver.