Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastian Wallkötter FirefoxMetzger

View GitHub Profile
View custom_posture.py
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 Mar 15, 2019
Print the full list of methods (including undocumented) that a naoqi module has to offer
View fullMethodList.py
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 Mar 15, 2019
A quick and dirty example on how to use the ALRobotPosture API on a NAO or Pepper robot
View basics.py
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")
View config.py
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 Dec 17, 2018
plumbing between MTurk and Questback
View index.html
<!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 Apr 16, 2018
A stub config to create self-signed SSL certificates with IP SANs via openssl
View config.cfg
[ 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 Apr 14, 2018
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)
View DNA_visualizer_optimization_2.py
#!/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 Apr 14, 2018
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.
View DNA_visualizer_optimization_1.py
#!/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 Apr 10, 2018
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
View trouble_sort.py
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 Apr 8, 2018
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? :) )
View shield.py
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