In a world of ignorance, knowledge is power

Here is a very well documented list of the facts on using masks to try to control transmission from the Association of American Physicians and Surgeons (AAPS): Mask Facts

And for those who like watching a video:

Why Face Masks DON’T Work, According To SCIENCE
by Ben Swann of ISE Media, July 15, 2020, on Facebook with useless fact checking

STUDY: Universal Masking in Hospitals in the Covid-19 Era (May 21, 2020, nejm.org)

“We know that wearing a mask outside health care facilities offers little, if any, protection from infection. Public health authorities define a significant exposure to Covid-19 as face-to-face contact within 6 feet with a patient with symptomatic Covid-19 that is sustained for at least a few minutes (and some say more than 10 minutes or even 30 minutes). The chance of catching Covid-19 from a passing interaction in a public space is therefore minimal. In many cases, the desire for widespread masking is a reflexive reaction to anxiety over the pandemic.”

A cluster randomised trial of cloth masks compared with medical masks in healthcare workers (Apr 22, 2015, nih.gov)

Posted in Health, Learning | Tagged | Leave a comment

Roasted Red Pepper Relish

Ingredients

3 red bell peppers
1 small or medium onion (red or yellow)
10 cloves of garlic
10 habaneros
olive oil
1 lemon
red wine vinegar
salt
pepper
(optional) greens: either cilantro, parsley or kale.

Directions

Clean produce. Peel the outside of onion. It’s OK to cut the onion into halves or quarters, as that can help peeling.

In a bowl, cover peppers, onion and garlic with olive oil. Salt and pepper. Cover the produce completely with the oil to protect it. Roast in the oven at 375F for 30 minutes.

TIP: Form a circle with the bell peppers, then pile the rest of the smaller ingredients in the middle. This prevents the the smaller ones, particularly the habaneros, from roasting faster than the big peppers.

You can let it cool before you handle it. Drain the water and remove the seeds from the peppers and remove any stems. If it is easy, remove the white parts the seeds cling to.

NOTE: It is critical you get all the seeds out or the lectins will give you the shits. Technically, it isn’t known to hurt you. But who wants to run to the bathroom every 10 minutes? This happens because your body can’t process lectins so goes into quick ejection mode.

Put the peppers, onions and garlic in your food processor. Add your greens. Dash in some red wine vinegar. Blend until desired consistency.

Toss the blended relish back onto the bowl where you had the olive oil so you don’t waste the extra that was at the bottom. Squeeze in the lemon. Stir well.

Enjoy! Refrigerate leftover portions. The vinegar and lemon will both give it flavor and help to preserve it longer.

How to Enjoy

There are a million uses for it. I’m looking forward to hearing how others use it. You can snack with it, add it to main dishes, spice up guacamole, and use in just about anything you want a little flavor in.

Here are some ways I’ve used it so far:

On homemade bread with mozzerella
pepper relish and fresh mozzerella on crackers

On baguette slices, pita bread, tortilla pieces, crackers or tostidos. You can add other things, too. While my favorite is on baguette slices, I can’t boast having fresh baguette on hand every day. It balances well with fresh mozzarella!

In a taquito! It is possible to make both the best tasting taquito and the healthiest taquito in the world AT THE SAME TIME! The pepper relish is the key.

Every taquito starts with a very generous portion of roasted red pepper relish:

My Chicken Taquito: Pepper relish, cheddar cheese, chicken and kale in a tortilla

Health Benefits

Onions, peppers and garlic are super foods! The list of benefits is long. One of the most important things they’ll do is boost your immunity, which impacts a lot of your overall health.

5 health benefits of red peppers

9 Impressive Health Benefits of Onions

13 Amazing Health Benefits of Garlic

Food Picture Porn

Red Bell Peppers
Onions
Covered in oil, ready for the oven
Out of the oven
Roasted Habaneros

Posted in Food | Leave a comment

Using Duration in Typescript

I’m converting Java 8 code to Typescript. Java 8 introduced a great Duration class that uses ChronoUnit to specify units such as DAYS or HOURS. You then instantiate a duration using that:

  Duration.of(3, SECONDS);
  Duration.of(465, HOURS);

Duration can then interact with LocalDateTime objects. To start, it can obtain a Duration from the difference of two times.

    Duration elapsed = Duration.between(startTime, endTime);

That gives us two ways to instantiate it. The latter can result in a conceptual combination, such as “3 days, 4 hours and 21 minutes” that the former method doesn’t result in.

We can also compare two durations to see which is greater:

boolean result duration1.compareTo(duration2) >= 0;

So how do we do that in Typescript?

Requirements

To summarize our requirements from our Java uses:

  1. Instantiate in time units, such a “6 weeks”. This would likely come from a human interface where a user is specifying a duration or interval.
  2. Calculate the difference between two dates and represent this in various usable forms, including human.
  3. Compare two periods to determine which is greater.

As long as we can convert a duration to milliseconds, it is easy to compare. This simplifies our last requirement. Likewise, if we can convert milliseconds to a duration object that has the capabilities we need, that solves requirement #2, since it is easy to calculate the difference of two Date objects:

diff = Math.abs(date1.getTime() - date2.getTime()); 

The issue we have is that not all human durations are easily translated into milliseconds. A month, for instance, is not a concrete block of time. It conceptually depends on a calendar. A duration of 5 months may simply require adding 5 to the month of a date, so that 5 months from Feb 5th is July 5th.

Leap years are another anomaly depending on the calendar so that not all years have the same number of days.

You really have to decide how these fit into your requirements for your application. I’ve chosen to treat them as bonus features in my case rather than core requirements.

NPM Libraries

duration (https://www.npmjs.com/package/duration)

This works great for calculating the difference of two Date objects. You then have the ability to view the result as either a total of any given unit, or as human breakdown, such as:

10y 2m 6d 3h 23m 8s 456ms

Because we can convert to total milliseconds, we can compare two durations.

This solves requirements #2 and #3, but does not provide a solution for requirement #1. It seems you can only instantiate from the differences between two dates.

to-time (https://www.npmjs.com/package/to-time)

This library meets our first requirement, the ability to instantiate with time units. It also allows us to convert to another unit easily:

toTime('1 hour').seconds(); //3600

You can even add up various units:

toTime('1 Year 365 Days 4 Hours').hours(); //17524

While it can’t calculate the difference between dates, you could calculate the milliseconds between dates, and then use that to create a time frame instance:

const frame = toTime.fromMilliseconds(500005050505005);

And, of course, since you can convert any time frame to milliseconds, you can compare two.

Together, this technically meets our 3 core requirements.

duration-converter (https://www.npmjs.com/package/duration-converter)

This also has the ability to instantiate from both number of units and difference between dates:

const sevenWeeks = new Duration('7 Weeks');
const threeDays = Duration.fromDays(3);

const a = new Date(2019, 3, 14);
const b = new Date(2019, 3, 15);
const betweenDates = Duration.between(a, b);

Because you can convert a duration to milliseconds, you can effectively compare two durations. This meets all 3 requirements.

The creator put a warning on the NPM module page that leap years are ignored as all years are treated as 365 days.

date-period (https://www.npmjs.com/package/date-period)

This looks promising. But, the documentation is lacking. It says it mimics PHP’s DatePeriod class. If you are a PHP programmer, you might find it useful.

@js-joda/core (https://js-joda.github.io/js-joda/manual/Duration.html)

NOTE: I completed this blog post, used date-converter for Duration, then realized in the next class I converted I also needed LocalTime. Only then did I discover this class, making this an update to this post the next day.

This appears to meet all the requirements because it is basically the same as the set of temporal classes added to Java 8 because Joda-Time was the original Java library that was adopted as the standard in Java 8, and js-Joda is a Javascript implementation of it.

According to a 2018 GitHub Issue, they changed it a little to be compatible with Typescript.

Summary

In the end we have three NPM modules that can meet our requirements. The to-time and duration-converter libraries do work, albeit with limitations and creativity. However, js-joda appears to be a complete solution if you are porting Java 8 code.

Posted in Angular, Development, Technology, Typescript | Tagged , , , , | Leave a comment

Using FirewallD as a Linux Router

There are already blogs out there on how to use FirewallD as a router. In general, you enable masquerade. However, I could not find any that mentioned how to do it if you have public static IPs.

Prior to using FirewallD, I used iptables for over a decade without an issue. Once FirewallD was setup correctly on a new Internet router on Centos 7, I haven’t had any issues. It has been running rock solid.

There were some lessons I had to learn the hard way due to the lack of documentation both on the blogs on using it as a router and via FirewallD documentation itself.

Presuming you have two zones labeled external and internal, your first step is to enable masquerade for your external zone.

firewall-cmd --zone=external --add-masquerade --permanent

The tricky part was what to do with the internal zone. If you run the same command on it, it will initially appear to run fine. The problem with it is how the IP addresses appear on your servers, which can quickly snowball into a huge problem with security.

The problem that I ran into is that I ran my email server for a week as an open relay and didn’t realize it until my outgoing email was getting rejected due to being blacklisted as a spammer. When I traced the issue, it was because every connection to it appeared to be coming from the internal IP address of my internet router (firewalld), which it trusted. Before you know it, you’re a spam sender for Russian bots.

But, if you don’t enable masquerade on internal, you will be the only one who can’t get to your servers via their public IP addresses. The rest of the world gets routed OK. You get on the Internet OK. You can access your servers via their internal IP OK. But, if you access yourpublicdomain.xyz (pointing to one of your public IPs) from inside your network, your router won’t route you.

It turns out there is a very happy place in the middle using the add-rich-rule option. Let’s say your private subnet that your Internet router is a part if is 10.10.5.0/24, you would simply issue this command:

firewall-cmd --permanent --zone=internal --add-rich-rule='rule family=ipv4 source address=10.10.5.0/24 masquerade'

This enables masquerade for your internal zone ONLY for traffic originating from inside your network. Now you can reach yourpublicdomain.xyz from inside your network without a problem. Meanwhile, if you check your server logs, they are all seeing the correct public IP of outside traffic, and can require SMTP authentication or apply whatever other security protections you have for untrusted sources.

Forwarding ports

It’s pretty simple. Note that you need to do it on your internal as well as your external even if your destination address is public. So, presuming you were running a web server on public IP 1.1.1.1 that is on your local 10.10.5.51, you would forward ports to it with the following commands:

firewall-cmd --permanent --zone=external --add-rich-rule='rule family=ipv4 destination address=1.1.1.1 forward-port port=80 protocol=tcp to-port=80 to-addr=10.10.5.51'

firewall-cmd --permanent --zone=internal --add-rich-rule='rule family=ipv4 destination address=1.1.1.1 forward-port port=80 protocol=tcp to-port=80 to-addr=10.10.5.51'

You’d repeat that for port 443 to support SSL.

Note that because you are using rich rules, you can easily limit access to internal only for something like SSH via a public IP (and your domain):

firewall-cmd --permanent --zone=external --add-rich-rule='rule family=ipv4 source address=10.10.5.0/24 service name=ssh destination address=1.1.1.1 log prefix="SSH Access" level="notice" accept'
Posted in Networking, Technology, Technology Services | Tagged , , , , , , | Leave a comment

Creating a new Angular Site on Google Firebase

Angular is a framework for creating front-ends for websites. Technically, the site is static from a web hosting perspective, meaning that in and of itself it does not have a database, but rather only serves static files from the web server. From a user perspective, it can appear to be very dynamic, with the ability to log in, create and work with data, and other normal web application behaviors.

The dynamic portions of an Angular app require integration with back-end services. Angular apps simply call out to these external services, and are not typically a part of providing the services.

The creation of these services is both out of scope for angular and out of scope for this tutorial. Instead, we’ll create a very simple static website with Angular and deploy it to Firebase.

Firebase is a set of services provided by Google. One service is hosting, which primarily hosts static websites such as those created with Angular. Google offers a free tier that allows you to get a site up and running quickly and easily.

Prerequisites

You have the following installed:

  • Node 10+ (node -v)
  • NPM 6+ (npm -v)
  • Angular CLI 8+ (ng --version)
    howto

Create Angular app

In the folder where you want to create the app, run

ng new <your-app-name>

It will ask you questions. If you are not sure what answer to choose, you can use the defaults. Routing allows you to have URLs that point to pages, which technically simulates multiple pages even though it is still a “single page” application. This is useful if you have menu navigation. The CSS options allows you to use CSS templates to add functionality.

Launch your app:

npm start

Open in your browser: http://localhost:4200/

You can now edit the src/app/app.component.html file to make it your own. When it looks good, build it for production.

ng build --prod

This creates static output in a dist folder in your project. This is what we’ll deploy to Firebase.

Deploy to Firebase

Use your Google account to log into firebase.google.com. Then click on “Go to console” in the top right. Create a new project and give it a name. Now you can come back to the console and drill into your project at any time.

Intall Firebase on the computer with your Angular project with the following command. This will update it if you already have it installed. Prefix with sudo if it fails with permission errors without it.

npm i -g firebase-tools

You will primarily use the command firebase to interact with it. You can use these commands to log into and out of a Google account:

firebase login
firebase logout

While in your project’s root directory, run

firebase init

This will fire off options to choose from. Begin by selecting Hosting. Select existing project if you created via the web console, or new otherwise. For your public directory, look in your dist folder. if it created another folder under it for your project, then you’ll include that. Let’s say your project is called helloworld, your public folder would be:

dist/helloworld

You can choose single page app since that is what Angular created.

Once it is done setting up the project, your process for deploying to Firebase will be to do a prod build to repopulate the dist folder, then to run a Firebase deploy command:

ng build --prod
firebase deploy

Posted in Angular, Development, Technology, Web | Tagged , , , , | Leave a comment

Protected: The Super Rich, News and Profits

This content is password protected. To view it please enter your password below:

Posted in Uncategorized | Enter your password to view comments.

Using JSONP in Angular 8

JSONP is one way to get around CORS when getting data from a REST service. It does require a callback feature on the part of the service, which isn’t readily clear in some of the blogs and samples online for JSONP. With or without JSONP, the server side has the ability to disable CORS. This could be useful if a service you want to call, and cannot modify, supports JSONP.

If you are adding support for it in your rest, you’ll be checking for a callback parameter, which we’ll make “callback” in this example. If your REST is in Java, you’d include this parameter:

@QueryParam("callback") String callback

Then your output might look like this:

if (callback != null) {
  out.append(callback).append("(");
}
out.append(data);
if (callback != null) {
  out.append(");");
}

In your component’s module, you’ll need to add this to your @NgModule imports:

HttpClientModule,
HttpClientJsonpModule,

imported with

import { HttpClientJsonpModule, HttpClientModule } from '@angular/common/http';

The odd thing I discovered was that you need HttpClientModule in your component’s module even if it is already declared in your application module. This isn’t very logical because the HttpClient worked just fine in my components with this only being in app.module.ts. But, when I tried to use JSONP, I kept getting this error in the JavaScript console:

Error: “Attempted to construct Jsonp request without JsonpClientModule installed.”

Yeah, I’m writing this blog to hopefully save another poor soul the torture of trying to connect those dots. I couldn’t find that error anywhere on the Internet; and, with HttpClient working just fine in the same component without JSONP, why do you need HttpClientModule in your submodule just for JSONP?

In your Angular service or component, you’ll then be able to use JSONP to call your service:

  this.http.jsonp(url, 'callback')
    .pipe(
      catchError(this.handleError('jsonpTest', 'ERROR')),
    ).subscribe(data => {
      this.log('data: ' + JSON.stringify(data));
    });

That second parameter in your jsonp call is the name of the parameter it will pass to the back-end. The value of that parameter passed to your service will be defined by JSONP.

Posted in Angular, Development, Technology, Web | Tagged , , , | Leave a comment

Channels On Charts Need Log Scale

Log scale is an option you can turn on when doing most financial charting.  Your software may default to off, so you need to check this.  You should really have log scale on your trading and investing charts all the time.  However, the case where you really need to have it is long-term trends and channels

The reason is simple.  If you look at when NVDA doubled from $20 on, it is 40, 80, 160 and, if it made it, 320.  So if you invested $10k at $80, you got the same 100% return on investment that you obtained when it went from $20 to $40.  In other words, in capital markets, it is percent return on investment that matters, or growth.  Not actual dollar amounts of individual stocks.  You only care how much your $10k will make. 

If you don’t use log scale, it will appear as though trends shoot up like a rocket, as it might go from $80 to 160 in the same amount of time it went from $20 to $40.  This creates a false breakout.  You won’t know if something truly breaks above the channel top unless you are using log scale to smooth it out into percent gains. 

So, here is a chart of NVDA with log scale enabled.  A nice clean channel.  You can see via weekly bars when it broke, and you can see the result.   Down down down.  Some people will note the market tanked during this time.  But isn’t that really a chicken and egg herring?  You have FB and NVDA breaking their channel, and plunging as a result.  Doesn’t this contribute the velocity of the market drop, especially with correlations? 

Now, look at this same chart where the only difference is log scale is disabled:

Looks very different.  You might of had some sort of channel for the past year, but not over this larger time frame going back to 2015.  A move from 20 to 300 is 15x.  investors from 20 to 160 quadrupled their investment, while those jumping in at 150 no more than doubled it. 

To understand it clearly, look at the distances between the prices on the Y axis.  With log scale, 20 and 40 are a lot further apart than 260 and 280, despite both being $20 differences.  If you bought at 260 and sold at 280, did you double your money? Or was it a smaller move for you than the one who bought 20 and sold 40? 

 

 

 

Posted in Finance, Investing, Trading | Leave a comment

SPX 2009 Channel Bottom Touched – First In 2018

On Friday, Oct 27th, 2008, SPX touched it’s 2009 channel bottom near 2630 for the first time since Feb 2016!  Predictably, it bounced over 60 points before coming back down.  First touches are nearly always bought hard. 

Being a Friday, when you have weekly close, it is unlikely it would close below 2630.  It just doesn’t do that on a bull run channel bottom on first touch in years.  But that doesn’t preclude the possibility of it testing that low, and possibly lower, as early as Monday.  Measured move targets on multiple time frames are at 2606 and 2601.  That will likely be bought.  But, in case it goes lower, the weekly 100 SMA on SPX is 2675.  Then, of course, you have the prior Feb low near 2532. 

If we hit a bottom this week, and it reverses, then what?  Good question.  The number of weeks between tests of the bull run channel low have ranged from 4 weeks in 2016 to 13-14 weeks in prior bull runs.  Keep in mind that every time is different, though, so this is a guide, not a guaranteed outcome. What’s behind this one, in addition to rising rates, is the simultaneous $75b of US treasuries being sold by the US Treasury (UST) per month to finance our budget deficit, as well as $50b of US treasuries being sold by the Federal Reserve Bank (FRB) as part of their balance sheet reduction, aka Quantitative Tightening (QT), as well as who knows what else they are selling.  This last part is unprecedented.

$75b per month is high enough.  Usually the FRB is buying some of those.  But, now, instead of buying, the FRB is selling, bringing the total to a historically high $125b per month!

That said, let’s look at what happened in 2016. 

In 2016, it did a perfect 50% touch before going down.  In SPX, a perfect touch is within 1 point.  Then it went back down to test the low.  Then up up up and away. 

Now our current 2018 setup puts half way back (HWB) at 2784. 

Keep in mind, though, that the bottom before going up may not be in, yet.  Monday can easily put in a lower low and hit our target of 2606.  In that case, we’ll need to redraw this fib set to locate our new HWB, lower than 2784. If we our new low is 2606, then HWB becomes 2772.93. 

The point is, based on prior first touches of channel bottom, this is a buy for a HWB run up.  If we get a weekly open significantly below this channel bottom, like below 2600, then it’s game over, and you’ll look to get out, ideally for a small profit.  But risk/reward is very much in your favor down here.  You can’t get a much better swing low setup long.

Here’s the big picture 2009 bull channel:

 

Posted in Finance, Investing, Trading | Leave a comment

Big Brother Watch Update, Aug 2018

Censorship

Google helps China control citizens

Dragonfly

Copyright is the new poster child for censorship in EU

New Copyright Powers, New “Terrorist Content” Regulations: A Grim Day For Digital Rights in Europe

 

 

Posted in Uncategorized | Leave a comment