James Reads

HomeBlog

Day of Feb 19th, 2020

  • Mike Bloomberg is not the lesser of two evils

    Like the vast majority of Americans, I have been effectively disenfranchised in the last few presidential elections. In 2011, I moved to Washington, D.C., which is so heavily Democratic that any vote for president is totally meaningless — in 2016, Hillary Clinton won with 93 percent of the vote.

    Read at 05:51 am, Feb 19th

  • TypeScript: Assertion signatures and Object.defineProperty

    Hey! Interested in TypeScript? There's a TypeScript conference happening in Austria: Check out TSConf.eu TypeScript: Assertion signatures and Object.defineProperty 06 February 2020 by @ddprrt | Posted in: TypeScript, JavaScript In JavaScript, you can define object properties on the fly with Object.defineProperty. This is useful if you want your properties to be read-only or similar. Think of a storage object that has a maximum value that shouldn’t be overwritten: defineProperty and property descriptors are very complex. They allow you to do everything with properties that usually is reserved for built-in objects. So they’re common in larger codebases. TypeScript – at the time of this writing – has a little problem with defineProperty: If we don’t explicitly typecast, we don’t get maxValue attached to the type of storage. However, for simple use cases, we can help! assertion signatures With TypeScript 3.7, the team introduced assertion signatures. Think of an assertIsNumber function where you can make sure some value is of type number. Otherwise, it throws an error. This is similar to the assert function in Node.js: To comply with behavior like this, we can add an assertion signature that tells TypeScript that we know more about the type after this function: - function assertIsNumber(val: any) { + function assertIsNumber(val: any) : asserts val is number if (typeof val !== "number") { throw new AssertionError("Not a number!"); } } This works a lot like type predicates, but without the control flow of a condition-based structure like if or switch. If you look at it closely, you can see those assertion signatures can change the type of a parameter or variable on the fly. This is just what Object.defineProperty does as well. custom defineProperty Disclaimer: The following helper does not aim to be 100% accurate or complete. It might have errors, it might not tackle every edge case of the defineProperty specification. It might, however, handle a lot of use cases well enough. So use it at your own risk! Just as with hasOwnProperty, we create a helper function that mimics the original function signature: We work with 3 generics: The object we want to modify, of type Obj, which is a subtype of object Type Key, which is a subtype of PropertyKey (built-in), so string | number | symbol. PDesc, a subtype of PropertyDescriptor (built-in). This allows us to define the property with all its features (writability, enumerability, reconfigurability). We use generics because TypeScript can narrow them down to a very specific unit type. PropertyKey for example is all numbers, strings, and symbols. But if I use Key extends PropertyKey, I can pinpoint prop to be of e.g. type "maxValue". This is helpful if we want to change the original type by adding more properties. The Object.defineProperty function either changes the object or throws an error should something go wrong. Exactly what an assertion function does. Our custom helper defineProperty thus does the same. Let’s add an assertion signature. Once defineProperty successfully executes, our object has another property. We are creating some helper types for that. The signature first: function defineProperty< Obj extends object, Key extends PropertyKey, PDesc extends PropertyDescriptor> - (obj: Obj, prop: Key, val: PDesc) { + (obj: Obj, prop: Key, val: PDesc): asserts obj is Obj & DefineProperty<Key, PDesc> { Object.defineProperty(obj, prop, val); } obj then is of type Obj (narrowed down through a generic), and our newly defined property. This is the DefineProperty helper type: First, we deal with the writeable property of a PropertyDescriptor. It’s a set of conditions to define some edge cases and conditions of how the original property descriptors work: If we set writable and any property accessor (get, set), we fail. never tells us that an error was thrown. If we set writable to false, the property is read-only. We defer to the InferValue helper type. If we set writable to true, the property is not read-only. We defer as well The last, default case is the same as writeable: false, so Readonly<InferValue<Prop, Desc>>. (Readonly<T> is built-in) This is the InferValue helper type, dealing with the set value property. Again a set of conditions: Do we have a getter and a value set, Object.defineProperty throws an error, so never. If we have set a value, let’s infer the type of this value and create an object with our defined property key, and the value type Or we infer the type from the return type of a getter. Anything else: We forgot. TypeScript won’t let us work with the object as it’s becoming never In action! Lots of helper types, but roughly 20 lines of code to get it right: Let’s see what TypeScript does: As said, this most likely won’t deal with all edge cases, but it’s a good start. And if you know what you’re dealing with, you can get very far. As always, there’s a playground for you to fiddle around. More articles about TypeScript Comments? Shoot me a tweet! Source: TypeScript: Assertion signatures and Object.defineProperty

    Read at 05:44 am, Feb 19th

  • Bloomberg's Civil-Liberties Record Is Disqualifying - The Atlantic

    Should Sunday’s apology make civil libertarians more favorably disposed toward a Bloomberg candidacy? No. Stop-and-frisk is not the only reason to worry about the former mayor’s paternalistic, coercive tendencies. Read: A Bloomberg presidential run comes down to one question Under Bloomberg, arrests rose steeply in New York City for marijuana possession. The city regulated trans fats, and barred the philanthropic donation of fresh bagels and other foodstuffs to the needy in homeless shelters because the salt, fat, and fiber content could not be assessed by city bureaucrats. When anti-war protesters wanted to assemble against the impending invasion of Iraq in 2003, New York City, “citing only vague security concerns, refused to grant a permit to march, allowing only a stationary rally and cramming attendees into a narrow penned area,” CityLab recounts. “Hundreds of thousands of protesters were unable to get within earshot.” And “for at least a year before the 2004 Republican National Convention,” The New York Times later reported, “teams of undercover New York City police officers traveled to cities across the country, Canada and Europe to conduct covert observations of people who planned to protest at the convention, according to police records and interviews.” Bloomberg favors the use of forcible seizure of private property by the government not only to build vital public infrastructure, but also to facilitate private development deals. Bloomberg called for the weakening of constitutional privacy protections after the Boston Marathon bombing. “We have to understand that in the world going forward,” he stated, “we’re going to have more cameras and that kind of stuff. That’s good in some senses, but it’s different than what we are used to. And the people who are worried about privacy have a legitimate worry, but we live in a complex world where you’re going to have a level of security greater than you did back in the olden days, if you will. And our laws and our interpretation of the Constitution I think have to change.” And he cannot be trusted to respect the civil rights of Muslims, as he illustrated after 9/11, when he presided over blatant religious profiling. Starting shortly after the attacks, officers infiltrated Muslim communities and spied on hundreds or perhaps thousands of innocents at mosques, colleges, and elsewhere. Peter Beinart: Elizabeth Warren couldn’t be luckier These officers “put American citizens under surveillance and scrutinized where they ate, prayed and worked, not because of charges of wrongdoing but because of their ethnicity,” the AP reported, citing NYPD documents. Informants were paid to bait Muslims into making inflammatory statements. The NYPD even conducted surveillance on Muslim Americans outside its jurisdiction, drawing a rebuke from an FBI field office, where a top official charged that “the department’s surveillance of Muslims in the state has hindered investigations and created ‘additional risks’ in counterterrorism.” Bloomberg defended the NYPD’s counterterrorism efforts as necessary to keep New Yorkers safe, yet “in more than six years of spying on Muslim neighborhoods, eavesdropping on conversations and cataloguing mosques,” the AP reported, “the New York Police Department’s secret Demographics Unit never generated a lead or triggered a terrorism investigation.” The police acknowledged, in court, having generated zero leads. Source: Bloomberg’s Civil-Liberties Record Is Disqualifying – The Atlantic

    Read at 03:37 am, Feb 19th

  • Mike Bloomberg just made the debate. Can he keep his cool?

    Mike Bloomberg’s free-spending campaign rollout has rocketed him into contention for the Democratic nomination — but he now faces a challenge immune to his fortune.

    Read at 02:03 am, Feb 19th

Day of Feb 18th, 2020

  • Don’t start your Sprint on Mondays - Max Sather - Medium

    Web server is returning an unknown error There is an unknown connection issue between Cloudflare and the origin web server. As a result, the web page can not be displayed. Ray ID: 567189decb89e71c Your IP address: 167.71.177.88 Error reference number: 520 Cloudflare Location: Newark Source: Don’t start your Sprint on Mondays – Max Sather – Medium

    Read at 04:57 pm, Feb 18th

Day of Feb 17th, 2020

    Day of Feb 16th, 2020

    • A Former Owner of Newsweek Pleads Guilty in a Fraud Scheme

      The Manhattan district attorney’s office seized 18 computer servers from the headquarters of Newsweek magazine in Lower Manhattan on Jan. 18, 2018. On Friday, the raid yielded guilty pleas to fraud and money-laundering charges from two publishing executives in Manhattan Criminal Court.

      Read at 04:37 pm, Feb 16th

    • Life on the slippery Earth

      When Halloween rolled around last year, my wife and I were prepared to be greeted by scores of eager trick-or-treaters. Guided by the thought that too much candy was better than too little, we bought entirely too much, and simply poured the excess on to a platter in our living room.

      Read at 02:16 am, Feb 16th

    • Border Patrol Will Deploy Elite Tactical Agents to Sanctuary Cities

      Agents from a special tactical team that normally confronts smugglers on the border are being sent to sanctuary cities across the country.

      Read at 02:01 am, Feb 16th

    • TypeScript: exhaustiveness checks via exceptions

      TypeScript supports exhaustiveness checking for enums and similar types. This blog post shows how to use idiomatic JavaScript for this kind of check. Can we also get static errors in TypeScript?

      Read at 01:56 am, Feb 16th

    • The MTA’s False Fare Evasion Narrative

      The MTA has been pushing a false fare evasion narrative. The narrative goes like this: fare evasion is on the rise, and there is no excuse for it. Fare evasion is costing the MTA inordinate amounts of money. The “problem” of fare evasion can be policed away.

      Read at 01:56 am, Feb 16th

    • Why do so many developers get DRY wrong?

      We’ve also looked at the reaction to various parts of the book, and discovered that we weren’t really communicating as well as we thought we were some of the ideas that we had. A classic one is DRY.

      Read at 01:42 am, Feb 16th

    • 7 really good reasons not to use TypeScript

      Everyone loves TypeScript. It “solves” many problems JS has, it is a “superset” of JS, it will make your code error-prone and pleasant to read. There are a lot of good reasons to use TypeScript, but I am going to give you 7 really good reasons not to. Wow.

      Read at 01:40 am, Feb 16th

    • Under Discussion: The Maintenance of Large Open-Source Projects

      Behind the Code got together with former Node.js core team member Bert Belder and creator of the JavaScript library Leaflet, Vladimir Agafonkin, to talk about what it takes to maintain large open-source projects. While at Node.

      Read at 01:38 am, Feb 16th

    • VA Democrats Kill Pro-Union Bill After Learning CEOs Oppose It

      Virginia isn’t for workers. Old Dominion is currently one of only three states to explicitly bar all public-sector employees from bargaining collectively.

      Read at 01:27 am, Feb 16th

    • Michael Bloomberg’s Campaign Suddenly Drops Memes Everywhere

      Mike Bloomberg has contracted some of the biggest meme-makers on the internet to post sponsored content on Instagram promoting his presidential campaign. The Bloomberg campaign is working with Meme 2020, a new company formed by some of the people behind extremely influential accounts.

      Read at 01:23 am, Feb 16th

    • The Bloomberg Campaign Is a Waterfall of Cash

      The billionaire has deployed his corporation in service of his presidential bid, producing slick events and recruiting staff members with unusually high pay and other perks.

      Read at 01:20 am, Feb 16th

    • Sanders Joins Trump in Telling the Media to Go to Hell

      Where are those medical records you promised to show us, NBC News’ Chuck Todd asked last weekend on “Meet the Press.“ Sen. Bernie Sanders sounded polite enough, as he exhaled a puffy cloud of obfuscation. It was not hard to translate Sanders’ word cloud: Go to hell, Chuck.

      Read at 01:04 am, Feb 16th

    • Biden Needs Black Voters to Lift His Campaign. But He Has Competition.

      Joe Biden is looking ahead to South Carolina to resurrect his candidacy. There are signs that it may be a bigger challenge after defeats in Iowa and New Hampshire. COLUMBIA, S.C. — Even before the final results from New Hampshire showed Joseph R. Biden Jr.

      Read at 12:34 am, Feb 16th

    • After Stone Case, Prosecutors Say They Fear Pressure From Trump

      The episode also brought to a head tensions in the U.S. attorney’s office in Washington.

      Read at 12:12 am, Feb 16th

    Day of Feb 15th, 2020

    • https://revolutionsperminute.simplecast.com/episodes/rank-and-file-socialism-and-the-struggle-for-democracy-in-the-workplace-w2jS2fCF

      Read at 09:52 pm, Feb 15th

    • Cancel Culture, or Capitalist Culture? | Many Peters⁶⁸

      Woke mobs and purity police... Is this really what "cancel culture" is? Why are we doing this stuff? Gutian's video: http://youtu.be/SPdB2YkSKSs Angie's video: http://youtu.be/qdDg8KYjePo--------subscribe, ring the bell, and/or become a patron @ http://patreon.com/petercoffinAshleigh's Joker video:

      Read at 09:29 pm, Feb 15th

    • Trump seeks to bend the executive branch as part of impeachment vendetta

      President Trump is testing the rule of law one week after his acquittal in his Senate impeachment trial, seeking to bend the executive branch into an instrument for his personal and political vendetta against perceived enemies.

      Read at 09:24 pm, Feb 15th

    • Episode 304: Straight Flush

      Nate and Andrew discuss the Commerce Casino, the new Encore Boston Harbor, and when to sit in the biggest game in the room. In the strategy segment, Hero rivers a straight flush, but is it strong enough to raise?

      Read at 09:22 pm, Feb 15th

    • TypeScript: exhaustiveness checks via exceptions

      TypeScript supports exhaustiveness checking for enums and similar types. This blog post shows how to use idiomatic JavaScript for this kind of check. more Pattern: exhaustiveness checks via exceptions   The switch statement in the following code is idiomatic JavaScript: NoYes { No = , Yes = , } { (x) { NoYes.No: ; NoYes.Yes: ; : UnsupportedValueError(x); } } Can we also get static errors in TypeScript? In line A, the inferred type of x is never because we have already taken care of all values that it can have. Therefore, we can instantiate the following exception in line A: UnsupportedValueError { () { ( + value); } } If, however, we forget one of the switch cases, then the type of x isn’t never anymore and we get a static error: { (x) { NoYes.Yes: ; : UnsupportedValueError(x); } } Another way of checking exhaustiveness   Instead of using a default case, we can also specify a return type. Then TypeScript warns us if we forget a case (because we implicitly return undefined): { (x) { NoYes.Yes: ; } } How does this approach compare to using an exception? Upside: less verbose Downside: no protection at runtime Can this pattern be used elsewhere, too?   This pattern works for: Enums Type unions Discriminated unions Source: TypeScript: exhaustiveness checks via exceptions

      Read at 03:04 pm, Feb 15th

    • Sections in source code

      In this blog post, I’ll briefly explain the idea of having sections in source code. The IDE Visual Studio Code has a related concept: folding regions. more Source code sections   In my code, I like to group related constructs – for example: Visual Studio Code: folding regions   Visual Studio Code supports folding regions. These are marked as follows: Alas, they only affect folding. There is an issue asking to display regions in the code outline, though. Source: Sections in source code

      Read at 02:56 pm, Feb 15th

    • Should You Ask Permission Before Reclining Your Airplane Seat?

      It is billed as the video which has the Internet "legitimately divided," as if the Internet is usually illegitimately divided: Wendi Williams was traveling from New Orleans to Charlotte on an American Eagle flight operated by American Airlines on Jan.

      Read at 02:41 pm, Feb 15th

    Day of Feb 14th, 2020

    Day of Feb 13th, 2020

    • PyOhio 2011: Names, Objects, and Plummeting From The Cliff

      The assignment statement is often the second thing a new Python programmer learns, right after the "print" statement - but the beginner can get seriously bogged down in all of the concepts that assignment involves! Using a simple analogy, this talk will tackle those issues head-on.

      Read at 03:02 pm, Feb 13th

    • Toward Responsive Elements

      In this piece I'll talk about the "Container Queries" problem, try to shine some light on some misconceptions, and tell you about the state of things. As developers, watching standards can be frustrating.

      Read at 04:23 am, Feb 13th

    • Bernie Sanders’ New Hampshire Victory Is a Big Deal for Socialism in America. Here's What to Know About the History of the Idea

      Bernie Sanders, the sole democratic socialist in the 2020 presidential race, came out on top in the Democratic Party’s primary in New Hampshire, winning about 26% of the vote. His victory followed a neck and neck race with former South Bend, Ind., mayor Pete Buttigieg in the Iowa caucuses.

      Read at 02:53 am, Feb 13th

    • Toward Responsive Elements | CSS-Tricks

      Hot news from Brian Kardell, regarding what we've been referring to as "container queries," the most hotly requested feature in CSS: There does seem to be some general agreement on at least one part of what I am going to call instead "Responsive Design for Components" and that is that flipping the problem on its head is better. The flipping here sounds like instead of doing it as media query, we do it at the property level. .foo { display: grid; grid-template-columns: switch( (available-inline-size > 1024px) 1fr 4fr 1fr; (available-inline-size > 400px) 2fr 1fr; (available-inline-size > 100px) 1fr; default 1fr; ); } I think this is still in the ideation phase, and other people are ideating as well on different ideas, but this seems worth sharing to me as it sounds like it has traction and is doable because it isn't plagued with well that's just not how browsers work that came up a lot with container queries. Brian also talks about "lightspeed progress" lately, for example: Consider that we shifted the stalemate conversation and ResizeObserver was envisioned, incubated, speced, tested, agreed upon, iterated on (we got things wrong!) and implemented in all browsers in about 2 years Two years is smokin' in standards. Direct Link → Source: Toward Responsive Elements | CSS-Tricks

      Read at 01:46 am, Feb 13th

    • A Thorn in YouTube’s Side Digs In Even Deeper

      Carlos Maza believes that YouTube is a destructive, unethical, reckless company that amplifies bigots and profits off fascism. Now it’s also his meal ticket.

      Read at 01:01 am, Feb 13th

    • It's Not a Clinic It's a Caste System

      Because I cover healthcare, and because I work for a website concerned with all the ways people try to separate women from their money, I’m often directed to clinics that say they are revolutionizing basic care.

      Read at 12:48 am, Feb 13th

    • The U.S. Military Is Not Ready for a Constitutional Crisis

      I spent nine years on active duty in the U.S. Navy. I served as an aircraft commander, led combat reconnaissance crews, and taught naval history. But the first thing I did upon joining the military, the act that solemnized my obligation, was swear an oath to support and defend the Constitution.

      Read at 12:02 am, Feb 13th