Skip to content

Instantly share code, notes, and snippets.

View marty1885's full-sized avatar
👨‍💻
Writing code

Martin Chang marty1885

👨‍💻
Writing code
View GitHub Profile
#include <chrono>
#include <iostream>
#include <vector>
#include <random>
#include <cstring>
#include <array>
#include <cblas.h>
#include <rknn_matmul_api.h>
#include <string>
#include <vector>
#include <functional>
#include <iostream>
#include <optional>
#include <cassert>
#include <unordered_set>
#include <cppcoro/generator.hpp>
#include <cppcoro/task.hpp>
#include <cppcoro/sync_wait.hpp>
#include <cxxabi.h>
#include <iostream>
void demangle_name(const std::string& mangled_name)
{
std::size_t len = 0;
int status = 0;
auto name = __cxxabiv1::__cxa_demangle(mangled_name.c_str(), nullptr, &len, &status);
if (status == 0)
{
#include <cstddef>
#include <functional>
#include <memory>
#include <utility>
#include <stdexcept>
#include <iostream>
template <typename>
struct shared_function{};
import gym
from etaler import et
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
def running_mean(x, N):
cumsum = np.cumsum(np.insert(x, 0, 0))
return (cumsum[N:] - cumsum[:-N]) / float(N)
@marty1885
marty1885 / crypto.cpp
Created March 15, 2021 00:07
Cryptographic (password hashing) library for Drogon
#include "crypto.hpp"
#include <regex>
#include <bsd/stdlib.h>
#include <botan/argon2.h>
#include <botan/system_rng.h>
static Botan::System_RNG rng;
uint32_t secureRandom(uint32_t lower, uint32_t upper)
#include <drogon/drogon.h>
#include <exception>
#include <coroutine>
#include <stdexcept>
using namespace drogon;
int main()
{
app().createDbClient("postgresql", "localhost", 5432, "test", "test", "some legit password 191561", 16)
==> Making package: root 6.22.06-1 (Mon 07 Dec 2020 02:32:35 PM CST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Found ROOFIT_LICENSE
-> Found root.xml
-> Found root.pc.tpl
-> Found settings.cmake
-> Found jupyter_notebook_config.py
-> Found nbman-for-arch.patch
@marty1885
marty1885 / sdl_gl.cpp
Created November 30, 2020 15:27
PoC code hacked from various sources, SDL with OpenGL (ES) using external context
// To compile: (Tested on Arch Linux)
// c++ sdl_gl.cpp -o sdl_gl `pkg-config sdl2 --cflags --libs` -lwayland-egl -lwayland-egl -lGL -lEGL -lX11 && ./sdl_gl
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include "SDL2/SDL_syswm.h"
#include <GL/gl.h>
from etaler import et
import gym
env = gym.make('FrozenLake-v0', is_slippery=False)
# The agent is very simple. Mathmetically, think it as a weaker Q table. Biologically, it is a bunch
# of perimedial neurons receving input signals and direcly connected to a motor. Then the reward is
# used for modifing the behaivor of the neurons.
class Agent:
def __init__(self):