Skip to content

Instantly share code, notes, and snippets.

View adamski's full-sized avatar

Adam Wilson adamski

  • CodeGarden / NodeAudio
  • Bristol UK
View GitHub Profile
@matkatmusic
matkatmusic / PEMFormatKey.cpp
Created June 9, 2022 04:12
OpenSSL <-> juce::RSAKey
/*
Code that allows conversion of OpenSSL public keys into the juce::RSAKey format.
This may or may not work with private keys.
I have not tested it with private keys from the server, only public keys from the server.
*/
struct PEMHelpers
{
using PEMMemoryBlock = juce::MemoryBlock;
using PEMDataType = juce::uint8;
/*
==============================================================================
MouseOverChecker.h
Created: 13 Aug 2019 1:26:42pm
Author: Daniel Walz
==============================================================================
*/
@lillypad
lillypad / rsa.hpp
Last active May 8, 2024 14:11
OpenSSL RSA Encryption / Decryption C++ Wrapper
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/err.h>
#define CRYPTO_RSA_KEY_LEN_4096 4096
#define CRYPTO_RSA_KEY_LEN_2048 2048
#define CRYPTO_RSA_KEY_LEN_1024 1024
extern crate custom_error;
extern crate memmem;
extern crate openssl;
extern crate openssl_sys;
extern crate hex;
extern crate foreign_types_shared;
extern crate tokio;
extern crate tokio_openssl;
@vermorel
vermorel / fast_convolve_1D.cpp
Last active April 10, 2024 12:31
Fast 1D convolution with AVX
// Fast 1D convolution with AXV
// By Joannes Vermorel, Lokad, January 2018
// Released under MIT license
#include <string.h>
#include <stdio.h>
#include <malloc.h>
/* A simple implementation of a 1D convolution that just iterates over
* scalar values of the input array.
@MisterRager
MisterRager / CMakeLists.txt
Last active March 22, 2021 17:10
Build SQLite fts5 extension with CMake
cmake_minimum_required(VERSION 2.8)
include(ExternalProject)
ExternalProject_Add(sqlite-sources
URL http://www.sqlite.org/2017/sqlite-src-3200100.zip
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/sqlite-sources
CONFIGURE_COMMAND cd ../sqlite-sources && ./configure
BUILD_COMMAND ""
INSTALL_COMMAND "")
@lanedraex
lanedraex / listener.rs
Created November 5, 2017 09:12
Rust UDP socket: send and receive
use std::net;
use std::env;
fn listen(socket: &net::UdpSocket, mut buffer: &mut [u8]) -> usize {
let (number_of_bytes, src_addr) = socket.recv_from(&mut buffer).expect("no data received");
println!("{:?}", number_of_bytes);
println!("{:?}", src_addr);
@ckunte
ckunte / cf.sh
Created June 4, 2017 13:58
Remove spaces and special characters from file and folder names (in zsh)
#!/usr/bin/env zsh
autoload -U zmv
# Safety first: Always use -n switch to test changes before commit.
# Clean up file names in subdirectories and remove special characters
zmv -n '(**/)(*)' '$1${2//[^A-Za-z0-9.-]/_}'
# Replace spaces in filenames and folders with a hyphen
zmv -n '* *' '$f:gs/ /-'
@jpoutrin
jpoutrin / reactNativeSwaggerV2HttpClient
Created May 15, 2017 15:00
This snippet can be used as a client parameter for swagger-client v2 on react native
export const reactNativeHttpClient = {
// implment an execute function
execute: async function (obj) {
const httpMethod = obj.method;
const requestHeaders = obj.headers;
const body = obj.body;
const url = obj.url;
const response = await fetch(obj.url, {
method: httpMethod,
@mochja
mochja / main.c
Last active September 25, 2023 15:08
Yoga + OpenGL Example
#include <GLFW/glfw3.h>
#include <yoga/Yoga.h>
#include <stdlib.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())