Skip to content

Instantly share code, notes, and snippets.

View Belrestro's full-sized avatar
🇺🇦

Andrew Vorobiov Belrestro

🇺🇦
  • Kiev
View GitHub Profile
const path = require('node:path');
const fs = require('node:fs');
const assert = require('node:assert');
const requireImpl = (pth) => {
assert((typeof pth) === 'string');
let moduleText;
const modulePath = path.join(process.cwd(), pth);
try {
moduleText = fs.readFileSync(modulePath);
@Belrestro
Belrestro / static.mjs
Last active April 29, 2024 20:53
Simplest Static metatech
import path from 'node:path';
import fs from 'node:fs';
import http from 'node:http';
const HTTP_PORT = 3000;
const STATIC_DIR = path.join(process.cwd(), './static');
const fsExists = (filePath) => fs.promises.access(filePath).then(() => true, () => false);
@Belrestro
Belrestro / generate.sh
Created August 20, 2019 11:57
Generate certificate for localhost
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
@Belrestro
Belrestro / run_core.sh
Created May 15, 2019 15:28
not so specific guide how to run core on a specific branch
# assuming you have pyhton 3.7-stretch
DIR=./
git clone --branch tags/0.14.3 git@github.com:RasaHQ/rasa_core.git $DIR \
&& cd $DIR
pip install pip==19.1
pip install -r requirements.txt
@Belrestro
Belrestro / example.py
Created May 13, 2019 09:27
train rasa core, and rasa nlu models programmatically rasa.core 0.14.3 nlu 0.15
from rasa_core.agent import Agent
from rasa_core.policies import KerasPolicy
from rasa_nlu.training_data import load_data
from rasa_nlu import config
from rasa_nlu.model import Trainer
import datetime
def _archive_name (type, environment):
t = datetime.datetime.now()
timestring = t.strftime('%Y%m%d-%H%M%S')
const http = require("http");
const path = require("path");
const fs = require("fs");
const busboy = require('connect-busboy');
const express = require("express");
const STORE_FOLDER = 'public';
const app = express();
app.use(busboy({
highWaterMark : 2 * 1024 * 1024 // alot
@Belrestro
Belrestro / simple_synth.js
Last active July 12, 2018 07:26
oscillator experiment
(() => {
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const noteMap = {
'90': {
key: 'Z',
note: 'C',
freq: 261.63
},
'83': {
export class Decoder {
getEmptyChunk () {
return {
name: '',
length: 0
};
}
readString (data, offset, length) {
return data.slice(offset, offset + length);
const mapToType = (parent, depth = 2) => {
const map = (object, lvl = 0) => {
if (object instanceof Array) object = object[0];
const props = {};
for (let key in object) {
const prop = object[key];
let type = typeof prop;
if (type === 'object') {
type = prop instanceof Array ? 'array' : 'object';
$(document).ready(function() {
$("a[href^='#']:not([data-toggle='tab']").click(function() {
var anchor = $(this).attr("href");
if ($(anchor).length != 0) {
$("html, body").animate({scrollTop: $(anchor).offset().top - ($('header').height()+10)}, 500);
}
return false;
});
});