Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Lincoln de Sousa clarete

🌴
On vacation
View GitHub Profile
@clarete
clarete / another-doc.org
Last active Aug 28, 2020
Proposal for blorg's API that's aware of HTTP endpoints
View another-doc.org

Just a file to be linked to

If you didn’t like it, you can go back To where you whence were

Github won’t render the link above properly, gotta see the raw content

View README.org

Goal

Tool for easily generating HTML assembled from a template off of org mode files

One API

The function `blorg-gen` takes a pattern that matches file names and apply a template to generate one HTML for each Org file yielded by the search.

Templating

View infix-expression.js
// This is an extremely fun exercise and I could have probably
// used something way simpler than this. But I love parsing <3
// For this lil calculator, I used a few mutually recursive
// functions aided by two very simple operations (or, star). It
// is an extremely simplified version of how Parsing Expression
// Grammars (PEG) work.
// Here's how it'd read in plain PEG
// Expr <- _ Term
@clarete
clarete / cacheddownload.py
Last active Sep 28, 2018
First lines of every single scraper/downloader I write in Python
View cacheddownload.py
def download(url):
"Use request to retrieve URL's content. It sleeps 1s before starting."
time.sleep(3) # Can't bring the scraped site down :)
return requests.get(url).text
def saverequest(path, req):
"Write `req' into file pointed by `path'. Assumes `req' is in UTF-8."
io.open(path, 'w', encoding='utf-8').write(req)
return req
@clarete
clarete / lispinho.py
Last active Jun 20, 2018
Small lisp implementation in Python
View lispinho.py
#!/usr/bin/env python3
# Licensed under GPLv3: https://www.gnu.org/licenses/gpl.txt
# Commit history available here: https://github.com/clarete/wheelbarrow/blob/master/lispinho/main.py
# no dependencies, may also work with python2
from __future__ import print_function
from pprint import pprint
import enum
import readline
import sys
View curldocsscraper.py
# Parse online cURL doc to generate binding definitions file
import os
import io
import urlparse
import re
import lxml
import lxml.html
import requests
View curl_prim.cpp
#include <vm.hpp>
#include <bindgen.hpp>
#include <curl/curl.h>
static std::map<void*, oop> meme_mapping;
static int prim_curl_global_cleanup (Process* proc) {
View curl.defs
//sys #include <curl/curl.h>
//sys typedef struct _ CURL
//sys typedef int CURLcode
//sys typedef int CURLoption
//sys void curl_global_cleanup(void)
//sys CURLcode curl_global_init(long flags)
//sys CURL *curl_easy_init()
//sys void curl_easy_cleanup(CURL *handle)
//sys CURL *curl_easy_duphandle(CURL *handle)
//sys char *curl_easy_escape(CURL *curl, const char *string, int length)
View curl_prim.me
meme central:memescript/compiler;
CURL_GLOBAL_SSL: (1<<0);
CURL_GLOBAL_WIN32: (1<<1);
CURL_GLOBAL_ALL: (CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32);
CURL_GLOBAL_NOTHING: 0;
CURL_GLOBAL_DEFAULT: CURL_GLOBAL_ALL;
CURL_GLOBAL_ACK_EINTR: (1<<2);
class CURL
View curl.me
meme central:memescript/compiler;
requires io, c
where
io = central:stdlib/io
c = central:stdlib/curl/curl_prim
get: fun(url) {
c.curl_global_init(c.CURL_GLOBAL_DEFAULT);
var handle = c.curl_easy_init();
You can’t perform that action at this time.