Skip to content

Instantly share code, notes, and snippets.

@yohanes
yohanes / click.py
Created January 28, 2016 06:54
Switch a button
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
PIN=18
GPIO.setup(PIN, GPIO.OUT)
GPIO.output(PIN, 1)
time.sleep(0.1)
GPIO.output(PIN, 0)
GPIO.cleanup()
@yohanes
yohanes / click_server.py
Created January 28, 2016 06:55
Click server
from flask import Flask, redirect, url_for
import os
app = Flask(__name__)
@app.route('/')
def index():
return """
<html><head><title>HDMI switcher</title><style>
.btn {
@yohanes
yohanes / pidgey.py
Last active September 6, 2016 03:54
How many Pidgeys you need to reach an XP (assuming you always evolve after 12 candies and not using lucky egg)
import sys
if (len(sys.argv)<2):
print "Usage: python pidgey.py targetxp"
exit(0)
target_xp = int(sys.argv[1])
print "Target XP ", target_xp
<?php
header("Content-type: application/json");
$lang = "en";
$dir = "/var/www/html/talkdata/";
$text = $_GET['t'];
$m = urlencode($text);
$filename = $lang . "-". $m . ".mp3";
$file = $dir.$filename;
if (!file_exists($file)) {
$mp3 = file_get_contents(
<html>
<head>
<title>Talk</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
Say
<form onsubmit="return say();">
<input type="text" style="font-size: 72pt; background: #eeeeee" id="t" size=30 >
</form>