Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 21 2018 17:11
    @MadLittleMods banned @OmarAlmaqtri
  • Jun 05 2018 23:13
    @MadLittleMods banned @LWSS
  • May 25 2018 16:50
    @MadLittleMods banned @TheRedstoneTaco
Anmol
@Anmol270900
Hi everyone ! I am new to react.js and this is the link to my first project : https://anmol270900.github.io/Friends/
Do suggest some changes so that the project gets better and I get to learn more.
Star my repository if you like it https://github.com/Anmol270900/Friends :)
dimtabu
@taburetkin

https://codepen.io/dimatabu/pen/vqjjRd
in this codepen i am trying to change instance class names without using eval. (with eval its very simple)
can someone point me to the right direction ?

function extend () {
   let parent = this;
   ....
   child = function() { return parent.apply(this, arguments); }
   ....
}

const Base = function(){}
Base.extend = extend;
const Test = Base.extend({ ... });
console.dir(new Test());

will output > child

Lioxor64
@lioxor64

Hello, my name is Liora and I am currently hunting open source projects for company NeuraLegion (www.neuralegion.com)
We just launched a free annual subscription for open source projects for our AIAST tool NexPloit.

If you are interested, please, reach us on opensource@neuralegion.com!

Thank you for your time and consideration! If you have any questions, please do not hesitate to contact us!

Best,

Richa verma
@therichaverma
hey ! i created this https://therichaverma.github.io/ website. Please have a look and tell me where i am wrong . Thanks .
_
Kimanje Patrick
@DrKimpatrick
@hrichaverma Nice work. I suggest you add a smooth scroll behavior to the destination of your Nav links
Richa verma
@therichaverma
@DrKimpatrick okay . thanks a lot.
Alexey Protchenko
@Severyanin
@hrichaverma, and it would be better to add favicon to allow browser to show it on the tab
aarck
@aarck
Error: Please install pg package manually
please anyone look over the error
Arun Kumar
@arunkumar413
test message
Can anybody see my message?
Alexey Protchenko
@Severyanin
@arunkumar413 , yes
Arun Kumar
@arunkumar413
Thanks :)
vg100
@vg100
hiiii
soulaimanassikiou
@soulaimanassikiou
Hi all!
Has anyone used Dropzone.js before? https://github.com/enyo/dropzone
Jaira
@jairadichoso
Hi, can somebody help me translate this into vanilla js/plain javascript?
$(".pop").popover({ trigger: "manual" , html: true, animation:false})
    .on("mouseenter", function () {
        var _this = this;
        $(this).popover("show");
        $(".popover").on("mouseleave", function () {
            $(_this).popover('hide');
        });
    }).on("mouseleave", function () {
        var _this = this;
        setTimeout(function () {
            if (!$(".popover:hover").length) {
                $(_this).popover("hide");
            }
        }, 300);
});
Chris Cullen
@123xylem
    for( var i = 0; i < arr.length; i++){
       var next = arr[(i+1)%len];

         diff = (values[arr[i]] - next );
          console.log(next);
          date += values[arr[i]];
        }
Why is next here going back to the start of the array once its finished?
how can I make it end at the end
dimtabu
@taburetkin
(i+1)%len - i suppose len here is the arr.length?
arr.length % arr.length returns 0, so, on the last array element your next receives value from the first element of array.
Nandhan-augment
@Nandhan-augment

Hi all

I'm running into a problem with recordrtc.
After recording the audio from my platfrom using recordrtc its been saved temporarily to /tmp folder. But in some scenario the audio file is missing or /tmp/upload_b6460cdff8c889265b0b063712f46c10: Invalid data found when processing input.

Can anyone explain this scenario?
Thanks in advance

Dmitriy
@dmitriy.__gitlab
Hey Guys, i wanna enhance my skills in react and any other technologies like redux, mobx, react-native etc. And i looking for internship or junior position. Maybe first time for free. I'll be glad to any suggestions
soulaimanassikiou
@soulaimanassikiou

´´´
module.exports = {
encryptFile: async function(file){

this.encodeToArrayBuffer(file).then(function(bufferFile) {
        return bufferFile;
    });

}
}
´´´

hey guys, im using this sitnaxis to define an methodn into an object using module.exports
in my case i have added the async declaration before the function word, is this correct? (since i want to return a promise)
soulaimanassikiou
@soulaimanassikiou
or how should i declare the async here?
dimtabu
@taburetkin
async converts your function result to a promise
but it mostly used for be able to resolve any promises with await
async function(file) {
  let bufferFile = await this.encodeToArrayBuffer(file);
  let magicfile = applyBlackMagic(bufferFile);
  return magicfile
}
ribhav sharma
@ribhavsharma
hi @/all
xtianus79
@xtianus79
hello I need help with something
anyone here
Rob Ede
@robjtede
just post the question my dude
Chigozie Igwebuike Christopher
@Gozieh
hi guys, i've been struggling with my algorithm for a couple hours now and still cant get one of the last test cases right. Below is the code i have for the cash register project, pls any feedback on all my wrongs would be appreciated, the code is a bit messy too so pls forgive me in advance
//function checkCashRegister houses the major global variables and conditions to be met
//function findChange searches for exact change to be returned
//function totalCid calculates the total number of change in the drawer
//'cid' stands for cash in drawer
//'theAvailable' refers to total number of available change in the drawer

function totalCid(cid) {
        let total = 0;
        for (let piece of cid ) {
            total += piece[1];   
        }
         return total.toFixed(2);
    };




//exact change

function findChange(moneyOwed, cid) {
            var change_arr = [];
            var currencyValues = {
                  'ONE HUNDRED': 100.00,
                  'TWENTY': 20.00,
                  'TEN': 10.00,
                  'FIVE': 5.00,
                  'ONE': 1.00,
                  'QUARTER': 0.25,
                  'DIME': 0.10,
                  'NICKEL': 0.05,
                  'PENNY': 0.01
            };
            for (let i = cid.length - 1; i >= 0; i--) {
                const currName = cid[i][0];
                const currTotal = cid[i][1];
                const currValue = currencyValues[currName];
                let currAmount = (currTotal/currValue).toFixed(2);
                let currToReturn = 0;
                while (moneyOwed >= currValue && currAmount > 0) {
                    moneyOwed -= currValue;
                    moneyOwed = moneyOwed.toFixed(2);
                    currAmount --;
                    currToReturn ++;
                }
                if (currToReturn > 0) {
                    change_arr.push([currName, currToReturn * currValue]);

                }



            }




     return change_arr   



};

function checkCashRegister (price, cash, cid) {
    var register = {'status' : null, 'change' : []};
    const moneyOwed = parseFloat(cash - price).toFixed(2);
    const theAvailable = totalCid(cid);

    if (Number(moneyOwed) > Number(theAvailable)) {
            register.status = 'INSUFFICIENT_FUNDS';
            return register;
    };

    if (Number(moneyOwed) === Number(theAvailable)) {
            register.status = 'CLOSED';
            register.change = [...cid];
            return register;
        };
          register.change = findChange(moneyOwed, cid);

     if (Number(moneyOwed) < Number(theAvailable)) {
        register.status = 'OPEN';
        return register
    }  return {status : "INSUFFICIENT_FUNDS"};

}
here is the test case i cant get right;
checkCashRegister(19.5, 20, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return {status: "INSUFFICIENT_FUNDS", change: []}.
dimtabu
@taburetkin
@Gozieh your test case has cid value of 1.01 and moneyOwed 0.50
so, in checkCashRegister you get third if.
dimtabu
@taburetkin
@Gozieh, also, i have to say
if you are going to calculate money values in js you probably want to use some special library, f.e. decimal.js
in case you dont know, in js: 0.1 + 0.2 != 0.3;
Stephen James
@sjames1958gm
@Gozieh you need to handle the case where after going through the drawer loop that there is still money owed be cause the denominations don’t match.
Chigozie Igwebuike Christopher
@Gozieh
@taburetkin thanks for the feedback buddy, i've heard about js and its complications with floats and i've tried to work around them in my solution: using toFixed as a method to bring the decimal to two places, although now you mention it, i might just look at other options
@sjames1958gm thanks for the feedback chief, i'll take another look at the logic in loop and see how to implement your hint.
i appreciate the feedback guys.
Stephen James
@sjames1958gm
:+1:
dimtabu
@taburetkin
@Gozieh , maybe this will help you somehow
https://codepen.io/dimatabu/pen/zgoQXq?editors=0010
Chigozie Igwebuike Christopher
@Gozieh
thanks for feedback gentlemen, i just handled the test case for that problem right after the function ran and boom.
//function checkCashRegister houses the major global variables and conditions to be met
//function findChange searches for exact change to be returned
//function totalCid calculates the total number of change in the drawer
//'cid' stands for cash in drawer
//'theAvailable' refers to total number of available change in the drawer

function totalCid(cid) {
        let total = 0;
        for (let piece of cid ) {
            total += piece[1];   
        }
         return total.toFixed(2);
    };


function checkCashRegister (price, cash, cid) {
    var register = {'status' : null, 'change' : []};
    const moneyOwed = parseFloat(cash - price).toFixed(2);
    const theAvailable = totalCid(cid);

    if (Number(moneyOwed) > Number(theAvailable)) {
            register.status = 'INSUFFICIENT_FUNDS';
            return register;
    };

    if (Number(moneyOwed) === Number(theAvailable)) {
            register.status = 'CLOSED';
            register.change = [...cid];
            return register;
        };

          register.change = findChange(moneyOwed, cid);


         if (moneyOwed > totalCid(register.change)) {
            register.status = 'INSUFFICIENT_FUNDS';
            register.change = []
            return register;
         };


        if (Number(moneyOwed) < Number(theAvailable)) {
            register.status = 'OPEN';
            return register
         }; 

};

//exact change
function findChange(moneyOwed, cid) {
            var change_arr = [];
            var currencyValues = {
                  'ONE HUNDRED': 100.00,
                  'TWENTY': 20.00,
                  'TEN': 10.00,
                  'FIVE': 5.00,
                  'ONE': 1.00,
                  'QUARTER': 0.25,
                  'DIME': 0.10,
                  'NICKEL': 0.05,
                  'PENNY': 0.01
            };
            //looping through the drawer for cash
            for (let i = cid.length - 1; i >= 0; i--) {
                const currName = cid[i][0];
                const currTotal = cid[i][1];
                const currValue = currencyValues[currName];
                let currAmount = (currTotal/currValue).toFixed(2);
                let currToReturn = 0;
                //selecting the right bill value to return
                while (moneyOwed >= currValue && currAmount > 0) {
                    moneyOwed -= currValue;
                    moneyOwed = moneyOwed.toFixed(2);
                    currAmount --;
                    currToReturn ++;
                }


                if (currToReturn > 0) {
                    change_arr.push([currName, currToReturn * currValue]);

                }           

            }

     return change_arr   
};
Khalifathul meeran
@khalifathul
@khalifathul
Hi
I've an array like this
var ab = [
{weight: 1, answer: "3"},
{weight: 2, answer: "5"},
{weight: 1, answer: "2"},
{weight: 2, answer: "3"},
{weight: 1, answer: "4"},
];
and I want to multiply this value like this (1 x 3) x (2 x 5) x (1 x 2) x (2 x 3) x (1 x 4) = 1440 using javascript
Can anyone help me
?
dimtabu
@taburetkin
let score = ab.reduce((memo, item) => memo += item.weight * item.answer, 0)
ah, there is multiply