Skip to content

Instantly share code, notes, and snippets.

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

Isael Sousa faelp22

🏠
Working from home
View GitHub Profile
(function() {
// Função para converter "mm:ss" em minutos
function timeToMinutes(timeStr) {
if (!timeStr) return 0;
const [min, sec] = timeStr.split(':').map(Number);
return min + (sec / 60);
}
// Formata minutos para "hh:mm"
function formatMinutes(mins) {
@faelp22
faelp22 / server.py
Last active November 19, 2024 10:28
Python3 SimpleHTTPServer for Static Serving (VueJS/ React / Angular / Ember) in HTML5 mode (a la mod_rewrite)
#!/usr/bin/env python
'''
Based on https://gist.github.com/chrisbolin/2e90bc492270802d00a6
'''
import os
from http.server import HTTPServer, SimpleHTTPRequestHandler
from urllib.parse import urlparse
import subprocess as terminal
import sys
import time
import requests
from requests.exceptions import ConnectionError as ErrorConecxao
from requests.exceptions import ReadTimeout
class FakeResponse:
@faelp22
faelp22 / main.go
Last active July 25, 2024 13:11
Um simples proxy reverso feito em Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httputil"
@faelp22
faelp22 / main.go
Created July 25, 2024 12:31
Simples Golang Kafka Consumer
package main
import (
"context"
"crypto/rand"
"encoding/hex"
"fmt"
"log"
"time"
@faelp22
faelp22 / main.go
Created July 25, 2024 12:31
Simples Golang Kafka Producer
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/segmentio/kafka-go"
)
@faelp22
faelp22 / server.py
Created December 30, 2019 18:10
I made an adjustment for Python 3, I don't know if it's very good
#!/usr/bin/env python
'''
Taken from:
http://stackoverflow.com/users/1074592/fakerainbrigand
http://stackoverflow.com/questions/15401815/python-simplehttpserver
https://gist.github.com/chrisbolin/2e90bc492270802d00a6
'''
@faelp22
faelp22 / django_deploy.md
Created November 2, 2019 17:32 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@faelp22
faelp22 / login.py
Last active September 29, 2019 00:29
Uso esse Middleware para bloquear todas as urls e libero só algumas, com isso evito ficar colocando o decorador @login_required.
import urllib.parse
from django.conf import settings
from django.urls import resolve, reverse
from django.shortcuts import redirect
'''
Isael Sousa <faelp22@gmail.com>
v: 3
@faelp22
faelp22 / cliente.py
Created May 10, 2019 19:50
Um simples exemplo de cliente socket com python
#!/usr/bin/env python3
# fonte http://pythonclub.com.br/upload-de-arquivos-com-socket-e-struct.html
import socket
import struct
host = '127.0.0.1'
port = 8001
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)