Skip to content

Instantly share code, notes, and snippets.

(ns hooks-store
(:require ["react" :as react]
["react-dom" :as react-dom]))
(defprotocol IStore
(-trigger-subs [this old-state new-state])
(-get-value [this selector])
(destroy [this])
(ns scratch
(:require [clojure.string :as str]))
(defn csv-split [line]
(str/split line #","))
(defn replace-col [cols idx s]
(map-indexed (fn [i x] (if (= i idx) s x)) cols))
(defn index-of [coll value]
@orestis
orestis / iterate.clj
Last active January 2, 2018 16:39
Elixir Streams in Clojure
;; Stream.iterate(0, &(&1 + 1))
;; |> Enum.take(5)
;; gives us [0, 1, 2, 3, 4]
(take 5 (iterate #(+ % 1) 0))
;; => (0 1 2 3 4)
;; Mandelbrot
;; defmodule Mandelbrot do
# relevant code is at https://github.com/orestis/adventofcode/blob/master/2016/day11/lib/day11.ex
$ elixir -pa _build/MIX_ENV/consolidated -S mix profile.fprof --callers -e "Day11.solve"
...
<snip>
...
End of trace!
Processing data...
Creating output...
import Ember from 'ember';
export default Ember.Component.extend({
value: null,
actions: {
change(e) {
return True;
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
response: '{"data":{"id":"35","type":"file-upload","attributes":{"file":"http://example.com/somefile"}, "relationships":{}}}',
data: null,
normal: null,
objPush: null,
objPushPayload: null,
actions: {
<html>
<head>
<script type="text/javascript">
var evtSource = new EventSource("/sse");
evtSource.onmessage = function(e) {
// onmessage is the generic handler
var eventList = document.getElementById("eventlist");
var newElement = document.createElement("li");
newElement.innerHTML = "message: " + e.data;
import crochet
crochet.setup()
from twisted.web import resource, server
import random
from datetime import datetime
import json
def _format_sse(msg, event=None):
# crochet allows non-twisted apps to call twisted code
import crochet
crochet.no_setup()
from twisted.application import internet, service
from twisted.web import server, wsgi, static, resource
from twisted.internet import reactor
from twisted.python import threadpool
# boilerplate to get any WSGI app running under twisted
from bottle import Bottle, template, request, run
app = Bottle()
@app.route('/hello/')
def greet():
return template('''
<html>
<body>
Please introduce yourself: