Categories
Uncategorized

Macbook Pro costs over time (2012 – early 2021)

My first MAC laptop was a mid 2012 13″ non retina MBP. The chunky one that they sold for many years. I believe it cost $1,100. I don’t know what the original specs were but it ended life with an old school 1 terabyte HDD and 16GB RAM. It used to eat HDD cables so I always kept a few on hand. I didn’t purchase Apple Care for this computer. I used it as my main laptop dual booting OS X and Windows. This was until I purchased my next MBP in early 2017. So, almost 5 years. I’m going to go with $1,500 / 5 years or $300 per year.

The second one was the first touchbar 13″ MBP. I also purchased AppleCare for three years. Ths one cost $2,000 and came with a 512GB ssd and 8 GB Ram. I never dual booted this machine as upgrades weren’t really a thing anymore. I’m going with $300 for AppleCare but can’t remember if this is right. Within the first year the machine was sent out for a new display as it stopped working randomly. At the end of 3 years it was sent out for keyboard issues (butterfly keyboard) and received a new battery and top case as part of fixing the problem. All off these issues were covered with the AppleCare. I still have this computer but have replaced it with a new MBP as of January 2020. So $2,300 / 3 years = $766 per year plus downtime of being sent out twice for repairs.

My third and current MBP is about one year old. I purchased it in January 2020 and it is considered a late 2019 model. I bought the base model 16″ model with an MSRP of $2400. I bought it on sale at Best Buy and paid almost $2400 with tax. I didn’t purchase Apple care. Although the keyboard design was improved it currently has one key giving me issues. It also on rare occasions panics and completely shuts down. If these types of issues persist I’ll probably get rid of it after another year. Likely cost is $2,400 / 2 or $1200 per year. Even if I get 3 years that gives $800 per year.

As I need the Mac for iOS development I’m kind of committed. I used to buy whatever Windows machine came along while never paying over $1000 per laptop. My current MBP was a huge improvement with the 16″ display so it’s not completely fair to compare these models. However, one thing is certain – My first MBP was more versatile, lasted longer, and cost less to own. These days it would be considered a brick as far as being bulky. It was still the best Mac I’ve ever owned aside from my mini’s that is.

TLDR: I used to spend around $300 per year on owning a MacBook Pro and now spend $800 or more per year.

Categories
App Development Uncategorized

Configure Push Notifications – OneSignal

iOS

We need to upload a .p12 push certificate to OneSignal.

  • CMD-Space and Enter Keychain Access
  • Keychain Access -> Certificate Assistant -> Request a Certificate From A Certificate Authority
  • Enter Email, Common Name and Select Save to Disk
  • Save CertificateSigningRequest.certSigningRequest somewhere convenient
  • Go to developer.apple.com -> Certificates, Identifiers & Profiles
  • + Create a New Certificate -> Apple Push Notification service SSL (Sandbox & Production)
  • Select an App ID for your Apple Push Notification service SSL Certificate
  • Upload a Certificate Signing Request (Select previously generated file CertificateSigningRequest.certSigningRequest)
  • Download and double click the .cer file generated
  • Keychain Access -> Login -> Right click the Apple Push Services cert and select export -> choose .p12
  • OneSignal dashboard -> select the OneSignal app and upload the .p12 file under Native App Platforms -> iOS

Android

We need a Firebase App (Server Key and Sender ID) for OneSignal.

  • Go to https://console.firebase.google.com/
  • Create a new project
  • Go to Settings Icon -> Project Setting
  • Select the Cloud Messaging tab
  • Grab the Server Key and Sender Id
  • Go to the One Signal Dashboard and select the OneSignal App
  • Go to Settings -> Platforms -> Google Android
  • Add the previously saved Firebase Server Key and Sender Id and click save
Categories
Software Development Uncategorized

Setup Cron Job

crontab -l (list)crontab: no crontab for james
export EDITOR=nano   //default vi
crontab -e (edit)
* * * * * command to be executed

– – – – –

| | | | |

| | | |+—– day of week (0 – 6) (where 0 represents Sunday and 6 represents Saturday)

| | | +——- month (1 – 12)

| | +——— day of month (1 – 31)

| +———– hour (0 – 23)+————- min (0 – 59)

Hourly at ‘0’


// every 15 minutes

0,15,30,45 * * * * cd /Users/james/Sites/local/api/sensor/; php -q GenerateWaterEventPush.php


// every 5 minutes

0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /Users/james/Sites/local/api/sensor/; php -q GenerateWaterEventPush.php


// Stop cron job  -> crontab -e -> remove above -> save -> do crontab -l to verify

Categories
Software Development Uncategorized

Setup and pass data through a simple ASP.NET MVC app

Creating a new data driven MVC Application (MyAppMVC) using Entity Framework

Add projects

MyAppMVC.Data.Model for the data model and MyAppMVC.Data for the DataContext (with dbset<> ) and migrations folder (include configuration.cs and then add a Seeder class)

Add an Adapters Folder with subfolders Data, Interface and Mock to the main (startup) project.

Add References between the projects:

MyAppMVC references MyAppMVC.Data and MyAppMVC.Data.Model

MyAppMVC.Data references MyAppMVC.Data.Model

Unit test References if needed

Add the Entity Framework Package (NuGet)

Add Data Model classes to .Data.Model

Add ——Context.cs class to .Data (it is a :DbContext)

in this class add DbSets (public DbSet<—-> ——-s { get; set; }

In Package Manager enable-migrations under .Data — a Migrations folder with

Configuration.cs file is added

Seed data via Configuration.cs

Add a Seeder.Seed(context) to Configuration and create a Seeder file with a Seed method that takes the dbcontext as a parameter. using System.Data.Entity.Migrations (for AddOrUpdate extension method)

public static void Seed(—–Context context)

        {

            context.——.AddOrUpdate(c => c.—-, new —- { Name=”James” });

        }

add-migration initial and then update-database. Open SQL Server Management Studio or VS Database Explorer and celebrate.  VS use (LocalDb)\v11.0

To move data up the stack we use an adapter class to fetch data from the database and return a view model. 


Create a new cotroller (Home) and right click then add a view(Index).

Next add a view model that contains the data the view needs. (Right click Model (top level) and add a .cs class called ——-ViewModel ).  Add the data needed from using .Data.Model project .

Right click Interface in Adapter and add an I—-Adapter interface that has a method Get——ViewModel that returns the desired view model.  Implement the interface in the Data (and Mock) folders.

 public class —-Adapter : —–.Adapter.Interface.I—-Adapter

    {

        public Models.——ViewModel Get——ViewModel()

        {

// create the viewmodel and dbcontext to work with

            —-Context db = new —-Context();

            —–ViewModel model = new —–ViewModel();

            model.—– = db.—–.ToList();    //.FirstOrDefault() for 1 item

// filter with .Where and use .take(#) .orderby() ……

            return model;      

        }

    }

// the adapter queries the database and returns our view model

Now we utilize the adapter in the Controller Action and return the view model to the view.

 —–Adapter _adapter;

        public HomeController()

        {

            _adapter = new —–Adapter();

        }

        public ActionResult Index()

        {

            return View(_adapter.Get——ViewModel());

        }

In the view we specify a view model

@model —–MVC.Models.—–ViewModel        

to loop through a List item with razor

@foreach(var element in Model.—–)

{

@element.—–

}

We have now built a database using code first and the Entity Framework. We then queried that database and passed the results up to a view model.