Skip to content

Instantly share code, notes, and snippets.

View aemitos's full-sized avatar

André Toscano aemitos

View GitHub Profile
@aemitos
aemitos / tmux-cheatsheet.markdown
Last active June 2, 2018 04:53 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

Command
start new tmux
start new with session name tmux new -s myname
attach tmux a # (or at, or attach)
attach to named: tmux a -t myname
list sessions tmux ls
@aemitos
aemitos / postgres-json-cheatsheet.md
Last active May 22, 2018 14:09 — forked from rmtsrc/postgres-json-cheatsheet.md
Using JSON in Postgres by example

PostgreSQL JSON Cheatsheet

Using JSON in Postgres by examples. The beuaty to be some schema-less over a schema-full database and still be as fast as a NoSQL document based database.

Quick setup via Docker

  1. Download and install: Docker Toolbox
  2. Open Docker Quickstart Terminal
  3. Start a new postgres container:
    docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
# Siraj Guide
# Learn_Blockchain_in_2_months
This is the code for "Learn Blockchain in 2 Months" by Siraj Raval on Youtube
## Overview
This is the code for [this]() video on Youtube by Siraj Raval on Learning Blockchain in 2 Months.
@aemitos
aemitos / gist:0cb43ad4d48ec8b3f80e0d906dd68b56
Created November 18, 2016 18:07
Removing tables of OpenTSDB when hbase just show that the tables exist but you can't access them. Raw
In some cases that your HDFS fails and you need to recreate the OpenTSDB schema on HBase. To remove the tables use the commands below.
```
root@hb-node4:/# hbase zkcli
ls /hbase
[replication, meta-region-server, rs, splitWAL, backup-masters, table-lock, flush-table-proc, region-in-transition, online-snapshot, master, running, recovering-regions, draining, namespace, hbaseid, table]
rmr /hbase/table/tsdb
rmr /hbase/table/tsdb-uid
rmr /hbase/table/tsdb-meta
rmr /hbase/table/tsdb-tree
@aemitos
aemitos / gist:1416bcdab0775300d46f
Created February 4, 2016 19:48 — forked from timf/gist:4040915
vagrant ramdisk (Linux)
cd /home/tim/VirtualBox\ VMs/
mv proxydev2_1351794515 tmp
mkdir proxydev2_1351794515
sudo mount -t tmpfs -o size=10G tmpfs /home/tim/VirtualBox\ VMs/proxydev2_1351794515
cp -a tmp/* proxydev2_1351794515/
# go back to vagrant directory and `vagrant up`
@aemitos
aemitos / gist:0c09f58e4c277b81d4ad
Created November 28, 2015 02:01
Python AES two-way encryption/decryption example
from Crypto.Cipher import AES
import base64
import os
# the block size for the cipher object; must be 16, 24, or 32 for AES
BLOCK_SIZE = 32
# the character used for padding--with a block cipher such as AES, the value
# you encrypt must be a multiple of BLOCK_SIZE in length. This character is
# used to ensure that your value is always a multiple of BLOCK_SIZE
#!/bin/bash
# https://httpd.apache.org/docs/2.2/misc/password_encryptions.html
HTPASSWD=$1
USERNAME=$2
PASSWORD=$3
ENTRY=`cat $HTPASSWD | grep "^$USERNAME:"`
HASH=`echo $ENTRY | cut -f 2 -d :`
SALT=`echo $HASH | cut -f 3 -d $`
@aemitos
aemitos / s3.py
Created September 25, 2015 14:24 — forked from nanvel/s3.py
Async s3 uploader for tornado
"""
Async Tornado S3 uploader with AWS4 sign.
https://gist.github.com/stalkerg/63bad3ea49be6268df49
Edited by @nanvel 2015-07-24
Usage example:
.. code-block:: python
@aemitos
aemitos / s3_async_client.py
Created September 25, 2015 14:24 — forked from advance512/s3_async_client.py
S3 client that uses Tornado's asynchronous mechanisms. Allows the uploading and downloading of files asynchronously, including metadata support as well. Based on https://gist.github.com/taylanpince/5876491
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2011-2013 Everything.me. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
@aemitos
aemitos / s3.py
Last active September 21, 2015 01:31 — forked from taylanpince/s3.py
Async Tornado S3 uploader, doesn't block, continues uploading after the request is closed
import hashlib, hmac, mimetypes, os, time
from base64 import b64encode, b64decode
from calendar import timegm
from datetime import datetime
from email.utils import formatdate
from urllib import quote
from tornado.gen import coroutine, Return
from tornado.httpclient import AsyncHTTPClient, HTTPError