Skip to content

Instantly share code, notes, and snippets.

View foxel's full-sized avatar
🇦🇲

Andrey Kupreychik foxel

🇦🇲
View GitHub Profile
@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 / 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 / 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
}
@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 / CsvTable.php
Last active June 7, 2019 16:38
CSV Data MediaWiki extension
<?php
/*
* CSV Data MediaWiki extension.
*
* Additional parameters allowed in the tag are:
* sep Specify a separator; ',' is default.
* head Specify a heading; "head=top" makes the first row a heading,
* "head=left" makes the first column a heading, "head=topleft"
* does both.
@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

@foxel
foxel / controlEverything-SI7021.py
Created April 26, 2017 15:57
Python example for SI7021 board from ControlEverything
#!/usr/bin/python
import sys
from time import sleep, strftime
from OmegaExpansion import onionI2C # requires fixes for https://github.com/OnionIoT/i2c-exp-driver/issues/13
while True:
i2c = onionI2C.OnionI2C()
i2c.write(0x40, [0xE5])
sleep(0.1)
#!/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 / 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;