Skip to content

Instantly share code, notes, and snippets.

@schabluk
schabluk / Promises.js
Last active May 20, 2021 10:56
Array / Object Tools
// Delaying response
let delay = time => result => new Promise(resolve => setTimeout(() => resolve(result), time))
const result = await fetch(endpoint).then(delay(1000)).then(data => data.json())
// Mocking Fetch
window.fetch = function () {
const body = { hello: "world" }
const blob = new Blob([JSON.stringify(body, null, 2)], { type : 'application/json' })
@bvaughn
bvaughn / index.md
Last active June 16, 2024 21:50
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@benoitv-code
benoitv-code / index.js
Last active November 13, 2022 18:21
d3, jsdom, node.js: server-side rendering
// Instructions:
// npm install --save d3 jsdom
const fs = require('fs');
const d3 = require('d3');
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
const fakeDom = new JSDOM('<!DOCTYPE html><html><body></body></html>');
@lixiaoyan
lixiaoyan / README.md
Last active June 21, 2021 08:46
Draft.js with line number.
@tomcask
tomcask / draftjs-force-selection.js
Created January 10, 2017 16:52
Example of force selection in draftjs
const getEditorState = this.props.store.getItem('getEditorState');
const setEditorState = this.props.store.getItem('setEditorState');
const selection = this.props.store.getItem('lastSelection');
const editorState = getEditorState();
const updateSelection = new SelectionState({
anchorKey: selection.anchorKey,
anchorOffset: selection.anchorOffset,
focusKey: selection.anchorKey,
focusOffset: selection.focusOffset,
isBackward: false,
@hrobeers
hrobeers / gist:214b2a7199875c477f13f48e5f675c4a
Last active February 3, 2021 10:39
Generate compressed and uncompressed bitcoin addresses from a private key with bitcore.
var bitcore = require("bitcore-lib");
var Buffer = require("buffer").Buffer;
var value = new Buffer.from("test", "utf8");
var hash = bitcore.crypto.Hash.sha256(value);
// Compressed Key (nu skool)
var bn = bitcore.crypto.BN.fromBuffer(hash);
var privateKey = new bitcore.PrivateKey(bn);
@caio2k
caio2k / oracle_curl.sh
Last active November 29, 2023 02:22 — forked from mvanvuuren/oracle_curl.sh
Download from OTN Oracle
#!/bin/bash
curl -L -O -H "Cookie: oraclelicense=accept-securebackup-cookie" $1
#ORACLE Solaris download links
#http://download.oracle.com/otn/solaris/11.2/sol-11_2-text-sparc.iso
#http://download.oracle.com/otn/solaris/11.2/sol-11_2-text-sparc.usb
#http://download.oracle.com/otn/solaris/11.2/sol-11_2-text-x86.iso
#http://download.oracle.com/otn/solaris/11.2/sol-11_2-text-x86.usb
#http://download.oracle.com/otn/solaris/11.2/sol-11_2-text-x86.iso #c09f40ed91d43b0adf109c124154a2b4
#http://download.oracle.com/otn/solaris/11.2/sol-11_2-vbox.ova #448619f56f48cd6dc7490ce379599f9a
@abtrout
abtrout / redis-pipe.md
Last active August 11, 2023 03:29
Bash script to prepare Redis commands for mass insertion via `redis-cli --pipe`

Redis supports mass insert via redis-cli --pipe, but commands need to be written in redis protocol. For more details, check out the Redis mass insertion page. This script takes care of converting ordinary redis commands to redis protocol.

#!/usr/bin/env bash

while read CMD; do
  # each command begins with *{number arguments in command}\r\n
  XS=($CMD); printf "*${#XS[@]}\r\n"
  # for each argument, we append ${length}\r\n{argument}\r\n
 for X in $CMD; do printf "\$${#X}\r\n$X\r\n"; done
@rxaviers
rxaviers / gist:7360908
Last active July 5, 2024 17:44
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//