Skip to content

Instantly share code, notes, and snippets.

import { BottomSheetModal, BottomSheetModalProps } from '@gorhom/bottom-sheet';
import { useCallback, useRef } from 'react';
import { BackHandler, NativeEventSubscription } from 'react-native';
/**
* hook that dismisses the bottom sheet on the hardware back button press if it is visible
* @param bottomSheetRef ref to the bottom sheet which is going to be closed/dismissed on the back press
*/
export const useBottomSheetBackHandler = (
bottomSheetRef: React.RefObject<BottomSheetModal | null>,
@nhphong
nhphong / swagger_spec.yaml
Last active May 6, 2024 08:06
Vector DB as a Service API Spec
swagger: '2.0'
info:
title: Vector DB Client API
version: '1.0.0'
host: 'your-api.com'
schemes:
- https
basePath: /api/v1
produces:
- application/json
@parmentf
parmentf / GitCommitEmoji.md
Last active May 6, 2024 08:03
Git Commit message Emoji
@channainfo
channainfo / 20231120092630_add_signature_to_delayed_jobs.rb
Last active May 6, 2024 08:02
Unique job with delayed_job using active job api
# add a new migration to the delayed_job table to track uniqueness
class AddSignatureToDelayedJobs < ActiveRecord::Migration[7.0]
def change
add_column :delayed_jobs, :signature, 'varchar(64)', index: true
end
end
@cyber-murmel
cyber-murmel / NixOS_on_Hetzner_Cloud.md
Last active May 6, 2024 08:00
NixOS on Hetzner Cloud

This is the gist of how to setup a NixOS server on a Hetzner Cloud instance with an admin user, ssh access and configuration management via git.

  1. Create a Hetzner Cloud instance and click to enter it.
  2. Stop the instance (top right corner icon).
  3. Go to ISO Images.
  4. Search for "nixos" and click mount. ISO Images tab of a Hetzner Cloud instance with the NixOS image already mounted
  5. Start the instance again (top right corner icon).
  6. Open the console (top right corner icon).
  7. Get the IP address by executing ip --brief --color address. The address can also be optained from the Hetzner Cloud web interface.
@enaeseth
enaeseth / objectid_to_uuid.py
Created June 12, 2013 19:29
Convert a MongoDB ObjectID to a valid, semantically similar UUID.
"""
Convert a MongoDB ObjectID to a version-1 UUID.
Python 2.7+ required for datetime.timedelta.total_seconds().
ObjectID:
- UNIX timestamp (32 bits)
- Machine identifier (24 bits)
- Process ID (16 bits)
- Counter (24 bits)
@wolfadex
wolfadex / elm-portal.js
Last active May 6, 2024 07:56
A Portal web component for Elm
window.customElements.define("elm-portal", class extends HTMLElement {
// Base custom element stuff
constructor() {
super();
this._targetNode = document.createElement('div');
}
connectedCallback() {
document.querySelector(this.getAttribute("data-target-selector")).appendChild(this._targetNode);
}
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/600.8.9 (KHTML, like Gecko) Version/8.0.8 Safari/600.8.9
Mozilla/5.0 (iPad; CPU OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H321 Safari/600.1.4
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0)
@codegenixdev
codegenixdev / 1_setup-commands
Last active May 6, 2024 07:55
video-scrolling
npm create vite@latest . -- --template react-ts
npm install
npm run dev
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent