Skip to content

Instantly share code, notes, and snippets.

View convert_schema.py
#!/usr/bin/env python3
import json
import sys
import re
TYPES = {
'boolean': 'bool',
'integer': 'int',
'string': 'string',
'object': 'object',
View CachedConfig.ts
import { AppConfig } from 'aws-sdk';
import { hostname } from 'os';
const TTL = 30 * 1000; // ms
export default class CachedAppConfig {
cache: any = {}
client: AppConfig
version: AppConfig.Version = 'null'
refreshTime: number
View Barrier.h
#ifndef __H_BARRIER
#define __H_BARRIER
#include <mutex>
// https://stackoverflow.com/questions/24465533/implementing-boostbarrier-in-c11
class Barrier {
public:
explicit Barrier(std::size_t count) : mThreshold(count), mCount(count), mGeneration(0) {
}
View rwlock.h
#ifndef __RWLOCK_H
#define __RWLOCK_H
#include <pthread.h>
class rwlock {
public:
rwlock() {
pthread_rwlock_init(&lock_, nullptr);
}
@romanbsd
romanbsd / CMakeLists.txt
Created Nov 18, 2019
Tensorflow Lite 1.15 CMake file
View CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
project(tensorflow-lite)
set(CMAKE_CXX_STANDARD 11)
set(SOURCES
allocation.cc
arena_planner.cc
c/c_api_internal.c
core/api/error_reporter.cc
@romanbsd
romanbsd / db.m
Created Feb 27, 2019
db function for Octave
View db.m
function y = db (x, SignalType)
if (nargin < 1)
print_usage ();
endif
if (nargin == 2 && SignalType == 'power')
m = 10;
else
m = 20;
View betterftp.py
from ftplib import FTP, parse227, parse229
import socket
class BetterFTP(FTP):
def makepasv(self):
if self.af == socket.AF_INET:
_, port = parse227(self.sendcmd('PASV'))
else:
_, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername())
View levinson.py
import numpy as np
def levinson(acf, p=None):
acf = np.asarray(acf).reshape(-1)
if p is None:
p = len(acf) - 1
# ref = np.zeros(p, dtype=np.complex)
g = -acf[1]/acf[0]
View CStrMap.h
#ifndef __H_CSTRMAP
#define __H_CSTRMAP
#include <cstring>
#include <unordered_map>
struct hash_c_string {
void hash_combine(size_t &seed, const char &v) const {
seed ^= v + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
View merge_model.py
#!/usr/bin/env python3
import sys
from keras.models import model_from_json
model = model_from_json(open(sys.argv[1]).read())
print('Loaded model')
model.load_weights(sys.argv[2])
print('Loaded weights')
model.save(sys.argv[3])
print('Saved model')