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
.preamble(io, net)
io: meme:io;
net: meme:net;
.code
server: fun(clients) {
var server = net.TCPServer.new("::", "8000");
server.bindAndListen();
while (true) clients.put(server.accept_client());
}
start = definitions;
module :m = definitions:xs => this.gen(m, xs);
definitions = [definition+:xs] => xs;
definition = include | struct_def | func;
include
= [:include string:name] => "#include " + name
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();
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
//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)
#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) {
# Parse online cURL doc to generate binding definitions file
import os
import io
import urlparse
import re
import lxml
import lxml.html
import requests
@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
@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 / libircclient.rb
Last active January 5, 2019 20:50
Brew formula to install libircclient
require 'formula'
class Libircclient < Formula
homepage 'http://www.ulduzsoft.com/linux/libircclient/'
url 'http://downloads.sourceforge.net/project/libircclient/libircclient/1.6/libircclient-1.6.tar.gz'
sha1 '10fb7a2478f6d668dce2d7fb5cd5a35ea8f53ed4'
depends_on 'pkg-config' => :build
depends_on 'autoconf' => :build
depends_on 'automake' => :build