Skip to content

Instantly share code, notes, and snippets.

@amundo
amundo / saveJSON.js
Created November 22, 2014 01:44
a simple function to export a JSON file
function saveJSON(data, saveAs){
var stringified = JSON.stringify(data, null, 2);
var blob = new Blob([stringified], {type: "application/json"});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.download = saveAs + '.json';
a.href = url;
a.id = saveAs;
document.body.appendChild(a);
@handcoding
handcoding / Ashley’s Light Fader.yaml
Last active May 6, 2024 08:07
This script for Home Assistant will fade a lamp over time with your choice of easing, including varieties of ease-in, ease-out, and ease-in-out.
alias: Ashley’s Light Fader
description: >
Fades a lamp over time. If you have any questions or comments about this
script, feel free to tweet Ashley Bischoff at @FriendlyAshley. Released under
the Apache 2.0 license. (v2.0)
fields:
light:
name: 💡 Light
description: entity_id of the lamp.
selector:
@cobyism
cobyism / gh-pages-deploy.md
Last active May 6, 2024 08:07
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

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);
}