Skip to content

Instantly share code, notes, and snippets.

View kangasta's full-sized avatar

Toni Kangas kangasta

View GitHub Profile
@kangasta
kangasta / README.md
Last active October 6, 2022 19:05
Example output for spf13/cobra #1822
@kangasta
kangasta / completion.go
Last active June 23, 2022 21:59
Cobra shell completion with whitespace
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var RootCmd = &cobra.Command{
@kangasta
kangasta / .env
Created April 28, 2021 17:24
Python dotenv parser
# comment
QUOTES="asd"
INNER_QUOTES="{"asd": 123}"
WHITESPACE= ws
WHITESPACE_QUOTES= " ws "
PLAIN=qwe
EMPTY=
# empty lines
@kangasta
kangasta / request_with_se_cookies.py
Last active December 17, 2020 21:10
Use python requests with cookies synced with RF SeleniumLibrary
from requests import request
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
@keyword
def send_http_request(method, url, return_value='json', **kwargs):
'''Send requests with cookies synced with RF SeleniumLibrary
Wrapper for requests.request to send requests with current cookies from Robot Framework SeleniumLibrary. Keyword also updates cookies from response to the SeleniumLibrary.
@kangasta
kangasta / demo.txt
Last active October 26, 2020 23:36
Python script to print out all txt files in folder
This file is in the gist repository.
@kangasta
kangasta / Dockerfile
Last active July 8, 2021 18:41
Jenkins pipeline Robot Framework exercise files
FROM python:3-alpine
RUN pip install robotframework
ENTRYPOINT [""]
// Example of declarative pipeline
pipeline {
agent any
stages {
stage("Build") {
steps {
echo "Build"
sh "cat README.md"
}
}
@kangasta
kangasta / Dockerfile
Last active August 19, 2020 15:32
RF robot with random end result for testing
FROM python:3-alpine
RUN pip install robotframework
ENTRYPOINT [""]
@kangasta
kangasta / max7219_clock.py
Created February 12, 2019 21:05
Digital clock implementation for Raspberry Pi + (4 * 1) MAX7219 LED matrix
#!/usr/bin/env python3
from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import viewport
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, CP437_FONT
from datetime import datetime
import pigpio
from math import pi, sin
from time import sleep
class RGBLed(object):
def __init__(self, r_pin=22, g_pin=23, b_pin=24):
self.__pins = (r_pin, g_pin, b_pin)
self.__pi = pigpio.pi()
def __call__(self, r, g, b):