Skip to content

Instantly share code, notes, and snippets.

@Grubba27
Grubba27 / fizzbuzz.ts
Created April 20, 2022 01:13
FizzBuzz made in typelevel
type Reverse<A> =
`${A}` extends `${infer AH}${infer AT}`
? `${Reverse<AT>}${AH}` : A
type Digs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
type DigsNext<I = Digs, R = {}> =
I extends [infer Head, infer Next, ...infer Tail]
// based on https://github.com/vit0rr/jogo-da-adivinhacao
//extern crate rand;
//use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn read_guess() -> u32 {
return loop {
let mut guess = String::new();
@onlime
onlime / .eslintrc.js
Last active May 7, 2024 08:54
ESLint/Prettier config for Vue 3 in VS Code
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
'prettier'
type NatModule<Nat> = {
zero: Nat;
one: Nat;
add: (x: Nat, y: Nat) => Nat;
};
const NatModule = <A>(cb: <Nat>(Nat: NatModule<Nat>) => A) => {
const zero = 0;
const one = 1;
open Lwt_engine;
[@ocaml.warning "-3"];
module Lwt_sequence = Lwt_sequence;
[@ocaml.warning "+3"];
module Fd_map =
Map.Make({
type t = Unix.file_descr;
let compare = compare;
@jgcmarins
jgcmarins / babel.config.js
Created April 24, 2020 23:37
Webpack configs for Node.js backends to run both locally and on AWS Lambda
module.exports = {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
@IanColdwater
IanColdwater / twittermute.txt
Last active April 14, 2025 16:31
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@jsjain
jsjain / isEqual.js
Last active February 14, 2024 16:17
basic native implementation for isEqual lodash
const isEqual = (first: any, second: any): boolean => {
if (first === second) {
return true;
}
if ((first === undefined || second === undefined || first === null || second === null)
&& (first || second)) {
return false;
}
const firstType = first?.constructor.name;
const secondType = second?.constructor.name;
@sibelius
sibelius / FormUseFormik.tsx
Last active March 10, 2025 03:04
Example showing how to useFormik and FormikProvider
type Props = {
};
const FormUseFormik = (props: Props) => {
const { enqueueSnackbar } = useSnackbar();
const onSubmit = (values) => {
enqueueSnackbar(`submit: ${JSON.stringify(values)}`, {
preventDuplicate: true,
persist: false,
});
@wojteklu
wojteklu / clean_code.md
Last active April 21, 2025 06:12
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules