Skip to content

Instantly share code, notes, and snippets.

@coder054
coder054 / n-queens.js
Last active March 4, 2024 09:02
n-queens problem
const log = (...args) => {
// console.log(...args)
document.write(...args)
document.write('<br />')
}
// get the print function (for printing the board)
const getPrint = (n) => (arr) => {
const print = () => {
let str = ''

Common Lisp Cheatsheet

Common Lisp is a general-purpose programming language with functions as first-class citizens. Don't worry about being purely functional, Lisp is Object Oriented too. CLOS is a very powerful object-oriented system!

Useful definitions

The Common Lisp lingo is quite unique:

  • Package: Basically a namespace, a place for symbols to live
  • System: Basically a Library. A bunch of code plus some instructions how it should be treated, for example which other systems it depends on, what should be loaded and/or compiled first, etc. Not in ANSI lisp but widespread. The most common system definition tool is ASDF.
  • Modules: Deprecated and implementation-dependent
  • Quicklisp: Like NPM or Ruby Gems for ASDF Systems.
@coder054
coder054 / parser.js
Created February 17, 2024 13:16 — forked from atungare/parser.js
JS lisp parser
function readToken (token) {
if (token === '(') {
return {
type: 'OPENING_PARENS'
};
} else if (token === ')') {
return {
type: 'CLOSING_PARENS'
};
} else if (token.match(/^\d+$/)) {

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@coder054
coder054 / README.md
Created October 26, 2023 02:45 — forked from tannerlinsley/README.md
Replacing Create React App with the Next.js CLI

Replacing Create React App with the Next.js CLI

How dare you make a jab at Create React App!?

Firstly, Create React App is good. But it's a very rigid CLI, primarily designed for projects that require very little to no configuration. This makes it great for beginners and simple projects but unfortunately, this means that it's pretty non-extensible. Despite the involvement from big names and a ton of great devs, it has left me wanting a much better developer experience with a lot more polish when it comes to hot reloading, babel configuration, webpack configuration, etc. It's definitely simple and good, but not amazing.

Now, compare that experience to Next.js which for starters has a much larger team behind it provided by a world-class company (Vercel) who are all financially dedicated to making it the best DX you could imagine to build any React application. Next.js is the 💣-diggity. It has amazing docs, great support, can grow with your requirements into SSR or static site generation, etc.

So why

@coder054
coder054 / downshift-example.js
Created October 9, 2023 04:43 — forked from JofArnold/downshift-example.js
Example of how to use Downshift as a controlled component with arbitrary items
// Untested code, but hopefully it gives you an idea.
// Ping me @jofarnold on Twitter if you get stuck
import React, { Component } from "react";
import Downshift from "downshift";
import PropTypes from "prop-types";
function nodeFromItem(id, items) {
return items.find(({ uuid }) => uuid === id);
}
@coder054
coder054 / spleeter.md
Created September 12, 2023 08:11 — forked from dungsaga/spleeter.md
Voice removal AKA karaoke creator
@coder054
coder054 / cypress_test_404_spec.js
Created July 6, 2023 04:05 — forked from paulmwatson/cypress_test_404_spec.js
Testing a 404 page with Cypress
cy.visit('/404')
//=> Test fails
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes but does not test the HTTP code was 404
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404)
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes, tests that the HTTP code was 404, and tests page was visited
@coder054
coder054 / The Y combinator
Created April 5, 2023 03:23
The Y combinator
const Y = (fn) => ((g) => g(g))((g) => fn((x) => g(g)(x)))
const factorialGenerator = (f) => (n) => n === 0 ? 1 : n * f(n - 1)
const factorial = Y(factorialGenerator)
factorial(5) // 120
const sumFromZeroToNGenerator = (f) => (n) => n <= 1 ? n : n + f(n - 1)
const sumFromZeroToN = Y(sumFromZeroToNGenerator)
sumFromZeroToN(5) // 15
/**
* DERIVING THE Y COMBINATOR IN 7 EASY STEPS
*
* Ionut G. Stan | ionut.g.stan@gmail.com | http://igstan.ro | http://twitter.com/igstan
*
*
* The Y combinator is a method of implementing recursion in a programming
* language that does not support it natively (actually, it's used more for
* exercising programming brains). The requirement is the language to support
* anonymous functions.