Skip to content

Instantly share code, notes, and snippets.

View mooreryan's full-sized avatar

Ryan Moore mooreryan

View GitHub Profile
@jmackie
jmackie / README.md
Last active August 30, 2021 14:29
Basic example of file upload with progress in PureScript

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

@chenyong
chenyong / check.cljs
Created June 3, 2019 03:28
Comparing Clojure spec and TypeScript with multiple structs
(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"}
@finalfantasia
finalfantasia / cons_and_lazy_sequences_in_clojure.md
Last active November 7, 2022 16:54
Cons and Lazy Sequences in Clojure

(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

@corilam
corilam / style.css
Created September 6, 2016 04:33
Center Tabs in Foundation 6
.tabs-title {
float:none !important;
display:inline-block;
}
.tabs {
text-align:center;
}
@HaleTom
HaleTom / print256colours.sh
Last active May 2, 2024 14:43
Print a 256-colour test pattern in the terminal
#!/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
@jamescmartinez
jamescmartinez / html5boilerplate.html
Created March 17, 2016 03:57
Super simple, no frills HTML5 boilerplate!
<!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>
@lukas-h
lukas-h / license-badges.md
Last active May 9, 2024 08:26
Markdown License Badges for your Project

Markdown License badges

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.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)

@bsmith89
bsmith89 / Makefile
Created February 5, 2016 19:21
Minorly redacted Makefile for a project using mothur to analyze 16S data.
# ====================
# Project Makefile
# ====================
# User Configuration {{{1
# ====================
# Major targets {{{2
.PHONY: figs res
figs:
# [Partially redacted]
@yang-wei
yang-wei / note.md
Last active April 2, 2024 22:27
Clojure Thread-first vs Thread-last Macros

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

@paulirish
paulirish / what-forces-layout.md
Last active May 9, 2024 07:00
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

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.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent