Skip to content

Instantly share code, notes, and snippets.

@faisalhmohd
faisalhmohd / atom.sh
Created July 30, 2016 15:23
Ubuntu Installations
sudo add-apt-repository ppa:webupd8team/atom
sudo apt-get update
sudo apt-get install atom
@faisalhmohd
faisalhmohd / installnodejs.sh
Created August 27, 2016 03:20
Installing NodeJS using N
apt-get install -y npm
npm install -g n
# Get NodeJS stable. Use 'n latest' for latest build
n stable
# Remove existing NodeJS symbolic link (optional)
rm -r /usr/bin/node
# Replace existing symbolic link
@faisalhmohd
faisalhmohd / location.js
Created September 20, 2016 04:22
Get location of current page
function getLocation(){
return window.location.pathname;
}
var currentLocation = getLocation();
@faisalhmohd
faisalhmohd / tagged.js
Last active October 12, 2016 15:40
Tumblr call tagged posts
function getRSSUrl(tag){
return '/tagged/'+ tag +'/rss'
}
var rssurl = getRSSUrl('featured');
$.get(rssurl, function(data) {
// Append to divs
});
@faisalhmohd
faisalhmohd / tagextract.js
Created September 22, 2016 05:38
Extract required HTML tag from string
var thehtmlstring =
'<h1 id="theid">headingone</h1>' +
'<p class="comments-section">'+
'thetext' +
'<div class="thediv">' +
'<div class="theinnerdiv">theinnerdivtext</div>' +
'</div>' +
'</p>';
function extractTag(string, tag){
@faisalhmohd
faisalhmohd / hideNDivs.js
Created October 25, 2016 16:53
Hide child div's dynamically
var hideDivs = [2, 3]; // Enter the divs to be hidden
$( ".div" ).each(function() {
for(var i = 0; i < hideDivs.length; i++){
$(this).find('a:eq(' + hideDivs[i] + ')').hide();
}
});
@faisalhmohd
faisalhmohd / fucntions.php
Last active September 24, 2017 08:30
Add a custom menu
<?php
// Custom Menu
add_filter( 'init', 'register_primary_menu');
function register_primary_menu() {
register_nav_menu('nav-primary',__( 'Navigation Primary' ));
}
function custom_primary_menu() {
$menu_name = 'nav-primary';
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
@faisalhmohd
faisalhmohd / keybase.md
Created December 23, 2017 13:44
Keybase Verification

Keybase proof

I hereby claim:

  • I am faisalhmohd on github.
  • I am mohdfaisal (https://keybase.io/mohdfaisal) on keybase.
  • I have a public key ASChfbgE3Ty-C2VsjNu2_H7TWmpMOsWkpiY_j-ScQKBcMAo

To claim this, I am signing this object:

@faisalhmohd
faisalhmohd / index.html
Last active January 12, 2019 13:55
React v16 Context API Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://fb.me/react-with-addons-15.1.0.js"></script>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
</head>
@faisalhmohd
faisalhmohd / index.html
Created January 12, 2019 14:30
React v16 Error Boundary Example
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="React v16 Error Boundary Implementation">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<title>JS Bin</title>
</head>