Skip to content

Instantly share code, notes, and snippets.

View tiagocardosos's full-sized avatar
🏠
Working from home

Tiago Cardoso tiagocardosos

🏠
Working from home
View GitHub Profile
@tiagocardosos
tiagocardosos / docker-ce-ubuntu-17.10.md
Created November 8, 2017 12:53 — forked from levsthings/docker-ce-ubuntu-17.10.md
Install Docker CE on Ubuntu 17.10

Installing Docker CE on Ubuntu 17.10 Artful Aardvark

As of 20/10/2017, a release file for Ubuntu 17.10 Artful Aardvark is not available on Download Docker.

If you are used to installing Docker to your development machine with get-docker script, that won't work either. So the solution is to install Docker CE from the zesty package.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@tiagocardosos
tiagocardosos / setup_ubuntu.md
Last active August 1, 2019 22:32
Server setup for Ubuntu 16.04 on Digital Ocean

Server setup for Ubuntu 16.04 on Digital Ocean

The setup installs the following software:

  • Nginx
  • MySQL
  • PHP
  • Node
  • Composer
@tiagocardosos
tiagocardosos / dump.sh
Last active December 5, 2017 12:54
MySQL database backup (mysqldump) shell script
#!/bin/bash
#mysql_config_editor set --login-path=local --host=localhost --user=username --password
echo "$(date +'%Y%m%d %k%M%S'): Starting daily backup." >> dump.log
echo "SET autocommit=0;
SET unique_checks=0;
SET foreign_key_checks=0;" > /root/backup.sql
#bkp mysql
/usr/bin/mysqldump --login-path=local --databases my_db >> /root/backup.sql
@tiagocardosos
tiagocardosos / solving_gpg.md
Created December 13, 2017 09:41
Corrigindo erro GPG (chave pública não disponível) - Solving GPG error (public key not available)

Solving GPG error (public key not available)

Exemplo de mensagem de erro:

W: Erro GPG: http://ppa.launchpad.net precise Release: As assinaturas a seguir não puderam ser verificadas devido à chave pública não estar disponível: NO_PUBKEY A8AA1FAA3F055C03

A mensagem acima indica que o sistema não possui a chave GPG de autenticação (número A8AA1FAA3F055C03) para o repositório PPA.

A solução é simples. Basta adicionar o número da chave (indicado na mensagem de erro). Sinopse do comando: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys NÚMERO_DA_CHAVE

@tiagocardosos
tiagocardosos / numpy.md
Last active December 22, 2017 14:18
Numpy tests

#aula 1

import numpy as np
my_array = np.arange(1000000)
my_list = list(range(1000000))

%time for _ in range(10):my_array * 2
%time for _ in range(10):my_list2 = [x * 2 for x in my_list]

data = np.random.rand(5, 7)
@tiagocardosos
tiagocardosos / install-postgres-10-ubuntu.md
Created January 15, 2018 18:31 — forked from alistairewj/install-postgres-10-ubuntu.md
Install PostgreSQL 10 on Ubuntu

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple.

dpkg -l | grep postgres
@tiagocardosos
tiagocardosos / setup_elastic_cluster_ubuntu.md
Last active March 26, 2020 01:39
Server setup for Ubuntu and Elasticsearch Cluster on Digital Ocean

Server setup for Ubuntu and Elasticsearch Cluster on Digital Ocean

Update system

apt-get update && apt-get dist-upgrade -y
apt-get autoremove -y

Create and expose a SSH Key for the new user

@tiagocardosos
tiagocardosos / install_python3.6_ubuntu.md
Last active February 10, 2018 18:24
How to Install Python 3.6.1 in Ubuntu 16.04 LTS

This quick tutorial is going to show you how to install the latest Python 3.6.1 in Ubuntu 16.04 LTS via PPA.

Ubuntu 16.04 comes with both Python 2.7 and Python 3.5 by default. You can install Python 3.6 along with them via a third-party PPA by doing following steps:

1. Open terminal via Ctrl+Alt+T or searching for “Terminal” from app launcher. When it opens, run command to add the PPA:

sudo add-apt-repository ppa:jonathonf/python-3.6
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""Death by Captcha HTTP and socket API clients.
There are two types of Death by Captcha (DBC hereinafter) API: HTTP and
socket ones. Both offer the same functionalily, with the socket API
sporting faster responses and using way less connections.
To access the socket API, use SocketClient class; for the HTTP API, use
@tiagocardosos
tiagocardosos / walk.py
Created April 18, 2019 18:45
What's the fastest way to recursively search for files in python?
# https://stackoverflow.com/questions/50948391/whats-the-fastest-way-to-recursively-search-for-files-in-python
import os
import glob
def walk():
pys = []
for p, d, f in os.walk('.'):
for file in f:
if file.endswith('.py'):