Skip to content

Instantly share code, notes, and snippets.

@Risto-Stevcev
Risto-Stevcev / pfrng.js
Created March 23, 2016 22:33
Point-free rngN
// Just made it as an exercise for point-free ramda
> const R = require('ramda')
> const pfRng = R.compose(R.partial(R.times(R.compose(Math.floor, R.converge(R.multiply, [R.identity, Math.random])))), R.of)
> pfRng(20)()
[ 0, 0, 1, 1, 0, 2, 2, 2, 6, 2, 6, 10, 9, 6, 13, 6, 2, 5, 14, 6 ]
@Risto-Stevcev
Risto-Stevcev / motorcycle.min.js
Last active March 27, 2016 15:54
MotorcycleJS bundle
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.Cycle=f()}}(function(){var define;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){!function(global,factory){if("function"==typeof define&&define.amd)define("@most/dom-event",["exports","most"],factory);else if("undefined"!=typeof exports)factory(exports,require("most"));else{var mod={exports:{}};factory(mod.exports,global.mo
@Risto-Stevcev
Risto-Stevcev / dom.js
Created March 27, 2016 19:50
@motorcycle/dom
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.DOM = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define('@most/dom-event', ['exports', 'most'], factory);
} else if (typeof exports !
@Risto-Stevcev
Risto-Stevcev / http.js
Created March 28, 2016 14:20
@motorcycle/http
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.HTTP = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define('@most/hold', ['exports', 'most/lib/source/MulticastSource'], factory);
} el
@Risto-Stevcev
Risto-Stevcev / where.js
Created April 6, 2016 16:15
where clause
// playing around with "where" clause functionality for JS
const def = fn => ({
where: obj => (function(obj) {
Object.keys(obj).forEach(key => this[key] = obj[key])
fn()
})(obj)
})
def(() => {
console.log(a + b)
@Risto-Stevcev
Risto-Stevcev / tmpl.js
Created April 10, 2016 14:04
String literal to template literal
const tmpl = string => new Function('return `'+ string +'`')()
const name = 'foo'
tmpl('hello ${name}!')
@Risto-Stevcev
Risto-Stevcev / core.cljs
Last active May 17, 2016 00:40
Converting callbacks to use core-async channels in ClojureScript
(ns callback-to-core-async.core
(:require-macros [cljs.core.async :refer go])
(:require [ajax.core :refer [GET]]
[cljs.core.async :refer [<! put! chan]]))
(defn http-get [url]
(let [out (chan)
handler #(put! out %1)]
(GET url {:handler handler :error-handler handler})
out))
@Risto-Stevcev
Risto-Stevcev / example.html
Created May 25, 2016 23:17
Snabbdom standalone example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="//cdn.rawgit.com/risto-stevcev/snabbdom/master/dist/snabbdom.min.js"></script>
<script src="//cdn.rawgit.com/risto-stevcev/snabbdom/master/dist/snabbdom_style.min.js"></script>
<script src="//cdn.rawgit.com/risto-stevcev/snabbdom/master/dist/snabbdom_class.min.js"></script>
<script src="//cdn.rawgit.com/risto-stevcev/snabbdom/master/dist/snabbdom_props.min.js"></script>
@Risto-Stevcev
Risto-Stevcev / example.html
Created May 28, 2016 12:39
Snabbdom bundled standalone example
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.rawgit.com/risto-stevcev/snabbdom/master/dist/snabbdom.min.js"></script>
</head>
<body>
<div id="app"></div>
</body>
@Risto-Stevcev
Risto-Stevcev / Dockerfile
Created June 14, 2016 16:43
Purescript 0.8.5 Dockerfile
FROM node:4
MAINTAINER Risto Stevcev
ENV PURESCRIPT_DOWNLOAD_SHA1 7ac8ded4bc3e2b5af378af4bed77598eb69bfde2
RUN npm install -g bower pulp@8.2.1
RUN cd /opt \
&& wget https://github.com/purescript/purescript/releases/download/v0.8.5/linux64.tar.gz \