This file contains hidden or 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 SwiftUI | |
import PlaygroundSupport | |
struct Desktop: View { | |
var body: some View { | |
ZStack { | |
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG")) | |
Color(UIColor.systemBlue) | |
macOS() | |
} |
This file contains hidden or 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
global.THREE = require("three"); | |
const canvasSketch = require('canvas-sketch'); | |
const Random = require('canvas-sketch-util/random'); | |
const gradientHeight = 512; | |
const settings = { | |
dimensions: [ 2048, gradientHeight * 2 ] | |
}; |
This file contains hidden or 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
class Spiderman { | |
lookOut() { | |
alert('My Spider-Sense is tingling.'); | |
} | |
} | |
let miles = new Spiderman(); | |
miles.lookOut(); |
This file contains hidden or 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
function parse(cssText) { | |
// this regex matches all non-contextual nodes; which are comments, whitespaces, strings, numbers, named identifiers, and delimiters. | |
var cssRegExp = /\/\*((?:[^*]|\*[^\/])*)\*\/|([ \t\n\f\r]+)|"((?:[^"\\\n\f\r]|\\\r\n|\\[\W\w])*)"|'((?:[^'\\\n\f\r]|\\\r\n|\\[\W\w])*)'|#((?:[-\w]|[^\x00-\x7F]|\\[^\n\f\r])+)|([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee]-?\d+)?)|(-?(?:[-A-Z_a-z]|[^\x00-\x7F]|\\[^\n\f\r])(?:[-\w]|[^\x00-\x7F]|\\[^\n\f\r])*)|([\uD800-\uDBFF][\uDC00-\uDFFF]|[\W\w])/g; | |
// the contextual nodes generated from these matches are: | |
// - numbers with a unit (number + named identifier), | |
// - at identifiers (`@` + named identifier), | |
// - blocks (everything between equally nested `(` and `)` or `[` and `]` or `{` and `}`), and | |
// - functions (named identifier + block). | |
// you will likely create a root/parent scope for organizing your blocks and functions |
At 1.7kB, parse.js can parse CSS as component values and mutate the tree with visitors:
var source = ':nth-child(5) {\n\tcolor: var(--foo, var(--bar, var(--cat, blue)));\n}';
var cssast = parse(source);
cssast.visit({
CSSFunction: {
exit: function(node) {
if (node.name === 'var') {
node.replaceSelf(node.last);
This file contains hidden or 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
export type ConsList<T> = null | readonly [T, ConsList<T>]; | |
function cons<T>(h: T, t: ConsList<T>): ConsList<T> { | |
return [h, t]; | |
} | |
function head<T>(xs: ConsList<T>): T { | |
if (!xs) { | |
throw new Error("can't take head of empty ConsList"); | |
} |
This file contains hidden or 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
-- original code: https://github.com/ericelliott/cuid | |
-- Add the "plv8" extension | |
create extension if not exists "plv8"; | |
-- Add the "pgcrypto" extension | |
create extension if not exists "pgcrypto"; | |
\dx | |
-- Connect a database |
%GetOptimizationStatus
return a set of bitwise flags instead of a single value,
to access the value, you need to take the binary representation of the returned value.
Now, for example, if 65
is returned, the binary representation is the following:
(65).toString(2).padStart(12, '0');
// 000001000001
Each binary digit acts as a boolean with the following meaning: