Skip to content

Instantly share code, notes, and snippets.

View ff6347's full-sized avatar
🤖
updating status…

Fabian Morón Zirfas ff6347

🤖
updating status…
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 22, 2025 09:41
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@m-radzikowski
m-radzikowski / script-template.sh
Last active May 22, 2025 17:41
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@Szymongib
Szymongib / warp_log_headers.rs
Created September 19, 2020 07:30
Filter to log request headers using Warp framework
// [dependencies]
// tokio = { version = "0.2", features = ["macros"] }
// warp = "0.2.2"
use warp::Filter;
use warp::http::HeaderMap;
use std::convert::Infallible;
#[tokio::main]
async fn main() {
@Weakky
Weakky / nexus-test-environment.js
Created June 25, 2020 09:22
SQLite jest environment for Nexus & Prisma
// tests/nexus-test-environment.js
const NodeEnvironment = require('jest-environment-node')
const { nanoid } = require('nanoid')
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const fs = require('fs')
const path = require('path')
const prismaBinary = './node_modules/.bin/prisma'

Unistore Hooks for Preact

Experimental hooks-based bindings for Unistore. Available on npm:

npm i unistore-hooks

Note: this should also work with React, just alias "preact" and "preact/hooks" to "react" in your bundler.

Usage

@ff6347
ff6347 / .vimrc
Last active May 25, 2020 10:27
Some basic vimrc so I can curl it into a ubuntu box
call plug#begin(expand('~/.vim/plugged'))
Plug 'arcticicestudio/nord-vim'
Plug 'sheerun/vim-polyglot'
call plug#end()
filetype indent plugin on
colorscheme nord
syntax on
set autoindent
set backspace=2
set cursorline
@ciiqr
ciiqr / dispatch.sh
Last active February 19, 2025 12:25
github actions, repository_dispatch with client_payload
# TODO: replace :token, :user, and :repo
curl -H "Authorization: token :token" \
-H 'Accept: application/vnd.github.everest-preview+json' \
"https://api.github.com/repos/:user/:repo/dispatches" \
-d '{"event_type": "awesomeness", "client_payload": {"foo": "bar"}}'
@iaurg
iaurg / GeneratePdf.js
Created September 25, 2019 18:44
react-pdf PDFDownloadLink
import React, { Component } from 'react';
import { render, hydrate } from 'react-dom';
import { PDFDownloadLink } from '@react-pdf/renderer';
import { ModelCertificate } from './ModelCertificate';
export default class PDFLink extends Component {
state = {
loading: false,
};
/* Helper buddy for removing async/await try/catch litter 🗑 */
function O_o(promise) {
return promise.then(data => {
if (data instanceof Error) return [data]
return [null, data]
}).catch(err => [err])
}
/* Look ma, no try/catch */
async function usageExample(params) {
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active May 22, 2025 22:57
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}