Tech News

NYC launches cyberdefense center amid major ransomware attacks

Amid growing ransomware attacks, New York City is the first major metro region in the US to launch a cyberdefense center, one that is, in this case, located in a Manhattan skyscraper. A mix of private and government entities are working together to help prevent similar future cyberattacks, including everything from Amazon to the NYPD.

The new cyberdefense center represents an evolution of the fully virtual New York City Cyber Critical Services and Infrastructure initiative, according to the Wall Street Journal. The new cyberdefense center has 282 partners that will work together to illuminate possible cybersecurity threats, helping protect the city and its critical infrastructure.

The new center is the result of years of talks and effort, according to the report — an effort that first led to the aforementioned online project launched in 2019. The growing number of ransomware attacks prompted the evolution in this initiative, better positioning the major metropolitan region to prevent and address cyberattacks that may threaten major businesses, financial hubs, and city infrastructure.

The report reveals that the cyberdefense center has already conducted their own version of “war games” at an IBM cyber range for practice using various systems to address cyberattacks. Likewise, the collective shares data amongst themselves whenever a cyberattack, such as ransomware, occurs anywhere in the US in order to ensure it doesn’t spread into the city.

The announcement comes only weeks after the Colonial pipeline ransomware attack, which resulted in gas shortages in parts of the US. Though the cyberattack was eventually resolved, it required the company to pay a substantial ransom, only part of which was later recovered by the federal government.

Hospitals have likewise been hit with ransomware attacks that lock down their systems — in one particularly large case in Southern California, hospital officials were forced to switch to paper-based records and communication, severely limiting their ability to treat patients. Such attacks have the potential to shutdown large sectors of the US, representing a major threat to the nation.

Repost: Original Source and Author Link

Tech News

Decorators in Python will make your code so much better

If there’s one thing that makes Python incredibly successful, that would be its readability. Everything else hinges on that: if code is unreadable, it’s hard to maintain. It’s also not beginner-friendly then — a novice getting boggled by unreadable code won’t attempt writing its own one day.

Python was already readable and beginner-friendly before decorators came around. But as the language started getting used for more and more things, Python developers felt the need for more and more features, without cluttering the landscape and making code unreadable.

Decorators are a prime-time example of a perfectly implemented feature. It does take a while to wrap your head around, but it’s worth it. As you start using them, you’ll notice how they don’t overcomplicate things and make your code neat and snazzy.

Before anything else: higher-order functions

In a nutshell, decorators are a neat way to handle higher-order functions. So let’s look at those first!

Functions returning functions

Say you have one function, greet() — it greets whatever object you pass it. And let’s say you have another function, simon() — it inserts “Simon” wherever appropriate. How can we combine the two? Think about it a minute before you look below.

The output is 'Hello, Simon!'. Hope that makes sense to ya!

Of course, we could have just called greet("Simon"). However, the whole point is that we might want to put “Simon” into many different functions. And if we don’t use “Simon” but something more complicated, we can save a whole lot of lines of code by packing it into a function like simon().

Functions inside other functions

We can also define functions inside other functions. That’s important because decorators will do that, too! Without decorators it looks like this:


The function respect() returns a function; respect("yes") returns the congrats function, respect("brother") (or some other argument instead of "brother") returns the insult function. To call the functions, enter respect("yes")() and respect("brother")(), just like a normal function.

Got it? Then you’re all set for decorators!

The ABC of Python decorators

Functions with an @ symbol

Let’s try a combination of the two previous concepts: a function that takes another function and defines a function. Sounds mind-boggling? Consider this:


The last line ensures that we don’t need to call startstop(roll)() anymore; roll() will suffice. Do you know what the output of that call is? Try it yourself if you’re unsure!

Now, as a very good alternative, we could insert this right after defining startstop():

This does the same, but glues roll() to startstop() at the onset.

Added flexibility

Why is that useful? Doesn’t that consume exactly as many lines of code as before?

In this case, yes. But once you’re dealing with slightly more complicated stuff, it gets really useful. For once, you can move all decorators (i.e. the def startstop() part above) into its own module. That is, you write them into a file called and write something like this into your main file:


In principle, you can do that without using decorators. But this way it makes life easier because you don’t have to deal with nested functions and endless bracket-counting anymore.

You can also nest decorators:

Note that we haven’t defined exectime() yet, but you’ll see it in the next section. It’s a function that can measure how long a process takes in Python.

This nesting would be equivalent to a line like this:

Bracket counting is starting! Imagine you had five or six of those functions nested inside each other. Wouldn’t the decorator notation be much easier to read than this nested mess?

You can even use decorators on functions that accept arguments. Now imagine a few arguments in the line above and your chaos would be complete. Decorators make it neat and tidy.

Finally, you can even add arguments to your decorators — like @mydecorator(argument). Yeah, you can do all of this without decorators. But then I wish you a lot of fun understanding your decorator-free code when you re-read it in three weeks…

Applications: where decorators cut the cream

Now that I’ve hopefully convinced you that decorators make your life three times easier, let’s look at some classic examples where decorators are basically indispensable.

Measuring execution time

Let’s say we have a function called waste time() and we want to know how long it takes. Well, just use a decorator!

A dozen lines of code and we’re done! Plus, you can use measuretime() on as many functions as you want.

Sometimes you don’t want to execute code immediately but wait a while. That’s where a slow-down decorator comes in handy:

Calling wakeup() makes lets you take a 5-minute break, after which your console reminds you to get back to work.

Testing and debugging

Say you have a whole lot of different functions that you call at different stages, and you’re losing the overview over what’s being called when. With a simple decorator for every function definition, you can bring more clarity. Like so:

There is a more elaborate example here. Note, though, that to understand that example, you’ll have to check how to decorate functions with arguments. Still, it’s worth the read!

Reusing code

This kinda goes without saying. If you’ve defined a function decorator(), you can just sprinkle @decorator everywhere in your code. To be honest, I don’t think it gets any simpler than that!

Handling logins

If you have functionalities that should only be accessed if a user is logged in, that’s also fairly easy with decorators. I’ll refer you to the full example for reference, but the principle is quite simple: first, you define a function like login_required(). Before any function definition that needs logging in, you pop @login_required. Simple enough, I’d say.

Syntactic sugar — or why Python is so sweet

It’s not like I’m not critical of Python or not using alternative languages where it’s appropriate. But there’s a big allure to Python: it’s so easy to digest, even when you’re not a computer scientist by training and just want to make things work.

If C++ is an orange, then Python is a pineapple: similarly nutritious, but three times sweeter. Decorators are just one factor in the mix.

But I hope you’ve come to see why it’s such a big sweet-factor. Syntactic sugar to add some pleasure to your life! Without health risks, except for having your eyes glued on a screen.

This article was written by Rhea Moutafis and was originally published on Towards Data Science. You can read it here

Repost: Original Source and Author Link

Tech News

Starlink teardown reveals how SpaceX keeps its secrets

A new Starlink teardown has revealed fresh details about SpaceX’s satellite internet dish, including how the company prevents its development hardware from being misused. Launched last year, Starlink relies upon both a growing constellation of satellites in orbit around Earth and an auto-positioning dish on the ground that communicates with them.

The satellite network has been a work-in-progress for SpaceX, with multiple launches of its Falcon 9 rockets adding to the mesh. As that happens, gaps in Starlink coverage have been filled, and more users added to the system.

On the ground, Starlink uses a custom satellite dish that links with a special router. Configured using the Starlink app, it’s designed to automatically move so as to keep the constellation overhead at the optimal angle. However, it has also proved to be a source of fascination among those curious to see what Elon Musk’s company have squeezed inside.

One such group is the Computer Security and Industrial Cryptography (COSIC) research team at KU Leuven, which acquired a Starlink system when it launched in Belgium at the end of May. Researchers there wasted no time in opening up the dish for a teardown, and then extracting the software for further analysis.

They came across some interesting tidbits along the way, not least the fact that SpaceX has clearly been iterating on its core dish design already. The COSIC Starlink hardware differs from what has been seen in prior teardowns, and there are some differences in connectors. Elon Musk recently said that the company is working on halving the cost of building each Starlink dish, since right now SpaceX is losing money on them.

What’s particularly curious is how SpaceX keeps those development systems from getting out into the wild. “Development hardware is geofenced to only work in certain predefined areas, most of which are clearly SpaceX locations,” COSIC’s Lennert Wouters explains. “SpaceX is likely notified if development hardware is used outside these predefined geofences.”

It’s not the only control on getting too much access to the underlying systems. The software exploration also revealed that SpaceX has prevented users from logging in to the live system, by including a check during boot to see whether the hardware has been fused or not. Consumer dishes are fused before they’re shipped, and so the login prompt is disabled.

While hacking a Starlink dish is probably a bad idea – almost as much as mounting one on the hood of your car, in fact – it’s interesting to see the amount of work that has gone into building the system. It’s certainly cost SpaceX no small amount, with Musk suggesting that it could be $5-10 billion in investment before Starlink is fully cash flow positive. As well as the improvements in the pipeline for the Starlink dishes, currently SpaceX is working on the v1.5 satellites – with laser-based links in-between each satellite – and then the v2.0 update sometime in 2022.

Repost: Original Source and Author Link

Tech News

Watch the Moon, Mars, and Venus form a celestial conga line on July 12

Early on the evening of Monday, 12 July, a thin crescent Moon will be seen low on the horizon, just after sunset. Just half a degree below and to the right of our planetary companion, Venus and Mars — the two closest planets to Earth, will shine in the twilight.

This is a perfect time for families to venture outside, viewing the wonders of the night sky.

“I’m NOT a Star” — Venus

Venus is often called the morning star, or evening star (depending on when the planet rises and sets), due to the fact it is seen near the Sun — in the east at dawn, and west at sunset.

The evening of 12 July is a perfect example of Venus as the evening star.

This planet, roughly the size and mass of the Earth, is home to a hellish landscape of scorching temperatures, a poisonous atmosphere, and sulfuric acid rain.
“In June, NASA announced that two new space missions would be heading to Venus beginning later in the decade. VERITAS and DAVINCI+ will investigate the planet’s surface and atmosphere, returning incredible images, maps, and other data, likely rewriting our understanding of how Earth’s sister planet became so inhospitable, along with how it might still be active today. They’ll be joined by the European spacecraft EnVision, for what’s sure to be an exciting new chapter in solar system exploration,” NASA describes.

“Better Red than Dead — Eat THAT, Pluto!” — Mars

Credit: The Cosmic Companion