Skip to content

Instantly share code, notes, and snippets.

View fiftin's full-sized avatar

Denis Gukov fiftin

View GitHub Profile
@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 / 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
version: '3'
services:
concourse-db:
image: postgres
environment:
- POSTGRES_DB=concourse
- POSTGRES_PASSWORD=concourse_pass
- POSTGRES_USER=concourse_user
- PGDATA=/database
@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"
}
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 / 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
@fiftin
fiftin / download-file.js
Created March 29, 2020 14:34 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@fiftin
fiftin / is-email.js
Created June 2, 2020 16:50
Email regexp (JavaScript)
function isEmail(s) {
return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(s);
}
@fiftin
fiftin / docker-compose.yml
Created November 1, 2020 06:38
Ansible Semaphore 2.5.3
# This dockerfile provides an example of using the production image in a working stack
version: '2'
services:
mysql:
ports:
- 3306:3306
image: mysql:5.6
hostname: mysql
@fiftin
fiftin / index.js
Last active November 21, 2020 14:35
AWS Lambda for implementing static site with using S3 and CloudFront.
const path = require('path');
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
if (!path.extname(request.uri)) {
if (!request.uri.endsWith('/')) {
request.uri += '/';
}
request.uri += 'index.html';
}