Skip to content

Instantly share code, notes, and snippets.

View nineinchnick's full-sized avatar

Jan Waś nineinchnick

View GitHub Profile
@nineinchnick
nineinchnick / randwp.py
Created June 12, 2011 13:20 — forked from FSX/randwp.py
Grabs a random wallpaper from the wallbase.net toplist.
#!/usr/bin/env python
"""
randwp
~~~~~~
Fetches random wallpapers from the wallbase.net toplist and sets it as the
background.
This script needs Python 3.*. Windows people need to install the `pywin32`_
and Mac OS X people need to install `py-appscript`_.
@nineinchnick
nineinchnick / benchmark.php
Last active August 29, 2015 14:16
php benchmark
<?php
// define benchmarked functions
$f1 = function ($string, $delimiter = ',', $trim = true, $skipEmpty = false) {
$result = [];
$parts = explode($delimiter, $string);
foreach ($parts as $value) {
if ($trim) {
$value = $trim === true ? trim($value) : (is_callable($trim) ? $trim($value) : trim($value, $trim));
@nineinchnick
nineinchnick / vhost.conf
Created May 23, 2015 08:38
nginx vhost
server {
listen 80;
server_name site.local;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name site.local;
@nineinchnick
nineinchnick / bench.php
Last active September 13, 2015 12:07
Check if adding strpos and strrpos is worth it
<?php
// define benchmarked functions
$f1 = function ($string) {
for ($i = 0, $count = strlen($string); $i < $count; $i++) {
if ($string[$i] === '*') {
$string[$i]= mt_rand(0, 1) ? '#' : '?';
}
}
@nineinchnick
nineinchnick / create_all_utf.php
Last active September 14, 2015 08:03
Tests does search for an ascii char with strpos works in utf-8 strings.
<?php
/** @link http://stackoverflow.com/questions/2748956/how-would-you-create-a-string-of-all-utf-8-characters */
function unichr($i)
{
return iconv('UCS-4LE', 'UTF-8', pack('V', $i));
}
$codeunits = array();
for ($i = 0; $i<0xD800; $i++) {
@nineinchnick
nineinchnick / test-trino.sh
Last active January 25, 2024 12:19
Test Flyway with Trino
#!/bin/bash
set -euo pipefail
function ensure_container() {
local name=$1
shift
local image=$1
shift
@nineinchnick
nineinchnick / sbom.sh
Last active August 9, 2022 07:58
Trino SBOM
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<EOF 1>&2
Usage: $0 [-h] -n <NAME>
Generates a Software Bill of Materials (SBOM) for the Trino Docker image
-h Display help
@nineinchnick
nineinchnick / sbom.cdx.json
Created August 9, 2022 07:51
Trino SBOM example
This file has been truncated, but you can view the full file.
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"serialNumber": "urn:uuid:70a0f4cc-835c-4fbb-a96f-269b201c7301",
"version": 1,
"metadata": {
"timestamp": "2022-08-08T16:38:35+02:00",
"tools": [
{
"vendor": "anchore",
@nineinchnick
nineinchnick / sbom.sh
Created August 10, 2022 15:40
Starburst Enterprise SBOM
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<EOF 1>&2
Usage: $0 [-h] -n <NAME>
Generates a Software Bill of Materials (SBOM) for the SEP Docker image
-h Display help
@nineinchnick
nineinchnick / trino.sh
Last active March 22, 2024 09:44
Install Trino and some plugins
#!/usr/bin/env bash
# This script:
# * installs Trino and Temurin JDK 21 in /home/trino
# * configures Trino to listen on port 8080, use it with a reverse proxy like Caddy
# * installs a SystemD service to run Trino on server startup
set -euo pipefail
usage() {