This file contains 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
(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]) |
This file contains 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
(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] |
This file contains 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
;; 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 |
This file contains 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
# 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... |
This file contains 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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
value: null, | |
actions: { | |
change(e) { | |
return True; | |
} | |
} | |
}); |
This file contains 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
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: { |
This file contains 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
<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; |
This file contains 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
import crochet | |
crochet.setup() | |
from twisted.web import resource, server | |
import random | |
from datetime import datetime | |
import json | |
def _format_sse(msg, event=None): |
This file contains 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
# 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 |
This file contains 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
from bottle import Bottle, template, request, run | |
app = Bottle() | |
@app.route('/hello/') | |
def greet(): | |
return template(''' | |
<html> | |
<body> | |
Please introduce yourself: |
NewerOlder