Skip to content

Instantly share code, notes, and snippets.

WonRhee /
Created Apr 17, 2021 — forked from kirang89/
Example for many-to-many relationship with extra columns in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
WonRhee / Native app communication
Created May 26, 2019 — forked from NielsLeenheer/Native app communication
How a web app running on HTTPS can communicatie with local services
View Native app communication
I have a web app that needs to talk to point of sale hardware: receipt printers, customer displays,
cash drawers and payment terminals. Direct communication from the web app with these devices is
impossible, so I created a native app that can be installed on the computer that can talk to the
devices. The app runs a web server that exposes these devices using a REST api.
The native app registers itself upon startup with a webservice. It sends its own IP address on
the local network and the server also sees the external IP address of the network. The web app
sends a discovery request to the webservice and it receives all the local IP addresses which
have the same external IP address.
View .bashrc
# ~/.bashrc
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ld='ls -ld -1 $PWD/*'
WonRhee /
Created Jul 26, 2017
Rename shell script example - dash to underscore
# rename dash to underscore using regex style
rename "s/-/_/g" *
WonRhee / findModeInArrayOfIntegers.js
Created Dec 20, 2016
Given array of integers, find its mode. (the number which appears most often in it)
View findModeInArrayOfIntegers.js
// Given array of integers, find its mode. (the number which appears most often in it)
function arrayMode(sequence) {
var arr = {};
for (var i=0; i < sequence.length; i++) {
var num = sequence[i];
if (arr[num] === undefined){
arr[num] = 0;
arr[num] += 1;