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.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: {
import Ember from 'ember';
export default Ember.Component.extend({
value: null,
actions: {
change(e) {
return True;
}
}
});
@orestis
orestis / monitortest.py
Created June 17, 2011 09:32
monitortest.py
from twisted.web.client import getPage
from twisted.internet import reactor, task
from twisted.names.client import createResolver
def p(s):
print s
def _getPage(address):
d = getPage(address, timeout=10)
d.addCallback(lambda _, a=address: p("OK " + a))
d.addErrback(lambda e, a=address: p("NO " + a + ' ' + e.getErrorMessage()))
@orestis
orestis / gist:1031120
Created June 17, 2011 09:26
server log
$ python monitor3.py
2011-06-17 12:22:43+0300 [-] Log opened.
2011-06-17 12:22:43+0300 [-] /etc/resolv.conf changed, reparsing
2011-06-17 12:22:43+0300 [-] Resolver added ('10.0.99.1', 53) to server list
2011-06-17 12:22:43+0300 [-] twisted.web.server.Site starting on 8000
2011-06-17 12:22:43+0300 [-] Starting factory <twisted.web.server.Site instance at 0x1025ff128>
2011-06-17 12:22:44+0300 [-] Starting factory <HTTPClientFactory: http://apple.com>
2011-06-17 12:22:44+0300 [-] Starting factory <HTTPClientFactory: http://adobe.com>
2011-06-17 12:22:44+0300 [-] <class 'twisted.names.dns.DNSDatagramProtocol'> starting on 56464
2011-06-17 12:22:44+0300 [-] Starting protocol <twisted.names.dns.DNSDatagramProtocol object at 0x102615c10>
@orestis
orestis / gist:1031119
Created June 17, 2011 09:25
adobe apple output
$ curl -N localhost:8000
<html><body>http://adobe.com <twisted.names.dns.Message instance at 0x10261c830> <twisted.names.dns.Message instance at 0x10261c830>
{'OK': 0, 'TIMEOUT': 0, 'ERROR': 1}
{'OK': 1, 'TIMEOUT': 0, 'ERROR': 1}
@orestis
orestis / monitor3.py
Created June 17, 2011 09:24
monitor3.py
from twisted.web.resource import Resource
from twisted.web.server import Site, NOT_DONE_YET
from twisted.web.client import getPage
from twisted.internet import reactor, defer, task
from twisted.names.client import createResolver
from twisted.names import dns
from twisted.python import log
import sys
log.startLogging(sys.stdout)