This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* Add language switcher polylang with slug inspite of names | |
//* Position header-right | |
add_action( 'genesis_header_right', 'custom_language_switcher'); | |
function custom_language_switcher() { | |
echo '<ul class="custom-lang-switcher">'; | |
pll_the_languages(array('show_names'=>1,'display_names_as'=>'slug')); | |
echo '</ul>'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://codeforgeek.com/2017/12/server-side-pagination-using-node-and-mongo/ | |
router.get('/users',(req,res) => { | |
var pageNo = parseInt(req.query.pageNo) | |
var size = parseInt(req.query.size) | |
var query = {} | |
if(pageNo < 0 || pageNo === 0) { | |
response = {"error" : true,"message" : "invalid page number, should start with 1"}; | |
return res.json(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ❌ You can skip the else block | |
function calcPercentage(number) { | |
// Check if valid number | |
if(typeof number === 'number') { | |
// Another check: only do calculation number is less than 1 | |
if (number > 1) { | |
return 'Number must be less than 1'; | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ❌ You can skip the else block | |
function hello(name) { | |
if(name) { | |
return '👋' | |
} | |
else { | |
return '👻' | |
} | |
} |