Skip to content

Instantly share code, notes, and snippets.

Alexander saniaky

View GitHub Profile
saniaky / websocket.js
Created Mar 1, 2020
Express Websockets + PassportJS
View websocket.js
const logger = require('../../../config/logger');
const WebSocket = require('ws');
const {uuid} = require('uuidv4');
const makeActionHandler = require('./chatEventsHandler');
//const sessionParser = require('../../../../config/session');
* Initialize the WebSocket server instance
const wss = new WebSocket.Server({clientTracking: true, noServer: true});
saniaky /
Last active Jun 7, 2020
Docker + nginx-proxy + let's encrypt + watchtower + fail2ban

Complete solution for websites hosting

This gist contains example of how you can configure nginx reverse-proxy with autmatic container discovery, SSL certificates generation (using Let's Encrypt) and auto updates.


  • Automatically detect new containers and reconfigure nginx reverse-proxy
  • Automatically generate/update SSL certificates for all specified containers.
  • Watch for new docker images and update them.
  • Ban bots and hackers who are trying to bruteforce your website or do anything suspicious.
saniaky /
Last active Apr 18, 2020 — forked from DavidBuchanan314/
Panopto video downloader
import os
import requests
import youtube_dl
Change the following values to yours one
TOKEN = "put .ASPAUTH token here"
saniaky /
Last active Apr 9, 2019
Automatic backup of all MySQL databases to AWS S3 + restore script that downloads latest backup and imports it
  1. Create S3 bucket db-backup
  2. Specify Expire Policty to remove old backups
    Open Bucket Settings -> Management -> Add lifecycle rule -> Expiration tab
    Select Expire current version of object. Use 30 days.
    Select Permanently delete previous versions. Use 1 day.
  3. Create user db-backup-user, assign inline permission policy:
        "Version": "2012-10-17",
        "Statement": [
saniaky /
Last active Aug 26, 2019
Backup and restore a ALL MySQL databases from a running Docker MySQL container.
# Backup
docker exec $CONTAINER sh -c \
'mysqldump --all-databases --quick --single-transaction --skip-lock-tables --flush-privileges -uroot -p"$MYSQL_ROOT_PASSWORD"' \
| gzip > ./backup.sql.gz
# Restore
gunzip ./backup.sql.gz
cat backup.sql | docker exec -i $CONTAINER sh -c 'mysql -uroot -p"$MYSQL_ROOT_PASSWORD"'
saniaky / custom_proxy_settings.conf
Last active Dec 1, 2018
Docker + Wordpress + Nginx Proxy + Let's encrypt + Watcher
View custom_proxy_settings.conf
client_max_body_size 64m;
saniaky / instructions.txt
Last active Dec 1, 2018
Initial Server Setup CentOS + Docker
View instructions.txt
# ============ Create separate user ============
local$ ssh root@server_ip_address
# adduser username
# passwd username
# usermod -aG wheel username
# ============ Copy your SSH key to server ============
saniaky / YoutubeVimeoUrlParser.js
Last active Oct 21, 2018 — forked from yangshun/youtube-vimeo-url-parser.js
YouTube Vimeo URL Parser ES6 Class
View YoutubeVimeoUrlParser.js
class YoutubeVimeoUrlParser {
* Creates an instance of YoutubeVimeoUrlParser.
* @constructor
* @this {YoutubeVimeoUrlParser}
constructor() {
this.pattern = /(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(&\S+)?/;
saniaky / package.json
Last active Sep 1, 2018
Reverse proxy server for API + create-react-app (CRA)
View package.json
"name": "test",
"version": "0.1.0",
"private": true,
"scripts": {
"app": "concurrently \"node proxy-middleware.js\" \"npm start\"",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
saniaky /
Created Dec 5, 2017
Example of using message resources in Spring Boot service layer code, in as simple way.
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;
import java.util.Locale;
* @author saniaky
* @since 12/5/17
You can’t perform that action at this time.