Skip to content

Instantly share code, notes, and snippets.

View sihu's full-sized avatar

Simon Huber sihu

View GitHub Profile
@sihu
sihu / laundry_day_generator.rb
Created December 21, 2020 19:26
Laundry Day Generator
require 'date'
require 'icalendar'
# Washday-ICS Generator
# /////////////////////////
# Author: Simon Huber
# Description: This script generates an ics file with a series of laundry_days.
# We are 5 parties and there are always 2 consecutive days, but not Sunday.
year = 2021
/**
Examples:
overrideDefaultConfig({ a: 1, b: 2 }, { a: 2 }); // => { a: 2, b: 2 }
overrideDefaultConfig({ a: { b: { c: 2 }}}, { a: { b: { c: 3, d: 4 }}}); // => { a: { b: { c: 3 } } }
overrideDefaultConfig({ a: 1, b: [2, 3]}, { a: 2, b: [4, 5] }); // => { a: 2, b: [4, 5]}
* This returns a new copy of the defaults and assigns all existing properties on the settings to the default config.
* @param {*} inputArg
* @returns {object}
def predict(model, path):
img = load_image(path)
predictions = model.predict(img)
certainties = []
labels = ['01', '02', '03', '04', '04b', '05', '06', '07', '08', '09', '10', '11', '12']
page_to_scene_mapping = {
'01': '1',
'02': '2',
'03': '2',
'04': '3',
import os
import numpy as np
from PIL import Image
SCENES = ['01', '02', '03', '04', '04b', '05', '06', '07', '08', '09', '10', '11', '12']
BATCH_SIZE = 4
def prepare():
@sihu
sihu / medium_tensorflow_grf_convolutions.py
Created February 5, 2020 16:55
Convolutions of GRF Model
model = tf.keras.models.Sequential([
# Note the input shape is the desired size of the image 150x150 with 3 bytes color
# This is the first convolution
tf.keras.layers.Conv2D(64, (3, 3), activation='relu', input_shape=(HEIGHT, WIDTH, 3)),
tf.keras.layers.MaxPooling2D(2, 2),
# The second convolution
tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D(2, 2),
tf.keras.layers.Dropout(0.3),
# The third convolution
from PIL import Image, ExifTags
def rotate_image(path):
try:
image = Image.open(path)
for orientation in ExifTags.TAGS.keys():
if ExifTags.TAGS[orientation] == 'Orientation':
break
exif = dict(image._getexif().items())
@sihu
sihu / test.rb
Created September 20, 2018 13:17
````
constraints subdomain: 'bauhaus' do
[['bodenbelaege', 'agb', :de], ['revetements-de-sol', 'cgv', :fr]].each do |route, terms, locale|
get route, to: 'bauhaus_carpets#new', locale: locale
get "#{route}/#{terms}", to: 'bauhaus_carpets#terms', locale: locale
get "#{route}/:code/edit", to: 'bauhaus_carpets#edit', locale: locale
patch "#{route}/:code", to: 'bauhaus_carpets#update', locale: locale
post route, to: 'bauhaus_carpets#create', locale: locale
get "#{route}/:code", to: 'bauhaus_carpets#show', locale: locale
end
@sihu
sihu / form_group_printer.ts
Last active June 25, 2018 14:02
Print form groups validity
printValidility(formGroup: FormGroup) {
return Object.keys(formGroup.controls).reduce((acc, current) => {
if ((formGroup.controls[current] as FormGroup).controls) {
acc[current] = this.printValidility(formGroup.controls[current] as FormGroup);
} else {
acc[current] = formGroup.controls[current].valid;
}
return acc;
}, {});
}

Keybase proof

I hereby claim:

  • I am sihu on github.
  • I am sihu (https://keybase.io/sihu) on keybase.
  • I have a public key ASB41ibY3DjdQojaD3kVGWYfk-mI3ZDtRj8jCvexkyKtiwo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am sihu on github.
* I am sihu (https://keybase.io/sihu) on keybase.
* I have a public key whose fingerprint is 6EC7 5242 D1B6 48DA 2365 9330 96DD 0E7D 1112 74AD
To claim this, I am signing this object: