Skip to content

Instantly share code, notes, and snippets.

@danackerson
danackerson / 100_base.conf
Last active September 19, 2024 15:42
using nginx + lua + redis for redirects and rewrites
# using such a setup requires `apt-get install lua-nginx-redis` under Ubuntu Trusty
# more info @ http://wiki.nginx.org/HttpLuaModule#access_by_lua
http {
lua_package_path "/etc/nginx/include.d/?.lua;;";
lua_socket_pool_size 100;
lua_socket_connect_timeout 10ms;
lua_socket_read_timeout 10ms;
server {
@JanTvrdik
JanTvrdik / .bashrc
Last active May 31, 2024 08:15 — forked from gsomoza/.bashrc
ssh-agent support for Git Bash / MinGW / msys / Windows
# put this in ~/.bashrc
export SSH_AUTH_SOCK=/tmp/.ssh-socket
ssh-add -l > /dev/null
if [ $? = 2 ]; then
rm -f $SSH_AUTH_SOCK
echo Starting new ssh-agent...
eval $(ssh-agent -a $SSH_AUTH_SOCK) > /dev/null
ssh-add && echo "ssh-agent set up successfully with the following keys:" && ssh-add -l
fi
@JanTvrdik
JanTvrdik / loadCacheFile.php
Last active December 13, 2016 21:51
General purpose thread-safe cache function
<?php
/**
* @param string $file
* @param callable $tryLoad (string $file, mixed & $data): bool
* @param callable $isExpired (string $file): bool
* @param callable $fallback (string $file): string
* @return mixed
*/
function loadCacheFile($file, $tryLoad, $isExpired, $fallback)
@hrach
hrach / dynamicReturnTypeMeta.json
Last active April 11, 2017 10:35
Dynamic Return Type
{
"methodCalls": [
{
"class": "\\Mockery",
"method": "mock",
"position": 0,
"mask": "%s|\\Mockery\\MockInterface"
},
{
"class": "\\Nette\\DI\\Container",
@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 {
/**
@kennwhite
kennwhite / vpn_psk_bingo.md
Last active May 16, 2025 20:51
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

@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];
}
@ilg-ul
ilg-ul / bash-inits.sh
Last active January 8, 2025 21:06
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=""
@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
@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');