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 / 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);
}
@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 / 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;
// #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 / 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);
}
const { Provider } = ReactRedux;
window.addEventListener("message", e => {
// extentions and other 3rd party scripts talk via postMeessage api(same orgin)
// so it is very important to filter those events
if (e.origin !== window.location.origin || !e.data || e.data.source !== "dialog-message") {
return;
}
// parent and window are same thing if the current page is not in any frame
// Suppose we want a div to have some custom attributes, normally react wouldn't allow custom attributes
// so this is a hack to att as much custom attributes to your component as you want
class Div extends React.Component {
componentDidMount() {
this.addAttributes();
}
componentWillReceiveProps(nextProps) {
@ar5had
ar5had / gist:5bb796b1f07fc9046ddaa10e78c152be
Created May 25, 2017 09:16 — forked from rxaviers/gist:7360908
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:
/ WARNING
//
// Do NOT edit this file while ZNC is running!
// Use webadmin or *controlpanel instead.
//
// Altering this file by hand will forfeit all support.
//
// But if you feel risky, you might want to read help on /znc saveconfig and /znc rehash.
// Also check http://en.znc.in/wiki/Configuration
@ar5had
ar5had / blockscope-vars-in-es5.js
Created May 12, 2017 15:40
hack for block scope variables in es5..
try {
throw 1;
} catch (myfancyvariable) {
console.log('This variable is only availabe within this catch block =>', myfancyvariable);
}