Skip to content

Instantly share code, notes, and snippets.

🤞
hope it works!

Anwar Hussain getanwar

🤞
hope it works!
Block or report user

Report or block getanwar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@getanwar
getanwar / mongoose_core_v1.js
Last active Sep 2, 2018
Experiment: Mongoose like static & virtual methods
View mongoose_core_v1.js
<script>
const users = [{
first: "Anwar",
last: "Hussain",
age: 27,
profession: 'dev'
}, {
first: "Rafsan",
last: "Hasemi",
age: 25,
@getanwar
getanwar / getPropsChainVal.js
Last active Jul 17, 2018
getPropsChainVal() - returns either the desired value or undefined
View getPropsChainVal.js
/**
* 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 Oct 31, 2017
Helper functions for VanillaJS
View helpers.js
/*
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 Feb 18, 2017
SASS: Radio input switch style
View radio.html
<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 Jan 15, 2017
Browser head Introduction style
View gist:3f088e16348550f86b50c2b553457cb2
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>
View gist:78fd63e964275240ac3905b1a5068853
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 Sep 26, 2016
Dribbble: Like all visible items
View dribbble-like
$('.fav').not('.marked').each(function(e) {
$(this).find('.toggle-fav').click();
});
@getanwar
getanwar / gist:356f84ac3e98a143c8b1
Last active Oct 2, 2016
JS: Treehouse - Course List (console)
View gist:356f84ac3e98a143c8b1
// course list
// copy this code to console and see result on the page
$('.video-22-icon').next().each(function(i) {
var el = $(this);
var title = el.parents('.stage-meta').find('h2').text();
var list = '<br><h6>' + (i + 1) + '. ' + title + ': ' + el.text() + '</h6>';
$('#syllabus-description').append(list);
});
@getanwar
getanwar / gist:1b8e85c910458dcf6c3c
Last active Oct 2, 2016
JS: Treehouse - Track List (console)
View gist:1b8e85c910458dcf6c3c
//track list
// copy this code to console and see result on the page
var write = $('#track-meta');
var track = '<h2>[Track] Treehouse - ';
track += $('h2').text() + '</h2>';
write.append(track);
$('.course').each(function(i) {
@getanwar
getanwar / gist:9046954
Last active Oct 2, 2016
JS: SIAF Utility Object
View gist:9046954
//Put into a SIAF
//this type of code will be protected for
//pollution of global functions
//and it can be accessed from the global scope :D
var utility = (function() {
var i = 0;
return {
nameGen: function() {
You can’t perform that action at this time.