This file contains hidden or 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
; `binding` definition from Clojuredocs.org: | |
; (binding bindings & body) | |
; | |
; binding => var-symbol init-expr | |
; | |
; Creates new bindings for the (already-existing) vars, with the | |
; supplied initial values, executes the exprs in an implicit do, then | |
; re-establishes the bindings that existed before. The new bindings | |
; are made in parallel (unlike let); all init-exprs are evaluated |
This file contains hidden or 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
require 'benchmark/ips' | |
def _codepoint(text) | |
text.each_codepoint do |p| | |
case p | |
when 97 then 97 | |
when 98 then 98 | |
when 99 then 99 | |
when 100 then 100 |
This file contains hidden or 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
require 'shin/compiler' | |
require 'shin/js_context' | |
require 'shin/ast' | |
require 'benchmark/ips' | |
opts = {} | |
compiler = Shin::Compiler.new(opts) | |
core_path = "../shin/lib/shin/cljs/cljs/core.cljs" | |
compiler.compile(File.read(core_path)) |
This file contains hidden or 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
function lpad(input, len) { | |
var s = "" + input; | |
while (s.length < len) { | |
s = " " + s; | |
} | |
return s; | |
} | |
function rpad(input, len) { |
This file contains hidden or 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 <microhttpd.h> | |
#define PORT 8888 | |
int answer_to_connection (void *cls, struct MHD_Connection *connection, | |
const char *url, | |
const char *method, const char *version, | |
const char *upload_data, | |
size_t *upload_data_size, void **con_cls) | |
{ |
This file contains hidden or 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
enum MHD_FLAG | |
{ | |
/** No options selected. */ | |
MHD_NO_FLAG = 0, | |
/** Run in debug mode. */ | |
MHD_USE_DEBUG = 1, | |
/** Run in HTTPS mode. */ | |
MHD_USE_SSL = 2, |
This file contains hidden or 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
MHDFlag: enum from Int { | |
noFlag: extern(MHD_NO_FLAG) | |
debug: extern(MHD_USE_DEBUG) | |
ssl: extern(MHD_USE_SSL) | |
threadPerConnection: extern(MHD_USE_THREAD_PER_CONNECTION) | |
selectInternally: extern(MHD_USE_SELECT_INTERNALLY) | |
ipv6: extern(MHD_USE_IPv6) | |
pedantic: extern(MHD_USE_PEDANTIC_CHECKS) | |
poll: extern(MHD_USE_POLL) | |
pollInternally: extern(MHD_USE_POLL_INTERNALLY) |
This file contains hidden or 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
_MHD_EXTERN struct MHD_Response * | |
MHD_create_response_from_buffer (size_t size, | |
void *buffer, | |
enum MHD_ResponseMemoryMode mode); | |
_MHD_EXTERN void | |
MHD_destroy_response (struct MHD_Response *response); |
This file contains hidden or 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
MHDResponse: cover from struct MHD_Response* { | |
createFromBuffer: extern(MHD_create_response_from_buffer) static func ( | |
size: SizeT, buffer: Pointer, responseMemoryMode: Int) -> This | |
destroy: extern(MHD_destroy_response) func | |
} |
This file contains hidden or 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
use microhttpd | |
import microhttpd/microhttpd | |
handleRequest: func ( | |
cls: Pointer, | |
connection: MHDConnection, | |
url: CString, method: CString, | |
_version: CString, | |
uploadData: CString, | |
uploadDataSize: SizeT, |