Skip to content

Instantly share code, notes, and snippets.

View florianherrengt's full-sized avatar

Florian Herrengt florianherrengt

View GitHub Profile
@florianherrengt
florianherrengt / listFilesRecursive.test.ts
Created March 13, 2023 12:24
All all the files in a folder and sub folders
import path from "path";
import { listFiles } from "./listFiles";
/**
└── test
├── file1.txt
└── folder1
└── file2.txt
*/
@florianherrengt
florianherrengt / wide-table.sql
Last active November 26, 2022 13:13
Wide Table benchmark
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS events_id_seq;
CREATE SEQUENCE IF NOT EXISTS countries_id_seq;
CREATE SEQUENCE IF NOT EXISTS browsers_id_seq;
CREATE SEQUENCE IF NOT EXISTS devices_id_seq;
-- Table Definition
CREATE TABLE "public"."countries" (
"id" int4 NOT NULL DEFAULT nextval('countries_id_seq'::regclass),
"name" varchar,
@florianherrengt
florianherrengt / sequelize-field-mapping.ts
Last active April 30, 2019 09:45
Sequelize existing database fields mapping
/*
How to map fields from an existing database to a Sequelize model with:
- @Table({ tableName: '...' })
- @Column({ field: '...' })
*/
import {
Sequelize,
Table,
Model,
@florianherrengt
florianherrengt / text_similarity.py
Created April 1, 2019 22:13
How to use cosine similarity to compare 2 strings
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import cosine_similarity
corpus = [
'This is my first sentence',
'This is my second sentence'
]
vectorizer = CountVectorizer()
@florianherrengt
florianherrengt / check_prettier.sh
Last active February 7, 2019 01:59
check if files have been through prettier
prettier --write frontend/**/*.ts
prettier --write backend/**/*.ts
if [[ $(git ls-files -m) ]]; then
echo "You need to run prettier on those files"
git ls-files -m
exit 1
fi
@florianherrengt
florianherrengt / docker-compose.node.yml
Created November 17, 2017 22:52
Run docker with node debugger
version: "3"
services:
web:
build: .
ports:
- "3000:3000"
- "5858:5858"
volumes:
- "./:/wanderpay"
command: 'npm run dev'
from random import random
from statistics import mean
variables = [3, 5, 7, 10, 12, 13]
weight = [.1, .05, .05, .2, .4, .2]
if sum(weight) != 1:
raise 'sum(weight) != 1'
range_of_weight = [sum(weight[0:index + 1]) for index, w in enumerate(weight)]
@florianherrengt
florianherrengt / cluster.py
Last active April 12, 2017 16:54
Predict posts topic from BBC dataset
# BBC Dataset: http://mlg.ucd.ie/datasets/bbc.html
import os
import glob
import sys
import nltk
import numpy as np
import scipy as sp
from sklearn.cluster import KMeans
@florianherrengt
florianherrengt / README.md
Last active April 9, 2016 19:31
osmc play next video

This script will automatically stop the video and play the next one in the list

  • Replace 192.168.1.188:8080 with the correct ip address and port
  • Install Chorus
@florianherrengt
florianherrengt / .babelrc
Created April 4, 2016 09:18
Lambda Reproduce middleware with decorators
{
"presets": ["es2015", "stage-0"],
"plugins": ["transform-decorators-legacy"]
}