Skip to content

Instantly share code, notes, and snippets.

View denvazh's full-sized avatar

Denis Vazhenin denvazh

  • Tokyo
View GitHub Profile
@holmberd
holmberd / socks-proxy.md
Last active May 29, 2021 08:30
Configure remote SSH service and set up local SSH SOCKS proxy tunnel

REMOTE: Set up SSH service on the remote host

  • Skip if already set up, check with: sudo service ssh status
  • sudo apt-get install ssh
  • Edit ssh config file with the lines below: sudo vim /etc/ssh/sshd_config
PermitRootLogin no              #Disable direct login from root
AllowUsers user1 user2 user3    #*Only* allow this users to connect
AllowTcpForwarding yes          #Required to setup the tunnel, yes or commented out
PubkeyAuthentication yes        #Enables public key authentication
Port 22                         #Listening port of the server
@luisbebop
luisbebop / install-rbenv-amazon-linux-ami.sh
Created November 26, 2017 16:32
Install rbenv on Amazon Linux AMI
sudo yum install -y git gcc make readline-devel openssl-devel
git clone git://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# Install ruby-build system-widely
git clone git://github.com/rbenv/ruby-build.git /tmp/ruby-build
cd /tmp/ruby-build
@sorjef
sorjef / converter-cli.js
Last active January 18, 2022 14:56
Script to convert AWS Data Pipeline template to Cloudformation template with a sample Terraform module
const fs = require('fs');
const Converter = require('./converter.js');
const options = {
name: process.argv[3],
description: process.argv[4],
activate: process.argv[5],
};
const converter = new Converter(JSON.parse(fs.readFileSync(process.argv[2])), options);
@tobywf
tobywf / boto3-gzip.py
Last active October 18, 2023 17:32
GZIP compressing files for S3 uploads with boto3
from io import BytesIO
import gzip
import shutil
def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'):
"""Compress and upload the contents from fp to S3.
If compressed_fp is None, the compression is performed in memory.
"""
@beyondeye
beyondeye / firebase_coroutine_integration.kt
Created May 27, 2017 20:32
integration of firebase wth kotlin coroutines
/**
* allow to define callback wrappers that are protected from accidental multiple calls to resume/resumeWithException
* Created by daely on 3/30/2017.
*/
class WrappedContinuation<T>(val c: Continuation<T>) : Continuation<T> {
var isResolved = false
override val context: CoroutineContext
get() = c.context
override fun resume(value: T) {
@khalidx
khalidx / simple_http_server_cors.py
Last active September 21, 2023 02:24
Python SimpleHTTPServer with CORS, supporting both Python 2 and 3
#!/usr/bin/env python
# Usage: python simple_http_server_cors.py <port>
try:
# try to use Python 3
from http.server import HTTPServer, SimpleHTTPRequestHandler, test as test_orig
import sys
def test (*args):
test_orig(*args, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
@BretFisher
BretFisher / docker-for-mac.md
Last active April 26, 2024 09:38
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@davisford
davisford / Setup MongoDB on localhost as Replica Set
Last active March 6, 2024 21:40
Setup MongoDB replica set on local host with only a single primary
Add the `replication` section to the mongod.conf file:
```
$cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
engine: mmapv1
@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active March 9, 2024 12:03
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

@lmmendes
lmmendes / elasticache_dump_to_rdb.md
Last active May 28, 2021 07:36
Save Amazon ElastiCache Redis to file dump.rdb

Instructions to DUMP localy a Elasticache Redis database

Connect to Redis CLI

$ redis-cli

Enable the current redis as a slave for the master node