Skip to content

Instantly share code, notes, and snippets.

@vitaly-t
vitaly-t / retry-async.ts
Last active November 4, 2024 10:26
retry-async
/**
* Retry-status object type, for use with RetryCB.
*/
export type RetryStatus = {
/**
* Retry index, starting from 0.
*/
index: number,
/**
* Retry overall duration, in milliseconds.
@alanzchen
alanzchen / popclip-chatgpt.js
Last active September 13, 2024 18:50
PopClip Actions using ChatGPT.
// #popclip extension for ChatGPT
// name: ChatGPT Quick Actions
// icon: iconify:logos:openai-icon
// language: javascript
// module: true
// entitlements: [network]
// options: [{
// identifier: apikey, label: API Key, type: string,
// description: 'Obtain API key from https://platform.openai.com/account/api-keys'
// }]
@sastan
sastan / $layout.svelte
Created April 14, 2021 20:56
sveltekit + urql (minimal version)
<script context="module">
import { get, readable } from 'svelte/store'
import { createClient, operationStore } from '@urql/svelte'
import { browser, dev } from '$app/env'
/**
* @type {import('@sveltejs/kit').Load}
*/
@tcrowe
tcrowe / npm-auth-token.js
Last active February 2, 2020 18:55
npm auth token with zsh or bash and curl or node
// npm install superagent
const superagent = require("superagent");
// this is verdaccio's url ↓ but you could use like registry.npmjs.com if that is allowed in their TOS
const registryUrl = "http://127.0.0.1:4873";
const username = "myusername2";
const password = "mypassword2";
const frm ={
name: username,
@jacobtomlinson
jacobtomlinson / minikube-update-hosts.sh
Last active October 26, 2022 15:50
A script to update your /etc/hosts file from minikube ingest records
#!/bin/bash
#
# A script to update your /etc/hosts file from minikube ingest records
#
# Installation
# ------------
# curl -L https://gist.github.com/jacobtomlinson/4b835d807ebcea73c6c8f602613803d4/raw/minikube-update-hosts.sh > /usr/local/bin/minikube-update-hosts
# chmod +x /usr/local/bin/minikube-update-hosts
set -e
@whereisaaron
whereisaaron / pfx-to-crt-and-key.sh
Last active November 5, 2024 16:42
Extract a crt file (PEM), key file, and chain bundle from a PFX file, prompts for password or use PFXPASSWORD environment variable
#!/bin/bash
#------------------
# Extract the key, certficiate, and chain in PEM format from a PFX format file
#
# Must supply the input pfx file
PFX_PATH="$1"
if [ "${PFX_PATH}" == "" ]; then
echo "Must supply pfx file path"
exit 1
@addyosmani
addyosmani / README.md
Last active October 17, 2024 13:41 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

# using VirtualBox version $VBOX_VERSION
FROM boot2docker/boot2docker
RUN apt-get install p7zip-full
RUN mkdir -p /vboxguest && \
cd /vboxguest && \
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso && \
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \
sh VBoxLinuxAdditions.run --noexec --target . && \
@possibilities
possibilities / meteor-async.md
Created August 23, 2012 22:53
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase: