I don't understand why we want to stub out yarn
- Sep 2021
-
github.com github.com
-
-
-
Webpacker used to configure Webpack indirectly, which lead to a complicated secondary configuration process. This was done in order to provide default configurations for the most popular frameworks, but ended up creating more complexity than it cured. So now Webpacker delegates all configuration directly to Webpack's default configuration setup.
more trouble than it's worth
- creating more complexity than it cured
-
Webpacker has become a slimmer wrapper around Webpack
Tags
- modern javascript development is complicated
- changed their mind/opinion
- complicated
- too complicated
- Why can't this be easier/simpler? Why does it have to be so hard/complicated?
- removing feature that is more trouble than it's worth (not worth the effort to continue to maintain / fix bugs caused by keeping it)
- thin abstraction/layer
- newer/better ways of doing things
- too hard/complicated/non-trivial
- more trouble than it's worth
- wrapper
- doing more harm than good
Annotators
URL
-
-
-
Breaking Changes
I like how they show the diff below
-
-
stackoverflow.com stackoverflow.com
-
Good question. Too bad it went unanswered.
-
-
github.com github.com
-
The upgrade instructions recommend yarn upgrade @rails/webpacker --latest
-
-
www.dictionary.com www.dictionary.com
-
Some would argue that the phrase ''survival of the fittest'' is tautological, in that the fittest are defined as those that survive to reproduce.
-
-
baileylineroad.com baileylineroad.com
-
Click below to download free plans for building my Dado Engine jig. It lets you safely rout dado grooves for cabinets and shelves with the perfect width of groove to match your sheet material.
-
Cut a dado groove with a 3/4” diameter router bit and you’ll almost certainly have a too-loose joint when you try to plug some 3/4” plywood in place. Under the guise of metrification, sheet material thicknesses have all shrank enough to cause problems with joinery if you rely on the old, Imperial thickness designations. And besides, material thickness varies enough from sheet to sheet that it can make a difference when it comes to prominent joinery. This is even true in the USA that still uses Imperial more or less exclusively. Sheet goods remain thinner than their name specifies.
-
-
stackoverflow.com stackoverflow.com
-
Unfortunately, it's too late to make the question more specific as this would invalidate some of the (good) answers.
-
This question is broad and not very clear -- with the result that the following answers cover quite different scenarios and use cases.
-
-
stackoverflow.com stackoverflow.com
-
My silly mnemonic for this is the longer the method name the stricter the comparison: eq < eql < equal
-
The differences are subtle
-
it means that 42.0 == 42 produces true and 42.0.eql? 42 produces false
-
-
github.com github.com
-
It is a descendent of the "Object Mother" pattern for creating objects for testing, and is related to the concept of an "object exemplar" or stereotype.
Object Daddy < Object Mother
-
-
github.com github.com
-
I first learned to love the functionality of Dave Thomas' annotate_models plugin (you can find a repo for it here). Later, when it became un-maintained and broke, I switched over to ctran/annoate. Then, when work on it waned and broke as well, I decided to write my own as an exercise.
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
One good use for /dev/tty is if you're trying to call an editor in a pipeline (e.g., with xargs). Since the standard input of xargs is some list of files rather than your terminal, just doing, e.g., | xargs emacs will screw up your terminal. Instead you can use | xargs sh -c 'emacs "$@" </dev/tty' emacs to connect the editor to your terminal even though the input of xargs is coming from elsewhere.
-
-
spin.atomicobject.com spin.atomicobject.com
-
An extensible plugin architecture allows for customizing your workflow or even making Yarn a package manager for non-JavaScript projects.
-
(Yeah, npm 7 has these too, but Yarn 2’s implementation is more expressive.)
-
Workspaces make monorepo-style projects more manageable.
-
This is no different from other popular libraries or frameworks making huge architectural changes (think React 16.8 with hooks or Python 3). The longer you wait to make the switch, the more painful it will be for your project when you finally do. And in the meantime, you’ll be missing out on valuable improvements to a fundamental part of the workflow of every single project you work on.
-
it’s time to reconsider that decision. Here are three reasons you might have waited to make the switch — and why those reasons are out of date in 2021.
-
If you don't learn from history, you're doomed to rebase it.
Tags
- benefiting from upstream development
- variation of a familiar saying
- using for a use case / application that is beyond/not what it was originally designed for
- monorepo
- git rebase
- funny
- reconsidering a decision
- programmer humor
- yarn: workspaces
- expressive
- outdated
- better ways of doing things
Annotators
URL
-
-
www.quora.com www.quora.com
-
Continue with Quora+Unlock this answer and support creators like Mark Jones by joining Quora+
Tags
Annotators
URL
-
-
www.quora.com www.quora.comQuora+1
-
Quora+ is a subscription to the best of Quora.Access great writing, straight-from-the-source knowledge, and stories you can’t find anywhere else while supporting creators who matter to you.
Another example of a service that tries to entice users with a free service (and writers with a financial incentive) and then once they achieve enough popularity, they make some of "their" content "premium".
(YouTube Premium, ...)
This is why we should distrust and avoid using "free" services.
-
-
stackoverflow.com stackoverflow.com
-
Node Sass does not yet support your current environment indicates that the version of node-sass you are trying to run is not compatible with the version of node installed.
-
-
github.com github.com
-
NodeJS Supported node-sass version
Tags
Annotators
URL
-
-
-
My understanding is that the caret is the answer for traditional SemVer, i.e., there will be breaking changes prior to 0.1.0, there may be breaking changes between minor versions prior to 1.0.0, and there may only be breaking changes between major versions above 1.0.0.
-
-
www.linuxquestions.org www.linuxquestions.org
-
I find it much simpler to use a partition label with LABEL=.... It is shorter, easier to remember, and also has the advantage that should the partition go bad and need to be replaced you can create a new partition, give it the same label provided the old partition is either removed or at least changed to be unlabelled and fstab will never know the difference.
-
-
ubuntuforums.org ubuntuforums.org
-
sudo apt-get autoclean sudo apt-get autoremove sudo apt-get clean sudo apt update sudo apt-get dist-upgrade --fix-missing sudo apt-get dist-upgrade --fix-broken sudo apt full-upgrade sudo apt -f install dpkg --configure -a
-
-
stackoverflow.com stackoverflow.com
-
But it is always important to remember that those are not language concepts. Those are community concepts that only exist in our heads and in the names of some library methods.
I'm not sure about this. I get what he's saying and agree that singleton methods are nothing but a naming convention for the more fundamental/atomic construct called instance methods (which indeed are the only kind of method that exist in Ruby, depending how you look at it), but I think I would actually say that singleton methods are language concepts because those methods like
Object#define_singleton_method
, ... are always available in Ruby (without needing to require a standard library first, for example). In other words, I would argue that something belonging in the Ruby core "library" (?) by definition makes it part of the language -- even if it in turn builds on even lower-level Ruby language features/constructs. -
have a philosophy that if someone can provide any more meaningful information to a problem even if it indirectly solves the problem, I think that should also be rewarded.
-
Note: when I wrote above that "there is no such thing as X", what I meant was that "there is no such thing as X in the Ruby language". That does not mean that those concepts don't exist in the Ruby community.
-
The important thing to understand is that there is no such thing as a class method in Ruby. A class method is really just a singleton method. There is nothing special about class methods. Every object can have singleton methods. We just call them "class methods" when the object is a Class because "singleton method of an instance of Class" is too long and unwieldy.
-
Class methods are actually instance methods defined on the singleton class of a class.
-
The question is similar but its in a Rails context. The solutions would answer my question, but I'm almost certain that he could probably leverage Arel to solve his problem. The question I posted was designed purely as a Ruby question so that it was easier to search for. You might want to suggest an edit of the title of his question because it didn't show up when I searched for a solution to my problem.
-
Yes, unfortunately the other question has a misleading and completely irrelevant Rails context and might be harder to find for some people. IMHO, it's still a perfect content duplicate, although not a topic one. Answers are also equal. Anyways, still a good question of yours.
-
Side note: When I flagged yours as a dupe during review, the review system slapped me in the face and seriously accused me of not paying attention, a ridiculous claim by itself since locating a (potential) dupe requires quite a lot of attention.
Tags
- distinction
- making it easy to search for / find later
- nothing special about
- I'm skeptical of this claim
- Ruby: class methods
- does not exist
- first-class concept
- not a duplicate
- automation/AI vs. human review/intervention
- good explanation
- I'm not sure about this
- requires attention
- philosophy
- rewarding/incentivizing people for good/desired behavior
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
Thanks to Rack Middleware and Rails 3 you can output pretty JSON for every request without changing any controller of your app. I have written such middleware snippet and I get nicely printed JSON in browser and curl output.
-
-
askubuntu.com askubuntu.com
-
This is a really frustrating problem.
-
One solution is to run this command to reset your keyring password: rm ~/.local/share/keyrings/login.keyring
-
I am being told my Login Keyring Password "no longer matches" my login. I am confused - I provided a password as I was setting this up, and so I don't know what this is about and how I can fix it. Thanks for the help.
-
Usually you get this error if you change your password by some other means which fails to update the password for the keyring.
-
-
www.systutorials.com www.systutorials.com
-
Scripts for disabling/enabling laptop keyboard
-
-
ask.fedoraproject.org ask.fedoraproject.org
-
Probably you should change the password using GNOME Settings to keep it synced.
-
-
ask.fedoraproject.org ask.fedoraproject.org
-
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
-
-
forums.linuxmint.com forums.linuxmint.com
-
I prefer legacy to UEFI because it's easier to move the OS from the installation SSD to the mdadm RAID0
-
I keep detailed records of my installation and configuration process so that I can quickly find out where something went wrong.
-
Indeed yes, but sometimes it is necessary to change one's password, even if one is not 'mucking about with' or 'tweaking' or 'customising' any other system settings.
-
-
It seems to me (N.b. what do I know about this? Nothing!) that the best solution would be to tweak the 'Change Password' process so that it also updates the 'Passwords and Keys'>Passwords>Login folder's properties.
"I'm not an expert, but it seems to me..."
-
this isn't a question, it's a warning for the unwary new Mint user (i.e. people like me)
-
-
thoughtbot.com thoughtbot.com
-
We understand that new bugs often occur when bugs are fixed and we want to leave the project in a stable state.
-
most recently the release of ActiveStorage in Rails 5.2
-
-
store.steampowered.com store.steampowered.com
-
I don't recommend the game, but since it is very inexpensive, you can try it for yourself and not be out a lot of money, so this review might not be necessary, but I'm writing it anyway because I have lots of thoughts that I don't see reflected in the first reviews I see on this first Store Page of Squidlit, although I haven't read every review, which would require a lot of time.
:-)
Tags
Annotators
URL
-
-
www.elegantthemes.com www.elegantthemes.com
-
Remote Access is something that we are really excited about because it will allow our support team to give you a seamless and high level of support that is truly unmatched. When you need extra help, you can enable the Remote Access toggle with a single click. This will send a secure token to the Elegant Themes support staff that they can use to log in to your WordPress Dashboard. No passwords are shared and there is no need to send the token to our team yourself. It all works seamlessly in the background. While remote access is enabled, our team will be able to log in to your website and help explore whatever problems you are experiencing. You can even enable it preemptively before chatting with our support team so that we can jump right in if necessary. By default, our support staff will have limited access to your website using a custom WordPress support role. You can also enable full admin access if requested. Remote access is automatically disabled after 4 days, or when you disable Divi. You can also turn it off manually after an issue has been resolved, and of course, Remote Access can only be enabled by you, the website owner, and not by Elegant Themes or anyone else. The Remote Access system is wonderful because it saves tons of time during support chat, and it saves you the hassle of having to debug certain complicated issues yourself. It allows us to take a hands on approach to solving problems quickly, instead of wasting hours or days chatting back and forth.
-
-
www.airtable.com www.airtable.com
-
One workspace.platform.source of truth.Endless solutions.Orchestrate powerful business solutions with a single source of truth. The only limit is your imagination.
-
From day one, your team will love the familiarity of a spreadsheet, and the power of a database.
-
Airtable evolves with you and your team, so you can build a solution with increasing sophistication and capability.
-
-
-
www.metacritic.com www.metacritic.com
-
As criticisms go, “it was too addictive and I finished it in a few hours” isn’t exactly the worst thing you can say about a game. In fact, as someone who prefers quality over quantity,
.
-
-
gettr.com gettr.com
-
founded on the principles of the free speech, independent thought and rejecting political censorship and “cancel culture”.
-
-
www.freecodecamp.org www.freecodecamp.org
-
-
The choice of stacking attributes should be based on:Do the attributes make sense when stacked vertically? and,When stacked vertically, does it save horizontal space?
-
since table data is essentially an ordered collection of items, it seems natural to use ordered lists.
-
to layout tables
-
-
us4.forward-to-friend.com us4.forward-to-friend.com
-
Three days before Labor Day, on Friday, September 2, 1921, the U.S. Army intervened on the side of coal companies against striking coal miners, marking the end of the Battle of Blair Mountain in southern West Virginia. The battle was the climax of two decades of low-intensity warfare across the coalfields of Appalachia, as the West Virginia miners sought to unionize and mining companies used violent tactics to undermine their efforts. The struggle turned deadly.
-
-
-
us4.forward-to-friend.com us4.forward-to-friend.com
-
first sighting: A Forward link at bottom of an e-mail, which takes you here, which has a link to a preview (which is basically a web version of the e-mail that was sent).
In some ways, this seems preferable over forwarding the original e-mail that you received using your e-mail client's forward feature. In particular:
- It doesn't inadvertently include your personalized unsubscribe link, allowing the forwarded-to person to maliciously unsubscribe you without your consent.
Tags
Annotators
URL
-
-
www.eff.org www.eff.org
-
a class of attacks that were enabled by Privacy Badger’s learning. Essentially, since Privacy Badger adapts its behavior based on the way that sites you visit behave, a dedicated attacker could manipulate the way Privacy Badger acts: what it blocks and what it allows. In theory, this can be used to identify users (a form of fingerprinting) or to extract some kinds of information from the pages they visit
-
-
stackoverflow.com stackoverflow.com
-
How can I make a link that will go directly to a specific location in the iFrame
-
-
www.gowallawalla.us www.gowallawalla.us
-
If you are riding a bicycle, you can get through the roundabout two ways: Get off your bike and go through a crosswalk like a pedestrian, or ride around it like a vehicle.
.
-
-
stackoverflow.com stackoverflow.com
-
target="_blank" which opens the anchor in a new window(which has been redirected to tabs by browser settings usually)
new window => new tab
-
Instead if this anchor was nested in frames it would open in a sandbox mode of sorts, meaning only in that frame.
-
-
en.wikipedia.org en.wikipedia.org
-
In thermodynamics, a diathermal wall between two thermodynamic systems allows heat transfer but do not allow transfer of matter across it
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
There is a huge explanation about why the dot is important quoting issues about DNS and character encoding
It doesn't seem like the dot, in this context, would have anything to do with/help with either DNS or character encoding
-
But I realized after a lot of research that the problem was that I did not copy the right URL address from the iTunes API documentation. It should have been https://itunes.apple.com/search?term=jack+johnson. not https://itunes.apple.com/search?term=jack+johnson Notice the dot at the end There is a huge explanation about why the dot is important quoting issues about DNS and character encoding but the truth is you probably do not care. Try adding the dot it might work for you too. When I added the "." everything worked like a charm.
-
-
stackoverflow.com stackoverflow.com
-
Mod note: This question is about why XMLHttpRequest/fetch/etc. on the browser are subject to the Same Access Policy restrictions (you get errors mentioning CORB or CORS) while Postman is not. This question is not about how to fix a "No 'Access-Control-Allow-Origin'..." error. It's about why they happen.
-
Applying a CORS restriction is a security feature defined by a server and implemented by a browser.
-
When you are using postman they are not restricted by this policy. Quoted from Cross-Origin XMLHttpRequest: Regular web pages can use the XMLHttpRequest object to send and receive data from remote servers, but they're limited by the same origin policy. Extensions aren't so limited. An extension can talk to remote servers outside of its origin, as long as it first requests cross-origin permissions.
-
Please stop posting: CORS configurations for every language/framework under the sun. Instead find your relevant language/framework's question. 3rd party services that allow a request to circumvent CORS Command line options for turning off CORS for various browsers
-
-
www.imdb.com www.imdb.com
-
The 2 stars this show received on average is really an inaccurate and lazy way to characterize the hard work of the cast and crew. The filmography is amazing and scenery beautiful, the characters are rich and complete, the people are beautiful. Few shows engage me, this one did.
unfairly bad rating
-
-
help.imdb.com help.imdb.com
-
To ensure that our rating mechanism remains effective, we do not disclose the exact method used to generate the rating.
secret / not transparent
-
-
www.reddit.com www.reddit.com
-
My pc and where i site when i watch netflix are not the same place, not at all.And thats beside the point, why in gods name does netflix feel the need to pause?It has a auto play function and a auto pause function that both can't be turned on or off, what the?
-
-
www.howtogeek.com www.howtogeek.com
-
According to Netflix, the Netflix app asks this question to prevent users from wasting bandwidth by keeping a show playing that they’re not watching. This is especially true if you’re watching Netflix on your phone through mobile data. Every megabyte is valuable, considering that network providers impose strict data limits and may charge exorbitant rates for data used on top of your phone plan. Advertisement tmntag.cmd.push(function(){tmntag.adTag('purch_Y_C_0_1', false);}); Of course, this saves Netflix bandwidth, too—if you fall asleep or just leave the room while watching Netflix, it will automatically stop playing rather than streaming until you stop it. Netflix also says this helps ensure you don’t lose your position in a series when you resume it. If you fall asleep in the middle of your binging session, you might wake up to find that several hours of episodes have played since you stopped watching. It will be difficult for you to remember when you left off.
-
If you watch Netflix via the desktop website, one way to disable the prompt is by using a browser extension called “Never Ending Netflix” for Google Chrome.
unofficial/fan-made extension
-
-
www.reddit.com www.reddit.com
-
It's kind of ridiculous that it does it 2 minutes in, it should just prompt before it starts playing the episode
bad UX
-
The reason is they don't want to stream to an empty house, and want to make sure you're there to watch the content (pandora does the same thing).
-
it's always the 3rd episode in a row, 2 minutes into the 3rd.
-
my problem is that it doesn't ask you at the end of the previous episode, or even at the beginning of the current one. It waits to interrupt what you're watching
bad UX
-
I called Netflix and they told me that there was no option to change this. So I asked why? He told me that nobody was requesting this as a feature. So I said I'm requesting this feature the ability to select continuous play without the pause or a play all without any pauses. He says he would put in my request but so far nothing has been done. Then I asked if Netflix had a Feedback or Feature Request page he said their Facebook, Twitter, or to call Netflix and request it.
how to submit feature request
-
they could just say they're putting in your request by phone without doing anything at all
skeptical
-
- Aug 2021
-
github.com github.com
-
I hope you'll forgive me for defaulting to the documentation: I think it will do a better job of explaining it than me.
-
-
stackoverflow.com stackoverflow.com
-
Th part of an URI after the # is called "fragment" and is by definition only available/processed on client side (see https://en.wikipedia.org/wiki/Fragment_identifier).
-
The main problem is that the browser won't even send a request with a fragment part. The fragment part is resolved right there in the browser. So it's reachable through JavaScript.
-
-
stackoverflow.com stackoverflow.com
-
Love the simplicity of this and that it uses native browser methods
-
-
stackoverflow.com stackoverflow.com
-
// if the load event does not fire because it fired before // loaded() will never be executed
-
Now, a solution would be to look inside the iframe contents document.readystate, but with cross-origin content we get security exceptions here.
-
+1 for the creative same-origin+redirect approach
-
This still would not eliminate all delay, but I think this could be faster (no render blocking), and cleaner than having inline scripts scattered all over the parent document.
-
Without any active cooperation from those 3rd-party providers (like postMessage communication), I think inserting those iframes via JS is your only realistic option. Or to at least “trigger” them to load their actually content only after you had a chance to add your load handler - so you could keep <iframe src="about:blank" data-real-src="http://3rd.party/..."> in your HTML, and have a script coming after that switch out src for data-real-src after adding the load handler.
.
-
But those inline scripts will be “render blocking”, so not the best regarding overall page performance.
render blocking
-
But for this approach we fear the performance impact of creating iframes via JavaScript -- the html iframe would be rendered and loaded before the script would even start to execute.
-
rewrite all onload iframes to javascript-inserted elements
javascript-inserted elements non-javascript-inserted elements
-
-
stackoverflow.com stackoverflow.com
-
if(document.getElementById('myIframe').readyState == 'complete')
-
-
www.csoonline.com www.csoonline.com
-
You cannot break security if you do not understand a system better than the people who made the system, and you cannot defend your organization if you do not understand how those systems work to the same degree.
-
We human beings pride ourselves on our ability to reason, but the truth is we use our brains nine times out of ten to justify what our gut wants, not what is rational to do.
-
Seeing what you want to see, and failing to understand the why and the how
-
"Highly complex memorized secrets introduce a new potential vulnerability: They are less likely to be memorable, and it is more likely that they will be written down or stored electronically in an unsafe manner. While these practices are not necessarily vulnerable, statistically some methods of recording such secrets will be. This is an additional motivation not to require excessively long or complex memorized secrets."
-
Forcing employees to use a complex password with special characters in it means everyone is just going to add an exclamation point at the end of their existing password. This is why your accounts payable clerk has a yellow sticky note on their cubicle wall with their password on it. They just want to get their job done, and you're making it harder for them with no discernible improvement to security.
-
-
github.com github.com
-
Using min-width to set the width of the iFrame, works around an issue in iOS that can prevent the iFrame from sizing correctly.
-
-
stackoverflow.com stackoverflow.com
-
I need a solution for auto-adjusting the width and height of an iframe to barely fit its content. The point is that the width and height can be changed after the iframe has been loaded.
-
resize the iFrame after the contents are modified
-
All solutions given thus far only account for a once off resize.
-
-
All answers here which mention scrollHeight/scrollWidth should be adjusted a bit to take body margins into account. Browsers apply default nonzero margins for documents' body element (and it's also applicable to content loaded into frames). The working solution I found is to add this: parseInt(window.getComputedStyle(this.contentDocument.body).margin.
-
-
stackoverflow.com stackoverflow.com
-
Make iframe automatically adjust height according to the contents without using scrollbar? [duplicate] Ask Question
-
note: when using for cross domain, requires you to be able to inject a js file into the iframe... Doesn't seem like a viable option when you don't control the iframe source.
-
Javascript required? In other words, one cannot do this on cross-site iframes (due to cross-site scripting restrictions), is that right? As @clankill3r is suggesting, this demonstrates the need for a pure CSS solution to this problem
-
-
-
The most likely cause of this problem is having set the height of an element to be 100% of the page somewhere in your CSS. This is normally on the html or body elements, but it could be on any element in the page. This can sometimes be got around by using the taggedElement height calculation method and added a data-iframe-height attribute to the element that you want to define the bottom position of the page. You may find it useful to use position: relative on this element to define a bottom margin or allow space for a floating footer.
-
-
en.wikipedia.org en.wikipedia.org
-
without requiring a learner to log in separately on the external systems, with information about the learner and the learning context shared by the LMS with the external systems
-
-
-
-
This seamless integration works with any LMS (Open edX, Moodle, ...) thanks to the LTI standard for interoperability.
Tags
Annotators
URL
-
-
css-tricks.com css-tricks.com
-
I always had to set the height of them literally almost 50% taller than the content itself to accommodate for the innards growing when the form was submitted with errors (the error messaging expanded the height). If I didn’t, the submit button would get cut off making the form un-submittable.
-
-
stackoverflow.com stackoverflow.com
-
this is most technical method that i could to find , great job @sudhir, Thank You :)
-
Works smooooothly. Thanks heaps!
-
-
onload="setIframeHeight(this)"
-
Good catch, @Hokascha. The project claims support for cross-domain iframes, but reading the docs reveals that it does still require server access to the embedded domain.
-
-
stackoverflow.com stackoverflow.com
-
This library on GitHub solves the cross-domain problem, along with making sure the iFrame stays sized to the content when things change. github.com/davidjbradshaw/iframe-resizer
-
-
stackoverflow.com stackoverflow.com
-
Sure it does: "should I always set width/height explicitly?"
-
-
destroytoday.com destroytoday.com
-
With JavaScript, you can actually calculate the width of the scrollbar and whether it’s visible by comparing two properties—window.innerWidth and document.body.clientWidth. If these are equal, the scrollbar isn’t visible. If these are different, we can subtract the body width from the window width to get the width of the scrollbar:const scrollbarWidth = window.innerWidth - document.body.clientWidthWe’ll want to perform this both on page load and on resize, in case someone resizes the window vertically and changes the overflow. Then, once we have the scrollbar width, we can assign it as a CSS variable:document.body.setProperty("--scrollbarWidth", `${scrollbarWidth}px`)
missing feature: vw/vh can't be used "directly" because doesn't account for scrollbars
-
I know, I know—needing to use JavaScript when writing CSS does feel like defeat, but unless there’s a vwWithoutTheScrollbarPlease unit in CSS, you’re going to need use JavaScript.
-
Maybe someday, we’ll get a viewport unit that doesn’t factor in the scrollbars, but until then, we can only work around the current one.
-
If width: 100% is your friend, then width: 100vw is the kid who only pretends to be your friend, so that he can swim in your pool. (I’ve never had a pool, but I know this kid exists from friends of mine who grew up with pools. Also, I am this kid)
-
Luckily, there are two easy ways to avoid this issue along with the humiliation of having a slight horizontal overflow on your website.
-
-
stackoverflow.com stackoverflow.com
-
It might be worth moving the latest updates to the top of this answer. I had to go through the whole thing to get to the best answer, flexbox.
-
-
www.timeanddate.com www.timeanddate.com
-
Caution: This is NOT the current local time in most locations in that time zone North America: Only some locations are currently on MST because most places in this time zone are currently on summer time / daylight saving time and are observing MDT.
-
In everyday usage, MST is often referred to as Mountain Time (MT) or the Mountain Time Zone. This can add a bit of confusion as the term Mountain Time does not differentiate between standard time and Daylight Saving Time, so Mountain Time switches between MST and MDT in areas that use DST during part of the year.
-
Some areas in British Coloumbia, including Creston, Fort Nelson, Fort St. John, and Dawson Creek use Mountain Standard Time all year.
-
Most North American time zones also have generic terms, including Pacific Time (PT), Central Time (CT), Eastern Time (ET), and Atlantic Time (AT).
-
Mountain Standard Time (MST) is 1 hour ahead of Pacific Standard Time (PST). To convert MST to PST, you have to subtract one hour.
-
-
www.kickstarter.com www.kickstarter.com
-
Yeah, I know, international shipping sucks. I wish it didn't.
.
-
-
www.kickstarter.com www.kickstarter.com
-
Collabescape
portmanteau
-
-
developer.mozilla.org developer.mozilla.org
-
This attribute is considered a legacy attribute and redefined as allow="fullscreen".
-
-
jacobfilipp.com jacobfilipp.com
-
“Ultimately, these kind of iframe limitations are the reason why vendors should implement embeddable marketing forms with JavaScript instead of iframes….” – I couldn’t agree more. The trouble is, Pardot’s developers still believe it’s the 1990’s
-
or email me at “j@thisdomain”
-
-
-
stackoverflow.com stackoverflow.com
-
Is it usual to close 4 year old questions as duplicates in favor of a more recent one and then link to your own answer? Seems a bit shady.
-
-
stackoverflow.com stackoverflow.com
-
Also note thet width: 100% is relative to it's first parent with a layout. So if you have an element with width:100% inside another element that has a specific width, the child element will only take up the total width of that parent.
-
-
www.benmarshall.me www.benmarshall.me
-
An intrinsic ratio means an element will maintain its aspect ratio when resized. Think of an img with max-width: 100%. Change the width of its parent and it’ll change the size while keeping the same shape (aka. its aspect ratio).
Tags
Annotators
URL
-
-
googlechrome.github.io googlechrome.github.io
-
"intrinsicSize" attribute tells the browser to ignore the actual intrinsic size of the image and pretend it's the size specified in the attribute
-
-
gist.github.com gist.github.com
-
-
Awesome resource - thanks for sharing
-
-
github.com github.com
-
const allRoles: string[] = Object.values(Role)
helped me!
-
which communicates your intent to the compiler
-
I'll stop spamming contributing to this thread now and wait for official word from a TS repo maintainer.
-
allRoles should be a string[] and not an any[] or a Role[]
-
For better or worse, TS doesn't do semantic versioning; see #31761
-
We would also like it if breaking changes were not made in a minor version update. If this breaking change is absolutely necessary, it should be made with TypeScript version 4.x, not in a minor version update. It's very notable that according to Dependabot, this version update saw an over 10% failure rate, despite being a minor update, when most other builds have less than 3%. Heck, even the 2.9.2 → 3.0.1 breaking change had a lower rate of failure than this one! Surely Microsoft can not consider that acceptable.
-
-
-
I really hope they keep breaking it. Being the lead on a library for several years, most of the forced refactors were pretty straight forward and in almost every case made our code either more sound or easier to be consumed. Now I work on a runtime that embeds TypeScript and 3.5.1 has broken some code, thought it took me all of about 15 minutes to make the changes to adopt it, and in every case, it broke because we were being a bit loose with the types. While it didn't find any bugs, it made the code more "safe".
I really hope they keep breaking it.
-
The TypeScript team has made it clear. They do not follow semver. "minor" (X.X) releases can contain breaking changes. . The fact that someone has made a bad policy clear, does not mean that the policy is therefore good. Major releases (X) have very little meaning. This negates the usefulness of using such versioning in the first place.
-
The TypeScript team has made it clear. They do not follow semver. "minor" (X.X) releases can contain breaking changes. Major releases (X) have very little meaning.
-
If you dig into the details, you will see that the TypeScript team take breaking changes very seriously and with consideration.
-
I think the TS team generally tries to minimize breaking changes from version to version and don't do so unless there is a good reason.
-
We'll sometimes need to make changes that can end up creating new type errors in existing programs - this is ultimately unavoidable, because for any change in the type system, including bug fixes, it's possible to construct a program that will have a type error introduced into it as a result.
-
-
github.com github.com
-
which seems to resolve the issue for me and makes no casts, ensuring that Typescript can keep doing its good job of widening as much as necessary and narrowing as much as possible without me having to claim I know better than the compiler. I'm posting it here since it doesn't seem to have been mentioned anywhere.
makes no casts, ensuring that Typescript can keep doing its good job of widening as much as necessary and narrowing as much as possible without me having to claim I know better than the compiler.
-
I'd like to update my proposal to be more general, following your answer on Stack Overflow and hack mentioned at the top of #14520
-
I'd like to think this issue isn't quite a duplicate
-
The problem is that, with the literal types, the includes call now gives a type error: // Error: Argument of type number is not assignable to 1 | 2 | 3 if(!legalValues.includes(userValue)) { throw new Error("..."); }
-
I think a more natural/appropriate behavior for type signature of includes would be for the literal types to be widened.
-
The above works great. However, the problem comes when I want to use literal types for my legal values. In my code, I want to do that so I can make sure I define a "handler" for every legal value: const legalValues = <const>["a", "b", "c"]; // later on... // Because legalValues entries are literal types, // I get a compiler error if I forget to define any behaviors const behaviors: { [K in typeof legalValues[number]]: any } = { a: something, b: somethingElse, c: anotherThing };
-
-
-
This isn't too restrictive, and provides a nice type type guard.
-
function includes<T, U extends T>(arr: readonly U[], elem: T): elem is U { return arr.includes(elem as any); }
-
Some details of my example were originally poorly chosen i.e. the example was constructed in a way that developer would probably have done a null check rather than a typeof comparison. I've addressed that now. My apologies to anyone who read this before-hand and thought the example seemed a bit too "fabricated".
-
Now consider we want to handle numbers in our known value set: const KNOWN_VALUES = Object.freeze(['a', 'b', 'c', 1, 2, 3]) function isKnownValue(input?: string | number) { return typeof(input) === 'string' && KNOWN_VALUES.includes(input) } Uh oh! This TypeScript compiles without errors, but it's not correct. Where as our original "naive" approach would have worked just fine. Why is that? Where is the breakdown here? It's because TypeScript's type system got in the way of the developer's initial intent. It caused us to change our code from what we intended to what it allowed. It was never the developer's intention to check that input was a string and a known value; the developer simply wanted to check whether input was a known value - but wasn't permitted to do so.
-
Changing every built-in function to accept anys would also "break" no one, but that doesn't make it a good idea. Part of TypeScript's value proposition is to catch errors; failing to catch an error is a reduction in that value and is something we have to weigh carefully against "Well maybe I meant that" cases.
-
Please read https://stackoverflow.com/questions/41750390/what-does-all-legal-javascript-is-legal-typescript-mean
-
See #14520 for discussion of upper-bounded generics.
Tags
- TypeScript: generics: upper-bounded
- compromise
- intention
- finding the right balance
- making it too easy to do the wrong thing
- caveat
- developer's intention
- getting in the way
- making it easy to do the right thing
- TypeScript: cost of using (tax)
- contrived/toy example
- poor example
- TypeScript: type guards
- TypeScript: generics
- relationship between
- poorly chosen
- javascript
- safety (programming)
- TypeScript
- convenience
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
This could be achieved using a dummy validating function. const validateType = <T> (obj:T) => undefined
-
-
github.com github.com
-
I believe he wants to use the as const feature while still type checking that the structure matches an interface. A workaround I'd use for something like that would be interface ITest { a: number; b: string; } let foo = { a: 5, b: "Hello" } as const;
-
<ITest>foo; //a useless javascript line, but checks the var `foo` is assignable to `ITest`
-
-
stackoverflow.com stackoverflow.com
-
the tuple() function you need can be succinctly written as: export type Lit = string | number | boolean | undefined | null | void | {}; export const tuple = <T extends Lit[]>(...args: T) => args;
-
const list = ['a', 'b', 'c'] as const; // TS3.4 syntax type NeededUnionType = typeof list[number]; // 'a'|'b'|'c';
-
This will obviate the need for a helper function of any kind.
-
This type of assertion causes the compiler to infer the narrowest type possible for a value, including making everything readonly.
"infer"?
-
possible to tell the compiler to infer the type of a tuple of literals as a tuple of literals, instead of as, say, string[], by using the as const syntax.
-
This is annoying repetition, but at least it doesn't introduce an extraneous object at runtime.
-
Or, maybe better, interpret the list as a tuple type: const list: ['a','b','c'] = ['a','b','c']; // tuple
-
You can force the type system to remember each value as a literal string: const list = ['a' as 'a','b' as 'b','c' as 'c']; // infers as ('a'|'b'|'c')[]
-
One problem is the literal ['a','b','c'] will be inferred as type string[], so the type system will forget about the specific values.
-
t's not supposed to work with that, since by the time you do const xs = ['a','b','c'] the compiler has already widened xs to string[] and completely forgotten about the specific values.
Tags
- forcing (software)
- concise
- obviate
- better/superior solution/way to do something
- TypeScript: type system
- TypeScript: union
- TypeScript: as const
- hard-coded list of literals
- succinct
- newer/better ways of doing things
- TypeScript: narrow or widen
- TypeScript
- workaround
- duplication
- TypeScript: tuple type
- TypeScript: helper functions
Annotators
URL
-
-
github.com github.com
-
function strictIsDog<T extends Dog extends T ? unknown : never>( // like <T super Dog> candidate: Dog | T // if Dog extends T then Dog | T is T ): candidate is Dog { // compiler recognizes that Dog | T can narrow to T return "bark" in candidate; } if (strictIsDog(animal)) {} // okay if (strictIsDog(dog)) {} // okay if (strictIsDog(mixed)) {} // okay if (strictIsDog(cat)) {} // error! // ~~~ <-- Cat is not assignable to Dog
-
If you really want to prevent people from passing in known Cat instances to isDog() you can fake up a lower-bound type parameter constraint like this:
-
therefore in practice it's a bit academic to worry about which lines inside that block the compiler should be happy or unhappy about. From falsehood, anythihng follows. So the compiler is free to say "if the impossible happens, then X is an error" or "if the impossible happens, then X is not an error". Both are valid (although one might be more or less surprising to developers).
-
-
stackoverflow.com stackoverflow.com
-
The best way to do this is to derive the type Format from a value like an array which contains all of the Format literals.
-
That should work as expected and not be too verbose (or at least it doesn't repeat string literals anywhere)
-
So is @Ryan Cavanaugh's answer the only viable solution? It seems extremely verbose...
-
My question is specifically if there is a way to do user defined type guards using the type itself
-
-
stackoverflow.com stackoverflow.com
-
function isKeyOfMcuParams(x: string): x is keyof McuParams { switch (x) { case 'foo': case 'bar': case 'baz': return true; default: return false; } }
-