Skip to content

Instantly share code, notes, and snippets.

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

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 ...

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

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.
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 June 11, 2018 11:24
Generic logic to walk both jar and filesystem isn't simple...
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

Note: this page is heavily chopped down from multiple earlier sources, so it doesn't hang together very well at this stage. It's now just a collection of facts and thoughts about Corda notaries.

How is a Corda notary different to a centralized DB?

Distributed DBs (both SQL and NoSQL) that guarantee eventual consistency have been around for a long time outside the world of distributed ledger.

How is a Corda notary really different to a centralized DB?

Note: whether behind the scenes a notary or centralized DB is implemented as a single system or as a distributed cluster is largely irrelevant to the primary parties involved (in a Corda environment that's the nodes).

@george-hawkins
george-hawkins / .bashrc_prompt
Created March 1, 2018 10:06
Setup PS1 prompt
if [[ -n $SSH_CLIENT || -n $SSH_TTY ]]
then
PS1_HOST='\h'
else
PS1_HOST=localhost
fi
# Usually people use raw escape sequences for colors but you can lookup these sequences with tput.
BOLD=$(tput bold)
GREEN=$(tput setaf 2)
diff --git a/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt b/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt
index 83462c2..0f3d67b 100644
--- a/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt
+++ b/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt
@@ -50,14 +50,20 @@ private abstract class JarType(private val jarName: String) {
}
val debugPort = debugPortAlloc.next()
println("Starting $jarName in $dir on debug port $debugPort")
- val process = (if (headless) ::HeadlessJavaCommand else ::TerminalWindowJavaCommand)(jarName, dir, debugPort, javaArgs, jvmArgs).start()
+ val appArgs = javaArgs + (if (headless) headlessArgs else headedArgs)