Skip to content

Instantly share code, notes, and snippets.

View DanCouper's full-sized avatar

Dan Couper DanCouper

View GitHub Profile
/**
* @typedef {Object} RangeOpts
* @property {number} [step=1]
* @property {boolean} [isInclusive=2]
*/
class Range {
#index = 0;
#length = 0;
#![feature(iter_array_chunks)]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Instructions
///
/// Pick the best hand(s) from a list of poker hands.
///
/// See wikipedia for an overview of poker hands.
///
/// Ranking a list of poker hands can be considered a sorting problem.
@DanCouper
DanCouper / daily-ui.md
Created November 16, 2022 01:24 — forked from Pustur/daily-ui.md
DailyUI – A list of every DailyUI design challenge

All DailyUI Challenges

  1. Sign Up
  2. Credit Card Checkout
  3. Landing Page (above the fold)
  4. Calculator
  5. App Icon
  6. User Profile
  7. Settings
  8. 404 page
function logColor(color, args) {
console.log(`%c ${args.join(' ')}`, `color: ${color}`);
}
const log = {
aliceblue: (...args) => { logColor('aliceblue', args)},
antiquewhite: (...args) => { logColor('antiquewhite', args)},
aqua: (...args) => { logColor('aqua', args)},
aquamarine: (...args) => { logColor('aquamarine', args)},
azure: (...args) => { logColor('azure', args)},
@DanCouper
DanCouper / zx_example_1.md
Created June 3, 2021 11:35
Examples of executable (via `zx`, using v1.14.1) markdown scripts. First one works, next two do not for described reasons

Expected Behavior

Only code I want to execute should execute.

Actual Behavior

Anything in either a fenced block or indented by 4 spaces/tab blindly executes.

Steps to Reproduce the Problem

@DanCouper
DanCouper / machine.js
Last active November 3, 2020 14:50
Generated by XState Viz: https://xstate.js.org/viz
const timermachine = Machine({
id: "timer",
initial: "inactive",
context: {
breakLength: 10,
breakRemaining: 0,
sessionLength: 10,
sessionRemaining: 0,
cooldownLength: 1,
cooldownRemaining: 0,
@DanCouper
DanCouper / artist.ex
Last active May 10, 2020 13:40
collection schemas
defmodule Collection.Artist do
use Ecto.Schema
schema "artists" do
field(:name, :string)
end
def changeset(struct, params) do
struct
|> Ecto.Changeset.cast(params, [:name])
@DanCouper
DanCouper / machine.js
Last active March 23, 2020 16:08
Generated by XState Viz: https://xstate.js.org/viz
const authMachine = Machine({
id: 'auth',
initial: 'idle',
context: {
error: null,
isAuthorised: false,
retries: 3,
},
states: {
idle: {
@DanCouper
DanCouper / CodeInput.jsx
Created January 23, 2020 12:00
Rough draft of a generic code input component
import React from "react";
import { StyleSheet, Text, TextInput, View } from "react-native";
/* --------------------------------------- *\
* Local versions of imported modules,
* just for isolated testing.
\* --------------------------------------- */
const s = StyleSheet.create({
white: { color: "#ffffff" },
bg_mid: { backgroundColor: "#1A5163" },
@DanCouper
DanCouper / machine.js
Created January 16, 2020 16:33
Generated by XState Viz: https://xstate.js.org/viz
const TheoUserSecurityPreference = {
PIN: "PIN",
BIOMETRIC: "BIOMETRIC",
NONE: "NONE"
};
// services
async function cacheStaticImages() {
console.log("Images cached")
return;