Skip to content

Instantly share code, notes, and snippets.

View lucnat's full-sized avatar

Luca Naterop lucnat

View GitHub Profile
// Fragebogen v2.0
let example = {
// Are you a Man / a Woman?
'sex': 'female', // one of: 'male', 'female', 'other'
// Age
'yearOfBirth': 1992,
@lucnat
lucnat / select_teams.py
Created February 17, 2019 21:02
Select teams in competition with random drawing and non-trivial matching
# A script to find plays in a group of N people where in one game k players plays
# To be executed in python 3
# Written by Luca Naterop and Philippe frei
# January, 2019
from itertools import combinations
import numpy as np
from random import randint
from operator import itemgetter
@lucnat
lucnat / Router.jsx
Last active August 21, 2019 00:42
Meteor React-Router Accounts
import { Meteor } from 'meteor/meteor';
import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import { BrowserRouter, Route, Link, Redirect, withRouter, Switch} from "react-router-dom";
// pages accessible to all users
import Home from './Home';
import Login from './Login';
@lucnat
lucnat / StoneCollection.js
Created September 6, 2018 12:09
Stone Collection: An extremely simple persistent collection - written in stone.
/*
usage:
Tables = new Stone.Collection('tables'); // create a stone collection
Profile = new Stone.Singleton(''); // create a stone singleton
------- shared API -------
get() returns all in DB
@lucnat
lucnat / react-native-maps-example.jsx
Created May 2, 2018 20:43
Example usage for react-native-maps
import React from 'react';
import * as Na from 'native-base';
import { View, Image } from 'react-native';
import MapView, {PROVIDER_GOOGLE} from 'react-native-maps';
import mapStyle from './mapStyle';
/*
Google Maps iOS API Key: AIzaSyCORnMnmibA-blbUrcW4RRtrlr4xWu_G60
Google Maps Android API Key: AIzaSyDe-trUbugoWigSlaOSQUWo6yQwRSaC1ns
@lucnat
lucnat / simple_methods.js
Created May 2, 2018 18:01
Simple methods for bonobi api
// BaseURL = 'http://localhost:3030';
BaseURL = 'https://backend.bonobi.ch';
BaseAPI = BaseURL + '/api/v1';
// define authenticated and non-authenticated headers
Globals = {
authHeaders: {
'X-User-Id': localStorage.getItem('userId'),
'X-Auth-Token': localStorage.getItem('authToken'),
'Accept': 'application/json',
@lucnat
lucnat / RouterNavigator.jsx
Created February 20, 2018 21:11
Onsen React RouterNavigator example
import React, {Component} from 'react';
import {Page, Toolbar, Button, BackButton, RouterNavigator, RouterUtil, Input} from 'react-onsenui';
const SecondPage = ({pushPage, popPage}) => {
return (
<Page contentStyle={{padding: 10}}>
<Toolbar />
<br/> <br/> <br/>
<Button onClick={popPage}>Pop page</Button>
@lucnat
lucnat / batchloader.py
Created January 30, 2017 17:39
A minimalistic batch loader for python. Can also load batches for RNN's.
#
# A minimalistic BatchLoader
# Written by Luca Naterop, Zuerich, 2016
#
import math
import numpy as np
class BatchLoader:
@lucnat
lucnat / typescript_oop.ts
Created January 30, 2017 17:28
Typescript OOP the right way
// ----------------- VECTOR CLASS EXAMPLE ----------------
class Vector {
components: [number];
constructor(components: [number]){
this.components = components;
}