Skip to content

Instantly share code, notes, and snippets.

@sdorra
sdorra / generate-keys.sh
Created June 6, 2021 19:55
ecdsa: sign in go, verify in node
openssl ecparam -name prime256v1 -genkey -noout -out private.pem
openssl ec -in private.pem -pubout -out public.pem
@sdorra
sdorra / JGitTest.java
Created July 22, 2020 05:02
Sign and verify commits with JGit
import org.bouncycastle.bcpg.ArmoredInputStream;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.BCPGOutputStream;
import org.bouncycastle.bcpg.HashAlgorithmTags;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPObjectFactory;
import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
@sdorra
sdorra / Vagrantfile
Created June 19, 2020 05:28
SCM-Manager on FreeBSD
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "freebsd/FreeBSD-12.0-STABLE"
# forward SCM-Manager port to host
config.vm.network "forwarded_port", guest: 8080, host: 8080
# add some more memory
@sdorra
sdorra / CorruptingProxy.groovy
Created April 29, 2020 19:33
svnkit-dav checksums
@Grab(group='org.eclipse.jetty', module='jetty-server', version='9.1.6.v20160112')
@Grab(group='org.eclipse.jetty', module='jetty-servlet', version='9.1.6.v20160112')
@Grab(group='org.eclipse.jetty', module='jetty-proxy', version='9.1.6.v20160112')
@Grab(group='com.google.guava', module='guava', version='29.0-jre')
import com.google.common.io.ByteStreams;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.util.BytesContentProvider;
import org.eclipse.jetty.proxy.ProxyServlet;
import org.eclipse.jetty.server.Server;
@sdorra
sdorra / keybase.md
Created September 14, 2019 07:09
Keybase Verification

Keybase proof

I hereby claim:

  • I am sdorra on github.
  • I am sdorra (https://keybase.io/sdorra) on keybase.
  • I have a public key ASAqzQv8znLxEcLWEJWrQUhXib91ha5mwDspYuZST9C6Xwo

To claim this, I am signing this object:

@sdorra
sdorra / Jenkinsfile
Created October 23, 2016 20:05
Docker jenkins pipeline example
node('docker') {
stage 'start database'
docker.image('redis:3.0.7-alpine').withRun { c ->
def ip = hostIp(c)
stage 'client set'
docker.image('redis:3.0.7-alpine').inside {
sh "redis-cli -h ${ip} set test 123"
@sdorra
sdorra / cert.go
Created July 3, 2016 20:56
Certificate generation in Go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"log"
"math/big"
@sdorra
sdorra / App.java
Created June 15, 2016 20:27
Jackson sample with deep field filter
public class App {
public static void main(String[] args) {
Type type = new Type("hg", "Mercurial");
Repository repository = new Repository("42", "scm", type, "SCM-Manager", "SCM-Manager Repository Hosting");
System.out.println(JSON.asString(repository));
System.out.println(JSON.asString(repository, "id", "desc"));
System.out.println(JSON.asString(repository, "id", "name", "type", "type.name", "displayName"));
}
@sdorra
sdorra / keys.go
Created April 17, 2016 19:31
Golang RSA Key Generation
/*
* Genarate rsa keys.
*/
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@sdorra
sdorra / app.go
Created April 6, 2016 19:48
SSEvents with golang
package main
import (
"io"
"strconv"
"time"
"github.com/gin-gonic/gin"
)