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 April 24, 2024 12:32 — 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:

@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 February 27, 2024 11:11
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
@arthurattwell
arthurattwell / dialog.html
Last active August 1, 2022 09:54
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
<div style="font-family: sans-serif;">
<? var data = valid(); ?>
<form id="form" name="form">
<? if(Object.prototype.toString.call(data) === '[object Array]') { ?>
<? for (var i = 0; i < data.length; i++) { ?>
<? for (var j = 0; j < data[i].length; j++) { ?>
<input type="checkbox" id="ch<?= '' + i + j ?>" name="ch<?= '' + i + j ?>" value="<?= data[i][j] ?>"><?= data[i][j] ?><br>
<? } ?>
<? } ?>
<? } else { ?>