Skip to content

Instantly share code, notes, and snippets.

View ar5had's full-sized avatar
🎯
Focusing

Arshad Khan ar5had

🎯
Focusing
View GitHub Profile
@ar5had
ar5had / ReactIgnore
Created July 25, 2017 14:45 — forked from alexeisavca/ReactIgnore
A simple component to make ReactJs ignore subtrees
var React = require('react/addons');
var ReactIgnore = {
displayName: 'ReactIgnore',
shouldComponentUpdate (){
return false;
},
render (){
return React.Children.only(this.props.children);
}
// #1
// Polyfill a few basic things.
['filter', 'forEach', 'map', 'reduce'].forEach(function (name) {
Array[name] = function (array, callback, init) {
return [][name].call(array, callback, init);
};
});
// Automatically set up asynchronous JSON forms (all with a 'method' attribute).
// Array.forEach(document.querySelectorAll('form'), function (form) { ....
@ar5had
ar5had / css-boilerplate.css
Created September 2, 2017 14:46
CSS boilerplate
:root {
--oc-white:#fff;
--oc-white-rgb:255,255,255;
--oc-black:#000;
--oc-black-rgb:0,0,0;
--oc-gray-0:#f8f9fa;
--oc-gray-0-rgb:248,249,250;
--oc-gray-1:#f1f3f5;
--oc-gray-1-rgb:241,243,245;
--oc-gray-2:#e9ecef;
@ar5had
ar5had / Local PR test and merge.md
Created October 29, 2017 15:47 — forked from adam-p/Local PR test and merge.md
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37
@ar5had
ar5had / debounce.ts
Created October 10, 2022 13:41 — forked from ca0v/debounce.ts
Typescript Debounce
// ts 3.6x
function debounce<T extends Function>(cb: T, wait = 20) {
let h = 0;
let callable = (...args: any) => {
clearTimeout(h);
h = setTimeout(() => cb(...args), wait);
};
return <T>(<any>callable);
}