Skip to content

Instantly share code, notes, and snippets.

View tspycher's full-sized avatar

Thomas Spycher tspycher

View GitHub Profile
def externalPaymentAttributes():
return {
'country': 'CH',
'email': self.host_emails[0] if self.host_emails else None,
'business_name': self.name,
#'business_tax_id_provided': False,
'tos_acceptance': {
'date': int(time.time()),
'ip': "185.90.38.128",
'user_agent': 'Cathedra Backend'
@tspycher
tspycher / Proofing_The_Monty_Hal_Problem.py
Created December 15, 2015 12:25
The Monty Hall Problem in Python
import random
summary = {"lose_inital":0, "win_initial":0, "lose":0, "win":0}
def game(switch=False):
fields = [False,False,False]
winField = random.randint(0,2)
fields[winField] = True
setField = random.randint(0,2)
@tspycher
tspycher / gist:604834a30f7dd99e371f
Created April 5, 2015 21:15
Geo Calculations for Flight Navigation
from math import radians, cos, sin, asin, sqrt, atan2, degrees
def _c(old):
direction = {'N':1, 'S':-1, 'E': 1, 'W':-1}
new = old
new = new.split()
new_dir = new.pop(0)
new.extend([0,0,0])
x = (float(new[0])+float(new[1])/60.0+float(new[2])/3600.0) * direction[new_dir]
return x
@tspycher
tspycher / MongoDB: AbstractTest.php
Created February 6, 2014 15:08
Base Clase wich drops all Collections and build the them from scratch
<?php
namespace XXX\Tests\Document;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
abstract class AbstractTest extends WebTestCase
{
static $container;
@tspycher
tspycher / _etc_init.d_selenium
Last active December 28, 2015 02:49
/etc/init.d/selenium for CentoOS 6.4
#!/bin/bash
# selenium - this script starts and stops the selenium grid
#
# chkconfig: - 85 15
# description: Selenium Grid is a distributed testing platform for browser-based automation.
# processname: selenium
# pidfile: /etc/selenium/tmp/selenium.pid
# Source function library.
. /etc/rc.d/init.d/functions