Skip to content

Instantly share code, notes, and snippets.

View kripod's full-sized avatar

Kristóf Poduszló kripod

View GitHub Profile
@jordansinger
jordansinger / macOS.swift
Last active November 17, 2024 02:37
macOS SwiftUI Playgrounds code
import SwiftUI
import PlaygroundSupport
struct Desktop: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
Color(UIColor.systemBlue)
macOS()
}
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 ]
};
@gaearon
gaearon / Classes.js
Created May 27, 2020 17:38
Beneath Classes: Prototypes
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
@jonathantneal
jonathantneal / css-parser-super-core.js
Created January 9, 2020 18:30
CSS Parser Super Core (the barest bits)
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
@jonathantneal
jonathantneal / README.md
Created December 28, 2019 07:02
CSS Parser (2019-12-28)

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);
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");
}
@notakaos
notakaos / create_function_plv8_cuid.sql
Last active August 16, 2024 10:10
cuid for PostgreSQL with PL/v8
-- 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

Reach UI Philosophy

Reach UI is an accessible foundation for React applications and design systems.

The three equally important goals are to be:

  • Accessible
  • Composable
  • Stylable
@naugtur
naugtur / GetOptimizationStatus.md
Created August 9, 2019 21:08 — forked from justjavac/GetOptimizationStatus.md
V8 %GetOptimizationStatus

%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: