Skip to content

Instantly share code, notes, and snippets.

alias dtail='docker logs -tf --tail='50' '
alias dstop='docker stop `docker ps -aq`'
alias drm='docker rm `docker ps -aq`'
alias dcp='docker-compose -f ~/docker-compose.yml '
alias dcporph='docker-compose -f ~/docker-compose.yml up -d --remove-orphans'
alias dprune='docker image prune'
alias dprunesys='docker system prune --all'
@simenbrekken
simenbrekken / README.md
Last active November 9, 2023 16:56
Hide fetch/XHR in Cypress command log

This novel workaround simply hides any command log entries that originate from fetch/XHR requests.

While I've updated this receipe for Cypress 10 and converted it to TypeScript you should be able to use it in a JavaScript project by ignoring the cypress.d.ts file and placing the snippet from e2e.ts in e2e.js instead.

@kentcdodds
kentcdodds / useOnRead.tsx
Last active June 9, 2021 04:24
How I determine whether you've read a blog post.
function useOnRead({
parentElRef,
onRead,
enabled = true,
}: {
parentElRef: React.RefObject<HTMLElement>
onRead: () => void
enabled: boolean
}) {
React.useEffect(() => {
@sindresorhus
sindresorhus / esm-package.md
Last active July 5, 2024 10:12
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.
#!/bin/bash
#
# renew-letsencrypt-certificates.sh DOMAIN [EMAIL]
#
# Copy Let's Encrypt SSL certs from a remote public facing web server to local filesystem
# Look for changes, if any change, restarts the web service
# Useful for using Let's Encrypt with local internal servers, with custom DNS.
# Working "mail" command needed for email alerts
#
@dfrankland
dfrankland / how_to_use_wireshark_with_nodejs.md
Created May 28, 2020 05:06
How to use Wireshark with Node.js (especially with HTTPS / TLS / SSL)

How to use Wireshark with Node.js (especially with HTTPS / TLS / SSL)

It can be difficult to trace network traffic from a Node.js application. Typically, folks will just instrument some logging to check that everything is working as it is supposed to. Unfortunately, sometimes there are too many abstractions or possible race conditions to accurately get a good trace. To get the most objective possible trace of network traffic Wireshark can be used.

Wireshark is a network protocol analyzer that makes it extremely simple to capture and trace network activity from any source on your computer. It also has

@benrobygreene
benrobygreene / Marquee.js
Created November 12, 2019 18:27
Marquee
import { debounce } from 'common/Helpers';
const dom = {
marquee: 'data-marquee-wrapper',
marqueeText: 'data-marquee-text',
};
/**
* Build an animation for a marquee wrapper
*
// please check https://docs.netlify.com/configure-builds/environment-variables/#declare-variables for most up to date info
// this was created before those docs existed
process.env = {
/**
*
* AUTOMATICALLY SET BY NETLIFY. IMMUTABLE!
* docs: https://www.netlify.com/docs/continuous-deployment/#environment-variables
*
*/
@FlorianRappl
FlorianRappl / useCarousel.ts
Last active March 27, 2024 13:58
The generic useCarousel hook.
import { useReducer, useEffect } from 'react';
import { useSwipeable, SwipeableHandlers, EventData } from 'react-swipeable';
function previous(length: number, current: number) {
return (current - 1 + length) % length;
}
function next(length: number, current: number) {
return (current + 1) % length;
}
@CharlesRyan
CharlesRyan / logger.liquid
Last active June 6, 2019 20:17
A liquid snippet that logs the value of any liquid variable that gets passed to it. It also has the ability to output the name of the variable if needed. There's a couple usage examples at the top of the snippet
{% comment %}
data_type options are 'string', 'object', 'iterable strings', 'iterable objects', and null
for numbers and booleans, enter a data_type of 'string'
it allows for omitting data_type by just logging it as both a string and an object
the capture tags can also be omitted if the name of the variable isn't needed
{% endcomment %}
{% comment %}
Usage Examples:
{% endcomment %}