« first day (3617 days earlier)      last day (1334 days later) » 

12:29 AM
any one know what im doing wrong here typescriptlang.org/play?#code/…
 
you can't access this from a static method
 
this is the class itself, not an instance of the class
for context, it works fine like this typescriptlang.org/play?#code/…
i just don't know how to call another static method from the base class
 
1:34 AM
@Scratte lol, everyone gets 1 welcome. Except feeds, it gets many because of a bug.
May 25 at 19:45, by JamesBot
@Scratte Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
 
2 hours later…
3:19 AM
how long till css gets custom functions?
 
 
3 hours later…
6:05 AM
can someone tell me how can I loop this html from js
<div>
        <div>
            <div>
                <div></div>
            </div>
        </div>
    </div>
 
6:19 AM
well you know how to loop things in js right?
do you know how to add a div to a page?
just combine the two
 
6:48 AM
@JBis I see. I have a friend for life then :)
 
7:10 AM
Hi All
im looking for a code analyser tool for nodejs service solution.
one of the tool i see is
SonarCloud
can anyone suggest about SonarCloud or anyother tools for nodejs
 
 
2 hours later…
9:25 AM
how do I open chrome node debug tools automatically

atm i have
"start:debug": "node --inspect --require ts-node/register src/load",

but i have to open chrome://inspect/#devices 1st manually
 
I am having difficulty understanding the sequence generated for this algorithem..
14
Q: Programming: Minimum steps required to convert a binary number to zero

roger_thatI was working on a programming exercise and was stuck on figuring out the correct algorithm. Here is the problem: Given a decimal number, how many minimum possible steps are required to convert this to zero provided: Change the bit i if the next bit i+1 is '1' and all the other bi...

1000→1001→1011→1010→1110→1111→1101→1100→0100→0101→0111→0110→0010→0011→0001→0000
Considering rules:
Change the bit i if the next bit i+1 is '1' and all the other bits i+2 and later are 0
Change the last bit without restriction
1000

i = 0
rule1: false
rule2: true = 1001 (perfect)
i = 1
rule1 = true (1101)
rule2 = true (1100)

so I feel the second in this sequence will be 1100 but rather 1011
Or may be I am doing something wrong or perhaps misunderstood the problem
Can any one please let me know what really I am missing or doing wrong?
 
in the second step, your value is 1001
you can apply either of the two rules
rule 2 is easy and the result would be 1000
rule 1 is more difficult
i is not the index of the step
but i is any bit in the value
so, 0, 1, 2 or 3
for i = 0, next bit 1001 is not 1, so we cannot apply it
for i = 1, next bit 1001 is not 1, so we cannot apply it
for i = 2, next bit 1001 is 1, and all bits after that (none) are 0, so we can apply it
the result would be flipping the bit on i=2, so you get 1011
the second rule may only be applied on the bit left of the first 1 bit, starting from the right side
if that makes sense
 
9:43 AM
since rule 2 can be done whenever, I think the strategy would be to apply rule 1 if possible, and if not, then to apply rule 2
this assuming a solution is possible. If there's the possibility that there isn't a solution, then you'd also have to check that you're not reverting to one of the previous states
 
ye, also doing rule 2 twice in a row is pretty silly
 
now that I think about it, you'd have to do that just the same, because there may be more than one bit you could apply rule 1 on
 
rule 1 can only be applied on the bit left of the first 1 bit, starting from the right side
 
@Neil so prioritize applying rule 1 first, if not otherwise rule 2.
 
my mistake, my earlier comment said "second rule", but it is the first rule
 
9:45 AM
you'd have to apply rule 1 on all bits where that would apply, then attempt to solve it after that step
which may result in no solution or a number of steps to get that solution
you'd grab of course the one that took the least number of steps and return that
 
you always have to alternate
 
I'm thinking in terms of recursion of course
 
applying the same rule twice always reverts it
basically being a no-op
 
depends on whether or not it is possible to apply rule 1 on more than one bit
 
you cant apply it on more than 1 bit
 
9:47 AM
Basically I would have to do while loop to see if Rule1 applies or not
 
then why ask the question what would be the minimum number of steps?
there is either a solution or there is not in that case
 
there is always a solution
it always properly terminates
 
I don't think you could find a solution if you had more than 4 bits
rule 2 applies only to the first bit
 
last bit
 
@Neil it says last bit but rather first
100*1*
 
9:50 AM
first from the right, I assume
at this point, you are dealing with a sequence of bits, where the right most bit would be considered "last"
 
@BasheerKharoti well I think of it as the first bit
just makes more sense in my mind
 
@Wietlol @Neil Will the rule 1 apply to the following?
1011
 
yep
the result would be 1001
the only case when you cannot apply rule 1 is if all bits (except the first one) are 0
the first bit can be either 1 or 0
so 1000 or 0000 cannot have rule 1 be applied on
 
no.. all the bits to the right of it must be 0 first
you can apply rule 1 on 1010
 
yes, and 1010 is neither 1000 nor 0000
 
9:54 AM
rule 1 can't apply to 1011
 
it can
 
> Change the bit i if the next bit i+1 is '1' and all the other bits i+2 and later are 0
you can make 1011 go to 1001, but that's going backwards
 
so, 0, 1, 2 or 3

for i = 0, next bit 1011 is not 1, so we cannot apply it
for i = 1, next bit 1011 is 1 but all other bits are not zero, so we cannot apply it
for i = 2, next bit 1011 is 1, and all bits after that does not exist and we assume 0, so we can apply it

1010
 
if your goal is to go to 1111, then you'd first need to go to 1011 to 1010 to 1110 to 1111
 
value = 1011
i = 2
assert value[i+1] == 1
assert value.skip(i+1).allMatch { it == 0 }
@Neil the goal is to go to 0000 though
 
9:57 AM
ok, fine technically you can apply it, but that's going backwards
 
@BasheerKharoti your reasoning is correct, but the outcome is not
it should be 1001 not 1010
 
@Wietlol ok, then you tell me how you can go to 1011 to 0000 by not passing to 1110
 
@Wietlol we've to flip the bit... so the last or i'th bit is 1..
 
@Neil why would you not pass to 1110 ?
@BasheerKharoti for i = 2 ( 1011 ), you can apply the rule
 
2 mins ago, by Wietlol
@Neil the goal is to go to 0000 though
 
9:59 AM
so, you flip that bit
then it becomes 1001
the rules say "change the bit" but not to a pre-defined value
 
@Wietlol correct but we are going backwards. See the following pattern
1000→1001→1011→1010→1110→1111→1101→1100→0100→0101→0111→0110→0010→0011→0001→0000
 
so you can either change from 0 to 1 or from 1 to 0
 
1011 -> 1010
 
and?
my point was that you cannot just say "apply rule 1 if possible"
you have to alternate between the rules
 
That is tricky..
 
10:03 AM
why?
 
How would I assume weather to go with first or not?
 
that is part of the puzzle :D
in the example sequence, you can see that they alternate, right?
 
Yes they do
1011→1010→1110 specifically in this case
 
ok, both rules have an overlapping contract
they both flip 1 bit
so either a bit is turned from 0 to 1 or from 1 to 0
 
that's true
 
10:06 AM
so, if there are an odd number of ones...
 
yes, then?
 
(now it is your turn)
 
we will apply rule 2
?
 
yea
 
10:07 AM
the odd and even alternate in the same sequence
 
so basically to check if we have odd number of 1, that means we can apply rule 1 otherwise rule 2
 
rule 2 otherwise rule 1
yes
 
cool, thanks
 
if you do rule 1 otherwise rule 2, you go backwards
 
let me put all this together.. :)
 
10:09 AM
and the right side of the result would always be 000... and the left side would always be 100...
those are the two states where you have an exception
there is a much faster way of figuring out how many steps you need...
you dont actually have to apply the steps and count them
you can do some weird maths to figure out the number
but that would be step 2 of the puzzle
 
@Wietlol I have seen some XOR operation with a for loop but I would just like to see applying the rules..
 
10:24 AM
Hi @all
-1
Q: Dropdown layout not working properly before and after ajax in multiselect dropdown

asdsadsa adasdsaI am using multi select dropdown where I create 6 dropdowns. In which 5 dropdown append options based on the dropdown 1 using ajax. If I use multiselect() on page load and ajax complete to show proper layout but in this cases dropdown option not append on ajax call. If I used multiselect() on aja...

 
@Wietlol "1001" so the number of 1's are even and we will be applying rule 2. Again this is going backwards if we apply that: 1001 -> 1000
 
26 mins ago, by Wietlol
rule 2 otherwise rule 1
> so basically to check if we have odd number of 1, that means we can apply rule 2 otherwise rule 1
you got them mixed up again
 
10:59 AM
@Wietlol So finally the algorithem is
But there are still certain cases failing due to timeout...
 
timeouts are expected
if you want to beat the times, you need to do the maths to get the number
 
Mornin
 
11:34 AM
morn
ew comp sci
 
11:46 AM
i got an idea for a new project
 
@JBis What kind of project?

Or whats the idea
 
similar to blackbox but for web
 
interesting
my current project is a simpler dat.gui remake
well my current project is actually Deepworld Remastered, my video game
but I cant exactly work on that in javascript
or at school
 
nice
 
12:38 PM
Hey Im kindof confused
how come when I save this to a variable
it doesnt work
but if I save a property of this
like this.guiInstance
then I can use it fine
    const $_this = this;
    const $_items = this.guiInstance.items;
I really dont get it
Like if I try to use the latter $_items in an if statement, it works fine
  if ($_items[e].type) {
    guiElement.style.cursor = "pointer";
    guiElement.style.borderLeft = "5px solid red";
  }
But if I try to use $_this to return a variable
if ($_this.guiInstance.items[e].title) {
itll return undefined
Im completely confused
Anyone got any tips or ideas?
 
Well you're trying with type and title, maybe title is not set
You should very very rarely have to do const $_this = this; though
 
Well I have another piece of code that accesses title
and both are in the same method
jsfiddle.net/MisterSirCode/sd5q0x9h/466 This is kindof a mess, but if you wanna look at it, go ahead
line 119 is the issue
I even changed it to $_items[e].title
and its still saying undefined
 
Uncaught TypeError: $_items[e] is undefined
 
both forEach statements are after $_items has been initialized
and both are in the same method
it doesnt make sense
 
Yes but it's e that is not in $_items
it means your defaultObjetcs are not all in the this.guiInstance.items
 
12:47 PM
But they are...
Thats really weird
const defObjs = {
  exampleButton: () => {
    console.log("test function");
  },
  exampleString: "string",
  exampleBool: false
}

const menu = new jGui(defObjs);

menu.add("exampleButton");
menu.add("exampleString").title("Example Input");
menu.add("exampleBool").title("Example Checkbox").color("blue");
 
I don't know what this $_ convention is, but hell it's unreadable
 
From what I can see... they ARE all there
 
Object { exampleButton: exampleButton()
, exampleString: "string", exampleBool: false }

Object { undefined: {…} }
nope they are not, your $_items is populated with undefined: {}
use your console log
Which means id is undefined in folder(id) or in add()
 
give me a moment to move to my next class
 
exampleButton undefined _display:57:33
exampleString undefined _display:57:33
exampleBool undefined
yes, add() doesn't do the right stuff, you don't pass any id, so it's undefined
But again, this $_ convention is horrifying
 
12:56 PM
I removed the $_
 
So you need to pass an id to add, else it can't work
 
I am already passing an id though...
    this.guiInstance.items[id] = {};
    this.guiInstance.items[id].title = id;
    this.guiInstance.items[id].type = type;
This sets the data of said ID
and sets the title to the ID if there is no custom title set
im confused as to what youre seeing
and for the default objects
it uses the variable name as a key
and looks for its existence in guiInstance.items
great...
now im getting errors in code that was fine before
 
no you're not passing it
menu.add("exampleButton");
menu.add("exampleString").title("Example Input");
menu.add("exampleBool").title("Example Checkbox").color("blue");
Where is the id?
it should be the second parameter
Do you have any idea about how a function call work?
Your function is add(type, id) {
And you call it with `menu.add("exampleButton");`

An id is missing
const this = this; might be your error
 
1:20 PM
I apoligze, those were some syntax issues because I was using find and replace
 
1:30 PM
@dievardump Menu.add(id)
the string
 
@MisterSirCode No, the syntax that you have in your code is add(type, id) and folder(id), change your code or the way you add, but if you use add like this, id will always be undefined
 
1:55 PM
I am going to add anchor as HTML in editor using shift+# key. I have used
document.execCommand("insertHTML",false,"<a href='"+href+"'>"+selected+"</a>"); but it's not working in firefox have
any other solution please
insertText is working but insertHTML not working
It's only problem in firefox, in chrome it is fine
 
what? also don't use execCommand its obsolete
 
have any alternative solution to add html editor
 
I don't know what you mean by that. Can you create an mcve?
|| mcve
 
If you would like assistance, please create a Minimal, Complete, and Verifiable Example
 
Simple i want to add <a href="">Click<a> as html on key press in forala editor
 
1:58 PM
@Wietlol Can I use it here? how?
 
@KevinB have any other solution?
 
If you're using Forala editor, just find out how they add a link, and put a shortcut on it
Why in hell would you want to recreate what they already have
Find how they define shortcuts, and prepopulate the label
or even better, use this
maybe rtfm first
 
@Ehsan88 I am
 
2:14 PM
Problem solved: When pass null in exec command its working document.execCommand('insertHTML', null, ''+linkHtml+'');
 
are you kidding? We told you it's obsolete, maybe tomorrow it won't work anymore.

Use Froala API
 
@Ehsan88 sorry, I read your question wrong... you could, but JBis is prolly going to yell at you
perhaps it is better to use the sandbox room for that

Sandbox

Where you can play with regular chat features (except flagging...
 
2:48 PM
is there a better way to write this?

    let data = { email, password }
        if (password) {
            data.password = password
        }
ie with 1 line
 
that makes no sense
 
sorry ignore the pass in tst line
let data = { email }
if (password) {
data.password = password
}
 
@SuperUberDuper Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
const data = { email, password }
 
2:49 PM
your if statement has no consequence it changes nothing
 
Im still having trouble figuring out whats undefined... JSfiddle isnt really the best option for debugging .-.
 
let data = { email }
if (password) {
data.password = password
}
is the same as const data = { email, password }
?
 
@SuperUberDuper thats fine, if you want single line:
 
let data = { email, password: password || undefined };
 
2:51 PM
what if password is false
it will output undef right
i think the if is most clear)
 
yes
i agree, just use the if
 
@MisterSirCode MVCE
MCVE*
 
Not a real JS Question, but can someone explain me what kind of Dateformat this is? /Date(1599134455628)/ I have no clue how to find out or convert it into something readable
 
> milliseconds since 1 January 1970 UTC
 
3:03 PM
it is returned by an oData server, but i find no documention
ah
 
||> (new Date(1599134455628)).toLocaleDateString()
 
@JBis "TypeError: Date(...).toLocaleTimeString is not a function" Logged: `` Took: 0ms
@JBis "8:00:55 AM" Logged: `` Took: 3ms
@JBis "9/3/2020" Logged: `` Took: 1ms
 
||> (new Date().getTime())
 
@MisterSirCode 1599750275645 Logged: `` Took: 0ms
 
9/3/2020 at 8:00:55 AM
 
3:04 PM
got it. Thanks !!
 
@JBis If youre able to get the eval's return value AND the console.log values..

Why not just merge them.

The whole `1599750275645 Logged: `` Took: 0ms` is actually really messy
You could also implement arguments.

I did that with a lot of my bots
 
?
 
In discord.js... my safe javascript eval uses these:

!safeEval (javascript) -d -l

-d shows debug info, like MS it took, and -l shows more output, like console logs, and other info
 
meh
 
arguments are quite easy to implement too, just .replace(/-d/g, "") and then have an if statement like.... if (args.includes("-d")) { log debug stuff }
it would clean things up a lot
Just my 2 cents of judgement :P
IMO if he just replied

@user `javascript output here`

itd look much better
 
3:11 PM
meh
 
"meh"
 
posted on September 10, 2020 by Bindu Suvarna

 Hi, everyone! We've released Chrome Beta 86 (86.0.4240.30) for iOS: it'll become available on App Store in next few days. You can see a partial list of the changes in the Git log. If you find a new issue, please let us know by filing a bug. Bindu Suvarna Google Chrome

 
3:27 PM
just found out you can use negative margins in the console
thats interesting
 
posted on September 10, 2020 by Richard Lau

Notable Changes Node.js 14.10.0 included a streams regression with async generators and a docs rendering regression that are being fixed in this release. Commits [3c92f93b44] - doc: restore color for visited links (Rich Trott) #35108 [0f94c6b4e4] - Revert "stream: simpler and faster Readable async iterator" (Richard Lau) Windows 32-bit Installer: https://nodejs.org/dist/v14.10.1/no

 
!!afk stop
 
HAMMERTIME!
@KevinB bye Kevin B
 
3:44 PM
@MisterSirCode how?
 
4:06 PM
@JBis Wdym? Just use the %c css selector in console.log
console.log("%ctext", "margin: -4px 0 -3px -24px; padding: 10px");
like that
 
why
 
forgot about that
also, just found a fairely large website that deployed the development version of react
 
4:33 PM
Is there a way to change the URL display text without redirecting
location.hash has been used in the past to make URL games
but its ugly
 
yes
|| google "Is there a way to change the URL display text without redirecting"
 
@MisterSirCode ^
 
 
2 hours later…
6:34 PM
posted on September 10, 2020 by Lakshmana Pamarthy

 The Dev channel has been updated to 87.0.4259.3 for Windows, Mac and Linux platforms. A partial list of changes is available in the log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues.Lakshmana Pamarthy Google Chrome

 
 
1 hour later…
7:59 PM
let a = [1, 2, 3, 4]
for (let foo of a) {
	console.log(a);
	console.log(a.shift());
}
What will be the output :D ?
 
8:44 PM
nvm im stupid
2
 
 
3 hours later…
11:22 PM
posted on September 10, 2020 by Bindu Suvarna

Hi, everyone! We've just released Chrome 85 (85.0.4183.109) for iOS: it'll become available on App Store in next few hours. This release includes stability and performance improvements. You can see a full list of the changes in the Git log. If you find a new issue, please let us know by filing a bug. Bindu Suvarna Google Chrome

 

« first day (3617 days earlier)      last day (1334 days later) »