This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.preamble(io, net) | |
io: meme:io; | |
net: meme:net; | |
.code | |
main: fun() { | |
var server = net.TCPServer.new(); | |
server.bindAndListen("::", "8000"); | |
while (true) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parse online cURL doc to generate binding definitions file | |
import os | |
import io | |
import urlparse | |
import re | |
import lxml | |
import lxml.html | |
import requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |