Skip to content

Instantly share code, notes, and snippets.

@rkrzr
rkrzr / auto_tags.py
Last active April 10, 2024 11:14
Automatically generate ansible tags of the same name for each role in a playbook
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin:
@samelhusseini
samelhusseini / microbit-spotify.js
Last active March 29, 2022 01:27
A node script for listening to micro:bit serial messages and controlling spotify on a Mac
var SerialPort = require("serialport");
const Readline = SerialPort.parsers.Readline;
var spotify = require('spotify-node-applescript');
var port = new SerialPort('/dev/tty.usbmodem1422', {
baudRate: 115200,
autoOpen: false
})
const parser = new Readline();
port.pipe(parser);
@rippo
rippo / account.login.page.js
Last active October 19, 2017 09:32
Page object pattern using chromeless
var AccountLoginPage = function (chromeless, options) {
this.chromeless = chromeless
this.options = options
this.usernameLocator = 'input[id="Username"]'
this.passwordLocator = 'input[id="Password"]'
this.submitButtonLocator = 'form input[type="submit"]'
this.inputWithValidationErrorLocator = 'input.input-validation-error'
this.usernameRequiredValidationLocator = '.field-validation-error[data-valmsg-for="Username"]'
@tombigel
tombigel / README.md
Last active May 27, 2024 23:48 — forked from a2ikm/limit.maxfiles.plist
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@valentinvieriu
valentinvieriu / README.MD
Last active May 26, 2024 10:12
Backup, restore postgres in docker container
  • make sure you mounted /var/lib/postgresql/data/ as a volume
  • to backup the database run this over docker exec replace tools_postgres_1 with the name of your postgres container
docker exec tools_postgres_1 bash -c "pg_dump --username=postgres --no-password --format=t db_name | gzip > /var/lib/postgresql/data/backup/backup_local_$(date +%Y-%m-%d).tar.gz"
  • restore the database using portainer console
docker exec tools_postgres_1 bash -c "pg_restore --username=postgres --no-password --dbname=db_name --verbose /var/lib/postgresql/data/backup/backup_local_29-01-2017.tar.gz"
  • to drop the old database use
@dragolabs
dragolabs / ovpn_in_lxc.md
Last active December 30, 2022 17:11
Openvpn server in lxc container

How to run openvpn in LXC container

For running openvpn server (or client) in CT you need to create tun (tap?) device.

In lxc config of container add line above. In proxmox we can find configs in /etc/pve/local/lxc/

lxc.cgroup.devices.allow: c 10:200 rwm

Then [re]start container and create tun device inside it. You can login into container or use proxmox tool pct:

@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@rezan
rezan / self_route.vcl
Last active February 28, 2024 12:56
Self routing Varnish Cache cluster example
# Self routing cluster example
vcl 4.0;
import directors;
backend node1 {
.host = "node1.example.com";
.port = "80";
}
@sergiojovanig
sergiojovanig / magento2-clear.sql
Last active January 15, 2024 12:25
Magento 2 Clear Database
##########################################################
# PRODUCTS
##########################################################
DELETE FROM `catalog_product_bundle_option`;
DELETE FROM `catalog_product_bundle_option_value`;
DELETE FROM `catalog_product_bundle_selection`;
DELETE FROM `catalog_product_entity_datetime`;
DELETE FROM `catalog_product_entity_decimal`;
DELETE FROM `catalog_product_entity_gallery`;
DELETE FROM `catalog_product_entity_int`;
@cupracer
cupracer / varnishlog-examples.sh
Last active May 12, 2024 17:50
varnishlog examples (version 4.x)
# filter by request host header
varnishlog -q 'ReqHeader ~ "Host: example.com"'
# filter by request url
varnishlog -q 'ReqURL ~ "^/some/path/"'
# filter by client ip (behind reverse proxy)
varnishlog -q 'ReqHeader ~ "X-Real-IP: .*123.123.123.123"'
# filter by request host header and show request url and referrer header