Skip to content

Instantly share code, notes, and snippets.

View Carlsson87's full-sized avatar

Daniel Carlsson Carlsson87

View GitHub Profile
@Janiczek
Janiczek / Main.elm
Created December 3, 2023 07:21
Synchronous string normalization in Elm
module Main exposing (main)
import Html exposing (Html)
import Json.Decode
import Json.Encode
main : Html msg
main =
Html.ul []
@Janiczek
Janiczek / elm-make-readable.mjs
Created April 15, 2022 19:46
elm-make-readable
import fs from 'fs/promises';
const rules = [
{
rule: /var ([^=]+)( = F\d\([^f]+function)[^(]\(/gmi,
replacement: `var $1$2 __$1( `,
},
{
rule: /(\sA\d\([\s]+)([^,]+)(,[\s]+)(function[^(]+)\(/gm,
replacement: `$1$2$3$4___$2(`,
},

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

@fideloper
fideloper / Gettable.php
Created March 9, 2014 19:33
Trait for making protected/private attributes "gettable", leaving "setting" the attributes a matter of business logic to be implemented.
<?php
trait Gettable {
/**
* Retrieve private attributes.
* Attributes should be protected
* so they cannot be *set* arbitrarily.
* This allows us to *get* them as if they
* were public.