Skip to content

Instantly share code, notes, and snippets.

View teschmitt's full-sized avatar
🏠
Working from home

Thomas Schmitt teschmitt

🏠
Working from home
  • MaibornWolff
  • Darmstadt, Germany
View GitHub Profile
@teschmitt
teschmitt / id.rs
Last active March 26, 2024 16:05
Rust newtype UUID implementation that can be used with diesel ORM
use diesel::{
backend::Backend,
deserialize::{self, FromSql},
serialize::{self, Output, ToSql},
sql_types::Binary,
AsExpression, FromSqlRow,
};
use std::fmt::{self, Display, Formatter};
use uuid;

Keybase proof

I hereby claim:

  • I am teschmitt on github.
  • I am teschmitt (https://keybase.io/teschmitt) on keybase.
  • I have a public key ASDsTOj4Tb0Ohcka0Mr18CdVQPmK91vIjj3aeLnRO7uRFgo

To claim this, I am signing this object:

@teschmitt
teschmitt / transf_demo.py
Last active April 23, 2021 12:32
CER Demo 1
from functools import reduce
from math import cos, sin, pi
import numpy as np
def rad(theta):
"""
Grad in Radiane umwandeln und zurückgeben
"""
return theta * pi / 180
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@teschmitt
teschmitt / inventory_models.py
Created June 26, 2018 13:10
Test Inventory Database Models
class Product(models.Model):
profile = models.ForeignKey('accounts.Profile', null=True,
blank=True, on_delete=models.CASCADE)
name = models.CharField(max_length=180)
class ProductOption(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
nr = models.IntegerField(default=0)
name = models.CharField(max_length=20, null=False, blank=False)
@teschmitt
teschmitt / output_data.csv
Last active July 9, 2018 11:37
Get tumblr posts by tag
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 8 columns, instead of 7. in line 1.
content,date,time,tags,id,blog_name,post_url,type
"When Grandma would take care of us at our old house. She would always conversate with @patgomez91 on the side about a lot of things! When looking at them together, it reminds me of the old days. 😢
.
.
.
#life #love #goals #happy #lifestyle #positivity #peace #believe #entrepreneur #positivevibes #goodvibes #blessed #beautiful #quotes #motivational #successful #healthy #business #strength #hope #truth #spiritual #quoteoftheday #health #smile #joy #inspirational #family #dream (at Los Angeles, California)",2017-12-24,23:17:06,"['positivity', 'goals', 'strength', 'dream', 'happy', 'peace', 'lifestyle', 'beautiful', 'inspirational', 'blessed', 'quoteoftheday', 'motivational', 'business', 'successful', 'love', 'life', 'positivevibes', 'family', 'quotes', 'health', 'spiritual', 'truth', 'healthy', 'entrepreneur', 'hope', 'goodvibes', 'joy', 'believe', 'smile']",168906004762,pjaysodope-blog,http://pjaysodope-blog.tumblr.com/post/168906004762/when-grandma-would-t
@teschmitt
teschmitt / forms.py
Last active December 14, 2017 21:58
Django ModelForm Label Transation
from django import forms
from .models import Topic
from django.utils.translation import ugettext_lazy as _
class NewTopicForm(forms.ModelForm):
message = forms.CharField(
widget=forms.Textarea(
attrs={'rows': 5, 'placeholder': 'What is on your mind?'}
),
max_length=4000,
@teschmitt
teschmitt / mergesort.py
Last active October 7, 2017 22:29
A pythonic merge sort implementation
""" Straightforward approach, shaving sorted elements off of the beginning of the partitions """
def merge(l_left, l_right):
l_sorted = []
while l_left and l_right:
if l_left[0] <= l_right[0]:
l_sorted.append(l_left.pop(0))
else:
l_sorted.append(l_right.pop(0))
# Extend return variable by list with remaining entries
return l_sorted + l_left + l_right