So you've come to a point where you want to build nice CLIs. There's a few different options for building CLI's. My two favorites are oclif and commander.js. I tend toward leaning to commander, unless I know I'm building a super big app. However, I've really enjoyed building smaller CLIs with commander recently.
So, incase you are unfamiliar, there is a meta tag called
<meta name="theme-color" content="..."> that is used to change the color of the navbar on desktop safari, mobile safari, and mobile chrome. If you don't set a value these browsers tend to find a color that match the site to the best of their ability. However, sometimes even setting the value can cause the site to look ugly.
I remember when (Accelerated Mobile Pages) first came out, and it was very restrictive and weird. I think this ultimately hurt the AMP Brand Beyond this, several companies have built AMP experiences which haven't always been the best experience. I do however think AMP pages always load extremely fast. A lot of that is just the constraints of AMP. Last night I put my blog posts on AMP for a laugh, and it was much easier than I thought it would be.
So I've been using monorepos for some time, and recently I've gotten a lot of questions about how to host them on Heroku. I figured I'd give you the simple guide. There are two basic scenarios. The root of your git repo has your yarn/npm workspace, or you have a folder inside of a gitrepo you wish to use.
Turborepo is a tool that came across my virtual desk recently. Monorepo develoment has been around for a long time. This is a strategy where all of your code remains in one repository regardless of services. A lot of people use monorepo's even for microservices. The huge upside is to keep everything in one place, which allows for development efficiency, such as grepping an entire codebase for specific keywords. A quick example would be a top level directory which has child directories that each contain an npm package, unlike publishing these packages, you access them locally as though they were published.
For many of us a JS workspace is the simplest way to structure code for future growth while providing very quick iterations. Incase you are unfamiliar, several technologies exist such as
npm workspaces, etc. That can seamlessly stitch npm packages on disk as though they were published to a private NPM registry. This allows for fast iteration inside of a single git repo, while allowing a future where these dependencies could be abstracted.
I've been getting back into building scrappy little web apps for my friends. On top of this, I recently joined a startup and getting away from Enterprise class software has made me make a huge mind-shift. In the recent past when I wanted to build apps I was thinking Kubernetes, Helm Charts, etc. However, in small app, and startup land reducing the barriers to ship is very important.
I've been working at CarGurus.com for the last 2 years or so. One of the biggest journeys we've been undertaking is to take accessibility far more seriously. However with an engineering team way into the triple digits it gets harder and harder to scale accessibility knowledge.
So many people know me as a very performance focused engineer, and as someone that cares about perf I've always been a bit embarrassed about this blog. In actual fact this blog as it sits now is fast by most people's standards. I got a new job in July, and well I work with an absolute mad lad that is making me feel pretty embarrassed with his 900ms page load times. So I've decided to build my own blog engine, and compete against him.
So incase you havn't been following me. I joined Cargurus in July. At cargurus we're currently working on our mobile web experience written in react, redux and reselect. As our implementation grew so did our time to first paint.
So I'm currently sitting on a plane at the moment. A recent project I started on was a travel guide where I live. Being on a plane without wifi for a long time is a quick wakeup to me how much I rely on the internet to code.
Here we are, its 2017 dotnet core is out, and finally dotnet has a proper cli. In a previous post we explored the new cli. In short you can use the dotnet cli to build, test, package, and publish projects. However sometimes just using the cli is not enough. Sometimes, you land in a place where you have many projects to compile, test, and package.
Ok so I've been in the alexa skills market recently, and obviously amazon wants you to use AWS Lambda for your skills. If you are like me, you have a ton of stuff in azure app service (the PaaS of azure). Azure app service supports nodejs, java, python, and of course .net. The two sdk's amazon ships (node, java) do not tie in with a web stack, and are obviously thought of as being used with Lambda.
tl;dr view this gist
So its 2016, and we are still making console apps/cli's. In fact I would say there has been a surge in popularity of these types of tools. I think we have come to the realization that buttons on forms are not automatable, and that the command line doesn't have to be scary.
I recently started writing an app in dotnet core, which is the new runtime for dotnet. In the past I have often used command line parser, but as of this writing it does not support core.
I was really lost trying to find an arguments parsing library when I realized the dotnet cli was open sourced.
After much struggle, failing to bingle. I started ripping through the Entity Framework, and dotnet cli's code hoping to find a gem. Thats when I stumbled across a diamond. You see many dotnet projects use Microsft.Extension.CommandLineUtils to do cli parsing.
So now that Windows server 2016 is generally avalible for the first time ever windows users can now use containers. Ok, so what exactly are containers? Well more or less they are virtual operating systems that share the same kernel as the host OS. In regular VM's the hardware is shared between machines, but containers go a step further and share the kernel of the OS. Why does this matter? Well because you are sharing an existing kernel that is already running, your startup times are instantanious. To put this in perspective, this is virtualization at the OS level.
On Linux, containers have been a thing for a long time. This technology is called LXC. Docker itself is a layer ontop of various container platforms embedded in operating systems.
dotnet CLI is currently in RC2, and while the train is fast approaching RTM, most tools are still catching up. dotnet seems to have a documented cli based install for every platform except the good ol windows. That being said getting a windows based install/build is possible.
Recently I have been working on an application that basically has a github bot (aka user) fork a repo, commit some files, and submit a PR against someone's repo. When it came down to actually making a new git commit through the github API, I had quite a hard time. I figured it out with some help from a ruby tutorial, and now I'm going to show you how to do it.
If you have read this blog for any length of time, you know I am a fan of Azure. I thought about using github pages with hexo, but github pages only supports 1 doman name. I could start 301 redirecting my other domains, but I really didn't want to do that.
Around a year ago I joined a new team where I work, and this team was starting to undertake a full rewrite of their code. We were going from a full c#/mvc app to a tiny c# api, and a very big SPA.
I started Bingling around and I stumbled across jsnlog. JSN log lets you quickly wire up your client side logs to your server. I have been able to get PR's into the code base and the guy behind it has been very friendly to me when I have had questions.
One feature that I think is highly under-documented in the C# MVC framework is custom
By simply making folders in your views folder called
EditorTemplates you can use the
EditFor(a=>a.TypeHere) with any custom types you so choose.
I was exploring around github, and I stumbled upon an interesting project called Miniblog which was a lightweight blog engine written in c#. The thing that immediately stood out to me was the lack of a
As I dug around the code I realized this was not a Web App, which most of us were familiar with, but a websites project. I then suddenly realized that the whole thing only used razor!
I am a huge fan of Nancyfx because its much more lightweight than the MVC framework created at Microsoft. To say the least I am a massive fan of small tools, and micro frameworks. So when I realized this whole thing was powered by razor only I was immediately impressed.
I decided to dig around on the internet to see if anyone else was talking about this. I found out quickly that it has been possible for some time, but I didn't find many references about it.
The one thing that bummed me out about the Miniblog example was that it was not a web app. You can use nuget packages will websites, but you cannot make references to other projects in the solution. This was a problem for me, and unlike websites, web app's are precompiled which reduces application startup time.
click here for vs2017
Resharper has long dominated the c# landscape as the tool of tools. Roslyn shipping with VS 2015, the quick actions light bulb, and the community analyzers, all combine to produce a resharper-like experience.
Github has become the defacto online source hosting provider. More projects than ever before use github, and it has become a predominate force in the open source community. I use github quite a bit, and I love it.
Where I work .NET rules supreme. Personally I really don't care that much about the technology so long as it supports really good workflows. One of my major issues with nuget is that is very opinionated.
Ok so to give you all some background. I always write my data access with a repository pattern in c#. Now I often use dapper, however I'd guess this problem would also apply with Entity framework.
The one problem I have always had with these tools is they dont go above and beyond to help you understand your code at a higher level.
LinqPad is an interactive C#/F#/VB.NET scratchpad that lets you run arbitrary C#/F#/VB.NET code, and also lets you query databases with linq.
In C# there are two kinds of types...Value and reference...
What are Reference Types?
Reference types in C# are mostly objects and strings. These are types when placed on a stack refer to a memory address in the heap.
What are Value Types?
Value types make up the bulk of types in c#. These include int, float, double, long, bool, etc. These types values are only stored in the stack.
Stack? Heap? What's the difference?
To put it short, the stack is a series of memory blocks (like a scratch pad) that is used for the current thread. The stack is used for basic property data access. Accessing the stack is very rapid, as its only used for trivial data. The heap is an area of memory for dynamic memory allocation. The heap is used to store things in data that are not value types, usually objects and strings. The heap is slower to access, but larger in size.
Reference type tripping points
Reference types are basically pointers. These pointers can trip you up in interesting ways. For example suppose you have an object called MyObjectName:
var MyObjectName = new SomeClass();
and you decide to make someone else's object name the same as you're name
var OtherObjectName = MyName;
When you change MyName to be something else, you will also change OtherName.
This is because objects are a reference type. On the stack the object is a pointer reference to the heap. When you make OtherName equal you are pointing it to the same memory address as MyName. You can see this in action here
var MyName = new SomeClass(); var OtherName = MyName; MyName = MyName.Name = "Joe"; //OtherName will now equal Joe
This is also the same for array's if you make 1 array equal another, you will not have 2 array's with the same value. You will have 2 variables that point to the same array.
So the same must work for value types right?
If you have 2 ints and assign one int to equal the other. The value on the stack will be copied to that int, and since the stack value is the actual value they will be independent of each other.
Boxing and Un-Boxing
When you have a value type and you want it on the heap you must convert it to an object. This is called boxing
var val = 3; var x = (object)val;
However once you do this, the two variables will be independent from each other. So if you change x you won't change val and vice-versa.
To get the object back on the stack you must cast it back into an int. This is called un-boxing
var y = (int)x;
To do custom error pages in Nancy you must implement an IStatusCodeHandler. This class must provide 2 methods. HandlesStatusCode is a bool that basically should tell Nancy if this class will handle the status code. If this returns true then this class will be responsible for handling the request.
SquishIt is a content bundler and minification tool. The github documentation contains exaples how to install and use it, and a sample application is provided. However I had some issues getting it to work with razor so I figured I would share these pain points with you.
This will be a brief overview on how to get admob working with Xamarin.
I highly suggest you run this on a real phone. I'm not sure if the virtual phones can load content on the internet. I always develop on a real phone.
Sample code located in a repo at github
The standard way to get/set SharedPreferences in Xamarin is with the following code.
var shared = con.GetSharedPreferences(_preferenceName, FileCreationMode.WorldReadable); var value = shared.All.Where(x => x.Key == key).FirstOrDefault().Value;
var shared = con.GetSharedPreferences("PreferenceName", FileCreationMode.WorldWriteable); var edit = shared.Edit(); edit.PutString(key, val); edit.Commit();
The main issue I have/had with this is you often have to know what will be returned, and what type you need to save as. Usually this isn't difficult, but it adds an un-needed level of complexity.
The other major issues I have with this, is that it is quite verbose, and unnecessary. The code duplication here can be quite high.
Setting up your robots.txt file for your blog is easy, by adding a file called robots.txt in the root of your current themes directory.
Giving and receiving feedback, allows us to maintain our strengths while improving our weaknesses. There are two major types of feedback, constructive, and reinforcing. Constructive feedback is asking someone to change behavior, while reinforcing is acknowledging good behavior.
The Parse Function
The parse function allows you to do some pre-processing of the data sent from the server before the model is created. Parse should return an object containing the values that will make up this models attribues. This is called after the fetch command has recieved the data, but before the response is put into the model. The example below parses dates to local time before adding them to the model using moment.
Xamarin is a very good platform, but like everything it has parts that are not so great.
One thing that was really hard for me, was to find documentation that was newer than 2012. Android has made great strides with Ice Cream Sandwich, and Jelly Bean. New features such as fragments have breathed life into the platform.
The Xamarin documentation provides examples even with the newest features, but there is something about it that feels lacking. Almost like it was thrown together at the last minute. They have been doing webcasts to improve the knowledge out in the wild, but googling the answer to your problem just won't do. Part of the problem is that most developers write in Java, and only bigger companies can afford the hefty license fees that come with full support.
The user community was helpful at times, but I often found myself wandering though GitHub hoping my answer could be found in some mystical repo; Eventually having to study the full implementation to find the answer I needed.
Although Xamarin has a forum where helpful users help each other, there are not nearly as many people coding on Xamarin than regular Java. Figuring out how to get something complicated working, was a nightmare. I'd look at a Java implementation, and then try to translate it into its Xamarin counterpart, which sometimes was far removed than the Java code. There are some examples of Xamarin for android out there, but nothing that really delves deep into manipulating the inner workings of the phone. I saw this especially when trying to edit contacts programatically. Xamarin support seemed helpful, but far too expensive for most freelance developers. This was a pretty huge put-off. If I went the Java route my questions would be answered with a simple search of stack overflow.
Like most things Java, Android requires a lot of boilerplate. For a developer like myself, whom avoids Java this was a problem. I would have thought that Xamarin would have abstracted out more of the boilerplate than they did. On the one had, having my code look somewhat familiar when I see Java examples was nice, but on the other hand because the API is still different often the Java versions would not be close enough to fully help. My main problem with this, is if I really wanted to write boilerplate I would have used the Java libraries myself. They did make a start for this by generating the manifest file automatically, but I feel it needs to go further to fully mature this platform as a viable alternative to Java.