Skip to content

Instantly share code, notes, and snippets.

View foxel's full-sized avatar
🇦🇲

Andrey Kupreychik foxel

🇦🇲
View GitHub Profile
@foxel
foxel / vpnshare.sh
Last active September 1, 2015 02:49
VPN share
#!/bin/sh
# Share the VPN connection with other machines on the local net.
# The assumption here is that the VPN networks are 10.10.0.0/24 and 10.10.1.0/24.
if [ `id -u` -ne 0 ] ; then
echo "You are not root. Rerunning with sudo..."
sudo bash $0
else
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth2 -d 10.10.0.0/24 -j ACCEPT
iptables -A FORWARD -i eth2 -d 10.10.1.0/24 -j ACCEPT
@foxel
foxel / bashSnippets.sh
Created August 27, 2012 17:43
Bash snippets
#copies files recursively but filter by extension
find . -name "*.txt" | cpio -pdmuv path/to/dest
@foxel
foxel / logrotate.d-docker
Last active October 23, 2015 08:07 — forked from chernjie/logrotate.d-docker
Logrotate docker logs, copy this file to /etc/logrotate.d/docker
/var/lib/docker/containers/*/*-json.log {
dateext
daily
rotate 60
compress
delaycompress
missingok
copytruncate
}
#!/bin/bash
# Used to cast screen with camera feed ttached + recording this stream along with audio mixed from both mic and speakers.
# For hangouts one should share gst-launch window (the window itself can then be minimized)
# Tested on Ubuntu 16.04
PIP_WIDTH=320
PIP_HEIGHT=240
SCREEN_WIDTH=1920
SCREEN_HEIGHT=1200
@foxel
foxel / haproxy.cfg
Last active June 26, 2017 03:35
Haproxy + letsencrypt + docker
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
@foxel
foxel / Chief_n_Pizza.ts
Created September 29, 2017 08:45
Phantom Builder in TS
// Inspired by https://medium.com/@maximilianofelice/builder-pattern-in-scala-with-phantom-types-3e29a167e863
export type Pizza = {};
namespace Pizza {
export type WithCheese = {
readonly cheese: string;
};
export type WithTopping = {
readonly topping: string;
@foxel
foxel / reactive-loader.ts
Created March 2, 2018 06:48
Reactive loader with guarantee of no load collisions and loading status provided.
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/switchMap';
export class ReactiveLoader<T, T1> {
private _requestQueue: Subject<T1>;
private _resultQueue: Observable<T>;
private _loaded: boolean = false;
{
"definitions": {
"CreateDocumentCommand": {
"type": "object",
"required": ["eventType", "documentName"],
"properties": {
"eventType": {
"type": "string",
"enum": ["CreateDocument"]
},
#!/usr/bin/python2.7
import sys
# assuming you have https://github.com/foxel/noolite-mqtt-python near
from noolite_serial import NooLiteSerial
noo_serial = NooLiteSerial('/dev/ttyS0')
if len(sys.argv) < 3:
raise Exception('Not Enough params. Usage: noo.py [ch] [cmd]')
@foxel
foxel / !haproxy+docker-gen.md
Last active January 23, 2019 11:50
Haproxy + docker-gen hostname routing

What is this?

This gist includes config for haproxy + docker-gen system with routing http requests to different containers based on hostname label.

pre requirements