Skip to content

Instantly share code, notes, and snippets.

View Drvanon's full-sized avatar
😀
Ready to get working

Robin Alexander Dorstijn Drvanon

😀
Ready to get working
  • Groningen
View GitHub Profile
movement1 = Movement("test1", "daily")
movement2 = Movement("test2", "daily")
for i in range(6):
user = User(f"user{i}", f"user{i}@email.com", "pass")
user.save_to_db()
users = User.query.all()
MUA = MovementUserAssociation
muas = [
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
@Drvanon
Drvanon / __init__.py
Last active June 8, 2019 12:20
Flask Context Problem
from flask import Flask
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__ )
app.config.from_mapping( SECRET_KEY='12398fjnkcm,zxcjnd123n')
from . import auth
app.register_blueprint(auth.bp)
version: '3.4'
services:
db:
restart: always
image: mysql:latest
command: --default-authentication-plugin=mysql_native_password
ports:
- '3306:3306'
environment:
MYSQL_ROOT_PASSWORD: root # TODO: Change this to something more secure on actual server!
def for_each(iterable, function):
running = True
while running:
try:
a = next(iterable)
function(a)
except StopIteration:
running = False
def length(array):
@Drvanon
Drvanon / .vimrc
Last active March 22, 2019 16:20
let mapleader =","
call plug#begin('~/.config/nvim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'junegunn/goyo.vim'
Plug 'tpope/vim-commentary'
Plug 'Townk/vim-autoclose'
Plug 'tpope/vim-surround'
@Drvanon
Drvanon / pysed
Created March 13, 2019 22:29
Simple script to act as a sed with python regex
#! /usr/bin/env python
# credit for the function to https://stackoverflow.com/a/40843600
# Commandline-ification by Robin A. Dorstijn
import re
import shutil
from tempfile import mkstemp
import click
@click.command()
@Drvanon
Drvanon / v4.py
Last active March 4, 2019 23:18
Self referential many to many relationship with extended data, containing foreign key
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, ForeignKey, String
from sqlalchemy.orm import relationship, mapper, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import association_proxy
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
#include <DRV8825.h>
#include <HX711.h>
HX711 scale;
#define CAL_VAL 385 // Set the calibration value
#define DOUT A1 // DOUT -> pin A1 on arduino
#define SCK A0 // SCK -> pin A0 on arduino
#define STEP_SIZE 10 // Set the step size in milimeter
user root;
worker_processes 1;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;