Consider the following markup:
<form class="root" state:theme=dark state:compact>
<div class="input-area">
<label for="username" class="label">Username:</label>
<input id="username" class="input" type="text">
</div>| # coding: utf-8 | |
| import os | |
| import vanilla | |
| import mojo.canvas | |
| from mojo.UI import PutFile | |
| from random import random | |
| from mojo.drawingTools import * | |
| import drawBot | |
| from AppKit import NSTimer |
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
| <!doctype html> | |
| <meta charset="utf-8"> | |
| <title>Example</title> | |
| <style> | |
| div { | |
| width: 100px; | |
| height: 100px; | |
| background: black; | |
| animation-duration: .5s; |
| from AppKit import * | |
| from lib.tools.misc import randomColor | |
| # get the application icon image | |
| icon = NSApp().applicationIconImage() | |
| # get the size | |
| w, h = icon.size() | |
| # make a rect with the size of the image | |
| imageRect = NSMakeRect(0, 0, w, h) | |
| # create a new image with the same size |
| // Promise.all is good for executing many promises at once | |
| Promise.all([ | |
| promise1, | |
| promise2 | |
| ]); | |
| // Promise.resolve is good for wrapping synchronous code | |
| Promise.resolve().then(function () { | |
| if (somethingIsNotRight()) { | |
| throw new Error("I will be rejected asynchronously!"); |
| * { | |
| font-size: 12pt; | |
| font-family: monospace; | |
| font-weight: normal; | |
| font-style: normal; | |
| text-decoration: none; | |
| color: black; | |
| cursor: default; | |
| } |
| from lib.settings import defaultFontInfoAttributes | |
| defaultFontInfoAttributes["descender"] = -200 | |
| defaultFontInfoAttributes["ascender"] = 800 |
$ compass compile --environment production && compass compile
Afterwards you will have both the minified and non-minified versions in your output folder. Note that compass clean will not clean up your minified files.