Skip to content

Instantly share code, notes, and snippets.

View lcezermf's full-sized avatar

Luiz Cezer lcezermf

View GitHub Profile
@petelacey
petelacey / Dockerfile
Last active April 22, 2024 00:56
Docker Compose setup for Elixir, Phoenix, and Postgres
FROM elixir:latest
# Install debian packages
RUN apt-get update && \
apt-get install --yes build-essential inotify-tools postgresql-client git && \
apt-get clean
ADD . /app
# Install Phoenix packages
@dmmeteo
dmmeteo / 1.srp.py
Last active April 27, 2024 05:48
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@frfahim
frfahim / oh-my-fish.md
Last active April 28, 2024 15:11
Install fish shell and oh-my-fish on ubuntu

First install fish shell on your system

sudo apt-get update
sudo apt-get install fish

Or install fish via ppa

sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update

sudo apt-get install fish``

package main
import (
"fmt"
)
type Mutator interface {
Change()
AnotherChange()
}
@ursuad
ursuad / kafka-cheat-sheet.md
Last active March 14, 2024 10:32
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@guumaster
guumaster / 00-README.md
Last active January 23, 2023 15:48
How to upload a file with $.ajax to AWS S3 with a pre-signed url

Upload a file with $.ajax to AWS S3 with a pre-signed url

When you read about how to create and consume a pre-signed url on this guide, everything is really easy. You get your Postman and it works like a charm in the first run.

Then you open your browser, try your usual $.ajax() and send your PUT operation, and you hit the cold iced wall of AWS error message, a simple <Code>SignatureDoesNotMatch</Code> that will steal hours from your productivity.

So here I come to save you and give you a free working example of how to upload a file directly to AWS S3 from your browser. You are wellcome :).

@sirkkalap
sirkkalap / Install-Docker-on-Linux-Mint.sh
Last active December 8, 2022 18:38
Install Docker on Linux Mint
##########################################
# To run:
# curl -sSL https://gist.githubusercontent.com/sirkkalap/e87cd580a47b180a7d32/raw/d9c9ebae4f5cf64eed4676e8aedac265b5a51bfa/Install-Docker-on-Linux-Mint.sh | bash -x
##########################################
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get install -y apt-transport-https
fi
@carlosspohr
carlosspohr / byString.js
Last active August 29, 2015 14:13
A simple script to help you when you need to get some nested property using strings, special when you are inside reflections.
Object.byString = function(o, s) {
s = s.replace(/\[(\w+)\]/g, '.$1');
s = s.replace(/^\./, '');
var a = s.split('.');
while (a.length) {
var n = a.shift();
if (n in o) {
o = o[n];
} else {
return;
@kelvinst
kelvinst / create-ruby-gem.md
Last active November 29, 2023 02:04
Como criar uma gem ruby?

Como criar uma gem ruby?

Escolhi tratar sobre esse assunto hoje simplesmente porque foi uma das primeiras coisas que me perguntei "como eu faço isso?" no mundo ruby. Acredito que muita gente se pergunte a mesma coisa e espero que eu possa ajudar em algo para elas. 😀

O que é uma gem?

Bem, se você é um programador java, você chama sua gem de jar, se você é um programador C#, você chama de dll. Resumindo, é uma lib, uma biblioteca contendo códigos que você pode reaproveitar importando em outros projetos.

E usar gems no ruby é muito fácil, se você já deu uma brincada com rails por exemplo, é só você adicionar o código gem 'nome_da_gem' no arquivo Gemfile que está no root, depois executar o comando bundle install para baixar sua gem do repositório e pronto, só sair usando a biblioteca!

@caarlos0
caarlos0 / elections.rb
Last active June 4, 2016 13:00
My Ruby script to list the top-3 president candidates in Brazilian 2014 elections. Updated with second round data as well. http://carlosbecker.com/posts/elections/
require 'net/http'
require 'uri'
require 'json'
uri = URI('http://divulga.tse.jus.br/2014/divulgacao/oficial/143/dadosdivweb/br/br-0001-e001431-w.js')
class String; def percent_of(n) "#{(self.to_f / n.to_f * 100.0).round(2)}%"; end; end
begin
data = JSON(Net::HTTP.get_response(uri).body)
system('clear')
puts "\n\n----\n#{data['ht']} - #{data['ea'].percent_of(data['e'])} dos votos apurados\n----"
data['cand'].take(3).each do |candidate|