Skip to content

Instantly share code, notes, and snippets.

Avatar

Hugo Lopes Tavares hltbra

View GitHub Profile
@hltbra
hltbra / b.c
Created Apr 6, 2020
Demo of Lua integrated with C
View b.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
int main (int argc, char *argv[]) {
if (argc < 3) {
fprintf(stderr, "Missing arguments. Use it like ./program <a> <b>\n");
View ast_func_parsing.py
import ast
code = """
import foo
a = 1 + 2
b = "a" + "b" * 3
@hltbra
hltbra / cdredis.c
Created May 24, 2019
Experiments using ae.c/anet.c with Cython + dredis
View cdredis.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "ae.h"
#include "anet.h"
#include "cdredis.h"
View our-queueing-solution-blog-post-ex0.py
def scrape_listing():
for link in get_links(LISTING_URL):
scrape_link(link)
def scrape_link(url):
resp = requests.get(url)
info = get_link_info(resp.content)
save('link', info)
View our-queueing-solution-blog-post-ex1.py
@starting_task
def scrape_listing():
for link in get_links(LISTING_URL):
schedule('scrape_link', link, seconds=0)
@subtask
def scrape_link(url):
resp = requests.get(url)
info = get_link_info(resp.content)
@hltbra
hltbra / ysh.py
Last active Jan 4, 2019
Basic implementation of a shell in Python. This is from a talk I gave at YipitData on August 29, 2018.
View ysh.py
# REPL
# read, eval, print, loop program
import os
import subprocess
import shlex
import sys
last_returncode = 0
try:
@hltbra
hltbra / dynamic-python.ipynb
Created Aug 1, 2018
Tech talk at Yipit about Python dynamic features - 2018/08/01
View dynamic-python.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hltbra
hltbra / spreadsheet.py
Last active Jul 26, 2018
playing with metaprogramming to create a spreasheet-like DSL. This is an extension of a Coding Dojo performed at Yipit (https://github.com/Yipit/yipit-dojo/tree/master/2018-07-25)
View spreadsheet.py
from collections import defaultdict
class BaseCell(object):
def __init__(self, value):
self.value = value
def __add__(self, other):
if not isinstance(other, Cell):
other = BaseCell(other)
You can’t perform that action at this time.