Skip to content

Instantly share code, notes, and snippets.

@x-yuri
x-yuri / 0001-Fix-line-breaks.patch
Created December 27, 2014 17:26
vagrant-1.7 patch (line breaks issue)
From 9d1834a3c98fcc5f413878bb1f3acd055b6fe90e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dou=C3=A9zan-Grard=20Guillaume?=
<silverwyrda@users.noreply.github.com>
Date: Sat, 13 Dec 2014 21:08:31 +0100
Subject: [PATCH] Fix line breaks
---
plugins/guests/arch/cap/configure_networks.rb | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
From 766623b7fe37d4de59ca02f7e58b5658724ab751 Mon Sep 17 00:00:00 2001
From: Mike <themike@libero.it>
Date: Thu, 30 Oct 2014 22:01:14 +0100
Subject: [PATCH] Add Nokia Lumia 630 device identifiers
---
src/music-players.h | 2 ++
1 file modificato, 2 inserzioni(+)
diff --git a/src/music-players.h b/src/music-players.h
@x-yuri
x-yuri / gist:0cfd472ca68505c8cf5ebd90841127bf
Last active August 23, 2018 14:42
ERROR: aggregate functions are not allowed in GROUP BY
$ psql db -c "select char_length(string_agg(legacy_id, ', ')) from products group by 1"
ERROR: aggregate functions are not allowed in GROUP BY
LINE 1: select char_length(string_agg(legacy_id, ', ')) from products...
^
$ psql db -c "select char_length(string_agg(legacy_id, ', ')) from products group by TRUE"
char_length
-------------
15666
(1 row)
@x-yuri
x-yuri / README.md
Created November 7, 2018 09:25
A script that let's you do partial PITR with Barman http://docs.pgbarman.org/release/2.5/#scope

Note. Test before putting to use.

With this script you don't set retention_policy in Barman's config, but run barman-clean-backups.sh periodically.

This script keeps files needed to restore to any point in time within the range of last x backups (--n-keep), plus y points in time before that (--n-keep-standalone).

@x-yuri
x-yuri / 1.py
Created January 6, 2019 17:37
python: substituting class
class A:
qux = 'A'
def __init__(self, name):
self.name = name
def foo(self):
print('foo')
class B:
qux = 'B'
def bar(self):
@x-yuri
x-yuri / 1.md
Created June 29, 2019 12:52
debug iptables rules

rules.txt:

*security
-A INPUT -p icmp -j LOG --log-prefix "*** IPTABLES (sec/IN): "
-A FORWARD -p icmp -j LOG --log-prefix "*** IPTABLES (sec/FORW): "
-A OUTPUT -p icmp -j LOG --log-prefix "*** IPTABLES (sec/OUT): "
COMMIT

*mangle
@x-yuri
x-yuri / [-command.md
Last active July 1, 2019 07:47
[ command

There exists a way in the shell to do different kinds of checks, like if a file exists:

$ if [ -e some-file ]; then echo exists; fi
exists
@x-yuri
x-yuri / 1.sh
Last active September 15, 2019 09:26
portainer: redeploy stack
#!/usr/bin/env bash
set -eu
portainer=https://example.com
user=name
password=...
endpoint=name
stack=name
auth_resp=$(http POST "$portainer/api/auth" Username="$user" Password="$password")
@x-yuri
x-yuri / index.md
Last active October 7, 2019 13:02
/opt/eff.org/certbot/venv/bin/python: No module named pip.__main__; 'pip' is a package and cannot be directly executed

Debian Wheezy

/opt/eff.org/certbot/venv/bin/python: No module named pip.__main__; 'pip' is a package and cannot be directly executed
Traceback (most recent call last):
  File "/tmp/tmp.Xxcju1yqBr/pipstrap.py", line 177, in <module>
    sys.exit(main())
  File "/tmp/tmp.Xxcju1yqBr/pipstrap.py", line 149, in main
    pip_version = StrictVersion(check_output([python, '-m', 'pip', '--version'])
  File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
@x-yuri
x-yuri / strapi: prefix the endpoints.md
Last active October 15, 2019 18:23
strapi: prefix the endpoints

config/environments/production/custom.json:

{
  "prefixed-router": {
    "enabled": true
  }
}