Skip to content

Instantly share code, notes, and snippets.

View mikahanninen's full-sized avatar

Mika Hänninen mikahanninen

  • Robocorp
  • Finland
View GitHub Profile

Keybase proof

I hereby claim:

  • I am mikahanninen on github.
  • I am mikahanninen (https://keybase.io/mikahanninen) on keybase.
  • I have a public key whose fingerprint is 7A4D 0AA7 F3F9 E5A1 00C0 37DE 7835 F687 1D1E C541

To claim this, I am signing this object:

@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
@mikahanninen
mikahanninen / syslogserver.js
Last active October 15, 2019 14:20
node.js syslogserver
const syslogserver = require('syslog-server')
let fs = require('fs')
function main() {
let logfile = process.argv[2]
if (!logfile) {
console.log('Logfile needs to be given as an argument.')
return
}
@mikahanninen
mikahanninen / saucelabs.py
Created November 5, 2019 15:14
SauceLabs configuration related to Robot Framework and SeleniumLibrary
import os
from sauceclient import SauceClient
from robot.libraries.BuiltIn import BuiltIn
username = os.environ.get('SAUCELABS_USERNAME')
access_key = os.environ.get('SAUCELABS_ACCESSKEY')
sauce_client = SauceClient(username, access_key)
def report_sauce_status(name, status, build=None):
@mikahanninen
mikahanninen / script.groovy
Last active November 7, 2019 12:57
Previous builds into Jenkins dashboard badges
def resultList = []
currentBuildNumber = manager.build.number
for (i = (currentBuildNumber - 19); i <= currentBuildNumber; i++) {
if (manager.setBuildNumber(i)) {
resultList << manager.getResult()
}
}
manager.setBuildNumber(currentBuildNumber)
for (i = 0; i < resultList.size(); i++) {
@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 / 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 / test_browser.py
Last active March 18, 2020 09:17
Default RPA.Browser test
from RPA.Browser import Browser
br = Browser()
br.open_chrome_browser('https://www.robocorp.com')
br.screenshot()
xpath = "//footer//p//a"
value = br.get_text(f"xpath:{xpath}")
print(xpath, value)
@mikahanninen
mikahanninen / logger.py
Created March 18, 2020 09:47
basic logging python
import logging
logging.basicConfig(
filename="dev.log",
format="%(asctime)s %(name)s %(levelname)-8s %(message)s",
level=logging.DEBUG,
)
@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