Skip to content

Instantly share code, notes, and snippets.

View getanwar's full-sized avatar
Building

Anwar Hussain getanwar

Building
View GitHub Profile
@getanwar
getanwar / watcher.js
Created March 11, 2021 07:46
Sync files and folders with server
const chokidar = require('chokidar');
const { exec } = require('child_process');
const watcher = chokidar.watch('.', {
ignored: ['**/node_modules/**/*', '**/.git/**/*'],
ignoreInitial: true,
interval: 1500,
binaryInterval: 1500,
});
@getanwar
getanwar / vscode-snippets.json
Created October 6, 2020 09:59
My Most Used VS Code Snippets
/* REACT HOOKS */
"Hook: useCallback": {
"prefix": "ucb",
"description": "Hook: useCallback",
"body": [
"const ${1:name} = React.useCallback(($2) => {",
"\t$3",
"}, [$4]);"
]
},
@getanwar
getanwar / uses.md
Last active August 26, 2020 15:50
Uses

Editor + Terminal

  • [Visual Studio Code][vscode] is my editor by choice. Sometimes I still use Sublime Text (beta) for a quick view or modification
  • I use Operator Pro for a font in my code editor, previously I used Fira Code
  • I find VS Code integrated terminal very handy. But if detailed result is needed, I use iTerm2 (+Zsh) 🖥
  • I keep VS Code configurations up-to-date across all my computers with [Settings Sync][ss] extension

Desktop and Mobile Apps

  • My primary browser is Google Chrome. Sometimes I switch between Brave Browser and Firefox
@getanwar
getanwar / mongoose_core_v1.js
Last active September 2, 2018 15:13
Experiment: Mongoose like static & virtual methods
<script>
const users = [{
first: "Anwar",
last: "Hussain",
age: 27,
profession: 'dev'
}, {
first: "Rafsan",
last: "Hasemi",
age: 25,
@getanwar
getanwar / getPropsChainVal.js
Last active July 17, 2018 15:55
getPropsChainVal() - returns either the desired value or undefined
/**
* getPropsChainVal function is helpful when we want to
* retrive value from a deep object and properties from
* anywhere in the middle can go missing resulting an error.
* `TypeError: Cannot read property '...' of undefined`
* The function returns either the desired value or undefined
*
* @param {Object} obj
* @param {String} propsChain // 'data.sample.posts.items'
* @return value || undefined
@getanwar
getanwar / helpers.js
Created October 31, 2017 12:45
Helper functions for VanillaJS
/*
Funciton Type: Array Function
Usage: Helps to clone an item next to it.
*/
Array.prototype.pushAfter = function(index, item) {
var deepClone = JSON.parse(JSON.stringify(item));
this.splice(index + 1, 0, deepClone);
};
@getanwar
getanwar / radio.html
Created February 18, 2017 07:13
SASS: Radio input switch style
<div class="col-md-6 radio-input">
<p class="text-uppercase">Gender</p>
<input type="radio" name="gender" value="M" id="male">
<label for="male">Male</label>
<input type="radio" name="gender" value="F" id="female">
<label for="female">Female</label>
@getanwar
getanwar / gist:3f088e16348550f86b50c2b553457cb2
Last active January 15, 2017 14:14
Browser head Introduction style
data:text/html,<div style="display: flex; align-items: center; justify-content: center; height: 100%; background-color: #f3f3f3;"><h1 style="font-family: Open Sans; font-size: 120px; color: #4CAF50;">Hello World</h1></div>
var toggleClass = function(element, toggleClass) {
var currentClass = element.className;
if (currentClass.indexOf(toggleClass) > -1) { //has class
var newClass = currentClass.replace(toggleClass, "")
} else {
var newClass = currentClass + " " + toggleClass;
}
element.className = newClass;
}
@getanwar
getanwar / dribbble-like
Created September 26, 2016 12:14
Dribbble: Like all visible items
$('.fav').not('.marked').each(function(e) {
$(this).find('.toggle-fav').click();
});