Generating Entity Framework classes for Database First project

Not all projects, or development teams, use Code First with Entity Framework for building and maintaining their database.  There are plenty of reasons for doing it either way but that discussion is outside of the scope of this post.  What this post is going to focus on is generating your EF classes in a Database First environment.

Microsoft has plenty of great documentation for developers and one such post that I used recently was Getting Started with EF Core on ASP.NET Core with an Existing Database.  My setup is Visual Studio 2017 Community Edition and a .NET Core 2.1 project structure.  The database is running on a free, local instance of SQL Server 2017 and consists of a handful of tables.  To generate the classes I utilized the Package Manager Console (PMC) in Visual Studio and the Scaffold-DbContext command.

Scaffold-DbContext "Data Source=localhost\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=True;" Microsoft.EntityFrameworkCore.SqlServer -outputDir Repository -Verbose

The connection string is pretty basic.  I’m telling it to connect to a database on my machine called MyDatabase and use my Windows Credentials for authentication.  The files generated should go into the directory called Repository in my project.  And for help with debugging any problems I include the -Verbose parameter.

Upon completion all generated files were open in my VS instance for inspection and located in the folder I set as the output destination.  If this didn’t happend and you have an error message make sure that your project builds on its own.  If the project doesn’t build then the Scaffold-DbContext won’t be able to generate the files.  One thing to check before you submit your code to any repository is that in your Context.cs class the connection string used for Scaffold-DbContext is hard-coded into the file.  If the code is going to a public repository you’ll want to make sure this line is removed.

Using AdMobFree plugin with Ionic 3

Recently I updated one of my applications to use the Cordova Plugin AdMobFree to show advertisements in my Ionic app to generate revenue. There are several plugins available to Ionic developers to use for showing ads from AdMob but this one provided the core features I needed without a bunch of bells and whistles I didn’t. This post will go over the steps I took in order to get the plugin to work in my project. If you run into any issues let me know and I’ll see if I missed a step.

To start, let me be clear that this is geared to projects developed utilizing the Ionic 3 framework. It should work for Ionic 2 applications as well but I would not base an Ionic 4 application off of this code given all the changes that have been made for that framework.

Installation

$ ionic cordova plugin add cordova-plugin-admob-free --save --variable ADMOB_APP_ID="<YOUR_ADMOB_APP_ID_AS_FOUND_IN_ADMOB>"
$npm install --save @ionic-native/admob-free@4

Make sure you include your APP ID from AdMob. You can get the value by going to AdMob then clicking on the application under Apps and going to App Settings.

In your config.xml file you should see a section for cordova-plugin-admob-free that has the ADMOB_APP_ID variable defined with the value you passed in during the installation. If not then run the remove command for the plugin and try adding it again.  

One thing worth remembering is that if you run into build issues where errors are reported about the Android version or support libraries used then you’ll want to install the Cordova Android Support Gradle Release npm package.  

When it comes to installing your Android platform I recommend installing version 6.3.0. 

$ ionic cordova platform add android@6.3.0

With that you should have all of the packages and configuration completed.  It is now time to dive into the code.

Code

The first changes to your code have to be made in the app.modules.ts file.  You’ll need to import the plugin and add it to the providers section.

import { AdMobFree, AdMobFreeBannerConfig } from '@ionic-native/admob-free';

@NgModule({
declarations: [...],
imports: [...],
bootstrap: [...],
entryComponents: [...],
providers: [...
AdMobFree,
....]
})

On the page you want to show the ads you’ll only need to make changes to the underlying TypeScript file.  You’ll first want to import the necessary packages.

import { AdMobFree, AdMobFreeBannerConfig } from '@ionic-native/admob-free';
In the constructor include the AdMobFree declaration.  
 
constructor(...,
    private admob:  AdMobFree) {}
 
private createBanner() {
let logger:LoggingProvider=this.logProvider;

try {
let bannerConfig:any= {
id: <android banner id>,
autoShow: true,
isTesting: true
};

this.admob.banner.config(bannerConfig);
this.admob.banner.prepare()
.then(() => {
//We have a banner :)
}).catch((error) => {
// Handle the error case
});
});
}
catch (exception) {
// Something bad happened
}
}

And that is it.  You should have a basic banner displaying on the application.  Once you are ready to go to production you’ll want to change the isTesting parameter to false so real advertisements come through.

If you want to give the option for your users to go advertisement free there is an easy method call to remove the banner.

this.admob.banner.remove(); 

When I get some time I’ll try to put up an example project or put in a pull request for a demo on the AdMobFree repo.  Until then, let me know if I missed anything and I’ll update the instructions.

Divide by Zero

You know what might ease tensions? If everyone took a break from political shows, web sites, radio, and news for a while. Take the soap opera drama that passes as news and just detox for a good few days, weeks, months, or years. Maybe the superficial hate will dissappear. Maybe the imaginary lines that have been drawn will fade away. Because if not this constant division will get to the point where you can’t divide society any further. That is when you divide by zero and everything falls apart.

A Break from Facebook

This past June I took some time off from Facebook.  The site was consuming too much time and always made me feel a bit empty after using it.  So, from June through most of August I was Facebook free.  I’d say it was nice but it wasn’t…the time off was GREAT!

I have no idea how much time I was able to get back but it had to be several hours a week.  And I honestly felt happier than before.  Now I will admit that I have Instagram and when I suspended my Facebook account I started spending a bit more time there, which is also owned by Facebook, but the draw to be on the app was far less.  Instead of checking multiple times a day I’d check once or twice every few days.  And when I was on Instagram the amount of time didn’t even compare to Facebook since I was only browsing photos of friends or organizations I followed and the numbers I follow are far less than the “Friends” I have on Facebook.

But, like so many other good things, the break came to an end.  The choice to reactivate the account was actually uncomfortable because I was afraid I’d go back to wasting time on the site.  The reason for re-activating was simple, my coworkers all message, trade and sell things, and setup work events through Facebook so if I wanted to be apart of the group I’d have to rejoin the social network.  I’m hoping that this will only be a temporary affair or that I’ll use the site sparingly now that I know how nice it is without it.  I hope…but if the hope doesn’t pan out then I may just need to suspend the account again.

Give it a try.  Try suspending your account for a few days, weeks, or months.  See what life is like without it.  You can still use the Messenger app with your account suspended.  And if you have any apps or sites that you login with your Facebook account you can do a “Forgot my password” option and just provide the email address you use for Facebook to get a temporary password.  Go ahead, see what life is like outside the blue of Facebook.

ion-toggle Toggle/Change event handling

I’m working on an Ionic v2+ app that requires some extra logic to be executed when a toggle switch, also known as a radio button, is changed.  In Ionic this component is called an ion-toggle.  I tried using the normal Angular.io decorators like (change) or (click) but none of them were firing.  What I didn’t realize, mainly because I didn’t see it in the Ionic documents was that in order to handle changes in the state I needed to use the (ionChange) decorator on the component.  With this I could pass in more details to the function being executed.

<ion-toggle id="toggle{{parent.name}}{{child.name}}"
     [(ngModel)]="child.selected"
     (ionChange)="onChildSelection(parent.name, child.name, child.selected)">
</ion-toggle>
 In the above example the id of the component is being set to include the name of the parent and child.  The state is based on the child.selected state which in this case is a boolean value.

Philadelphia Region Tech Employers

One of the hard things when looking for a job is getting a good listing of companies that hire in your field. Over the years I’ve kept track of companies that have posted jobs related to software development or developer operations in the Philadelphia, Pennsylvania region. There are a few that are more north in the Lehigh Valley region but I didn’t take them out as they are all within commuting distance.  Hopefully this helps out fellow technologists find the next step in their careers in southeast Pennsylvania.

Last updated 06 April 2019

– 3Gtms https://www.3gtms.com/
– Accolade, Inc https://www.accolade.com
– Acurian https://www.acurian.com/
– Alion Science and Technology http://alionscience.com/
– Allied Wire & Cable http://www.awcwire.com/
– Almac https://www.almacgroup.com/
– Alphapoint https://alphapoint.com/
– Amdocs https://www.amdocs.com/
– AmerisourceBergen https://www.amerisourcebergen.com/abcnew/
– Arrowroot Capital https://www.arrowrootcapital.com/
– AWeber https://www.aweber.com/
– Azavea https://www.azavea.com/
– Bainbridge Health https://www.bainbridgehealth.com/
– Benefits Data Trust http://www.bdtrust.org/
– Bentley Systems https://www.bentley.com/
– Betterment https://www.betterment.com/
– Blackfynn http://www.blackfynn.com/
– Blackrock https://www.blackrock.com/
– Blue Cadet http://www.bluecadet.com/
– Boeing http://www.boeing.com/
– Bolt On Technology http://boltontechnology.com/
– Brio Solutions http://www.briosolutions.com/
– Brooks Instruments https://www.brooksinstrument.com/
– BULOGICs http://bulogics.com/
– Cadent http://www.cadent.tv/
– CardConnect https://cardconnect.com/
– CDM Smith https://cdmsmith.com/
– Cerner https://www.cerner.com/
– Chariot Solutions http://chariotsolutions.com/
– CHI Systems http://www.chisystems.com/
– Cloudreach https://www.cloudreach.com/
– Cobham plc https://www.cobham.com/
– Comcast http://corporate.comcast.com/
– Converge Consulting http://convergeconsulting.org/
– CreativeMMS http://creativemms.com/
– Creedence Solutions Inc http://credence-llc.com/
– Curalate https://www.curalate.com/
– Dell http://www.dell.com/en-us/home/
– Dick’s Sporting Goods https://www.dickssportinggoods.com/
– Dorman Products https://www.dormanproducts.com/
– Drama Fever https://www.dramafever.com/
– Drexel University Libraries https://www.library.drexel.edu/
– Elsevier https://www.elsevier.com/
– ECRI https://www.ecri.org/
– Elsevier https://www.elsevier.com/
– eMoney Advisor http://emoneyadvisor.com/
– EmployVision https://employvision.com/
– empowr http://www.empowr.com/
– EPAM Systems https://www.epam.com/
– Equisoft https://www.equisoft.com/
– Evantage Technologies Inc http://evantagetechnologies.com/
– Evolve IP https://www.evolveip.net/
– FBI https://www.fbi.gov
– Express Scripts https://express-scripts.com/index.html
– Freedom Pay http://corporate.freedompay.com/
– Frontage Laboratories http://www.frontagelab.com/
– GlaxoSmithKline https://www.gsk.com/
– goPuff https://gopuff.com/
– Greystones Group https://www.greystonesgroup.com/
– Grubhub https://www.grubhub.com/
– Guru https://www.getguru.com/
– HealthJump http://www.healthjump.com/
– Healthverity http://healthverity.com/
– HomeNet Auto https://www.homenetauto.com/
– Honeywell https://www.honeywellprocess.com
– I-CAT https://www.i-cat.com/
– ICON plc https://www.iconplc.com/
– Inspire http://www.inspire.com/
– Integrity Applications Incorporated https://www.integrity-apps.com/
– Interactive Mechanics http://interactivemechanics.com/
– Invata Intralogistics http://www.invata.com/
– IQVIA https://www.iqvia.com/
– JOOR Engineering https://www.jooraccess.com/
– Kenexa (IBM) https://www.ibm.com/software/smarterworkforce/
– Kepler Group http://www.keplergrp.com/
– KL Discovery https://www.kldiscovery.com/
– Kulicke & Soffa https://www.kns.com/
– LifeShield http://www.lifeshield.com/
– Linode https://www.linode.com/
– Lockheed Martin http://www.lockheedmartin.com/
– Lutron http://www.lutron.com/
– McKesson https://www.mckesson.com/
– McNeil Consumer Healthcare https://www.jnj.com
– MeetMe http://www.meetme.com/
– Merck http://merck.com/
– Microsoft http://www.microsoft.com/en-us
– Mikros Systems https://www.mikrossystems.com/
– Miles Technologies https://www.milestechnologies.com/
– MMIT https://www.mmitnetwork.com/
– Molecular Devices http://www.moleculardevices.com
– Monetate http://www.monetate.com/
– Moven https://www.moven.com/
– Music Choice http://musicchoice.com/
– Nartal Systems http://nartal.com/
– National Board of Medical Examiners https://www.nbme.org/
– NCC Automated Systems http://www.nccas.com/
– Neat https://www.neat.com/
– Northrop Grumman http://www.northropgrumman.com/
– NuCitrus Technologies https://www.nucitrus.com/
– Oracle https://www.oracle.com/index.html
– ORS Partners https://www.orspartners.com/
– Pariveda https://www.parivedasolutions.com/
– Penn Mutual https://www.pennmutual.com/
– PerPay http://www.perpay.com
– Philadelphia Housing Authority https://www.pha.phila.gov/
– Philadelphia Media Network https://www.philly.com/
– Pinnacle 21 https://www.pinnacle21.com/
– PMA Companies https://www.pmacompanies.com/
– Practice https://www.practice.xyz/
– PracticeFusion http://www.practicefusion.com/
– Proconex https://www.proconexdirect.com/
– Promptworks https://www.promptworks.com/
– PTC https://www.ptc.com/
– Pure Storage https://www.purestorage.com/
– Push10 https://www.push10.com/
– QuantaVerse http://www.quantaverse.net/
– QVC https://www.qvc.com/
– Red Tettemer https://rtop.com/
– RELX Group https://www.relx.com/
– RevZilla https://www.revzilla.com/
– Ring (Amazon) https://ring.com/
– RJMetrics https://rjmetrics.com/
– ROAR for good http://www.roarforgood.com/
– RS Energy Group https://www.rseg.com/
– s2s Communications http://www.s2scommunications.com/
– Sabre Systems http://www.sabresystems.com/
– Sapient https://sapient.indistries
– Sapling Inc https://sapling-inc.com/
– Sapvix http://www.sapvix.com/home.php?pageid=home
– SAS https://www.sas.com/
Scientific Search https://scientificsearch.com/
– SEI Investment Company http://www.seic.com/enUS/index.htm
– ShareTracker https://www.sharetracker.net/
– Sidecar https://www.side.cr/
– Siemens https://www.siemens.com/us/en/home.html
– Skyhook https://www.skyhook.com/
– smithwise http://smithwise.com/
– Stratus EMS https://stratisems.com/
– SRI https://www.sri.com/
– Subaru of America https://www.subaru.com/
– Susquehanna International Group http://www.sig.com/
– Syapse https://www.syapse.com/
– Syncro Medical http://www.syncro.com/
– Tabula Rasa HealthCare https://www.tabularasahealthcare.com/
– TechField https://www.techfield.com/
– Temenos https://www.temenos.com/en/
– The Meet Group https://www.themeetgroup.com/
– Therapy Notes https://www.therapynotes.com/
– Think Company https://www.thinkcompany.com/
– Tonic Design Co. https://www.tonicdesign.com/
– trizic https://www.trizic.com/
– Turn5 https://www.turn5.com/
– Tyndale USA http://tyndaleusa.com/
– Unisys http://www.unisys.com/
– Universal Health Services http://www.uhsinc.com/
– UPenn School of Medicine http://www.med.upenn.edu/
– URBN http://www.urbn.com/
– USLI https://www.usli.com/
– Vandegrift http://www.vandegriftinc.com/
– Vanguard http://www.vanguard.com/
– Vertex https://www.vertexinc.com/our-company
– VertMarkets https://www.vertmarkets.com/
– Vistar Media http://www.vistarmedia.com/
– Vitaver & Associates http://www.vitaver.com/
– West Pharmaceutical Services https://www.westpharma.com/
– Weather Trends International http://www.weathertrends360.com/
– Weblinc https://www.weblinc.com/
– We Buy Any Car https://www.webuyanycar.com/
– WipFli https://www.wipfli.com/
– Wirecard https://www.wirecard.us/
– YPrime https://www.yprime.com/

If you have any questions or suggestions leave a comment below.

Dealing with multiple HDD and SSDs

Over the years I’ve collected a lot of spinning hard disk drives as well as solid state drives.  The problem has been easily swapping between them when all I had were enclosures.  This year I finally decided to start consolidating the drives and reformatting some of them to be used for backup and went searching for an easy solution to swap the drives.  What I found was the StarTech USB 2.0 to SATA IDE Adapter.  With this adapter I was able to quickly connect and switch between my laptop and desktop sized HDDs and SDDs.  My laptop is a Windows 10 machine and required no extra drivers to be installed.  All that I needed to do was plug in the power adapter and the data cable to the drive, then connect the data cable to the computer and plugin the power adapter.  After that the drives appeared on my computer and I could easily explore the files on them.

So if you are looking for cables to quickly connect SATA IDE drives to your computer via USB then the StarTech USB 2.0 to SATA IDE Adapter is the way to go.  They even have USB 3.0 connectors too for your newer machines.

Convenient dumb light

In our garage the only way to turn on the light is to walk over to it and pull the cord.  Unfortunately this light is located between two hanging bikes, which my head hits often, and over our car.  After a few practice runs in the pitch black I’ve become somewhat proficient at pulling the cord without much fuss.  Still, it is a pain on several levels so a few months ago I started looking for an easy fix.  I didn’t feel like rewiring the light to a new switch by the door; too much work to figure out the right way to do it and patch all the holes I’d make.  And I didn’t want to install a smart light that could be controlled by an app as that seemed like overkill.  What I ended up settling on was a First Alert PIR725 Motion Sensing Light.

The sensor is a basic motion sensor that looks in a 360 degree radius for movement.  It seems to easily sense movement 15 feet away and is even able to peer through the bikes hanging on either side to detect when someone first steps into the garage.  Once the sensor turns on the light it will keep the light on for about two minutes after the last movement was detected.  This is great as it keeps the light from turning on and off while you are going in and out of a room as well as not letting the light stay on for a long time after you’ve finished up.  We’ve been using this light for about three months and haven’t had any problems with it.  So if you are someone who has a light in a hard to reach location I highly recommend taking a look at First Alert PIR725 Motion Sensing Light.  It just may make your life a little bit easier.

Diving into Cryptography

Cryptography is an art that has a rich history spanning over 2,000 years.  It has evolved from simple letter swapping algorithms called transposition ciphers, to using a key to shift multiple letters in the text with the Vigenère cipher, to modern day symmetric-key cryptography that uses advanced mathematics.  With this evolution the art has transformed itself into a science powered by mathematics.

The problem with cryptography is that it is extremely intimidating if you don’t already have a strong mathematical background.  While I enjoy math I am far from a strong candidate in the subject.  When I began to get really interested in the subject I started looking for a good book to break down the concepts into something easily understood and entertaining.  While there are plenty of books that deal with the raw subject the one I’ve found that walks the reader through the history and explains both how the algorithms work and how to crack them is The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography.  It even has a section at the end of the book that challenges the reader to break the codes for several different types of algorithms.

It is hard to imagine that a book which dives into the mathematical properties of cryptography could be a fun read but somehow the authors nailed it.  The first chapters start off explaining the basic forms of encryption and then build up to the advanced quantom cryptography that is being researched by some of the topped mathematicians.  The challenges at the end of the book have their answers available online.  When the book was published there was a challenge to see who could crack the codes first.  After just over a year the prize was claimed.  You can read about the challenge on the authors page, Simon Singh: Cipher Challenge.

If you have any interest in the subject I highly recommend picking up the book.  After you complete the book you’ll have a great grasp on the subject and maybe an itch to dive even deeper.

Tag all of your music with MusicBrainz Picard

For the last decade I’ve been half-heartedly trying to clean up and organize my collection of music.  This collection has duplicate, triplicate, quadricate? copies of songs.  Some songs are tagged with no name or artist while others have the completely wrong information associated with them.  In addition to this hole of chaos I could never figure out a good way to get updates made on my phone over to my computer without a huge hassle.  All that changed after I decided to pick up a new Micro SDHC for my phone that can more than handle my entire collection.

My saving grace turned out to be MusicBrainz Picard.  Not only is it free but it took my piece of chaos and fixed it.  The software has a great way to fix all of the ID3 tags in my MP3 and M4A files.  The application will tag songs based on the names of the files as well as lookup the fingerprint of the song.  Since the software is lets developers create their own plugins you can extend the application to incorporate information from Last.fm or try your own hand at writing a customing plugin.

After playing around with Picard over the weekend I was able to cleanup over 90% of the music on my machine.  In looking at the music that wasn’t fixed I’m seeing a trend of duplicate songs and some that appear to have been corrupted.  Most likely I’ll be deleting the untagged files once I’ve verified they aren’t worth saving.  As always, if you find this software useful consider donating some money towards its development at MetaBrainz.