Skip to content

Instantly share code, notes, and snippets.

View FirefoxMetzger's full-sized avatar

Sebastian Wallkötter FirefoxMetzger

View GitHub Profile
from naoqi import ALBroker
from naoqi import ALProxy
from pprint import pprint
# start a local broker that connects to the NAO
robot_ip = "love"
myBroker = ALBroker("myBroker", "0.0.0.0", 0, robot_ip, 9559)
# get a handle to the module
@FirefoxMetzger
FirefoxMetzger / fullMethodList.py
Created March 15, 2019 16:32
Print the full list of methods (including undocumented) that a naoqi module has to offer
from naoqi import ALBroker
from naoqi import ALProxy
from pprint import pprint
# start a local broker that connects to the NAO
robot_ip = "your-ip-here"
myBroker = ALBroker("myBroker", "0.0.0.0", 0, robot_ip, 9559)
# get a handle to the module
@FirefoxMetzger
FirefoxMetzger / basics.py
Last active March 15, 2019 16:02
A quick and dirty example on how to use the ALRobotPosture API on a NAO or Pepper robot
from naoqi import ALBroker
from naoqi import ALProxy
# start a local broker that connects to the NAO
robot_ip = "your-ip-here"
myBroker = ALBroker("myBroker", "0.0.0.0", 0, robot_ip, 9559)
# get a handle to the module
posture_proxy = ALProxy("ALRobotPosture")
tts_proxy = ALProxy("ALTextToSpeech")
AWS_ACCESS_KEY_ID = "YOUR KEY ID HERE"
AWS_SECRET_ACCESS_KEY = "YOUR SECRET KEY HERE"
USE_SANDBOX = False
@FirefoxMetzger
FirefoxMetzger / index.html
Last active December 17, 2018 20:18
plumbing between MTurk and Questback
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Redirecting to the Survey ...</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
@FirefoxMetzger
FirefoxMetzger / config.cfg
Created April 16, 2018 20:57
A stub config to create self-signed SSL certificates with IP SANs via openssl
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
x509_extensions = v3_ca # The extentions to add to the self signed cert
string_mask = utf8only
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = AU
countryName_min = 2
@FirefoxMetzger
FirefoxMetzger / DNA_visualizer_optimization_2.py
Created April 14, 2018 13:19
Code from: https://codereview.stackexchange.com/questions/192027/genetic-sequence-visualizer-generating-large-images ; No longer uses `largearray` and removed timing statements (can be done better with cpython)
#!/usr/bin/env python3
# Python3
import logging
from argparse import ArgumentParser
from os import remove
from os.path import exists
from re import sub
from time import time
@FirefoxMetzger
FirefoxMetzger / DNA_visualizer_optimization_1.py
Created April 14, 2018 13:00
The code from https://codereview.stackexchange.com/questions/192027/genetic-sequence-visualizer-generating-large-images slightly optimized. It avoids storing things that can easily be computed on the fly saving 40x memory.
#!/usr/bin/env python3
# Python3
#
# Run from command line
#
import logging
from argparse import ArgumentParser
from copy import deepcopy, copy
from datetime import timedelta
@FirefoxMetzger
FirefoxMetzger / trouble_sort.py
Created April 10, 2018 20:49
My answer to the second problem of the Code Jam. It has a small error: Instead of printing "Case #1:" it's printing "Case 1:" ... small things :D
import sys
def trouble_sort(L):
# in place sorting
done = False
while not done:
done = True
for idx in range(len(L) - 2):
if L[idx] > L[idx + 2]:
done = False
@FirefoxMetzger
FirefoxMetzger / shield.py
Created April 8, 2018 12:54
Solution for the first question of the Google Code Jam 2018. (It passes the first round of tests, but is to slow for the second; thus requires runtime optimization. Can you see what could be changed? :) )
from collections import deque
import sys
def get_damage(sequence):
current_strength = 1
damage = 0
for char in sequence:
if char == "C":
current_strength *= 2