« first day (2826 days earlier)      last day (2347 days later) » 

00:08
how can I use a string 'key1.key2' to get (simply) the value from an object such as obj = { key1 : { key2: 'value' } }
@JBallin does it have to be a string or would you accept other convenient formats?
I'm open @PatrickRoberts
I'm accepting input to get a value from an object
I thought that key1.key2 is easiest on the user
I realize [key1, key2] would be easy on my end
const getKey = ({ key1: { key2: v } }) => v

getKey(obj) === 'value'
In this case, the function itself could be the user-provided value
If you really wanna use a string, there are so many edge-cases to deal with, like how do you deal with keys that have . in them, and if you decide to allow bracketed notation, the parsing gets really messy.
man I was really hoping that obj['key1.key2'] would work
Haha no, that would work on an object like obj = { 'key1.key2': 'value' }
If you want, lodash has a _.pick(obj, 'key1.key2') that works right out of the box though.
00:19
ok cool maybe I'll check that out, thanks for your help!
user1596138
function getNestedPropFromStr(str, object) {
    return str.split('.').reduce((nestedObj, key) => {
       return nestedObj[key];
    }, object);
}
getNestedPropFromStr('key1.key2.key3', {key1: {key2: {key3: 'hello'}}})
user1596138
I guess lol
@Jhawins like I said earlier, what if a key actually has a . in it though, or you want to support bracket notation?
user1596138
Just don't
00:22
what do you mean by "support bracket notation" @PatrickRoberts
key1[key2] for example
user1596138
I thought he had a specific need to use dots from some shit framework. If not... Don't do it in strings like that lol
oh I see what you're saying now, you think users may try to send me bracket notation
let me back up. I'm creating a project that has a config file that's in JSON. I'm writing a getConfig function that takes a key such as key1.key2 and returns the value
I'm also writing a set function that behaves similarly
user1596138
Do you care if it's XY
user1596138
Or do you just wanna do this, cause I bet there's a better solution
00:26
not sure what xy means
I'm open
user1596138
I mean I bet there's no reason to do this at all ;P
user1596138
Unless you have some truly unique constraints
well how would you have users easily edit their config?
user1596138
Wait users send this?
I dont want them to have to go into the json file
yea
00:27
Wait also I messed up
_.get(obj, 'key1.key2') was what I should have linked.
user1596138
Probably just have them edit it, JSON is simpler to understand intuitively than the dot notation
yea for sure maybe I should just have them edit the JSON
I got the idea from git actually
user1596138
Or maybe give them a more user friendly interface if that's the plan, like some buttons that are linked to those properties without using a string of dot notation
git config --global user.email "[email protected]"
I shoul'dve specified that this app runs in the shell
00:31
npmjs.com/package/lodash.get is a module all by itself you can include in your project :D
that's a good idea, may just do that
01:00
morn
 
2 hours later…
02:51
mom
 
1 hour later…
04:19
sup fam
up 104.00
 
2 hours later…
06:31
dad
🚽
so original Kevin ... 💩
06:47
💩
 
1 hour later…
08:01
does 0 divide by i?
according to Wolfram, it does
yes
hm, I think I want to buy another guitar
0 / x = 0 where x element of â„š
err, I meant that other symbol
08:09
who's the real "morn"
i have a difficulty to find an unicode for that C
 
1 hour later…
09:11
> What's the difference between a hippo and a zippo?
> One's really heavy and another's a little lighter.
 
1 hour later…
10:15
ba dum tss
10:32
@BartekBanachewicz that escalated quickly
user4371848
hi i have order list start with 1. 2. etc...
i want to change 1) 2) etc
how can i achieve this?
do you mean the numbered list <ol> ?
user4371848
@KarelG yes
that is possible with some css magic
user4371848
how? can u help me
10:36
57
Q: Ordered list (HTML) lower-alpha with right parentheses?

Tony_HenrichThe default lower-alpha list type for ordered list uses a dot '.'. Is there a way to use a right parenthesis instead like a)... b) ..etc?

he has the exact same question as you have :P The answer is what you need
user4371848
ohhh nice thaank you ! i will check that
css magic--> magicss
please use the css snippet after "Update" tho
is there a cleaner way to reduce
span.style.color = 'blue';
span.style.fontWeight = 'bold';
span.style.lineHeight = '1em';
ok used Object.assign
user4371848
there is little problem the orlder list is like this
1) blah blah
blah blah
user4371848
but i want a space after next line like standard ol
what's the problem?
10:45
can you create an image or something with some drawing to explain that " a space after next line like standard ol " ?
(put a jsfiddle if needed. that would be handy)
that can mean a lot thing. Like an extra space after #) where # is the number
or a space between the list elements
user4371848
10:56
the standard ol tag make some thing like this
https://codepen.io/mesterjohnsmith/pen/KBpaNp
user4371848
uncomment the css and see the difrence
@ThiefMaster (or another mod) You might want to look at the comments here, there's some useless name throwing in my opinion:
This could end up becoming one of the most famous questions on StackOverflow. For jonsca, Clyde Lobo, andrewsi, Andrew and RedDwtght, that won't be a good thing. — Jason Evans 3 hours ago
This QA has been posted on reddit
who are those people?
link to the reddit post?
that was going to be my next question as well
151
Q: How do I clear the content of a div using JavaScript?

RajasekarWhen the user clicks a button on my page, the content of a div should be cleared. How would I go about accomplishing this?

It looks like it was closed and reopened.
@towc The guys who closed the question long ago I think
11:00
oh. I can't see that either way
but yeah, useless name calling
Reopening was probably an OK move, even if the fact the brigading went through redit was a little shameful. But naming closers in an exposed comment isn't cool
1 message moved to Trash can
@AminSamani Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
oops... I posted the wrong link... thanks @Rob
why do people even care so much that a question was closed six years ago to bother posting on reddit...
11:08
@ThiefMaster are you trying to solve the internet?
you know better than that
yeah, i mean i like to rant about stuff that annoys me as well.. but not if it's that old
(unless it's a bug that still exists and nobody bothered fixing it in almost a decade... looking at you, mozilla)
@ThiefMaster you could argue that's the case here
11:25
I cant escape the variable counter here what am I missing?
`this.config.screenshotSliderContainer.prepend(
'<img src="" id="current-video-screenshot-" + counter + " class="img-rounded img-responsive" alt="screenshot" />'
);`
And somebody's trying to CV it again ^^
@ThiefMaster do you see the time when it got closed?
@KarelG Closing "occurred Sep 12 '12 at 20:39"
And it was reopened an hour ago
/history or something in url param?
and somebody's trying to close it.
@KarelG you see that in the edit history
But I guess you don't have enough rep for that ?
11:32
ah yes
I see it now
thanks
It should be frozen. Battles about this question make no sense today. It was a lazy question, it's a useful reference now for many users. Closing it or Reopening it achieves nothing.
lawl
the Google Crawler Bot doesn't understand ES6 code
-5
Q: Is this question considered on-topic?

Ian KempHow do I clear the content of a div using JavaScript? Yes, it's a "specific programming problem" involving "a software algorithm" and definitely "a practical, answerable problem that is unique to software development". But it shows zero effort - it's seriously the epitome of "just Google it" - a...

Good, it's locked
11:40
@jAndy source?
no source, I just realised, that if my SPA is published without Babel'ed ES5 code, the Google Web Tools/Console can't render the page
which works fine, if you compile it down.
well, that's interesting
maybe you're using ES7+ stuff?
no way
I'd have thought it would work well with ES6 by now
the only thing I had in there were class properties, but I removed those
11:44
is there a link? I'm curious now
I'm not sure if the Web Console equals the Crawler software.. but.. I mean, it's pretty ridiculous anyway. I can't even measure page speed with ES6 code
that is part of Web Console
of course it's hard to say if it doesn't understand ES6 in general or only certain parts of it
Does anyone know a trick to get window.fetch if someone fucked with it?
you mean like, fucked with it like the good ol' days of window.undefined = true; ?
without dropping the stupid libraries replacing it, I guess ? Or storing it before that library got called ?
@BenjaminGruenbaum do you have control over anything before the fucker is loaded?
technically speaking
you could reload it as a shim
or from an iframe
11:49
maybe try to call it from a service worker ?
oooh that might work
I just wanted to suggest to call createHTMLDocument, but then I realised the document is part of window not vice versa
create an iframe, get a reference to its window, use the fetch from it
@towc no
@towc messes with the referrer
@DenysSéguret not transferable
I didn't mean to transfer it, but to use it from the worker
But what's the context of the question ?
11:51
I'm writing code that uses fetch, it's an SDK and there is a website using it that overrides window.fetch
Well, actually new relic overrides window.fetch and their code is full of huge memory leaks
I want to get a reference to fetch back.
well, again, you could conditionally shim it
although it's not ideal
but if their website uses leaky stuff, then a slower .fetch isn't going to be something they get to complain about
@BenjaminGruenbaum if you get the function reference of fetch from an iFrame-Window messes with the referrer?
it really shouldn't
@jAndy it's the iframe's fetch
It uses the iframe's referrer
@towc I can't shim fetch, I'm actually using things it does like streaming. What I need to do is impossible with XHR
oh :/
@BenjaminGruenbaum what are we talking about? window.location.href ?
12:03
can you somehow reuse the fucked .fetch?
@jAndy yes, note I don't control the page
how is it being changed?
it's a shame that window.fetch isn't immutable anyway
not a solution that will work for every page that screws with it, but hey
sounds actually pretty... exploitable too??! If you have illegal stuff in mind, overwritting window.fetch might come in handy
12:06
does this mess with referrer too?
let w = window.open('.');
let f = w.fetch;
w.close()
doesn't that..."open a window"
@jAndy that you close instantly. It's ugly, but overriding fetch is uglier
might get blocked anyway
code without user input isn't allowed to do that
yeah
but then you get a null/undefined as reference
12:08
I agree
it's not ideal, but covers more cases than before
nah I'd disagree. Chances are (95%+) the browser won't allow that to happen and you can't work with the ref. The other 5% see a window popping up/close, which doesn't really feels like a trustable page :P
@BenjaminGruenbaum how about just instructing the client to load your sdk before things that might break it, then you provide a nice log of what is broken for when things are broken by screwing with stuff like fetch
@towc delete window.fetch for example
@BenjaminGruenbaum how about that specific scenario
if you just type window.fetch, what do you get
12:12
oh, well
ok
benjamin, did you have thought to try to proxy window?
@KarelG would be pointless if he can't load anything before .fetch is removed
put it in the first script tag
and place rest behind it
well, that's outside of the initial conditions
create iframe -> steal from it and use it
as a failsafe
12:23
@KarelG screws with referrer
you might want to read the whole convo :P
I know but you can adjust that header when you are in failsafe mode
can you overwrite referrer with JS?
can you even get your current referrer with JS?
I think that for security purposes, the former isn't possible either way
via object.defineproperty I think
wat
example?
something like Object.defineProperty(document, 'referrer', {get : _ => return 'hello'})
12:26
I don't think fetch uses the user-facing referrer property either way
PS: I think. not sure. needs to be tested. Feel free to try out
^
if it does not work then he at least tried that route
can you not call a method of the same class from the constructor in typescript?
@Neil what do you mean?
like:
export class TestPage {
  testVal: string;
  name: string;

  constructor(public navCtrl: NavController) {
    this.changeName('Testing');
  }

  public changeName(newName: string) {
    this.name = newName;
    this.testVal = `My name is ${this.name}`;
  }
}
I'll go the worker route
and yet
ERROR
Error: Uncaught (in promise): ReferenceError: changeName is not defined
ReferenceError: changeName is not defined
maybe (probably) I'm making a stupid mistake somewhere
are you sure that's the line that the error comes from?
oh
that's odd.. it works
I made a change and then reverted back to what it was before
and now it doesn't give me that problem
It autoupdates when I make changes
Gave me the illusion of "no caching" I suppose
12:43
@Jhawins what do you mean 'other way around' ?? using 18650s to power 5v usb?
every battery based power bank I've used was 18650's internally.
user1596138
Yeah but on the 18650 itself.
and that battery seems like a waste of money. you can get cheap chargers now (safe ones) that take usb input for a source.
thankyou ecigs
almost $30 for a 18650 just seems excessive.
user1596138
All I said was it's weird. Weird to have a micro USB input on the end of a 18650 lol
regardless of the neat charging
@Jhawins ohh sure, I'm just commenting about it
I have a lot of those batteries (the normal ones)
user1596138
I bought like a 20,000mAh power bank full of them. Funny how everything uses those internally
user1596138
12:46
Festival this weekend
because they're a good battery, if not for the exploding bits
I suppose it wouldn't be a battery if not for the exploding bits
though it is generally preferable that it doesn't explode
people got too lazy with all those protected cells they've been given
now they get a real battery and poof, literally.
protect those as well :P
pretty sure they make them
just not as popular I guess.
12:56
I wouldn't buy anything unless it had a small chance of spontaneously exploding. Adds to the thrill of living
and there goes my left shoe
and left foot?
you think that was my first left shoe to explode?
and left sock, don't forget that
Lucky for you, quantum physics is a thing
that would help ya with your development decision since you have a less chance to shoot in your own foot
12:58
or is it?
user1596138
@rlemon I think they're about the cheapest way to go capacity wise
user1596138
Is Tesla selling them or are they just making batteries to satisfy their own needs?

« first day (2826 days earlier)      last day (2347 days later) »