Skip to content

Instantly share code, notes, and snippets.

View fiftin's full-sized avatar

Denis Gukov fiftin

View GitHub Profile
@fiftin
fiftin / Fix_VPN_under_NAT.reg
Created March 10, 2020 13:16
Fix_VPN_under_NAT.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PolicyAgent]
"AssumeUDPEncapsulationContextOnSendRule"=dword:00000002
add_filter('upload_dir', 'cdn_upload_url');
function cdn_upload_url($args)
{
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
$is_id_user = ($current_user_id > 0) ? true : false;
switch($is_id_user)
{
case true:
$admin_users = array('administrator', 'editor', 'author'); //Add roles that you don't want to CDN swap
@fiftin
fiftin / azuredeploy.json
Last active September 24, 2019 06:53
Create VM from existing VHD
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"defaultValue": "newvm",
"metadata": {
"description": "Name of the VM"
}
version: '3'
services:
concourse-db:
image: postgres
environment:
- POSTGRES_DB=concourse
- POSTGRES_PASSWORD=concourse_pass
- POSTGRES_USER=concourse_user
- PGDATA=/database
@fiftin
fiftin / digitalocean-$5.txt
Last active October 15, 2018 09:12
Benchmarking Disks
root@scw-985e9d:~# sysbench --test=fileio --num-threads=6 --file-total-size=10G --file-test-mode=rndrw --max-requests=-1 --max-time=300
run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 6
@fiftin
fiftin / datacesters.txt
Created July 11, 2018 15:39
AWS Datacenters
us-east-1;Virginia;38.13;-78.45
us-east-2;Ohio;39.96;-83
us-west-1;California;37.35;-121.96
us-west-2;Oregon;46.15;-123.88
eu-west-1;Ireland;53;-8
eu-west-2;London;51;-0.1
eu-west-3;Paris;48.86;2.35
eu-central-1;Frankfurt;50;8
sa-east-1;Sao Paulo;-23.34;-46.38
ap-southeast-1;Singapore;1.37;103.8
@fiftin
fiftin / gifenc.sh
Created March 31, 2018 07:43
ffmpeg: script for convering to gif with high quality
#!/bin/sh
palette="/tmp/palette.png"
filters="fps=15,scale=1000:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
@fiftin
fiftin / request.js
Created March 19, 2018 19:45
MyDataSpace request data
const data = Mydataspace.request('entities.get', {
root: 'MyDemoRoot',
path: 'data',
children: true,
filter: {
field1: 'test'
},
offset: 10,
limit: 200
});
@fiftin
fiftin / delay.js
Created October 2, 2017 20:24 — forked from daliborgogic/delay.js
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {
@fiftin
fiftin / mongodb-s3-backup.sh
Created August 21, 2017 14:58 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh