« first day (3826 days earlier)      last day (1137 days later) » 

1:29 AM
Hey guys, I am trying to programmatically allow origins based on a origins I've chosen to allow as an admin. It is for an API that I decide with customers what websites we'll allow calls from. I thought of using a database for this but I figure I just put all the allowed origins into a file, parse it into an array and do an "includes". If true, allow, else refuse connection
Is this a bad idea? This seems sound to me or is there a more common way of doing something like this?
now it doesn't matter much at all really right now, but the scalability of this solution is something I like to ponder on. parsing 1 million origins from a file to check if the 1 sent is allowed. In my head this is cheaper than letting random origins call to a database but maybe this is stupid?
Im essentially trying to qualify if the overhead of querying a database to determine allowed origins is greater than the potential drawback of parsing a big comma separated file.
i could use another redis db... idk. So many choices
 
1:51 AM
probably inevitably go with redis. Sorry for thinking out loud
 
yea
 
@Taptaplit10 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.
 
 
4 hours later…
6:00 AM
@lovgrandma this is for CORS, right? TBH sounds overcomplicated. First off, you can allow requests with a certain header. This removes the reliance on allowing specific origins, however, then anybody who sends the correct header (and value) can still call your API. So, it's not really down to "where" a requests comes from, you just want to vet "requests". Which is why you might just want to give users an API key to use. Anybody with the correct key has access.
Sure, key sharing may happen but in practice it shouldn't be a huge problem.
Also, if you really want to allow/disallow based on origins, just set the CORS settings with an option to re-load them. This may vary on your setup but a reverse proxy might be a very simple workaround. Setup Apache (or whatever) that acts as a gateway with whatever CORS settings you want and just swap out/restart that with the new settings.
Your application will be running without caring who exactly access it as it's handled elsewhere.
 
 
4 hours later…
9:43 AM
hello
 
@Alpha 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.
 
10:28 AM
1
Q: typeorm query to add another option to a question in many to many relationship

Shaheer IzharI have two tables questions and options. I already have a option associated with question.how i can add another option to the same question. I have a mongoose query in comments but now i want this in typeorm. I have a many to many relationship with questions and options. questionsRouter.post('/qu...

 
@ShaheerIzhar 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.
 
11:03 AM
Should rename the room to "JavaScript: Advertise your JS Stackoverflow Questions"
Hey. this isnt real syntax, right? Found this on a javascript question:
function gcd (a,b):
    if b == 0:
        return a
    return gcd (b, a mod b)
Ive never seen colon syntax used in a function... I thought it was exclusive to object arrays
I think they were just making up fake syntax to describe a recursive GCD algorithm, but I cant be sure
I mean I can replicate it with normal syntax easily... but I just found it strange
#GCD(a, b) {
    return (b == 0) ? a : this.#GCD(b, a % b);
}
 
11:46 AM
||> function gcd (a,b):
    if b == 0:
        return a
    return gcd (b, a mod b)
 
@JBis "SyntaxError: Unexpected token ':'" Logged: `` Took: 42ms
 
nope
@MisterSirCode that looks like psuedocode. Not real language.
 
@JBis yeah, had guessed.
 
12:05 PM
that's python isn't it?
 
python uses def gcd(a, b)
 
oh yeah
 
@BenFortune considering its the description of an algorithm inside a javascript question, Im sure it was just some kind of psuedocode the dude came up with out of the blue
 
12:21 PM
Morning
 
never log an array in an animation frame..
goddamnit..
 
CSS Question - Why can I not use psuedo elements with certain input types? Like for example it works just fine with the input type "date", but almost any other type it doesn't work?
 
example?
 
12:29 PM
lol thats a weird ass pattern
 
I included all form elements in a div with the class required, and applied this CSS styling
.required input:after {
    content: "*";
    color: red;
}
And it is only applying to the input type = "date"
 
@BeerusDev fwiw, is it not more useful to apply that on the labels, which makes more sense?
and ... AFAIK it is not possible
what :after does is to add content in the given container
 
That works as well, I don't know if it is a mandela effect or not haha but I swear any forms I have come across them have it applied to the input
 
but the input containers are already self-containing; you cannot add elements
they are probably wrapping another element around the input
 
I can't believe I didn't even think about that..
 
12:37 PM
eh <br> within flexbox?
 
I removed those in my dynamic application, didn't remove from fiddle
 
hmm jsfiddle does not save by /## anymore
but I really advise to apply that on labels. It makes more sense
 
1:05 PM
@JBis Visual Studio has a similar thing. It's called Live Share and seemed to work quite well when I tried it last.
 
the times i tried it, it sucked
 
I must admit, I've not done very thorough testing of it.
 
you suck
 
Hey! I also blow.
 
1:27 PM
it's quite insane how much config and setup is required to start a js project in 2021
the ecosystem really sucks
 
lol
 
1:38 PM
im gonna try a monorepo for an electron app and a node server
i have a feeling its gonna be a bad idea
 
@JBis Hey! It also blows.
 
2:02 PM
@VLAZ I was using the CORS module on express but using the reverse proxy is probably a lot more ideal. This could be a apache config file with a million plus entries. But the API key sounds more ideal
 
webpack, typescript, eslint, prettier, electron, babel, yarn, husky
when does it end
 
Atleast with the API key I could map that to an origin and if it doesn't match that origin then the customer is breaking the terms of our agreement (sharing)
 
i never should have tried a different programming language
ignorance is bliss
 
@VLAZ yeah thanks I think ill atleast match the API key to origins via the express CORS functionality
using the reverse proxy mm idk. I like dealing with code, that doesn't give me the option to use an in-memory database
 
im gonna go cry myself to sleep
o/
 
2:05 PM
@JBis husky? electron?
lemme do a googles
electron seems like a highly specific thing, why you dogging on javascript man
one day everything will be made in javascript and what will you do then
cars will be running on javascript
planes
 
In the grimdark future of the 21st century, there is only .js
 
Nuclear Missile Software
We took over everything
learning babel and webpack doesn't take too long but its a little bit of a pain once you've already completed your application
 
2:34 PM
@JBis it is completely fine
just create a new KotlinJS project and done, ez pz
:p
 
2:49 PM
KotlinJS thats crazy. Didnt even know that was a thing
 
@Wietlol * shows you the door *
 
dw KarelG, I can find the door by myself, at least KotlinJS tells me where the door is as opposed to JS, where you need someone to tell you where the door is
 
All you need is Mint, obviously.
 
🚽
 
Disclaimer: I do not endorse Mint.
 
2:54 PM
https://replit.com/@MisterSirCode/Image-Data#script.js

Text to pixelated image
thoughts?
just seemed like an interesting experiment
 
3:09 PM
uselesss
 
3:21 PM
not useless
fun
 
Hello everyone
Do you have experience with Kendo UI ReactJS ?
 
in a way
 
Nice, I have an issue with Kendo Grid sorting
 
that is quite unfortunate
 
3:25 PM
An example
https://1wwegf--run.stackblitz.io
but have a problem with sorting one of rows
I have these rows, and sorting works properly but does not work just for Provider Name
 
doesn't seem to want to run
got a code sample?
 
It's probably an issue with sorting Provider name because it's bound to an Object
@KevinB , for example
https://stackblitz.com/edit/1wwegf--run?file=app/products.json
 
that's a 404
 
and see product.json file
how can I sort by nested object ?
"Category" : {
    "CategoryID" : 1,
    "CategoryName" : "Beverages",
    "Description" : "Soft drinks, coffees, teas, beers, and ales"
}
for example
that's the same as this
https://i.stack.imgur.com/oSQTZ.png
 
3:41 PM
and the stackblits link doesn't do anything
so how are you treating the sorting of that column differently to accomodate the fact that it's an object and not a string?
 
Hi all around
A question about typescript module reexports: If I want to have the module exports writable for mocking, I can't export them using export * from "...", is that right?
Instead I need to import them and then reexport them as export const ..., right?
 
@MileMijatović Looks like in 2013 the solution was to simply not do that telerik.com/forums/…
 
3:56 PM
@VLAZ why not
actually looks pretty intersting
 
Can I get some help with this? stackoverflow.com/questions/66989726/…
 
@JBis it's coffeescript all over again
 
hmm
Yeah i guess
 
@JBis it's not a solution to anything. It's yet another thing that in the end compiles to JS because it must compile to JS because it must run in the browser. I don't mind having languages around. But throwing just more of them at JS is just feeding the meat grinder.
 
I'd like to see a solution that doesn't use XML
The only thing that i like that compiles to JS is typescript
 
4:04 PM
BTW, the image from the article has some duplicates:
The circled are just two logos for JS.
 
NodeJS vs JS
 
the whole Article is weird.. like how is "Mint’s entire executable weighs ~34mb and covers most use cases without resorting to external dependencies." an actual measurement for anything?
 
Eh, I guess.
 
@JBis good joke :|
 
@makadev It isn't. I'm not even sure what the article was about because my first reaction to it before I even read it was the XKCD comic from the end of the article.
 
4:06 PM
Let me ask you this
 
@VLAZ ye, that was basically the first thing I was thinking about after reading a bit into it.. and then the image is even referenced at the end lol
 
We have abstraction and compilation all over software development. (Java to JavaByte code. C++ to machine code, etc.). Why is the js environment so bad?
 
but well.. I guess, if you are more used to Elm/Haskell it might even be a solution.
 
It's not JS. The problem is the whole damn ecosystem where random people tried to recreate the wheel about a bajillion times.
 
I think the issue is that all these abstractions target JS. So using them together is a nightmare.
Webpack targets JS. To use it with TypeScript (which also targets JS) you need an extension.
Babel targets JS too.
These are all abstractions above JS. But when you try to use them together its a nightmare.
It's like trying to use C++, Swift, Objective-C, GoLang, Rust all at the same time
 
4:10 PM
Ya know what, Im going to go out and say this right now...

Why is reinventing the wheel so bad? A lot of people are tactile learners, even if theyre unaware, and they learn well by experiencing and taking action, rather than reading on and on and doing courses.

If they want to reinvent something thats been made a million times... So what?

Not to mention that sometimes, though rarely, on occasion, someone might reinvent the wheel BETTER.. where it improves upon something previously thought to be the best
Personally, Im a junior developer, but I have enough experience to see that theres really no reason to reinvent something already made... But I myself also remake and reinvent the wheel a LOT.

It helps me practice and learn
 
"Why is reinventing the wheel so bad?" it's bad when we need about six of these wheels in order to cobble together a vehicle that barely works.
 
And all the wheels are different sizes
 
If it helps someone learn, theres really no issue there
 
Reinventing it is indeed valuable learning tool. Don't then release the learning tools as stuff we're expected to run in production.
 
Not many people would use a broken wheel
 
4:12 PM
^^
@MisterSirCode you'd be surprised
 
@MisterSirCode *points at the JS ecosystem* I mean...
 
Ill say it, as Ive said to anyone talking about a Majority > Minority system...

If someone uses something inferior, less functional, less efficient, or otherwise "worse" then something else, it is their fault as a person. People make mistakes.
However, a better wheel is bound to be more useful and more widely used then a broken one
 
@MisterSirCode i don't think you are understanding what we are saying
 
@JBis I think I do understand... You want people to use whats better for themselves and those around them... correct?
 
I want the developer experience when I am building my app to be good. In order to do that, I can't use vanilla JS. I need to use 100 different tools.
@MisterSirCode no
 
4:15 PM
then what do you want
 
We want a stable system
 
^
 
Maven is (sort of) the Java version of NPM. It has its issues for sure but it doesn't completely destroy the project of people around the globe.
It cannot.
 
@VLAZ How do the "clones" and "remakes" of projects, which barely have any attention, actually destabilize the entire javascript populous and foundation...
I want you to explain that
 
@MisterSirCode nobody is saying that
 
4:18 PM
Because, as it stands, there are hundreds or thousands of rewrites of almost every popular or well known piece of code out there
and that wont stop
 
HAMMERTIME!
 
Way to kill the mood... ya damn bot
 
It's weird and bulky to be sure but not an actual danger because it has built-in redundancies and is more sane with naming packages. So you wouldn't even get into the chain of failure that lead to the NPM disaster. That's because NPM, while being newer, has not really taken any of the lessons of other package systems out there that mitigate these problems.
 
it's one of those things that great on paper, but once you get it into production you realize it's faults
 
Alright VLAZ is talking about a separate issue
 
4:20 PM
so ... umm ... question: why is the property of a module that results from an export const writable?
 
for example.. say you use it to build something customer facing, and it has an image gallery
great!
except now the client wants a different kind of dancing bologna that looks like this other site...
now you need to re-build whatever that other site did in mint
becuase it's not js, it's mint
coffeescript at least had some interoperability with other libraries that weren't coffeescript
if you take your project outside of the javascript ecosystem, you no longer have access to the benefits of that ecosystem
while still at the end of the day being javascript
 
I don't really know how you fix the JS ecosystem.
 
@Vogel612 WDYM? Imports are immutable. Should be, at least.
 
ya... narp
I have a module that reexports a renamed import
// lib.ts
import { foo as foo_ } from "./foo"
export const foo = foo_;
when you import that as a module with a *-import, the property foo is writable
 
do you mean foo.x is writable?
 
4:26 PM
it's certainly possible that a community builds around mint and such tools/etc are created, but... i mean
 
Do you mean you can do foo = 42 or foo.bar = 42?
 
look at wordpress
 
import * as fooMod from "foo";
Object.getOwnPropertyDescriptor(fooMod, "foo"); // writable: true
it's configurable and enumerable as well
 
the binding is immutable - so you cannot reassign fooMod. The object itself is just an object.
 
the other problem is how configurable everything is
tsconfig, .prettierrc, webpack config, babel config
 
4:29 PM
@VLAZ sure, but it's not about fooMod, it's about fooMod.foo
 
Yep. It's just an object. You can change it, if you want. You can Object.freeze() it before exporting if you don't want that but it's not done by default.
 
Maybe if JS devs got whipped everytime a new package was installed....
 
no... you misunderstand me.
fooMod["foo"] = {}; does not result in an error
 
Correct.
 
the sad part is even after all this tooling most of js written is still shit
 
4:31 PM
When you import an object, it's not automatically write protected.
Only its binding is.
const doesn't make the object itself immutable
||> const obj = {foo: 1}; obj.foo = "hello"; obj
 
@VLAZ {"foo":"hello"} Logged: `` Took: 0ms
 
||> const obj = {foo: 1}; obj = 5
 
@JBis "TypeError: Assignment to constant variable." Logged: `` Took: 0ms
 
Only the variable is protected from reassignment. A similar protection is there for imports
 
@VLAZ okay, with you so far then. Now why is that different when I use export { foo } from "foo"; in lib.ts?
 
4:33 PM
Do you get a mutable binding then?
 
no
 
???
So...it works as expected?
What am I missing?
 
it feels like those should be semantically equivalent
whether you get a local binding in a reexporting module shouldn't be relevant to the writability of the imported local binding of the reexporter
also that would imply there's no semantic difference between export const and export let
which sounds like a really bad idea
guess that's just me being used to languages that have an actually strict typesystem with consistent semantics for the same keyword :/
 
hmm
what if browsers were just virtual machines virtualizazing a cross platform OS
 
WDYM what if?
 
4:42 PM
why do we like web apps over native apps?
- saftey
- cross platform
- easy to access
why do we hate web apps over native apps?
- speed/efficiency
- functionality
 
because native apps cost more
 
@JBis Don't like SPAs because I love my middle clicks.
 
so just take the best of both
make an extremely safe OS that is cross platform
it's basically where we are headed with WASM
and it'll fix the issue of cross platform native apps
that is the future, mark my words
 
Microsoft wanted to integrate that into Windows. Where you'd be able to write a Windows app in HTML + JS + CSS and be able to use it in a browser and also install it on the PC.
Not sure where that really went, though.
 
bleh
scrap HTML JS CSS
 
4:49 PM
Microsoft also called ".NET" cross plattform, not sure if they still do. It was all a lie from the very beginning.
 
Ahoy!
this irc has been hidden in plain sight
I have been searchin' it all my dev life... har! har!
 
@PrashantSinghal 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.
 
@makadev .NET Core
 
no, we don't want a cross platform framework/language
 
But I really don't know if it works cross-platform
 
4:50 PM
I am saying a cross platform OS
 
@VLAZ the mono project added some cross platform usage but of course it was not cross plattform as in "I can do everything on Linux as I can on Windows" and afair the mono project was not from microsoft either
 
Mono was available a long time before MS made .NET Core and claimed its cross-platformness
 
.NET core is pretty close to cross-platform, so long as you don't use the .NET native window stuff
 
And yeah, IIRC it was limited, not completely compatible but a lot more than just .NET which just..wasn't
 
WinForms and WPF are not gonna work on linux, ever, because DirectX is never going to
 
4:55 PM
Heh, I wonder if you can write some application that only works under WSL because it runs in Linux but uses the Windows host for display in some weird fashion.
 
that sounds perfectly doable, actually
 
Probably. I'm just not very well versed in the Windows API and stuff.
Was pretty stoked when I managed to get git in my WSL Ubuntu to launch the Windows Meld application.
 
Doesn't WSL run virtualized with a linux kernel? You'd need some sort of connection to the Windows WindowServer (or.. use a custom one) to use the host UI afaik.
 
That's a mystery for me. I really don't know how the WSL process communicates with Windows.
 
if the mounts are fair game you can just link something under /mnt/c/system/ and bind to it
that way you can definitely also hook into the host UI
 
4:59 PM
You can do IPC between host and guest
Thats what I mean, you probably need a UI Server on the host side (or just install an XServer port)
I don't think you can do direct calls since.. Windows has PE and Linux Elf, there is no common binary interface
also Windows Host/Guest calls shouldn't work either without common address space
aanyway
 
5:35 PM
U-Haul apparently doesn't have server-side validation for pre-checkin on their site, was successfully able to have my drivers license expiry of last year work
 
Is there a way to count hypothetical line counts from a string?
https://replit.com/@MisterSirCode/Image-Data-Encoder

Like, I have a long string of text, I have a for loop that sets an X position to draw the text.

After 256 characters, it resets to 0 and starts drawing +1 in the y direction
 
So line length is 256, then?
 
so is there a way to see how many 256s fit into that string, and then use it?
yes
exactly
 
Division sounds like a good idea
 
oh
wiat
Im fking stupid
Works! https://replit.com/@MisterSirCode/Image-Data-Encoder

Now it automatically creates the encoded image, appends the encoded version data, along with the image data, and creates a custom image height and wide based on that...
beautiful
totally useless and more or less for fun
but still cool
 
6:14 PM
am i the only one that continuously clears their clipboard after use?
 
Heres a useless page I made to do fun stuff with the junk in your clipboard
https://image-data.mistersircode.repl.co/

Instead of clearing it, visualize it
but in all seriousness, to answer your question, no
I really dont.
 
@MisterSirCode what does that do
 
6:34 PM
posted on April 07, 2021 by Srinivas Sista

 The Beta channel has been updated to 90.0.4430.61 for Windows Mac and Linux. A full list of changes in this build is available in the log. Interested in switching release channels?  Find out how here. 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. Srinivas Sista Goog

 
lolz
 
6:54 PM
When this is collapsed, it reads Open Instructions https://jsfiddle.net/bfeoa3m0/1/

Is it possible to use strictly CSS to have it read Close Instructions once it has been expanded?
 
7:26 PM
I'm trying to refresh a table using JavaScript. But I'm getting [object Response] where the table should be on the web page. Can anyone spot why the following code isn't refreshing the table by making a new request, and using the response as the table?
<script>
function load(url, element)
    {
          fetch(url).then(response => element.innerHTML = response});
    }
        var intervalID = window.setInterval(load("TableData", document.getElementById("theTable")), 5000);
</script>
 
7:45 PM
response isn't what you think it is
any fetch tutorial or code sample would not be using response directly like that
 
8:19 PM
@KevinB Isn't response html? I want to replace the content of the element with id theTable, with the response.
 
it is not
it's a response object
it tells you information about the response, such as if it was successful
!!mdn fetch
!!||
james is ignoring me
 
8:33 PM
|| status
oh i must of killed him
sorry james
 
I see. So if I want to replace inner html of <div id="theTable">...</div> with a response in the form of <table><thead></thead....</table>, which function of fetch do I call?
 
|| status
 
I am currently alive!
 
sorry james
 
see the body interface methods here: developer.mozilla.org/en-US/docs/Web/API/Response
in your case, you're looking to get text from the response object
so, fetch(...).then(response -> response.text()).then(text => doStuffWith(text))
error handling would go in step 2 of that
 
8:41 PM
@KevinB thanks for the hint and link. I did this:
element.innerHTML = response.headers.set('Content-Type', 'text/html');})
 
hmm
why
 
Now the table is showing up but it is not refreshing despite this code using setInterval(...):
<script>
function load(url, element)
    {
          fetch(url).then(response => element.innerHTML = response.headers.set('Content-Type', 'text/html');});
    }
        var intervalID = window.setInterval(load("TableData", document.getElementById("theTable")), 5000);
</script>
 
response.headers.set( returns void, and doesn't make any sense in a callback, since there's no headers to set.
the request is already done
 
@KevinB From what you said, I got the impression response wasn't actually html. So I changed the content-type to HTML
 
yeah no that's not what i meant at all
 
8:45 PM
 
response, the variable you are working with
isn't html
it isn't supposed to be
regardless of what your server returns
fetch isn't $.ajax
8 mins ago, by Kevin B
so, fetch(...).then(response -> response.text()).then(text => doStuffWith(text))
 
@KevinB Let me try that
@KevinB This:
fetch(url).then(response => response.text).then(text => element.innerHTML = text);
shows this on the web page:
function text() { [native code] }
It doesn't update the content of the html element with id theTable.
 
you missed a ( and a )
 
@KevinB Thanks. I have this now:
fetch(url).then(response => response.text()).then(text => element.innerHTML = text);
But the table on the webpage is still not updating?
This line should update the table element by replacing it with the table element (and its children) returned by fetch:
var intervalID = window.setInterval(load("TableData", document.getElementById("theTable")), 5000);
 
9:09 PM
@KevinB Do you have any idea why setInterval(...) isn't executing the load function periodically?
 
because you call it immediately...
use e.g. () => load(...)
also, var has no place in JS code nowadays
 
@phenomnomnominal Interesting read! Always nice when large companies publish things like this.
@phenomnomnominal csc.kth.se/~gkreitz/spotify-p2p10/spotify-p2p10.pdf is also interesting tho it doesn't entirely make sense to me
> Spotify clients currently do not perform any NAT traversal.This lack of NAT traversal is mitigated by two factors.Firstly, when a client wishes to connect to a peer a request is also forwarded through the Spotify server asking the connectee to attempt a TCP connection back to the connecter. This allows the connection to be established provided one of the partiescan accept incoming connections
That sounds like NAT traversal. In fact, thats exactly how TCP hole punching is performed. en.wikipedia.org/wiki/TCP_hole_punching
 
 
1 hour later…
10:46 PM
posted on April 07, 2021 by Veenita Joshi

Hi, everyone! We've released Chrome Beta 90 (90.0.4430.63) 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. Veenita Joshi Google Chrome

 

« first day (3826 days earlier)      last day (1137 days later) »