Skip to content

Instantly share code, notes, and snippets.

View enzzc's full-sized avatar
🫨
Focusing

Luciano C. enzzc

🫨
Focusing
View GitHub Profile
@enzzc
enzzc / now.c
Created July 8, 2016 18:33
Lua, get clock time in msecs
/*
Usage:
$ cc -fPIC -c now.c -I/usr/include/luaX.Y -O3
$ cc now.o -shared -o now.so
In Lua:
> now = require 'now'
> now.now_ms()
#!/usr/bin/env python3
# sc: size count
import sys
BUF_READ_SIZE = 2**24
buf_size = 0
buf = None
while buf != b'':
import sys
import requests
base_url = 'https://itunes.apple.com/lookup?id=%s&entity=podcast'
itunes_url = sys.argv[1]
itunes_id = itunes_url.split('/id')[1].split('?')[0]
r = requests.get(base_url % itunes_id).json()
print(r['results'][0]['feedUrl'])
import requests
MAPS_API_KEY = 'secret'
def geocode(address):
url = 'https://maps.googleapis.com/maps/api/geocode/json'
params = {
'address': address,
'key': MAPS_API_KEY
}
from bottle import route, run, template, request
import urllib.parse
import requests
CLIENT_ID = 'client_id'
CLIENT_SECRET = 'client_secret'
REDIRECT_URI = 'http://localhost:5555/oauth_line'
@route('/')
def index():
import requests
base_url = 'https://zestedesavoir.com'
endpoint = 'https://zestedesavoir.com/api/membres?page_size=1000'
endpoint_user = 'https://zestedesavoir.com/api/membres/{user_id}/'
r = requests.get(endpoint)
res = r.json()['results']
suspicious = [

Keybase proof

I hereby claim:

  • I am enzzc on github.

  • I am enz (https://keybase.io/enz) on keybase.

  • I have a public key ASCUuC60gFpVmQqWkDPWa0P3mGfVrl39xE1zQ3ae5OwcKQo

from functools import reduce
from collections import defaultdict
class IndexBackend:
def index_document(self, doc_id, text):
raise NotImplementedError
def search(self, query):
raise NotImplementedError
@enzzc
enzzc / auth_dns_serve.py
Created June 16, 2019 08:00
A simple authoritative DNS server which returns the same answer for all questions
import time
import socket
import select
import sqlite3
import dns.message
import dns.exception
DNS_SERVER_PORT = 53
IP4_ADDR = '0.0.0.0' # IPv4 address to return
IP6_ADDR = '::' # IPv6 address to return (if you want to support IPv6)
@enzzc
enzzc / sqs_aiobotocore.py
Created June 30, 2019 14:40
Simple example using AWS SQS with aiobotocore
import pathlib
import json
import asyncio
import aiobotocore
import time
import uuid
def message(msg):
return json.dumps({