This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The status file: | |
import ansible # tested with 6.7.0 | |
import ansible_runner # tested with 2.3.1 | |
[…] | |
r = ansible_runner.run( | |
private_data_dir="ansible/web", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
import zipfile | |
# tested with python 3.8.10 | |
def secure_zipfile_extractall(zip_filedesc, target_directory): | |
"""Copy all files recorded in zipfile `zip_filedesc` | |
to the directory `target_directory`, but prevent malicious filepaths | |
like `../../../etc/hosts` by using os.path.normpath | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- load pixels.lua (attached as part of this gist) | |
package.path = package.path .. ';?.lua' | |
local hat = require('rpi_sensehat_pixels') | |
-- a generic color table | |
local colortable = { | |
[0] = '0000FF', | |
[1] = '00FF00', | |
[2] = 'FF0000', | |
[3] = '1354AA', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local M = {_TYPE='module', _NAME='sensehat_pixels', _VERSION='0.0.1'} | |
-- Sleep this thread | |
function sleep(n) | |
io.popen("sleep " .. tostring(n)):read() | |
end | |
-- Split a string into lines | |
function lines(str) | |
local t = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Input: we define \loop to print some text the number of given times | |
\newcount\c% | |
\long\def\loop#1 for #2 times{ | |
\c=#2\relax% | |
\begingroup% | |
\def\iterate{% | |
\ifnum\c>0 % | |
\advance\c by -1% | |
{#1}\par% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local tests = { | |
["gsub"] = string.gsub, | |
["testID"] = 0 | |
} | |
function tests.assert(self, cond, identifier) | |
self.testID = self.testID + 1 | |
assert(cond, "test #" .. tostring(self.testID) .. " (" .. tostring(identifier) .. " test) failed") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logging.basicConfig(level=logging.NOTSET) | |
logging.getLogger(__name__).setLevel(logging.NOTSET) | |
""" | |
http://erlang.org/doc/reference_manual/functions.html#syntax | |
Erlang equivalent: | |
fact(N) when N>0 -> % first clause head | |
N * fact(N-1); % first clause body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:buster-20190708 | |
RUN apt-get update && apt-get upgrade | |
RUN apt install -y python3-pip nginx postgresql redis sudo | |
RUN adduser root sudo | |
# corresponds to “Step 0: Prerequisites” | |
RUN adduser pretalx --disabled-password --home /var/pretalx --system --gecos 'pretalx user account' | |
# corresponds to “adduser pretalx --disabled-password --home /var/pretalx” of “Step 1: Unix user“ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"image/color" | |
"image/png" | |
"image" | |
"fmt" | |
"os" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Inkscape Layer to Object-ID | |
=========================== | |
Inkscape represents layers as SVG `g` elements annotated with metadata like layer name. | |
This script takes an SVG file and returns a JSON map of layer names to object IDs. | |
If you supply CLI option `-l`, you can retrieve the object ID of an individual layer. |
NewerOlder