Skip to content

Instantly share code, notes, and snippets.


Diego Garcia drgarcia1986

View GitHub Profile
drgarcia1986 /
Created Sep 25, 2018
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.wfile.write(b'{"message": "hello world"}')
drgarcia1986 / output
Created Jun 5, 2018
Trie Data Structure
View output
KEY: b
-KEY: o
--KEY: b
KEY: c
-KEY: a
--KEY: r
-KEY: u
--KEY: t
---KEY: e
KEY: t
View logger.go
package logger
import (
type FilteredWriter struct {
drgarcia1986 / main.go
Created May 25, 2017
Ultra simple Golang Reflection example
View main.go
package main
import (
type sA struct {
foo int
bar string
drgarcia1986 / type.go
Last active Dec 22, 2017
Golang Error Handling examples
View type.go
// By Type
// Go playground
package main
import "fmt"
type ErrorX struct{}
func (e *ErrorX) Error() string {
return "It's error X"
drgarcia1986 / main.go
Last active Aug 25, 2016
Link redirect and click counter in Go
View main.go
package main
import (
type RedirectHandler struct {
Counter chan string
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):
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="([^"]+)"/>'
'dolar': '',
'euro': '',
drgarcia1986 /
Last active May 21, 2018
asyncio/muffin/aiohttp examples
from concurrent.futures import ProcessPoolExecutor
import time
import muffin
app = muffin.Application('hello_world')
def get_msg():
drgarcia1986 /
Created Aug 15, 2015
Python asyncio.wait example with identified futures.
import asyncio
import aiohttp