Skip to content

Instantly share code, notes, and snippets.

View fasterthanlime's full-sized avatar
🌌
4 oreos from heaven

Amos Wenger fasterthanlime

🌌
4 oreos from heaven
View GitHub Profile
; `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
@fasterthanlime
fasterthanlime / codepoint_bench.rb
Last active August 29, 2015 14:10
Comparing codepoints is faster it seems
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
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))
@fasterthanlime
fasterthanlime / trace.js
Created December 23, 2014 14:57
Pretty stack trace support for Duktape/ooc with TypeScript & sourcemaps
function lpad(input, len) {
var s = "" + input;
while (s.length < len) {
s = " " + s;
}
return s;
}
function rpad(input, len) {
#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)
{
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,
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)
_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);
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
}
use microhttpd
import microhttpd/microhttpd
handleRequest: func (
cls: Pointer,
connection: MHDConnection,
url: CString, method: CString,
_version: CString,
uploadData: CString,
uploadDataSize: SizeT,