Skip to content

Instantly share code, notes, and snippets.

Avatar
Proletarier aller Länder, vereinigt euch!

坂本ポテコ sakamoto-poteko

Proletarier aller Länder, vereinigt euch!
View GitHub Profile
@sakamoto-poteko
sakamoto-poteko / gen.sh
Created Jan 23, 2021
OpenSSL generate root and intermediate CA (simple)
View gen.sh
#!/bin/bash
# Root CA
echo 'Generating Root CA'
openssl ecparam -name secp384r1 -genkey -noout -out ca.key.pem
openssl req -x509 -new -nodes -key ca.key.pem -sha512 -days 3650 -out ca.crt.pem
openssl pkcs12 -inkey ca.key.pem -in ca.crt.pem -export -out ca.pfx
# Intermediate CA
echo 'Generating Intermediate CA'
View bin2hex.zsh
file=`cat cipher.txt | sed -e 's/[\r\n]/ /g'`
for word in ${=file}
do
printf '%02x ' $((0b$word))
done
@sakamoto-poteko
sakamoto-poteko / pose_est.cpp
Last active Jan 9, 2020
Pose estimation from accelerometer and gyroscope
View pose_est.cpp
// libshovel.cpp : Defines the entry point for the application.
//
//
#include "Eigen/Eigen"
namespace shovel {
struct Pose
{
@sakamoto-poteko
sakamoto-poteko / HPS.m
Last active Dec 4, 2019
HPS algorithm for tone detection
View HPS.m
function [ freq ] = HPS(audiofile)
CORRECTFACTOR=1;
[sample, fs] = audioread(audiofile);
fftn = fs;
sample = sample .* hann(length(sample));
fftr = abs(fft(sample,fftn));
fftr = fftr(1:fftn/2);
@sakamoto-poteko
sakamoto-poteko / Makefile
Created Apr 18, 2018
.Net Interop Example
View Makefile
all:
g++ -shared interop.cpp -o libmain.so
View edgerouter-azure-vpn-commands.txt
set vpn ipsec ipsec-interfaces interface pppoe0
set vpn ipsec auto-firewall-nat-exclude enable
set vpn ipsec nat-traversal enable
set vpn ipsec esp-group esp-azure compression disable
set vpn ipsec esp-group esp-azure lifetime 3600
set vpn ipsec esp-group esp-azure mode tunnel
set vpn ipsec esp-group esp-azure pfs disable
set vpn ipsec esp-group esp-azure proposal 1 encryption aes256
set vpn ipsec esp-group esp-azure proposal 1 hash sha1
@sakamoto-poteko
sakamoto-poteko / ecdsa.cpp
Created Sep 22, 2017
OpenSSL ECDSA signing and verification
View ecdsa.cpp
#include <cstdio>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <vector>
#include <openssl/ecdsa.h>
#include <openssl/sha.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
@sakamoto-poteko
sakamoto-poteko / move.cpp
Last active Sep 1, 2017
std::move in ctor initializer
View move.cpp
#include <utility>
#include <iostream>
class ctor
{
public:
ctor()
{
std::cout << "default ctor" << std::endl;
}
@sakamoto-poteko
sakamoto-poteko / calib.py
Created Jul 26, 2017
OpenCV camera calibration and undistort
View calib.py
import numpy as np
import cv2
import glob
# termination criteria
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
cbrow = 7
cbcol = 9
View checksum.c
int checksum(const char *str)
{
int weight[] = {7, 3, 1};
int checksum = 0;
int len = strlen(str);
for (int i = 0; i < len; ++i) {
int mappedNum = 0;
if (isdigit(str[i])) {