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.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
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
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())) |
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
$ 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> |
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
$ 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} |
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 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) |
NewerOlder