Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
arthuralvim / github.pages.registro.br.md
Created January 25, 2017 14:06
Pequeno tutorial de como configurar o DNS do registro.br para seu projeto hospedado aqui no GitHub. https://github.com/orige/githubpages.registro.br

tutorial de referência orige/githubpages.registro.br

GitHub:Pages no Registro.br

Este é um pequeno e simples tutorial para a utilização de domínios personalizados registrados no registro.br com github:pages para seu projeto ou página pessoal.

O que é o GitHub:Pages

GitHub Pages é um sistema de hospedagem grátis e de fácil uso para algum projeto ou página pessoal com um repositório no GitHub.

@arthuralvim
arthuralvim / slackpost
Created February 7, 2017 14:04 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@arthuralvim
arthuralvim / mdb_keys.json
Created February 21, 2017 19:55
Get all keys for a MongoDB collection.
mr = db.runCommand({
"mapreduce" : "extracao_unimed",
"map" : function() {
for (var key in this) { emit(key, null); }
},
"reduce" : function(key, stuff) { return null; },
"out": "extracao_unimed" + "_keys"
})
db[mr.result].distinct("_id")
@arthuralvim
arthuralvim / cryptokids-polybius-grid.py
Created March 5, 2017 02:24
Decifrando em Python.
import string
alfabeto = string.ascii_uppercase
matriz_alfabeto = [alfabeto[x * 5:(x * 5) + 5] for x in range(0, 6)]
mensagem = ['14', '34', '42', '25', '11', '31', '42', '41', '11', '41', '51', '', '14', '11', '34', '11', '', '53', '44','', '12', '34', '11', '31', '53', '44', '', '54', '34', '11', '43', '44', '14', '11', '34', '51', '43', '31', '42', '11', '', '14', '11', '34', '11', '', '53', '44', '', '14', '53', '41', '51', '34', '53', '44', '53', '44']
for msg in mensagem:
if not msg:
print ' ',
continue
@arthuralvim
arthuralvim / creating_modules.py
Created March 29, 2017 19:10
Creating modules with Python.
def import_code(code, name, add_to_sys_modules=0):
"""
Import dynamically generated code as a module. code is the
object containing the code (a string, a file handle or an
actual compiled code object, same types as accepted by an
exec statement). The name is the name to give to the module,
and the final argument says wheter to add it to sys.modules
or not. If it is added, a subsequent import statement using
name will return this module. If it is not added to sys.modules
import will try to load it in the normal fashion.
@arthuralvim
arthuralvim / pytest.sublime-snippet
Created April 20, 2017 14:54
Just a snippet for Pytest files.
<snippet>
<content><![CDATA[
import pytest
@pytest.mark.parametrize('input, expected', [
('2 + 3', 5),
('6 - 4', 2),
pytest.mark.xfail(('5 + 2', 8))
])
@arthuralvim
arthuralvim / password_reset_protocol.py
Created May 2, 2017 14:14
Every year activate password reset protocol.
# SAFETY PROTOCOL
from supernice.lib.password import magic_password
from supernice.lib.password import set_mail_new_password
from supernice.lib.password import set_new_recovery_mail
from supernice.lib.password import activate_two_factor_authentication
from supernice.lib.password import activate_google_authenticator
from you.sites import all_sites
# AWS Lambda Coding & Config (part 4)
# Ben Emson
# https://www.youtube.com/watch?v=o-8U_3s_zWI
import os
import json
class ConfigLoader(object):
@arthuralvim
arthuralvim / mongodb-s3-backup.sh
Created June 9, 2017 11:40 — 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
@arthuralvim
arthuralvim / from_bucket_policy.json
Created June 9, 2017 13:26
Move S3 files to another bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAll",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::111122223333:user/iam_role"
]