Skip to content

Instantly share code, notes, and snippets.

Aldi Zhupani Aldizh

Block or report user

Report or block Aldizh

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
View charges_refactor
const clickHandler = (e, charges) => {
const hasCharges = Number(advanceCharges) > 0
switch (type) {
case 'Advance Charges':
hasCharges ? callRelaventFunction(okToPayCharges, toggleAdvanceChargesDialog, showAdvanceCharges, snackbarMessage) : snackbarMessage(locale('There are no advance charges'))
case 'Member Charges':
hasCharges ? toggleDialog(!showMemberCharges) : snackbarMessage(locale('There are no member chanrges'))
Aldizh / highest_power
Created Jan 2, 2018
Gives you the highest power of x less then provided number n
View highest_power
var highestPower = function(n, x) {
var res = 0;
for (var i = n; i >= 1; i--){
var pow = Math.pow(x, i);
if (pow < n) { res = pow; break;}
return res;
//Log solution
View reduce_for_objects
// Input
const dataSource = [
{id: 48, code: "firstName", description: "John"},
{id: 49, code: "lastName", description: "Smith"},
{id: 49, code: "occupation", description: "Agent"},
{id: 47, code: "status", description: "Active"},
// Output should be as follows
const output = {
Aldizh / gist:d062abd329a3ebed5a6416cd6c6f5edc
Last active Nov 20, 2017
How to merge multiple remote commits into one
View gist:d062abd329a3ebed5a6416cd6c6f5edc
# Switch to the master branch and make sure you are up to date.
git checkout master
git fetch # this may be necessary (depending on your git config) to receive updates on origin/master
git pull
# Merge the feature branch into the master branch.
git merge feature_branch
# Reset the master branch to origin's state.
git reset origin/master
Aldizh / constructObject.js
Created Sep 15, 2017
This is used to convert a flat file into a nested object structure, give the flat file is in proper dot notation.
View constructObject.js
* @function constructObject
* @param {file} file in dot notation ('a.b.c':'Hey', 'd.e.g': 'you')
* @return {Object} - a nested object.
* @example
* const object = constructObject(file)
* Returns the following:
* a: {
* b: {
Aldizh / flattenObject.js
Created Sep 15, 2017
Utility function to transform an object to flat key value pairs. It is used to maintain a mapping between an object structure and a general purpose file which could be translated for example.
View flattenObject.js
* Flattens an object given a nested object structure
* @function flattenObject
* @param {Object} obj - The object whose values and keys you want to map over.
* @return {String} - A json string with key-value pairs.
* @example
* const original = {
* address: {
* 'addressLine1': 'Address (Line 1)',
Aldizh / counter.js
Last active Sep 20, 2019
Basic counter that demonstrates javascript closure concept
View counter.js
// In the function below changeBy is a private function
// whereas increment and decrement are public and hence
// can be invoked outside the Counter's scope
function Counter(initialCounter) {
var privateCounter = initialCounter || 0;
function changeBy(val) {
privateCounter += val;
return {
Aldizh / script.js
Last active Sep 20, 2019
Prototype Inheritance example javascript
View script.js
// Every function created in javascript inherits from
// Object which is made of a constructor function and
// __proto__ which allows for sharing across multiples instances
// Defining a Person Object/Function
function Person(first, last, age, gender, interests) { = {
View gist:5da1877cef5e5db2b6e7c4169e3796a1
//Have to create a closure and redefine "i" inside so that the console won't throw undefined error
var index = i;
var elem = document.getElementsByClassName('cat');
array[index].count = array[index].count + 1;
var total= array[index].count;
var numb = document.getElementsByTagName("p")[index];
numb.innerHTML = total;
You can’t perform that action at this time.