Skip to content

Instantly share code, notes, and snippets.

View mikahanninen's full-sized avatar

Mika Hänninen mikahanninen

  • Robocorp
  • Finland
View GitHub Profile

Offline Python Package Install Notes

Two common cases which make the install of Python packages harder due to networking issues are: a) Install behind a Proxy b) Install without access to the internet

(a) Install behind a Proxy

In the case where the target machine connects to the internet over a network proxy, export the following environment vars, as appropriate - http_proxy and https_proxy. Eg:

@mikahanninen
mikahanninen / led.py
Created September 2, 2020 13:33 — forked from mickey-happygolucky/led.py
HTTP server with python
import RPi.GPIO as GPIO
class Led:
def __init__(self, pin):
self.pin = pin
self.s = 0
GPIO.setmode(GPIO.BOARD)
GPIO.setup(self.pin, GPIO.OUT)
@mikahanninen
mikahanninen / gist:5d4789a7304c6d90fe16327fe59a28fc
Created June 12, 2020 07:14 — forked from simonw/gist:68d19a46e8edc2cd8c68
Fix "Do you want the application "python" to accept incoming network connections?" by code signing the python executable in your virtualenv - copied here in case https://www.darklaunch.com/2014/02/02/fix-do-you-want-the-application-python-to-accept-incoming-network-connections ever goes away.
With the OS X firewall enabled, you can remove the "Do you want the application "python" to accept incoming network connections?" message.
Create a self-signed certificate.
Open Keychain Access. Applications > Utilities > Keychain Access.
Keychain Access menu > Certificate Assistant > Create a Certificate...
Enter a Name like "My Certificate".
Select Identity Type: Self Signed Root
Select Certificate Type: Code Signing
Check the Let me override defaults box
@mikahanninen
mikahanninen / listener.py
Last active June 8, 2020 11:37 — forked from shpaker/listener.py
Robot's listener v3 implementation
""" Robot's listener v3 implementation
For more information see:
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#listener-version-3
"""
ROBOT_LISTENER_API_VERSION = 3
def start_suite(suite, result):
""" Called when a test suite starts.
@mikahanninen
mikahanninen / pdfmod.py
Created May 11, 2020 06:53 — forked from jrsmith3/pdfmod.py
Convert specified pages from a PDF to png
"""
This script was used to create the figures for http://jrsmith3.github.io/sample-logs-the-secret-to-managing-multi-person-projects.html from a PDF file containing some old CMU sample logs.
"""
import PyPDF2
from wand.image import Image
import io
import os
@mikahanninen
mikahanninen / jupyter_logging.py
Last active November 1, 2020 16:32 — forked from wassname/jupyter_logging.py
simple logging for jupyter or python which outputs to stdout (or a console or terminal) and a log file
"""
In jupyter notebook simple logging to console
"""
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
# TO exclude log message from certain package
logging.getLogger("urllib3").setLevel(logging.WARNING)
@mikahanninen
mikahanninen / gist:4e46d589b3cac5e4b365fa6244f80e38
Last active March 27, 2020 07:20 — forked from ymirpl/gist:1052094
Python unicode e-mail sending
#coding: utf-8
from cStringIO import StringIO
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email import Charset
from email.generator import Generator
import smtplib
# Example address data
@mikahanninen
mikahanninen / osx_install.sh
Created January 8, 2020 13:18 — forked from cassiocardoso/osx_install.sh
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@mikahanninen
mikahanninen / fixup.txt
Created December 30, 2019 06:36 — forked from lucasdavila/fixup.txt
Fixing mac os yosemite issue "bash: fork: Resource temporarily unavailable"
# see the current limits
$ sysctl -a | grep maxproc
# increase it
$ sudo sysctl -w kern.maxproc=xxxx
$ sudo sysctl -w kern.maxprocperuid=xxx
# run at startup
$ sudo vim /etc/sysctl.conf
@mikahanninen
mikahanninen / adb-screen
Created October 10, 2019 05:28 — forked from vrendina/adb-screen
Turn the screen on or off on all connected Android devices
#!/bin/sh
# Returns the power state of the screen 1 = on, 0 = off
getDisplayState() {
state=$(adb -s $1 shell dumpsys power | grep mScreenOn= | grep -oE '(true|false)')
# If we didn't get anything it might be a pre-lollipop device
if [ "$state" = "" ]; then
state=$(adb -s $1 shell dumpsys power | grep 'Display Power' | grep -oE '(ON|OFF)')
fi