Skip to content

Instantly share code, notes, and snippets.

View dawud-tan's full-sized avatar
💭
Loːts 100₂.C.a.111₂.101₂

Dawud Tan dawud-tan

💭
Loːts 100₂.C.a.111₂.101₂
  • PT Pungkook Indonesia One
  • Tanjungrejo, Wirosari, Grobogan
  • X @dawud_tan
View GitHub Profile
@natereed
natereed / CRMClientTest.java
Last active December 30, 2016 00:35
Stubbing/mocking Jersey Client. Inspired by WebMock.
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
public class CRMClientTest {
private CRMClient crmClient;
private StubbedClientHandler clientHandler;
@akorobov
akorobov / PkiUtils.java
Created October 9, 2013 23:46
Example of reading and writing x509 certificate and RSA private keys encoded in PEM format using BouncyCastle 1.48 (new api)
public class PkiUtils {
public static final int MinPassPhraseLength = 4;
public static List<?> readPemObjects(InputStream is, final String pphrase)
throws IOException {
List<Object> list = new LinkedList<Object>();
PEMParser pr2 = new PEMParser(new InputStreamReader(is));
JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC");
JcaX509CertificateConverter certconv = new JcaX509CertificateConverter().setProvider("BC");
@herpiko
herpiko / klas-pki-playground.md
Last active January 2, 2020 16:18
💻 🔨 :neckbeard: PKI

Membuat sertifikat self-signed

openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out cert.pem

Melihat isi sertifikat

openssl x509 -in cert.pem -text

PEM dan DER

@puf
puf / ChatMessage.java
Last active July 12, 2021 21:56
Zero to App: Develop with Firebase (for Android - Google I/O 2016)
package com.google.firebase.zerotoapp;
public class ChatMessage {
public String name;
public String message;
public ChatMessage() {
}
public ChatMessage(String name, String message) {
@meoyawn
meoyawn / EmptyRecyclerView.java
Created November 1, 2014 11:20
RecyclerView doesn't have an emptyView support, we gotta fix that
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class EmptyRecyclerView extends RecyclerView {
@Nullable View emptyView;
@ianmackinnon
ianmackinnon / match.c
Created August 8, 2012 12:01
C Regex multiple matches and groups example
# gcc -Wall -o match match.c && ./match
#
#include <stdio.h>
#include <string.h>
#include <regex.h>
@VimleshS
VimleshS / ruby_cert.rb
Created August 30, 2016 09:35
Usage examples of ruby’s openssl lib
#Reference
#https://devnotcorp.wordpress.com/2012/08/21/usage-examples-of-rubys-openssl-lib/
#!/usr/bin/ruby
require 'openssl'
require 'date'
require 'time'
@ymnk
ymnk / ECCKeyAgreement.java
Last active December 19, 2023 18:35
ECC with Java
// The following code is from http://www.academicpub.org/PaperInfo.aspx?PaperID=14496 .
import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
import javax.crypto.KeyAgreement;
public class ECCKeyAgreement {
public static void main(String[] args) throws Exception {
KeyPairGenerator kpg;
kpg = KeyPairGenerator.getInstance("EC","SunEC");
@aodin
aodin / gist:9493190
Last active March 23, 2024 20:24
Parsing JSON in a request body with Go
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type Message struct {
@kchristidis
kchristidis / protobuf-serialization.md
Last active April 12, 2024 20:09
Notes on protocol buffers and deterministic serialization (or lack thereof)

There doesn't seem to be a good resource online describing the issues with protocol buffers and deterministic serialization (or lack thereof). This is a collection of links on the subject.

Protocol Buffers v3.0.0. release notes:

The deterministic serialization is, however, NOT canonical across languages; it is also unstable across different builds with schema changes due to unknown fields.

Maps documentation:

Wire format ordering and map iteration ordering of map values is undefined, so you cannot rely on your map items being in a particular order.