Skip to content

Instantly share code, notes, and snippets.

View sakamoto-poteko's full-sized avatar
Proletarier aller Länder, vereinigt euch!

坂本ポテコ sakamoto-poteko

Proletarier aller Länder, vereinigt euch!
  • Duna, Kerbol System
View GitHub Profile
@sakamoto-poteko
sakamoto-poteko / gnutls-verify-chain.c
Created December 22, 2014 02:51
Verify certificate chain against given CA (PEM) using GnuTLS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
int main(void)
{
FILE *fl;
@sakamoto-poteko
sakamoto-poteko / openssl-verify-rsa-signature.c
Last active November 18, 2020 15:37
OpenSSL verify RSA signature, read RSA public key from X509 PEM certificate
#include <stdio.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
void verifyRSASignature(unsigned char *originalMessage, unsigned int om_length,
unsigned char *signature, unsigned siglen)
{
int result;
FILE *file;
@sakamoto-poteko
sakamoto-poteko / convert.sh
Last active August 29, 2015 14:15
Async & Queued MgConvert
#!/bin/bash
src=$1
des=$2
width=$3
height=$4
watermark=$5
if [ `identify -format "%n" ${src}` -eq 1 ]
then
convert ${src} -resize ${width}x${height} ${des}
@sakamoto-poteko
sakamoto-poteko / a20test.asm
Last active January 30, 2024 01:51
A20-test
[bits 16]
org 07c00h
mov ax, cs
mov ds, ax
mov es, ax
call check_a20
test ax, ax
@sakamoto-poteko
sakamoto-poteko / nvml.cpp
Last active October 21, 2022 23:11
NVML Get GPU Utilization
#include <cstdio>
#include <nvml.h>
#pragma comment(lib, "nvml")
int main(int argc, char* argv[])
{
nvmlReturn_t result;
unsigned int device_count;
#include <stdlib.h>
#include <stdio.h>
#include <immintrin.h>
const static __m256i SEED_MUL = _mm256_set1_epi32(214013);
const static __m256i SEED_ADDI = _mm256_set1_epi32(2531011);
const static __m256i SEED_MASK = _mm256_set1_epi32(0x3F800000);
const static __m256 FLOAT_1 = _mm256_set1_ps(1.f);
const static __m256i INT32_1 = _mm256_set1_epi32(1);
@sakamoto-poteko
sakamoto-poteko / checksum.c
Created July 15, 2016 05:30
ICAO 9303 Checksum
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])) {
@sakamoto-poteko
sakamoto-poteko / calib.py
Created July 26, 2017 12:42
OpenCV camera calibration and undistort
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
@sakamoto-poteko
sakamoto-poteko / move.cpp
Last active September 1, 2017 04:12
std::move in ctor initializer
#include <utility>
#include <iostream>
class ctor
{
public:
ctor()
{
std::cout << "default ctor" << std::endl;
}
@sakamoto-poteko
sakamoto-poteko / ecdsa.cpp
Created September 22, 2017 10:48
OpenSSL ECDSA signing and verification
#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>