Skip to content

Instantly share code, notes, and snippets.

View Leechael's full-sized avatar
🐹
Working from home

Leechael Leechael

🐹
Working from home
View GitHub Profile
@WickyNilliams
WickyNilliams / LICENSE
Last active May 10, 2022 15:22
formdata event polyfill
The MIT License (MIT)
Copyright (c) 2021 Nick Williams (https://wicky.nillia.ms)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
@ben-rogerson
ben-rogerson / twin.code-snippets
Last active June 16, 2023 02:22
Twin Code Snippits for use in vscode - Shortcuts that make working with Twin a little easier
{
// Snippits that make working with Twin a little easier
// https://github.com/ben-rogerson/twin.macro
"Add react import": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "react",
"body": "import React from 'react'",
"description": "Add react import"
},
"Add twin imports": {
@tannerlinsley
tannerlinsley / createCrudHooks.js
Created November 29, 2020 06:39
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>
@tannerlinsley
tannerlinsley / README.md
Last active April 12, 2024 17:04
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

@waylybaye
waylybaye / Measure.swift
Last active March 12, 2024 14:09
SwiftUI view render performance Indicator
// Created by Baye Wayly on 2020/3/13.
// Copyright © 2020 Baye. All rights reserved.
import SwiftUI
struct Measure<Content: View>: View {
@State var cost: TimeInterval = 0
var content: Content
init(@ViewBuilder builder: () -> Content) {
/* *******************************************************************************************
* PUPPETEER
* https://pptr.dev/
* ******************************************************************************************* */
// When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win)
// that is guaranteed to work with the API.
npm install puppeteer
@ruizb
ruizb / advanced-example.md
Last active September 26, 2023 20:21
Reader monad example using fp-ts

The following section is not part of monet.js documentation, but I think it's worth showing how we can compose readers using fp-ts.

Reader composition

Let's say we have the following piece of code:

interface Dependencies {
  logger: { log: (message: string) => void }
 env: 'development' | 'production'

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@gchavez2
gchavez2 / free.py
Created July 2, 2019 17:49
Report available RAM memory with Python
#!/usr/bin/python
import subprocess
import re
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'],
stdout=subprocess.PIPE).communicate()[0].decode()
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[
0].decode()