Skip to content

Instantly share code, notes, and snippets.

View cdfpaz's full-sized avatar

bzero cdfpaz

View GitHub Profile
@cdfpaz
cdfpaz / greeks.cpp
Created October 5, 2015 17:08
Calculating the greeks
#include <stdio.h>
#include <math.h>
const double Pi = 3.14159265359;
// Standard Normal probability density function
// Normal PDF(x) = exp(-x*x/2)/{sigma * sqrt(2 * Pi) }
double Normal_PDF(const double & x) {
return (1.0/(double)pow(2 * Pi, 0.5)) * exp(-0.5 * x * x);
}
package main
import (
"fmt"
"log"
"net/http"
"encoding/json"
)
type test_struct struct {
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#endif
#include <R.h>
#include <Rmath.h>
#include <Rinternals.h>
SEXP BSput (SEXP S, SEXP X, SEXP b, SEXP r, SEXP t, SEXP v)
{
/* possible add vectorization to this to make it faster, though
the R code is plenty fast enough */
#include <set>
#include <iostream>
#include <complex>
#include <algorithm>
#include <stdexcept>
template <typename T> int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
@cdfpaz
cdfpaz / PinblockTool.java
Created May 17, 2016 18:36 — forked from Gilmor/PinblockTool.java
Pinblock ISO 9564 format 0
package cz.monetplus.mnsp.tools.misc;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang.StringUtils;
/**
* Tools for encoding a decoding pinblock
*
* @author Tomas Jacko <tomas.jacko [at] monetplus.cz>
@cdfpaz
cdfpaz / latency.markdown
Created October 9, 2016 15:30 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

/****************************************************************************
*
* Hello VBE!
*
*
* Language: C (Keyword far is by definition not ANSI, therefore
* to make it true ANSI remove all far references and
* compile under MEDIUM model.)
*
* Environment: IBM PC (MSDOS) 16 bit Real Mode
@cdfpaz
cdfpaz / gist:4cc02cf400b48d5214f76ed2ebcd3d8a
Created June 7, 2017 00:26
Convert jks file to PKCS12
Convert jks file to PKCS12:
keytool -importkeystore -srckeystore mycert.jks -destkeystore keystore.p12 -deststoretype PKCS12

Keybase proof

I hereby claim:

  • I am bzero on github.
  • I am bzero (https://keybase.io/bzero) on keybase.
  • I have a public key ASBr1aoT2gtuuqlbPCnCIhRiqjREacjappXNtcOPh-VvqQo

To claim this, I am signing this object: