Open Source, Technology

Why I’m Leaving WordPress for Ghost

This was originally published at my new blog here 
http://blog.jfaquinojr.com

WordPress is so awesome. It has tons of resources and contributors from its very large community. From themes to plug-ins, free and paid, you will have no problems finding what you need.

Its Success becomes its Downfall

WordPress has grown into something else. It has evolved from a blogging platform, into a CMS, and then into whatever it is now. People are doing all kinds of stuff with it. That kind of success attracts malicious folks. If you host your own wordpress site, you better be updating it once every path comes up.

Fortunately for me I didn’t host my own so I dont have to deal with security and upgrades. My previous blog was in jfaquinojr.wordpress.com.

I Just Want to Write my Blog

I don’t need all that cruft. I just want to write whats in my mind and be done with it.

WordPress is like a Swiss Army Knife with all the knives out.

Enter Ghost

Initially I wanted to move to a static site generator such as Jekyll or some other shit. But I wanted to try Ghost as well so here we are. And so far, everything is peachy.

Ghost is a blogging platform period. Its dedicated to doing one thing: Publishing.

I’m not completely ignoring Jekyll. If I find benefits to moving to Jekyll or similar over Ghost, maybe I will.

Amazon AWS

I am hosting my new Ghost blog on Amazon AWS. I find it much cheaper than hosting on Azure. Even with my free 100 USD Azure credits that comes along with the company MSDN subscription, I still decided to host on Amazon but that’s another story for some other time. But that might change in the future.

Probably more useful to me than to you but IDC.
https://desiredpersona.com/how-to-create-a-static-website-with-ghost/

https://help.ghost.org/hc/en-us/articles/224410728-Markdown-Guide

C#, Open Source, Software

ScrapySharp: C# Web Scraping Library

I heard about ScrapySharp in dotnetrocks and I have been meaning to play around with it ever since. It is an excellent open source library for .NET that may have been a port of scrapy.

As for this exercise, I decided to scrape TipidPC (TPC). TPC is an online buy and sell community website for PCs, laptops, computer accessories, and similar gadgets.

My goal is to list all of the new items for sale (IFS) and then do something with those data later on.

When I browse TPC website, there is a button there that allows me to browse the catalog under Items For Sale. Clicking on it redirects me to this page:

tpc-ifs
Fig 1: https://tipidpc.com/catalog.php?cat=0&sec=s

This is a list of all items for sale, arranged by most recent first.  Perfect! Just what I need to achieve my goal. Take note of the URL as we will need this later.

Now lets open up developer tools in the browser by hitting F12 and do some dissecting. Looking closer, the particular list that we want is a <ul> with an id of “item-search-results”. This list is composed of items with all the goodies which can lead us to more goodies, all of them ready for harvesting. Again, mind the URLs. I cant wait to get my hands dirty, and I hope you are as excited as I am.

tpc-dissection
Fig 2: Goodies!

 

Roll up your sleeves and fire up Visual Studio. Create a new console app and enter the following in the Package Manager Console:

PM> Install-Package ScrapySharp

Once you have that installed, we can now create an instance of HtmlWeb and call the Load() method.

var web = new HtmlWeb();
web.Load("https://tipidpc.com/catalog.php?cat=0&sec=s");

It’s that easy! The Load method returns an instance of HtmlDocument that represents the target webpage in its entirety. Note that ScrapySharp can also load HTML via ScrapingBrowser as shown in the official repository page. I just use the above because I find it much easier and cleaner.

But the party is just getting started. If you like JQuery, and by extension, CSS, you would be comfortable with the next piece of code.

 var nodes = document.DocumentNode.CssSelect("#item-search-results li").ToList();
 foreach (var node in nodes)
 {
 Console.WriteLine("Selling: " + node.CssSelect("h2 a").Single().InnerText);
 }

CssSelect() method accepts CSS syntax to process the target HtmlNode. In the above code, the first CssSelect gets all the <li> items under the <ul> named “item-search-results” (see Fig 2 above). The second CssSelect call simply gets all the h2 links so the program can write them to the console.

The complete code listing is below

static void Main(string[] args)
{
  var url = "https://tipidpc.com/catalog.php?cat=0&sec=s";
  var webGet = new HtmlWeb();
  if (webGet.Load(url) is HtmlDocument document)
  {
    var nodes = document.DocumentNode.CssSelect("#item-search-results li").ToList();
    foreach (var node in nodes)
    {
      Console.WriteLine("Selling: " + node.CssSelect("h2 a").Single().InnerText);
    }
  }
  Console.ReadLine();
}

Running the above results to:

scrapyboy-console

Using ScrapySharp is so convenient! If you have attempted scraping before, using plain HtmlAgilityPack or some other .NET library, I feel your pain.

Now go and play around with it and let me know what cool projects you are and will be working on.

Productivity, Software, Technology

VS2017 Introduces Go To All

In addition to the already existing phenomenal search and navigation features in Visual Studio, the VS team finally implemented the Go To All.

gotoall
The ‘Go To All’ Popup

Prior VS versions attempted this feature in the form of ‘Navigate To…’. But it was too slow to even be usable specially in large solutions. People usually end up using ‘Find in Solution’ – the proverbial hammer to solve all navigation problems.

NavigateTo.png
Navigate To.. is slow specially in large solutions

If you have used Jetbrains Resharper before (and other Jetbrains products), you will definitely appreciate this feature. This is perhaps the main reason why I use Resharper. Now that it landed on Visual Studio 2017, I can be free from Resharper. In many ways, the VS version even feels superior.

resharper-vs-nativegotoall
Reshaper (Left) and Visual Studio 2017 Go To All (Right)

In my current keyboard mapping scheme (Visual C# 2005), I needed to configure the shortcut for this – but maybe that’s just me. My co-worker reported that Ctrl+T worked for him out of the box. In any case, its super easy to set it up. Just hit Ctrl+Q and enter “keyboard” to take you to Keyboard Mapping options. Then search Edit.GoToAll and assign Ctrl+T. OK your way out of the boxes and you’re golden! Why Ctrl+T? No reason. I just followed Resharper’s lead. You can choose any shortcut key you want though.

AssignCtrlT
Assign Shortcut Key

By default, the ‘Go to All’ popup searches all occurrences of the string. Filter it even further to clean up the results and its very easy. For example, if you want to search the file /Web/Controllers/HomeController.js, just enter “f homecontroller”. Other search options are below.

# Symbols
: LIne
? Shows this list
f Files
m Members
t Types

Conversely, if you want to be more visual about it, you can click on the icons on the top of that nice Go To All popup to achieve the same results. Two buttons on the side allow you to personalize your overall experience.

gotoall_buttons

How do you find this Go To All feature? Is it useful for you or not really? Let me know your thoughts in the comments section below.

 

Software

​I am a Mediocre Programmer and that’s OK

Sometimes, impostor syndrome kicks in. I feel that after all these years, I haven’t improved as much as I hoped for.

I have been writing software for 13 years. I am mainly a .NET guy, starting out my career making windows-based apps. Now I create websites using .NET and mostly angular 1.x on the front-end. I recently am loving TypeScript and use it each chance I get. On my free time I contribute to open source by writing my own or helping others.

And then I think about guys like Damien Edwards (SignalR), DHH (Ruby on Rails), Rob Eisenberg (EmberJS), Miguel de Icaza (MONO/Xamarin), Linus Torvalds (Linux/Git), and all the other famous devs who created X. People who make great software and imagined them doing everything I am doing, only 1000 times better.

I am a mediocre programmer. And you know what? I dont care. It means I am just part of the 90% of developers out there. Average. 9% consists of the shitty ones, and 1% are the Torvalds-class.

All of this just means I still have room for improvement. Which is a good thing. Keeping a Learner’s attitude is nice and it’s what I intend to do. It’s hard to fill a glass that’s already full.

I acknowledge this and accept it wholeheartedly. Because what’s important is we are having fun at what we do. So, Keep writing software, play around with new stuff, learn old stuff or whatever floats your boat.

Who knows maybe one day you accidentally write the next (insert new hotness here).

Software

yo aspnet not updating to Core 1.0

The Environment

On my Linux Mint 17.3 machine here’s what everything looks like:

yoman_env

 

I am able to update aspnet generator successfully thru yeoman wizard.

But when I try to yo aspnet, I always get the ASP.NET 5 welcome screen, instead of ASP.NET Core 1.0 like this one:

yoman_core1

The solution

All of the solution I found in the web does not apply to my specific case. What we need to do is to search for and remove any outdated generator that somehow remained in one or more global folder.

To start, search you computer for any instance of generator-aspnet

$ cd /
$ sudo find -name generator-aspnet

Among the search results, we should focus only on global folders. In my case, the following were found

./usr/lib/node_modules/generator-aspnet
./usr/local/lib/node_modules/generator-aspnet
./home/jokab/dev/pochela/node_modules/generator-aspnet
./home/jokab/.npm/registry.npmjs.org/generator-aspnet
./home/jokab/.npm/generator-aspnet

The global folders we will focus on are those under /usr/ folder, two shown above.

I open up /generator-aspnet/app/index.js for both one of them shows

Welcome to the marvellous  ASP.NET 5 generator!

This is the old generator – and for some reason, yeoman is picking this up instead of the updated one. I removed the folder by doing

rm -rf /usr/lib/node_modules/generator-aspnet

Now try yo aspnet again. Yeoman should now be able to pick up the latest generator.

Did you have a similar issue? Let me know how yours went.

Software, Technology

Battle of the Code Editors C# edition

 

Lets set the arena. The editors must be:

  • Cross platform
  • Light weight
  • Extensible with C# support!
  • Modern UI

The IDEs

Code editors must be light weight. That said, take a look at these clunky, cross-platform full-blown IDEs so we can move them out of the way.

md-heroMonoDevelop IDE. Blandness Theme.
rider_navigation_preview2x
Jetbrains Darcula Theme. I’m a fan.

Visual Studio Code

Let me introduce myself. I am a Software Developer with 12 years of experience specializing in Microsoft technologies. That statement not only hints that I’m old, it also says I am a long-time Windows Developer. And in our world, Visual Studio is king. I’m going to be blatantly biased so just suck it.

codebasics_layout

PROS:

  • Excellent intellisense and code snippet support
  • Rich plugins collection
  • Easy git intergration
  • Tab-less UI (because tabs are overrated)
  • Markdown Preview
  • Its from Microsoft! <- just suck it.
  • FREE

CONS:

  • Initial loading is slow

The biggest let-down is the loading speed. But don’t get discouraged yet, once its loaded, its pretty darn fast. To be honest my initial intent was to replace notepad/gedit with VSCode, but I guess that’s not going to happen.

 

Sublime 3

Now I keep hearing all good stuff about this editor so I decided to give it a spin. Its not free but watch out for Lime Text, which looks very promising.

st3_split_screen

PROS:

  • Excellent intellisense support
  • Rich plugins collection
  • Easy git intergration
  • Very fast. Everything is just fast.

CONS:

  • Not Free
  • Cant change font

 

Atom

Made with love by the people from GitHub. Its built with Electron, same as VSCode.

atomfiga101614

PROS:

  • Excellent intellisense support
  • Rich plugins collection
  • Easy git intergration
  • FREE

CONS:

  • Initial loading is slow

 

Brackets

This is probably the best HTML editor to date mainly because of the Live Preview feature. Its like Visual Studio’s Browser Link. It only works with Chrome/Chromium for now but its better than nothing. Also, watch out for Light Table.

Selection_012

PROS

  • Rich plugins collection
  • Easy git intergration
  • FREE

CONS

  • Somewhat limited settings (Cant change font for example)
  • poor code snippets support
  • inferior intellisense

 

Conclusion

I therefore conclude that VSCode is the best. Kidding aside, these code editors are better at one thing than the other. For example, when my project needs to deal with more HTML than most, I prefer to use Brackets. If I want to modify something really quick, then I’d fire up Sublime because its blazing fast. For the rest of the day, its VSCode all the way. I just keep Atom on my machine for diversity.

For your C# needs, checkout omnisharp.

That’s it?

Where is Notepad++? Or GEdit? Vim/Emacs?

They’re not here because they don’t meet the requirements stated from the start. If you feel I have violated you in any way and left out your favorite code editor, please drop a message in the comments section below.

Uncategorized

Hello Again JetBrains Rider

I mentioned last time that Jetbrains’ cross-platform IDE for .NET is still too young for an affair, but after receiving a few version update notices in my inbox, I decided to give it another chance.

After using it for a few number of days, I was and still am being pleasantly surprised by all the cool features this IDE has to offer. To start with Darcula theme is awesome. The built-in terminal window is very handy. Its auto-complete and code snippets is not terrible, its just second to Visual Studio but still better than MonoDevelop. It takes a while to wrap your head to the window layouts and toolboxes but once you get it, you will appreciate most of them. There are plenty more gems scattered around, you just have to carefully watch out for them.

Visual Studio spoils us rotten. Chews our food for us and shoves it down our throat with a silver spoon. Its like a wife that gives you everything you can possibly need at home so you don’t have to go outside for a drink or look at another woman. With Jetbrains Rider, you will have to dig around for the feature or setting you need. For example, at one point I struggled to add a reference to a specific project. But the Project Properties page isn’t there. And for a number of times, I manually add those reference by directly modifying the csproj file and typing in text. Lately I discovered that Rider can do it for us thru the red bulb icon or by pressing Ctrl+Space while the cursor is on the class you want to add.

Selection_011

I am definitely enjoying Rider right now. Its still brand new so the community is still flourishing so don’t expect support to come flooding in. Its just been a few days, and I haven’t tried  poking around for Rider support. But I’m sure Jetbrains people are on top of it.

Workspace 1_010
Rider spanning multiple monitors on Linux Mint and screenshot 
of my pet project, MICS.