Skip to content

Instantly share code, notes, and snippets.

View clarete's full-sized avatar
🌴
On vacation

Lincoln Clarete clarete

🌴
On vacation
View GitHub Profile
package main
import (
"fmt"
"os"
"github.com/prometheus/prometheus/promql/parser"
)
func main() {
@clarete
clarete / another-doc.org
Last active August 28, 2020 02:12
Proposal for blorg's API that's aware of HTTP endpoints

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

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

// 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 September 28, 2018 18:25
First lines of every single scraper/downloader I write in Python
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 June 20, 2018 14:30
Small lisp implementation in Python
#!/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
# Parse online cURL doc to generate binding definitions file
import os
import io
import urlparse
import re
import lxml
import lxml.html
import requests
#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) {
//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)
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