Build the purescript bundle:
spago init
spago install aff console effect web-file web-xhr
spago build && spago bundle-module -m Upload -t index.cjs && browserify index.cjs -s Upload -o index.js
Spin up a dumb server to accept the POST request
Build the purescript bundle:
spago init
spago install aff console effect web-file web-xhr
spago build && spago bundle-module -m Upload -t index.cjs && browserify index.cjs -s Upload -o index.js
Spin up a dumb server to accept the POST request
(def data { | |
:mock-all? false | |
:mocks [ | |
{:path "api/test/json", :type :json :status 200 :data {"code" 200, "message" "This is a test json message in EDN"}} | |
{:path "api/test/file", :type :file :status 200 :file "user-info.json"} | |
{:path "api/test/text", :type :text :status 200 :text "user-info.json"} | |
] | |
:sites { | |
"api" {:target :apis} | |
"web" {:target :proxy, :path "/web", :host "http://localhost:8200"} |
(conj collection item)
adds item
to collection
. To do that, it needs to realize collection
. (I'll explain why below.) So the recursive call happens immediately, rather than being deferred.
(cons item collection)
creates a sequence which begins with item
, followed by everything in collection
. Significantly, it doesn't need to realize collection
. So the recursive call will be deferred (because of using lazy-seq
) until somebody tries to get the tail of the resulting sequence.
The following is how it works internally:
cons
actually returns a clojure.lang.Cons
object, which is what lazy sequences are made of. conj
returns the same type of collection which you pass it (whether that is a list, vector, or whatever else). conj
does this using a polymorphic Java method call on the collection itself. (See line 524 of clojure/src/jvm/clojure/lang/RT.java
.)
What happens w
.tabs-title { | |
float:none !important; | |
display:inline-block; | |
} | |
.tabs { | |
text-align:center; | |
} |
#!/bin/bash | |
# Tom Hale, 2016. MIT Licence. | |
# Print out 256 colours, with each number printed in its corresponding colour | |
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163 | |
set -eu # Fail on errors or undeclared variables | |
printable_colours=256 |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello, World!</title> | |
<link rel="stylesheet" href="stylesheet.css"> | |
</head> | |
<body> | |
Hello, World! | |
<script src="javascript.js"></script> |
Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.
Translations: (No guarantee that the translations are up-to-date)
# ==================== | |
# Project Makefile | |
# ==================== | |
# User Configuration {{{1 | |
# ==================== | |
# Major targets {{{2 | |
.PHONY: figs res | |
figs: | |
# [Partially redacted] |
Repost from:
http://yangweilim.com/blog/2015/11/18/clojure-thread-first-vs-thread-last-macros/
In this post, I am going to show you {when|how} to use Clojure marcos, ->>
aka thread-last and ->
aka thread-first. In some case, ->
and ->>
may perform the same operation if you do not pay enough attention. So I will also show you what's the difference between them. Note that doc ->
and docs ->>
din't make sense for me at first, so if same thing happened to you I hope that this post will make it clear.
If I am coding a function in Clojure, I would not think to write in macro firstly(maybe I am still new to it?). Macros like ->
and ->>
only come in my mind when it comes to refactoring. They are not neccessary in our program but they will make it elegant.
To explain how both of these macros work, let's us solve a quiz together.
[Write a function which calculates factorials.](http://www.4clojure.com/prob
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent