Monday, July 31, 2017

July Queso

  1. TechCrunch has a bunch of tech news! TechCrunch Disrupt is a conference these guys put on. I only know about this from watching that Silicon Valley TV show.
  2. Midway Games which did Ms. Pac-Man is no more.
  3. www.visualstudio.com/vs/visual-studio-express has the Visual Studio Community Edition which does not require a license.
  4. IntelliJ IDEA is the IDE that JetBrains offers. Eclipse is a different Java IDE. NetBeans is a Java IDE too. One of the criticisms I've heard of the Java space is that there are too many ways to do things and this would an example of that.
  5. There used to be the concept of shadowing sessions in PC LANs. An administrator could watch the desktop of particular user without them knowing about it. This didn't really work because the victim's computer ended up running with a bunch of lag giving away that something was wrong.
  6. FoxPro (or perhaps Visual FoxPro) is some archaic language that is out of vogue. Its heyday was a dozen years ago. PHP survived Hurricane Katrina. This didn't.
  7. Marissa Mayer, the once CEO of Yahoo! which got bought by Verizon "Can you hear me now?" Communications, should probably really be remembered for Google Maps (and maybe Gmail). Before Google Maps everyone used MapQuest. Remember them? They have been bought out by Aol (formerly America Online) just like Netscape and are about as relevant anymore as is Netscape. The entire time I used MapQuest they never innovated. They were just kinda stale and stagnant.
  8. Carly Fiorina oversaw the buyout of Compaq when she was CEO of HP (Hewlett-Packard). Meh.
  9. I'm not going to do the surveys for Chili's or FedEx Office. Stop torturing your clientele with this stuff guys.
  10. Visual Studio Team Services has ways to share code and plan. You can manage scrum boards and Agile tools, etc.
  11. TMZ supposedly stands for thirty-mile zone in a reference to a bunch of Hollywood movie studios that are within a thirty mile expanse of LA (Los Angeles, California). It is some sort of celebrity gossip news organization and the term TMZ has become it's own animal in a more general sense vaguely conveying gossip and sleaze and the like.
  12. Hangfire looks to be a tool for "background processes" in .NET Core applications. Instead of having a windows service run what were referred to as cron jobs in FreeBSD gunk a dozen years ago (i.e. processes that get triggered at a specific time daily or weekly without a human pressing a button) or using Windows Task Scheduler you could, I suppose, use Hangfire now. I hear you may set it to ping an API endpoint X number of times before compensating... however it might... etc.
  13. Adobe InDesign is software for desktop publishing.
  14. Type "flip a coin" at Google to virtually flip a coin.
  15. Trellian SubmitWolf is a tool to register your web sites with search engines!
  16. The Go programming language of Google may be referred to as golang.
  17. If you were to graph my confidence whenever I'm looking for a job it would make a U shape. I start out really confident and obviously I'm back to being confident again when I finally get a job offer, but there is a dip in the middle. It basically takes me about a month to start working again once the floor falls out from under me. I haven't been out of work for two full months since 2002.
  18. I don't see any way to change the home page in Safari on my iPad. The true home page is just an empty browser pane. I just destroyed my history to make a sinister site that had been reappearing stop appearing when I opened the browser. The ability to do that is in the Settings for Safari. I'm using iOS 10.3.2 by the way.
  19. QWERTY is name for the standard way keys are laid out on a keyboard. It's named for the first six letters that appear left to right. The layout will supposedly make the most common letters the easiest to reach quickly. The Q, the most obscure English letter, for example, is only reached by moving one's left pinky upwards.
  20. "Elevated Mode" implies running Visual Studio 2017 as Administrator.
  21. You may pick songs or even one song and then make a Pandora station around them on Pandora. In doing so Pandora's algorithm will crawl outwards to find different things to recommend and it will suggest things for you to thumb up to keep to hear again. If you never thumb up anything it will keep finding new things in an attempt to placate you. Don't let it placate you. Dangle the carrot of affirmation just out of grasp of the codependent and have a laugh at its expense.
  22. webhookapp.com captures API requests for... I dunno... logging or the like I suspect.
  23. Google Play is something akin to Pandora or Spotify.
  24. cloudmailin.com turns inbound mail into POSTs to REST endpoints at your apps!
  25. Full Stack Developer as a term kinda implies someone who can work on the frontend and backend both of an application and all grey areas in between, database up to CSS styles.
  26. As of this month, Uber now has a way for you to tip through their app.
  27. Amazon Prime is a paid subscription that makes stuff on Amazon cheaper. It is one of those things that is only worth it depending upon how much you use it to get your money's worth. Prime Day is a day for deals to be had for Amazon Prime account holders, more deals than usual that it.
  28. In the JavaScript space... where there is no compiler safety... when you merge against someone else's rearrangement of an object that you need and end up with breaking changes... well, that is a rare example of a moment in which I actually crave the o of SoLID principles.
  29. dist is going to be short for distributed or distribution - In an app I'm working on there is a CI build process to build JS from TypeScript to a "dist" folder making "dist" files.
  30. nepotism is the practice of showing favoritism towards friends and loved ones and this materializes all the time in the tech sphere as people give jobs to people they know (In many ways this is not unfair if you think of the drought. There are is more work to be done in code than there are people who can write code so if you know someone who might be a fit for your open position they may not have any competition when interviewing. Are there even any other candidates to prefer your friend over? If not, are you even doing anything wrong by working every angle you can to fill a seat?)
  31. If you declare a bunch of characters like [-_+.a-zA-Z0-9]+ to maybe match in RegEx I kinda think the hyphen needs to go first. I have put the underscore before the hyphen before and it wasn't pretty.
  32. A skimmer attached to an ATM card reader at its "mouth" will pass on your credit card information while keeping it for itself.
  33. LINE is some app for free calls/messages.
  34. A punch card was a paper card full of holes that held instructions in programming up until the 1960s and vacuum tubes controlled the flow of electricity in 1940s and 1950s programming giving way to transistors around the time punch card fell out of fashion.
  35. Jelly is some thing wherein a bunch of people from different jobs get together in a common space and work side by side in the name of pseudooffice social butterflydom.
  36. Facebook now owns the Oculus.
  37. As best as I can tell, Cisco WebEx meeting will not show my name to others if I give a name with a space in it. No, that's not true. I also didn't work with the name TOMJAESCHKE even though CANYOUSEEMYNAME works.
  38. When database records contain bytes blobs for files and you "update" a file should you destroy the only record or just leave it orphaned, unassociated with the metadata at a different database table that loops it into the application?
  39. the Wayback Machine lives at: http://web.archive.org
  40. Maybe the word "please" should come out of validation error messages. These are really not options.
  41. Microsoft Planner ...is a planning application.
  42. Friendster was the thing like Myspace and Facebook before Myspace and Facebook.
  43. Discord is an app for mobile chat, like for two individuals who are gaming together with headsets in different homes.
  44. Twitch is now owned by Amazon.
  45. DbUpdateException is an explicit type of exception thrown by an Entity Framework DbContext in C#.
  46. You may use react.js in tandem with the new Angular! Redux (for JavaScript state management) and NGRX (for Angular-specific JavaScript state management) tie into that, I think.
  47. Best Buy credit cards come with a ridiculous interest rate of like twenty-four or twenty-five percent, but this rate is shelved for a few months on items actually purchased at Best Buy itself! There is a long window of no interest in these cases. (like six months)
  48. In a double-blind study both the testers and the tested do not know which drugs are real and which are sugar pills.
  49. While in-ear headphones get jammed deep into the ear like ear plugs, earbuds, in contrast, utilize the tragus and and other protusions around that waxy hole into your head to stay in place.
  50. The Iron Yard is a school that teaches people to code.
  51. A pick list is a grocery list of items to pull from your inventory for order fulfillment.
  52. A toaster component is going to give you popup messages.

sorting collections in TypeScript

whatever = whatever.sort((yin, yang) => {
   if (yin.label > yang.label){
      return 1;
   }
   if (yin.label < yang.label){
      return -1;
   }
   return 0;
});

Sunday, July 30, 2017

some notes on the template-driven approach to forms in Angular 4 applications

  1. This is the alternative to reactive forms.
  2. <form action="/action_page.php" method="post"
       enctype="application/x-www-form-urlencoded">
    is an old school example of a form tag. None of these inline settings will be present in a form tag at a template-driven form.
  3. import { FormsModules } from '@angular/forms'; needs to go at the top of the module wrapping a component that will use a template-driven form and the module needs to spec FormsModules at imports.
  4. Each element inside a form must be registered. Give the tags name attribute settings and put ngModel inline at any one element, perhaps with no banana box around it.
  5. <form (ngSubmit)="onWhatever(f)" #f>
    ...is an example of a form tag that would trigger the onWhatever event when a button within it that was of type="submit" was clicked. On the TypeScript side you could loop in this...
    import { ElementRef } from '@angular/core';
    ...and then have some sort of something like this...
    onWhatever(myObject: ElementRef): void {
    ...however the ElementRef here may prove frustrating to work with. A suggested revamp of this is:
    <form (ngSubmit)="onWhatever(f)" #f="ngForm">
    ...and...
    import { NgForm } from '@angular/forms';
    ...and, yes...
    onWhatever(myObject: NgForm): void {
    ...allowing one to inspect myObject.value to see key/value pairs for the form fields designated. The name attributes hydrate the keys.
  6. myObject.controls will have an object wherein each of the parameters holds a FormControl for each registered element. A FormControl will have more details, like dirty, etc.
  7. @ViewChild('f') myObject: NgForm; as a variable in a component would be another way to have at the local reference if you didn't want to pass it in ngSubmit
  8. putting required inline at an input tag will allow for some validation in the template-driven paradigm and putting email beside it furthermore validates for an email address ...This ends up changing the true or false state of the valid setting of the given FormControl and also the valid setting overall at the form, big picture. Classes like ng-dirty, ng-touched, and ng-valid get conditionally applies to form controls and, as you might guess, ng-invalid shows up when ng-valid does not. You can have a [disabled] on the form button based on if the whole of the form is valid, and a bunch of other similar tricks based on this stuff.
  9. Putting a local reference like #foo="ngModel" inline at an input tag allows for help blocks like so to appear when one screws up what one puts in the form field:
    <span class="help-block">Yikes!</span>
    ...and herein help-block is a Bootstrap class for this sort of thing.
  10. At an input changing ngModel to [ngModel]="whatever" will allow for one-way data binding and set a default value based on whatever is in the whatever variable as defined back at the TypeScript side of things. Banana box two-way databinding with something like [(ngModel)]="whatever" would allow whatever to be displayed elsewhere on the form as a magic string and it would get updated real time as the user types in the input with the two-way data binding.

temp token

Kinda like the bearer-token here, this is instead session-based. Whenever you log in a row is created in a database table and the GUID for the unique key is given to you. You use it for all API calls downstream. The row at the database is destroyed by an automated process after fifteen minutes. You will want to double authenticate with another piece of data, probably a bearer-token which will be kept at the database row.

Saturday, July 29, 2017

notes from some online trainings on Observables

  1. http://reactivex.io/rxjs/ has the RxJS documentation. Pick "Observable" from the menu at the left and scroll down to see all of the operators! Just have up top import 'rxjs/Rx'; at your component to let the operators be accessible.
  2. import { Subject } from 'rxjs/Subject';
    export class PezDispenser() {
       dispensePez = new Subject();
    }
    ...is an example of using Subject out of the RxJS stuff, or perhaps more appropriately, an example of the cornerstone of the example as what is above by itself does not yet show off using it. I named this service PezDispenser as these kinda behave like Pez Dispensers, well, if Pez Dispensers had some state swappablity going on. I'll get to what I mean in a moment, but more simplistically we may get a piece of candy from our Pez Dispenser by looping it in as a service in a component and then tapping its head like so:
    onTap(): void {
       this.pezDispenser.dispensePez.subscribe(
          (pez: Pez) => {
             alert(pez.flavor);
          }
       );
    }

    I think if you call what is above first without setting what type of candy the PezDispenser will spit out that this will blow up and you'll get a nasty red message in the Google Chrome console about how flavor of undefined cannot be resolved. Then again, for all I know, this process will just hang out until the type of candy is set and the PezDispenser can actually dispense. That takes us to a second caveat. You will want to have an ngOnDestroy implementation at your component to unsubscribe for things like this to avoid memory leaks. You may set the type of Pez, perhaps from a second component, using the service as a middleman state machine for messaging between two components, like so:
    setFizzy(): void {
       let pez = new Pez();
       pez.flavor = "Fizzy";
       this.pezDispenser.dispensePez.next(pez);
    }

    Alright, that makes for an end to end example and yet there is nothing interesting about this without the swappable state stuff I eluded to earlier. Indeed, you don't even need a service or RxJS if you want to consistently give Pez that is Fizzy in flavor from your dispenser. The thing that makes this interesting, and you can probably see it already, is that you may set the Pez candies to be of a different variety like so:
    setPeppermintSugarFree(): void {
       let pez = new Pez();
       pez.flavor = "Peppermint Sugar-free";
       this.pezDispenser.dispensePez.next(pez);
    }

    For the other party (component) tapping the head, there is a what-will-I-get mystery akin to that of Erwin Schrödinger's cat in that you may either get candy that tastes like dead cat or candy that tastes like live cat and there is no way to know until you do.
  3. .map(
       (digit:number) => {
          return digit + 13;
       }
    );
    ...is, of course, an example of the .map operator. Duh.
  4. BehaviorSubject is like Subject only it starts with a default beginning placeholder setting.

Friday, July 28, 2017

making sure a parent's initialization lifecycle hook is called from a child component in Angular 2

Use an ngOnInit in this way to call a parent's ngOnInit from a child component which will otherwise not go off if the child component has an ngOnInit.

ngOnInit():void {
   super.ngOnInit();
   childishStuff();
}

 
 

Removing the child's ngOnInit would also be another way to get the parent's ngOnInit to fire off, but then you couldn't do childishStuff();

Thursday, July 27, 2017

How do I pass both a POCO and a file to a Microsoft.AspNetCore.Mvc.Controller at once?

It turns out this is modestly challenging and unintuitive and that you cannot really pass an object at the method signature of the action catching stuff if you are catching a file too in this manner. Instead try something like so:

[HttpPut]
[Route("api/widget/{keyId}")]
public bool UpdateWidgetWithInstructionManual(long keyId)
{
   HttpRequest request = this.Request;
   IFormFile file = request.Form.Files[0];
   string serializedWidget = request.Form.Keys.ToList()[0];
   serializedWidget = serializedWidget.Replace("%22", "\"");
   Widget widget = JsonConvert.DeserializeObject<Widget>(serializedWidget);
   var fileName = file.FileName;
   var fileContentType = file.ContentType;
   var fileData = default(byte[]);
   using (var reader = new StreamReader(file.OpenReadStream()))
   {
      using (var memoryStream = new MemoryStream())
      {
         var buffer = new byte[file.Length];
         var bytesRead = default(int);
         while ((bytesRead = reader.BaseStream.Read(buffer, 0, buffer.Length)) > 0)
         {
            memoryStream.Write(buffer, 0, bytesRead);
         }
         fileData = memoryStream.ToArray();
      }
   }
   _myStaticStuff.Act(fileName, file.Length, fileContentType, fileData, widget, keyId,
         _widgetRepository);
   return true;
}

 
 

I am deferring saving the stuff I collect to a database in the third to last line above by calling another method. The signature for as much would look like so:

public static void Act(string fileName, long fileLength, string fileContentType, byte[]
      fileData, Widget widget, long keyId, WidgetRepository widgetRepository)
{

 
 

What does this do? Well, you can use your imagination. The point of this exercise is not really to show the savings of a bytes array to a database, but instead to exhibit taking in both an object and a file at a controller action. This does beg the question of how does one hand off to the action to begin with. In TypeScript in an Angular 2 application you would have to have some magic like this wherein this.http is an Http looped in from @angular/http as an import. Note: no options! Headers seem to sabotage things.

public updateWidgetWithInstructionManual(widget: any, keyId: number, file: any): void {
   let url = "http://www.example.com/api/widget/";
   let formData:FormData = new FormData();
   formData.append('uploadFile', file, file.name);
   formData.append(JSON.stringify(widget), 'widget');
   this.http.put(url + keyId, formData, {headers:{}})
         .toPromise()
         .then(function(data){
            console.log('success');
         },function(error){
            console.log(error);
         });
}