Skip to content

Instantly share code, notes, and snippets.

@JanTvrdik
JanTvrdik / generate-root-certificate.sh
Last active May 16, 2017 19:08
Generate TLS certificate signed by root certificate
#!/usr/bin/env bash
set -o errexit -o pipefail -o nounset
IFS=$'\n\t'
ROOT="$(dirname $0)/root"
if [[ -f $ROOT.key || -f $ROOT.crt ]]; then
echo "Root certificate already exist"
exit 1
fi
@JanTvrdik
JanTvrdik / bench.php
Last active October 10, 2018 06:41
PHP quick benchmark skeleton
<?php
$runCount = 1000;
$dataSets = [
'setA' => [$runCount, 123],
];
$tests = [
'testA' => function ($count, $n) {
@kaja47
kaja47 / burst.scala
Created April 2, 2016 23:22
quick and dirty sketch of burstsort
import java.util.Arrays
// BurstSort
// Cache-Conscious Sorting of Large Sets of Strings with Dynamic Tries
// http://goanna.cs.rmit.edu.au/~jz/fulltext/alenex03.pdf
class BurstLeaf(initSize: Int) {
var size: Int = 0
DELIMITER ;;
DROP PROCEDURE IF EXISTS `normalize_foreign_key_name`;;
CREATE PROCEDURE `normalize_foreign_key_name`(IN `param_database_name` varchar(100) CHARACTER SET 'ascii', IN `param_table_name` varchar(100) CHARACTER SET 'ascii', IN `param_column_name` varchar(100) CHARACTER SET 'ascii')
BEGIN
DECLARE var_constraint_name_current VARCHAR(100);
DECLARE var_constraint_name_new VARCHAR(100);
DECLARE var_constraint_target_table VARCHAR(100);
@tzmfreedom
tzmfreedom / pg_notify.php
Last active March 8, 2023 23:09
postgresql notify/listen sample
<?php
$db = new PDO(
"pgsql:dbname=postgres host=localhost port=5432", 'postgres', 'postgres', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]
);
$db->exec('LISTEN hoge');
@hrach
hrach / config.neon
Created December 8, 2015 08:42
neon + aws sdk + guzzle + kdyby curl ca bundle
- Aws\Sdk({
credentials: {
key: %s3.key%,
secret: %s3.secret%,
},
version: latest,
region: 'eu-west-1',
http_handler: @Aws\Handler\GuzzleV6\GuzzleHandler,
})
- Aws\Handler\GuzzleV6\GuzzleHandler
@ilg-ul
ilg-ul / bash-inits.sh
Last active April 19, 2022 13:24
BASH recommended initialisation sequence
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
@jakubkulhan
jakubkulhan / ClassDeclarationSniff.php
Last active October 10, 2018 06:43
Skrz Coding Standard
<?php
class Skrz_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff
{
public function register()
{
return [T_CLASS, T_INTERFACE, T_TRAIT];
}
@kennwhite
kennwhite / vpn_psk_bingo.md
Last active February 24, 2024 12:19
Most VPN Services are Terrible

Most VPN Services are Terrible

Short version: I strongly do not recommend using any of these providers. You are, of course, free to use whatever you like. My TL;DR advice: Roll your own and use Algo or Streisand. For messaging & voice, use Signal. For increased anonymity, use Tor for desktop (though recognize that doing so may actually put you at greater risk), and Onion Browser for mobile.

This mini-rant came on the heels of an interesting twitter discussion: https://twitter.com/kennwhite/status/591074055018582016

@chernomyrdin
chernomyrdin / pg_listen.php
Created March 11, 2015 12:49
Using LISTEN/NOTIFY PostgreSQL in PHP (async/pool mode)
<?php
/**
* Class Main - Проверяем возможность работы с LISTEN/NOTIFY в PostgreSQL
* Вывод: Подобное возможно только начиная с PHP 5.6, так как только там появилась функция pg_socket($dbh)
* Так-же демонстрируется возможность работать по опросу, что менее удобно, но это лучше чем ничего
*/
class Main {
/**