Skip to content

Instantly share code, notes, and snippets.

@sdorra
sdorra / generate-keys.sh
Created Jun 6, 2021
ecdsa: sign in go, verify in node
View generate-keys.sh
openssl ecparam -name prime256v1 -genkey -noout -out private.pem
openssl ec -in private.pem -pubout -out public.pem
@sdorra
sdorra / JGitTest.java
Created Jul 22, 2020
Sign and verify commits with JGit
View JGitTest.java
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 Jun 19, 2020
SCM-Manager on FreeBSD
View Vagrantfile
# -*- 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
View CorruptingProxy.groovy
@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 Sep 14, 2019
Keybase Verification
View keybase.md

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 Oct 23, 2016
Docker jenkins pipeline example
View Jenkinsfile
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 Jul 3, 2016
Certificate generation in Go
View cert.go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"log"
"math/big"
@sdorra
sdorra / App.java
Created Jun 15, 2016
Jackson sample with deep field filter
View App.java
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 Apr 17, 2016
Golang RSA Key Generation
View keys.go
/*
* Genarate rsa keys.
*/
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@sdorra
sdorra / app.go
Created Apr 6, 2016
SSEvents with golang
View app.go
package main
import (
"io"
"strconv"
"time"
"github.com/gin-gonic/gin"
)