Skip to content

Instantly share code, notes, and snippets.

@kdkanishka
kdkanishka / EtcdV3Client.java
Created June 17, 2021 02:18
Demonstrating locking abilities via etcdv3 client.
package etcd;
import io.etcd.jetcd.*;
import io.etcd.jetcd.kv.GetResponse;
import io.etcd.jetcd.kv.PutResponse;
import io.etcd.jetcd.lease.LeaseGrantResponse;
import io.etcd.jetcd.lease.LeaseRevokeResponse;
import io.etcd.jetcd.lock.LockResponse;
import io.etcd.jetcd.lock.UnlockResponse;
@kdkanishka
kdkanishka / sign
Created January 13, 2021 08:10 — forked from koba-ninkigumi/sign
How to make, show and verify binary signature with openssl.
自己署名証明書の作成
# Make key.pem and cert.pem
openssl req -new -days 365 -x509 -nodes -keyout key.pem -out cert.pem
証明書の内容の表示
# Show cert.pem
openssl x509 -text -noout < cert.pem
署名ファイルの作成
# Make signature
object Test extends App {
val list = List(10, 20, 30, 40, 50)
println(list)
val ls2 = calc(list)
println(ls2)
if (list.length != ls2.length) {
println("Unable to process it successfully")
}
@kdkanishka
kdkanishka / SprayJsonTest.scala
Created October 2, 2020 06:45
spray json example
package com.pagero.services.emailapi
import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import spray.json.DefaultJsonProtocol
case class Customer (id :Option[Int],name: Option[String])
object Test extends App with DefaultJsonProtocol with SprayJsonSupport{
implicit val CompanyFormat = jsonFormat2(Customer)
<html>
<script src="hello.js"></script>
<script>
var fibProxy = Module.cwrap("fib", "number", ["number"]);
function calcFib(){
var input = document.getElementById("fibInput").value;
var result = fibProxy(input);
alert(result);
@kdkanishka
kdkanishka / hello.c
Created January 24, 2020 09:32
Simple C program that can be compiled into WebAssembly
#include <stdio.h>
#include <emscripten.h>
int EMSCRIPTEN_KEEPALIVE fib(int n){
if(n == 0 || n == 1)
return 1;
else
return fib(n - 1) + fib(n - 2);
}
package jaxb;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import java.io.ByteArrayOutputStream;
/**
*
* @author kanishka
*/
public class RetrofitTest {
public static void main(String[] args) throws IOException {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
Retrofit retrofit = new Retrofit.Builder()
@kdkanishka
kdkanishka / TestSocket.java
Created March 25, 2019 04:44
Raw HTTP Request Using Sockets
import com.pagero.services.protocol.as2outbound.core.util.IOUtil;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
public class TestSocket {
public static void main(String[] args) {
int SERVER_PORT = 31481;
@kdkanishka
kdkanishka / hello_as2.go
Last active March 24, 2019 10:11
AS2 (RFC 4130) in Golang
package main
import (
"bytes"
"crypto"
_ "crypto/md5" // for crypto.MD5
_ "crypto/sha1" // for crypto.SHA1
_ "crypto/sha512" // for crypto.SHA384 & 512
"crypto/x509"
"encoding/asn1"