Skip to content

Instantly share code, notes, and snippets.

View will123195's full-sized avatar

Will Schmid will123195

View GitHub Profile
@rafaelsq
rafaelsq / GCM.js
Last active January 3, 2020 00:12
WebCrypto - PBKDF2-HMAC-256 + encode AES-CBC/AES-GCM
export const EncodeGCM = (pass, salt, iv, iterations, data) =>
new window.Promise((ok, fail) => {
pbkdf2(strToBuf(pass), salt, iterations, 'SHA-256', 'AES-GCM')
.then(key => {
const chunkSize = 2 << 10
let len = data.byteLength / chunkSize + (data.byteLength % chunkSize ? 1 : 0) | 0
let out = new window.Uint8Array([...salt, ...iv])
for (let i = 0; i < len; i++) {
@krstffr
krstffr / debounced-redux-thunk-action.js
Created December 16, 2016 12:04
Debouncing redux thunk actions.
// A common redux pattern when dealing with async functions is to use thunk.
// This usually means your action returns a new function instead of an action object,
// and the thunk middleware will make it all work. Example:
const asyncAction = () => dispatch => setTimeout(() => dispatch(someOtherAction()), 10000);
// Now: maybe that async stuff going on is calling some API which you don't want to overload
// with request, and that's what debounce is for.
// This is an example of a debounced function which will only be calleable once every second.
import { debounce } from 'lodash';
const debouncedFn = debounce(() => callApi(), 1000, { leading: true, trailing: false });
@DaniSancas
DaniSancas / neo4j_cypher_cheatsheet.md
Created June 14, 2016 23:52
Neo4j's Cypher queries cheatsheet

Neo4j Tutorial

Fundamentals

Store any kind of data using the following graph concepts:

  • Node: Graph data records
  • Relationship: Connect nodes (has direction and a type)
  • Property: Stores data in key-value pair in nodes and relationships
  • Label: Groups nodes and relationships (optional)
@paulirish
paulirish / what-forces-layout.md
Last active July 24, 2024 14:23
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
@jbenet
jbenet / simple-git-branching-model.md
Last active June 17, 2024 14:53
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@stanistan
stanistan / aqlmodule-usage.js
Created April 19, 2012 21:53
js-aqlmodule usage
/*
given an HTML element that corresponds to the selector '#el'
with "data-" attributes ['model', 'token', 'ide']
*/
var module = new Module($('#el'), options);
// or