- Aug 2021
-
stackoverflow.com stackoverflow.com
-
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
- javascript
- TypeScript: generics
- relationship between
- TypeScript
- finding the right balance
- making it easy to do the right thing
- convenience
- TypeScript: generics: upper-bounded
- caveat
- developer's intention
- TypeScript: type guards
- safety (programming)
- contrived/toy example
- poor example
- compromise
- making it too easy to do the wrong thing
- getting in the way
- intention
- poorly chosen
- TypeScript: cost of using (tax)
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
- succinct
- TypeScript: tuple type
- duplication
- hard-coded list of literals
- TypeScript
- forcing (software)
- TypeScript: as const
- TypeScript: helper functions
- better/superior solution/way to do something
- workaround
- newer/better ways of doing things
- TypeScript: narrow or widen
- TypeScript: type system
- TypeScript: union
- obviate
- concise
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).
-
* Now it's correct within the laws of the type system, but makes zero practical sense, * because there exists no runtime representation of the type `Date & string`. * * The type system doesn't care whether a type can be represented in runtime though.
new tag?: makes zero practical sense
makes zero practical sense because there exists no runtime representation of the type
-
no plans to reduce empty cases to never more aggressively to help developers exclude weird/absurd/accidental cases
-
As a design decision, TypeScript does not collapse that type to `never` (although it could).
-
thank you again for taking the time to explain how the compiler thinks in such an elaborate way. This is some blog post material!
-
candidate is Dog { // compiler recognizes that Dog | T can narrow to T
-
What I don't understand is why you need to make it explicit? Given: function isBarAlsoFoo(obj: Bar): obj is Foo; Without resorting to any, how can we get any code to typecheck in which you pass an object that's not a Bar to isBarAlsoFoo()?
-
The Cat & Dog says meowoof?
-
I think I get why adding a seemingly neutral T is T bit actually changes a lot.
-
Please correct me if anything in there is incorrect!
-
I wrote down how I understand it using layman's terms for anyone finding this issue in the future.
-
that is, a type like {foo: never} does not itself get reduced to never even though you shouldn't be able to have a value of type {foo: never}
-
Using the second type guard forces the user to write a more precise type and therefore manifest any nonsensical type guards that produce never, like: function silly<T extends number>(candidate: T): candidate is T & boolean { … }
-
You can't just move 'side-ways' between unrelated types; you need to move either up or down the lattice.
-
There is always a way to work around that by doing expr as unknown as T, but it stops people making basic errors.
-
Search Terms:
Tags
- academic
- appreciation
- funny
- make it hard to get wrong/incorrect
- TypeScript
- need simple explanation
- in one's own words
- detailed answer
- I don't understand
- surprising behavior
- theory vs. practice
- impossible
- good point
- TypeScript: type guards
- TypeScript: never
- TypeScript: reducing types
- detailed explanation
- workaround
- good question
- annotation meta: may need new tag
- correct me if I'm wrong
- footgun
- in theory
- TypeScript: type system
- providing list of search terms/keywords to make it easier to find later
- unintuitive
- in practice
- key point
Annotators
URL
-
-
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; } }
-
you can use whatever control flow block you like instead of return (e.g. an if, or throw, etc)
-
Ryan Cavanaugh
-
Is it possible to write a user defined type guard for a keyof string type such as keyOf foo when foo is defined ONLY as a type (and not in an array)?
-
-
charlypoly.com charlypoly.com
-
While this io-ts might look “overkill”, if you’re dealing with data or complex SPA, you might want to make your types “real” and io-ts is the best way to reach this.
-
Introduced in the perfectly named “Typescript and validations at runtime boundaries” article @lorefnon, io-ts is an active library that aim to solve the same problem as Spicery:TypeScript compatible runtime type system for IO decoding/encoding
io-ts
-
[K in keyof User]-?:
-
It means that when having a type guard:TypeScript and JavaScript runtime are tied to the same behaviour.
-
Inside the if statement, TypeScript will assume that amount cannot be anything else than a string, which is true also at the runtime thanks to typeof JavaScript operator.
-
This “gap” between what we call “runtime” and “static analysis” can be filled using TypeScript Type Guards.
-
We will see that this is not a fatality, because TypeScript is more powerful than you thought and some developers of the community are very crafty.
-
TypeScript is often resumed as “only being a static type checker”, meaning that, at runtime, all the gains of types are a loss.In this chapter, we will see together that this allegation is totally untrue.
-
-
dev.to dev.to
-
we use a type guard here to say that, if this function returns true, any further usage of key will be of the specified type. Otherwise, it's still just a string.
-
keyof is a keyword in TypeScript which accepts a given object type and returns a union type of its keys. These are equivalent: type StatusKey = keyof { online: string; offline: string; busy: string; dnd: string; } type StatusKey = 'online' | 'offline' | 'busy' | 'dnd'
-
function hasKey<O>(obj: O, key: PropertyKey): key is keyof O { return key in obj }
-
which looks like complete nonsense if you don't really know what's going on
-
-
stackoverflow.com stackoverflow.com
-
Adding to the accepted answer, if you happen to need to use a type guard against a mixin, you'll get this error too, since the is operator doesn't behave as an implements would.
-
Regarding the error message, the predicate type must be assignable to the value type because the type guard is used to check whether a value with a less-specific type is in fact a value with a more-specific type. For example, consider this guard: function isApe(value: Animal): value is Ape { return /* ... */ } Ape is assignable to Animal, but not vice versa.
-
If you really don't want to use any, you could use an empty interface - {} - instead:
-
If there is no relationship between the value's type and the type in the type predicate, the guard would make no sense. For example, TypeScript won't allow a user-defined guard like this: function isString(value: Date): value is string { return typeof value === "string"; }
-
the generic means "give me one of each function a -> Boolean" so if any of those functions doesn't exist, then the generic doesn't exist.
-
-
stackoverflow.com stackoverflow.com
-
const isValidMethodForHandler = <T extends { [i: string]: any }>(handler: T) => ( method: string ): method is Extract<keyof T, string> => Object.keys(handler).indexOf(method) !== -1;
-
-
blog.alexdevero.com blog.alexdevero.com
-
Aside to global and local scope there is also something one could call a “block” scope. This is not an “official” type of scope, but it does exist. Block scope was introduced to JavaScript as a part of the ES6 specification. It was introduced along with two new types of variables let and const.
-
-
en.wikipedia.org en.wikipedia.org
-
github.com github.com
-
Why not just prettier-ignore? Because I want to keep Prettier here. Still format my code. But just with another config. This already works with prettierrc > overrides. But this proposal is for a better usability and flexibility.
-
-
github.com github.com
-
In the vast majority of cases when I'm using prettier-ignore I'm only really looking to prevent it from breaking my code into new lines, whilst keeping its other transformations such as switching quotes and adding space between brackets. When ignoring single lines, fixing these formatting problems by hand is very manageable. With the ability to have Prettier ignore entire blocks of code I think the ability to specify what you want it to ignore is essential.
-
This should be basic functionality.
-
Noticed that with 100+ s, I am not alone here. There are definitely a lot of devs wanting this feature. So I took some time out and decided to give this a go myself. I have created a PR for the same
-
In javascript prettier-ignore ignores the next block, so what I did was just make the next few lines a block.
-
I will start working on this feature if there are at least 100 thumbs up on this comment. Let's see if people still need this feature except myself.
Tags
- gauging interest
- good point
- expected library/language to have feature but is missing
- configuration: overriding/disabling some things without having to override/disable _all_ of them (flexibility)
- I agree
- workaround
- don't just complain: do something about it
- prettier
- programming: block (of code: {}, begin/end)
- don't just complain; help improve/fix things
Annotators
URL
-
-
english.stackexchange.com english.stackexchange.com
-
The Simplified Spelling Board of the early 1900s in the United States made gauge one of its targets in the early 1920s, urging the replacing of au with a to yield gage. From Simplified Spelling Board, Handbook of Simplified Spelling (1920): Principles Adopted Its [the Board's] recommendations, accordingly, have been based on the following principles : 1) When current usage offers a choice of spellings, to adopt the shortest and simplest. EXAMPLES : blest, not blessed ; catalog, not catalogue; center, not centre; check, not cheque or checque; gage, not gauge; gram, not gramme; honor, not honour; license, not licence; maneuver, not manoeuvre; mold, not mould; plow, not plough; quartet, not quartette; rime, not rhyme; tho, not though; traveler, not traveller.
-
What happens when you look it up in a dictionary rather than as a phrase in Google? Google just catalogues other people's [mis-]uses
-
-
github.com github.com
-
Using a flag to disable prettier for a line, the next line or until I activate it again (ESLint like syntax). // prettier-disable border: { sep: "║", topLeft: "╔", topMid: "╦", top: "═", topRight: "╗", midLeft: "╠", midMid: "╬", mid: "═", midRight: "╣", botLeft: "╚", botMid: "╩", bot: "═", botRight: "╝" }, // prettier-enable
-
-
developer.mozilla.org developer.mozilla.orgwith2
-
If you forget to define x in the object you pass as the second argument, or if there's some similar bug or confusion, you won't get an error -- just unexpected results.
-
Performance pro & contra
-
-
github.com github.com
-
In general it should probably look something like: setClient(writable(apolloClient)); let client getClient().subscribe((_client) => client = _client);
.
-
-
stackoverflow.com stackoverflow.com
-
You should realize that a Svelte store is actually a very simple construct. It has a subscribe method, an optional set method and basically, that's all. Read the store contract in the docs: everything is in there. Three short rules. That means you can easily handle them (and create new sorts), because you know everything there is to know already!
you can do it!
-
-
medium.com medium.com
-
arguments = method_proc.parameters.map(&:last)
Gets names of parameters, like
[:arg_a, :b]
Should be called
parameter_names
(the key word being names). "arguments
" implies that it is the actual values that were passed in — not the name of the variables to which they will be assigned. -
We focus so much on black magic and avoiding it that we rarely have a chance to enjoy any of the benefits. When used responsibly and when necessary, it gives a lot of power and expressiveness.
-
What if I told you there was a way to do this in Ruby?:destructure def adds(a: 1, b: 2) a + bendadds(a: 1, b: 2)# => 3adds(OpenStruct.new(a: 1, b: 2))# => 3Foo = Struct.new(:a, :b)adds(Foo.new(1,2))# => 3
-
def destructure(method_name) meta_klass = class << self; self end method_proc = method(method_name) unless method_proc.parameters.all? { |t, _| t == :key } raise "Only works with keyword arguments" end arguments = method_proc.parameters.map(&:last) destructure_proc = -> object { values = if object.is_a?(Hash) object else arguments.map { |a| [a, object.public_send(a)] }.to_h end method_proc.call(values) } meta_klass.send(:define_method, method_name, destructure_proc) method_nameend
-
-
www.geeksforgeeks.org www.geeksforgeeks.org
-
Type Annotations:These annotations can be applied to any place where a type is being used. For example, we can annotate the return type of a method.
Tags
Annotators
URL
-
-
www.martinfowler.com www.martinfowler.com
-
this kind of run-time code generation is certainly more natural in Ruby, it's one of its Lispish elements
-
Rubyists don't call these things annotations. One of the things I like doing is to find common techniques that cross languages, for me this is a common technique and 'annotation' seems like a good generic word for it. I don't know if Rubyists will agree.
-
-
www.martinfowler.com www.martinfowler.com
-
Languages may provide annotations in ways that don't reflect the syntax of the language
-
When writing about programming, I prefer to use 'annotation' as the general term. Although .NET was first, the word 'attribute' is just too widely used for different things.
-
An annotation on a program element (commonly a class, method, or field) is a piece of meta-data added to that program element which can be used to embellish that element with extra code.
-
-
-
martinfowler.com martinfowler.com
-
I'm often asked to give talks at conferences, from which I've inferred that I'm a pretty good speaker - which is ironic since I really hate giving talks.
-
've long been a fan of board games, I enjoy a game that fully occupies my mind, clearing out all the serious thoughts for a bit, while enjoying the company of good friends. Modern board games saw dramatic improvement in the 1990's with the rise of Eurogames, and I expect many people would be surprised if they haven't tried any of this new generation.
Tags
Annotators
URL
-
-
www.martinfowler.com www.martinfowler.com
-
As with any classification there's a fuzzy line between them (Rake could be thought of either way.)
-
When people talk about internal DSLs I see two styles: internal minilanguages and language enhancements.
-
An internal DSL (often called an Embedded DSL) is a DomainSpecificLanguage that is written inside an existing host language. It's a common way of thinking in a number of programming language communities - particularly the Lisp community. It's now gaining a lot of attention as DSLs are a common way of thinking in the rapidly growing Ruby community.
-
-
-
# And standalone like a case:Qo.match(people.first, Qo.m(age: 10..19) { |person| "#{person.name} is a teen that's #{person.age} years old" }, Qo.m(:*) { |person| "#{person.name} is #{person.age} years old" })
-
# How about some "right-hand assignment" pattern matchingname_longer_than_three = -> person { person.name.size > 3 }people_with_truncated_names = people.map(&Qo.match_fn( Qo.m(name_longer_than_three) { |person| Person.new(person.name[0..2], person.age) }, Qo.m(:*) # Identity function, catch-all))
-
-
en.wikipedia.org en.wikipedia.org
-
Isolation ensures that concurrent execution of transactions leaves the database in the same state that would have been obtained if the transactions were executed sequentially
-
-
www.thespruce.com www.thespruce.com
-
Pipe assessment is never an elective activity. It's usually forced upon you when the toilets refuse to flush and wastewater comes up instead of going down.
-
-
softwareengineering.stackexchange.com softwareengineering.stackexchange.com
-
Someone could mean to say different thing by each of them, but there's hardly any common agreement.
-
the nomenclature seems to be totally confused
-
This is very useful answer to understand concepts behind each technical words.
-
-
Input check = Tests the user input, as opposed to some internal data structure or the output of a function.
-
which could also be a sanity check for a command like find or mail
input check could also be a sanity check
-
Special case check = Non-obvious, non-boundary special values, for example log(1 + the smallest floating point number).
-
logₑ-1 is iπ
-
Edge / Boundary check = The maximum or minimum input which is expected to produce correct output
.
-
Corner case check = A more complex boundary check (a corner is a two-dimensional boundary)
-
Sanity check = Does this even make sense? For example, if your application only outputs integers, sqrt(-1) and log(-1) are undefined.
-
Regardless of the differences between the words, what you'd use to describe a test depends on the semantics (meaning) of the test, not the exact code
-
-
softwareengineering.stackexchange.com softwareengineering.stackexchange.com
-
For better understanding of something that is complicated, just make it more simplier. In this example, just split the word into atoms, like these: Update - UP_DATE - make it up to date; Upgrade - UP_GRADE - move it to the upper (or next) grade (or level).
-
-
www.youtube.com www.youtube.com
-
2021.01.24-2021.08.09
date/time formats
I used to use this format, too!
-
Tags
Annotators
URL
-
-
www.bobvila.com www.bobvila.com
-
Alternately, set out a few bowls of white vinegar, which also neutralize odor molecules.
-
To remove any lingering musty smell, try the old-fashioned yet effective remedy of setting out a few small bowls of baking soda around the room; baking soda absorbs and neutralizes odor molecules well.
-
-
www.waterdamageplus.com www.waterdamageplus.com
-
Treat the carpet with a white vinegar spray. One part vinegar to two parts warm water. A simple spray over the carpet will remove any light surface residue – definitely better suited for a lesser spill or odor.
Tags
Annotators
URL
-
-
en.wikipedia.org en.wikipedia.org
-
usually-17-key section
hyhenation
-
-
www.merriam-webster.com www.merriam-webster.com
-
measuring the distance between datum points
-
to pick up a datum or two about geriatrics
Tags
Annotators
URL
-