|
Tanners posted:Tagged literals probably https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates Thanks! I was having a conversation with a coworker yesterday where we got on the topic of what the smallest possible JS program is. We agreed that the program has to 'do something', as vague as that is. We figured that j=1 is probably the smallest program. Is there any smaller meaningful combination of characters in JS?
|
# ? Sep 10, 2019 17:06 |
|
|
# ? Jun 3, 2024 20:27 |
|
Kraus posted:Thanks! !0
|
# ? Sep 10, 2019 17:25 |
|
j=1 doesn't do anything. According to thefreedictionary.com a program is "(Computer Science) a sequence of coded instructions fed into a computer, enabling it to perform specified logical and arithmetical operations on data" but j=1 isn't performing any logical or arithmetical operations it's just assigning something to memory. Lets not get metaphysical here guys.
|
# ? Sep 10, 2019 21:31 |
|
https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
|
# ? Sep 10, 2019 21:38 |
|
Anyone here experienced with Apollo Server? I'm trying to fix up the auth for one of our services, but for some reason, when using express, adding something to the request object in some custom middleware doesn't affect the req object in the context configuration when setting up the apollo server. Ideas? Here is a rough example of the code I have:JavaScript code:
I found this article where someone more or less is doing the same thing so I assume that this would work, but for some reason the req object just doesn't seem to carry over in any meaningful way. I also can't use session storage, because the request/response objects in context don't seem to receive the middleware that has been applied to the main express app. Any ideas? I feel like I'm missing something obvious. Edit: Also if I simple change doStuffToGetToken() to a string literal it still doesn't work, so there's definitely nothing wrong with the function itself. reversefungi fucked around with this message at 23:42 on Sep 10, 2019 |
# ? Sep 10, 2019 23:22 |
|
Or an even smaller program, !0
|
# ? Sep 11, 2019 01:15 |
|
Nolgthorn posted:j=1 doesn't do anything. Well, we also figured that if "do something" meant output, the smallest you could get was: alert`` , which I mentioned above.
|
# ? Sep 11, 2019 03:24 |
|
The Dark Wind posted:Anyone here experienced with Apollo Server? I'm trying to fix up the auth for one of our services, but for some reason, when using express, adding something to the request object in some custom middleware doesn't affect the req object in the context configuration when setting up the apollo server. Ideas? Here is a rough example of the code I have: The issue is that you're trying to make GraphQL requests without understanding how those requests are made. To keep things simple for now, I recommend that if you're using a GraphQL server, then you should always use a GraphQL client to make requests. In your case, I highly recommend you stick with Apollo and use Apollo Client to make your API requests. The section of the docs on authentication, that will help populate req.token in your context() method, is here: https://www.apollographql.com/docs/react/recipes/authentication/
|
# ? Sep 12, 2019 00:16 |
|
How do I make documentation for my JavaScript library that is pretty? Like the MDN web docs that explain JavaScript's built-in functions? I see tools like JSDoc but they seem more geared towards short automated descriptions instead of the long explanatory paragraphs found on MDN, mainly because any text has to be in the source code itself along with a bunch of markup added to generate the documentation. I understand how it could be useful to have code comments and documentation that automatically stays in sync like JSDoc offers, but I would rather have my code comments merely be links to the documentation pages where a longer and much more human-friendly description is made of each function. Happy Thread fucked around with this message at 18:24 on Sep 16, 2019 |
# ? Sep 16, 2019 08:35 |
|
Maybe gitbook?
|
# ? Sep 16, 2019 15:02 |
|
Why do service workers define self? I tried to google it, but google is useless for precise techical questions.
|
# ? Sep 18, 2019 13:12 |
|
Wheany posted:Why do service workers define self? self refers to the global execution context. (https://developer.mozilla.org/en-US/docs/Web/API/Window/self) e.g. in a window, self returns the window. in a worker or a service worker, it is defined as the execution context of the worker/service worker. the spec indicates that the global execution context of service worker is ServiceWorkerGlobalScope (https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope-interface).
|
# ? Sep 18, 2019 13:33 |
|
Wheany posted:Why do service workers define self?
|
# ? Sep 18, 2019 20:54 |
|
roomforthetuna posted:The capitalist's eternal question. Heyooooo
|
# ? Sep 19, 2019 07:48 |
I'm attempting to write a messenger web app mainly for a portfolio piece in which the conceit is that it doesn't require registration and functions more like a burner phone(you're randomly assigned a 10-digit id when you start and you can clear it and get a new one whenever, and messages automatically decay and/or get removed from conversation partners' devices when one of the participants tells it to) All the messaging functionality works fine now but in order for any of the other security measures to matter I need to actually encrypt the message contents and I don't really have much of an idea how since I've only been coding for ~10 months. I've used Bcrypt for passwords before but that process doesn't really work when you've got to be able to decrypt messages from someone else besides yourself, right? Is there any crypto library in particular that anybody would recommend for this? Stack for it is React/Redux/Node Express/Mongo
|
|
# ? Sep 19, 2019 19:53 |
|
TheIncredulousHulk posted:I've used Bcrypt for passwords before but that process doesn't really work when you've got to be able to decrypt messages from someone else besides yourself, right? That's right. Bcrypt isn't an encryption algorithm, but a hash algorithm. It changes a password to a hash, i.e. a string of gibberish, the same string of gibberish every time (with the same settings and same input) and with no way of finding out what the password was even if you know the settings and the gibberish. I don't know which library to recommend, perhaps this is good: https://github.com/ricmoo/aes-js Google "block cipher vs stream cipher" to see which is best for you. I think block cipher, so you pad out the message to a certain length. You also need to come up with a way of storing the keys. For a portfolio piece you could perhaps simplify, use the same key everywhere and write "//imagine a secure key storage and exchange thing goes here". Then you can expand into public/private key pairs and Diffie-Hellmann key exchange later.
|
# ? Sep 19, 2019 20:07 |
Thanks!
|
|
# ? Sep 19, 2019 22:26 |
|
I'm writing tests for functions that deal with strings that are ints. Like:JavaScript code:
"A string that contains an int"? "A stringified int"? "A string of only digits"? Why is my brain failing me here?
|
# ? Sep 24, 2019 23:56 |
|
Thermopyle posted:I'm writing tests for functions that deal with strings that are ints. Like:
|
# ? Sep 25, 2019 00:58 |
|
The latter sounds the best. edit: numeric string could also work but could imply decimals as well.
|
# ? Sep 25, 2019 00:59 |
Integer string
|
|
# ? Sep 25, 2019 10:14 |
|
fractionless whole natural sequence encoded byte array
|
# ? Sep 25, 2019 10:22 |
|
strinteger
|
# ? Sep 25, 2019 10:44 |
charray
|
|
# ? Sep 25, 2019 11:12 |
|
String with numeric characteristics
|
# ? Sep 25, 2019 13:45 |
|
asciint
|
# ? Sep 25, 2019 13:47 |
|
pre-parseInt integer.
|
# ? Sep 25, 2019 18:56 |
|
"string matching the regex /^-?\d+$/"
|
# ? Sep 25, 2019 18:57 |
|
So far, all equally-great ideas!
|
# ? Sep 25, 2019 19:45 |
"a mistake"
|
|
# ? Sep 25, 2019 22:15 |
|
Does anyone know how to properly implement a texture atlas in modern THREE.js that uses geometry based UVs instead of hacking offset/repeat in the texture and cloning it's UUID? The latter now results in multiple texture uploads to the GPU. I'm after a Sprite and PlaneGeometry based Mesh detail for a texture atlas and anything to do with UVs is confusing the hell out of me. I can see THREE.js examples for Minecraft have a texture atlas for BoxGeometry but that doesn't easily translate. I've managed various messed up results, didn't save the really odd ones with trippy random dots and odd angles. demo It's supposed to look like this:
|
# ? Sep 25, 2019 22:56 |
|
I have looked at two (or three) new APIs in the last week. Service workers + caches seems like a really good and simple API and Indexed DB looks like complicated garbage. It's really easy to cache a few resources and then just serve them from the cache forever while everything else uses normal http requests. Indexed DB looks like a ton of yak shaving before you get to the part where you can dump data in there. I was looking at Indexed DB because Safari on ios doesn't share localstorage with PWAs and that's where our app's auth keys are stored, but then I read that it doesn't share Indexed DB either. So I guess our iphone users get to log in again with the app.
|
# ? Sep 26, 2019 20:31 |
|
IndexedDB is the foundation for building a database on. There are quite a few extensive database libraries built on it providing SQL or document type interfaces you should use instead This is even mentioned on the MDN page https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
|
# ? Sep 26, 2019 21:19 |
|
The docs make it look worse that it needs to be. For simple key-value storage if you don't have localstorage, it is manageable. Wrapping in Promises is probably the way to go, something like this:JavaScript code:
|
# ? Sep 26, 2019 21:52 |
|
I have an actual javascript question: does cache.addAll guarantee that those files will always stay cached? Currently my service worker just caches all the js, css, images and fonts that the app uses using addAll (8 files, a little over 1 megabyte total) and the fetch listener will just return the cached version or fetch the resource if not found in cache. The cache is never updated. Should I be checking if the requested resources match the files listed in addAll and re-cache them if they have been purged?
|
# ? Sep 27, 2019 16:40 |
|
https://developer.mozilla.org/en-US/docs/Web/API/Cache posted:You are also responsible for periodically purging cache entries. Each browser has a hard limit on the amount of cache storage that a given origin can use. Cache quota usage estimates are available via the StorageEstimate API. The browser does its best to manage disk space, but it may delete the Cache storage for an origin. The browser will generally delete all of the data for an origin or none of the data for an origin. Make sure to version caches by name and use the caches only from the version of the script that they can safely operate on. See Deleting old caches for more information
|
# ? Sep 27, 2019 16:45 |
|
I've read that before but I guess what I wanted to hear was that everything in the cache is treated equally and can disappear from under you. I guess that makes the default boilerplate javascript that keeps static resources cached a bit more complex. Or can the browser just reinstall the service worker after a cache purge?
|
# ? Sep 28, 2019 09:07 |
|
My react knowledge is old an rusty, so I look up a 2019 react article and see this: JavaScript code:
|
# ? Sep 29, 2019 09:27 |
|
Wheany posted:My react knowledge is old an rusty, so I look up a 2019 react article and see this: Keep in mind that hooks have some weird gotchas, because basically there's some dumb magic going on there where it keeps track of hooks by just what calls to useWhatever get made in order, so you'll break stuff if you put one inside an if or do other flow control things with them. Also, you have to be careful about stale callbacks. If you can keep a handle on all that, though, they're very useful for abstracting away "initial state" vs "current state" handling, especially once you add in a library for declarative-style data loading with hooks.
|
# ? Sep 30, 2019 02:18 |
|
|
# ? Jun 3, 2024 20:27 |
|
Everything I've ever read about hooks has been: Some guy: I finally get hooks, they're really simple! Here's a fun thing you can do with hooks React maintainer: Actually, this will break in edge case A, B, C. Use this obscure feature instead Some guy: oh... hm...
|
# ? Sep 30, 2019 17:59 |