Skip to content

Instantly share code, notes, and snippets.

from concurrent.futures import as_completed, ThreadPoolExecutor
from urllib.request import urlopen
import re
import sys
DEFAULT_REGEX = r'<input type="text" id="nacional" value="([^"]+)"/>'
CURRENCY = {
'dolar': 'http://dolarhoje.com/',
'euro': 'http://eurohoje.com/',
from concurrent.futures import ProcessPoolExecutor, as_completed
import sys
TO_CALCULATE = range(1000, 15000, 1000)
def primes_until(num):
result = []
for p in range(2, num+1):
@drgarcia1986
drgarcia1986 / main.go
Last active August 25, 2016 10:25
Link redirect and click counter in Go
package main
import (
"fmt"
"net/http"
)
type RedirectHandler struct {
Counter chan string
}
@drgarcia1986
drgarcia1986 / type.go
Last active December 22, 2017 20:10
Golang Error Handling examples
// By Type
// Go playground https://play.golang.org/p/lJOCJAq8WL
package main
import "fmt"
type ErrorX struct{}
func (e *ErrorX) Error() string {
return "It's error X"
@drgarcia1986
drgarcia1986 / main.go
Created May 25, 2017 18:55
Ultra simple Golang Reflection example
package main
import (
"fmt"
"reflect"
)
type sA struct {
foo int
bar string
package logger
import (
"bytes"
"io"
"log"
)
type FilteredWriter struct {
io.Writer
@drgarcia1986
drgarcia1986 / output
Created June 5, 2018 02:18
Trie Data Structure
KEY: b
-KEY: o
--KEY: b
KEY: c
-KEY: a
--KEY: r
-KEY: u
--KEY: t
---KEY: e
KEY: t
@drgarcia1986
drgarcia1986 / hello.py
Created September 25, 2018 17:53
simple python built-in web hello world
from http.server import BaseHTTPRequestHandler, HTTPServer
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200, 'OK')
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(b'{"message": "hello world"}')