Archive for the ‘Software Development’ Category

Don’t use JSON for configuration files

Monday, April 25th, 2016

For quite some time, I wondered about this: “why the hell are comments forbidden in json files?”.

The short answer is: Douglas Crockford cared about interoperability (https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSr).

The problem is that nowadays, many CLI tools make us of json files to store their configuration. It’s nice because the syntax is pretty lightweight and because it’s really easy to parse, but that’s where it ends because you know what? Comments are pretty darn useful in configuration files..

Unfortunately, as it stands, many of those tools (or at least the parsers they rely upon) choose not to accept comments. As Douglas states, nothing prevents us from sending json files through a minifier to get a comments-free version but… but it’s just a pain to have to do that before passing json files around; worse so when you need to have the file available on disk for some tool and even worse when that file needs to have a certain name (e.g., tsconfig.json).

Some tools do add support for comments, but then you realize that any surrounding tools must also accept that, which is often not the case or takes a while to get there. So that’s that, and IDEs which will complain if you start adding comments to json files (and rightly so..).

All in all, my opinion about this matter now is that json is just not the answer for configuration files. Since json does not support comments, then don’t use json, use something else, don’t try to hack your way around.

What should we use instead? Who cares, as long as it supports comments and doesn’t force you into hacks just to be able to comment things that need be!

YAML is one option, TOML is another, XML is yet another (though way too verbose) and I’m sure there are a gazillion other ones.

If you’re in the JS world then why not simply JS modules? There you get the benefit of directly supporting more advanced use cases (e.g., configuration composition, logic, etc).


Static sites? Let’s double that!

Monday, March 14th, 2016

Now that I’ve spent a good deal of time learning about what’s hot in the front-end area, I can go back to my initial goal: renew this Website.. or maybe I can fool around some more? :) In this post, I’ll describe the idea that I’ve got in mind.

One thing that’s been bothering me for a while is the dependency that I currently have on WordPress, PHP and a MySQL database. Of course there are pros and cons to consider, but currently I’m inclined to ditch WordPress, PHP and MySQL in favor of a static site.

Static site generators like Hugo (one of the most popular options at the moment) let you edit your content using flat files (e.g., using Markdown) with a specific folder structure. Once your content is ready for publication, you have to use a CLI/build tool that takes your content (e.g., posts, pages, …) and mixes it with a template.

Once the build is completed, you can upload the output on your Web host; no need for a database, no need for a server-side language, no need for anything more than a good old Apache Web server (or any Web server flavor you like). Neat!

Now what I’m wondering is: can we go further? What if we could create doubly static static sites? :)

Here’s the gist of my idea:
First, we can edit/maintain the content in the same way as with Hugo: through a specific folder structure with flat files. Of course we can add any feature we’d like around that: front matter, variables & interpolation, content editor, … For all that a build/CLI should be useful.. more on that later.

Note that the content could be hosted on GitHub or a similar platform to make the editing/publishing workflow simpler/nicer.

So, we’ve got static content, cool. What else? Well now what if we added a modern client-side Web application able to directly load those flat files and render them nicely?

If we have that then we could upload the static content to any Web host and have that modern Web app load the content directly from the client’s Web browser. The flow would thus be:

  • go to https://www.dsebastien.net
  • receive the modern Web app files (HTML, CSS, JS)
  • the modern Web app initializes in my Web browser
  • the modern Web app fetches the static content (pages, posts, …)
  • the modern Web app renders the content

Ok, not bad but performance could be an issue! (let’s ignore security for a moment ok? :p).
To work around that, we could imagine loading multiple posts at once and caching them.
If we have a build/CLI could also pack everything together so that the Web app only needs to load a single file (let’s ignore the HTTP 1.1 vs HTTP 2.0 debate for now).

In addition, we could also apply the ‘offline-first’ idea: put pages/posts in local storage on first load; the benefit would be that the application could continue to serve the content offline (we could combine this with service workers).

The ideas above partially mitigate the performance issue, but first render would still take long and SEO would remain a major problem since search engines are not necessarily great with modern client-side Web apps (are they now?). To fix that, we could add server-side rendering (e.g., using Angular Universal).

Server-side rendering is indeed nice, but it requires a specific back-end (let’s assume node). Personally I consider this to be a step back from the initial vision above (i.e., need for a server-side language), but the user experience is more important. Note that since dedicated servers are still so pricey with OVH, it would be a good excuse to go for DigitalOcean.. :)

Another important issue to think about is that without a database, we don’t have any way to make queries for content (e.g., search a keyword in all posts, find the last n posts, …). Again, if we have a build/CLI, then it could help work around the issue; it could generate an index of the static content you throw at it.

The index could contain results for important queries, post order, … By loading/caching that index file, the client-side Web app could act more intelligently and provide advanced features such as those provided by WordPress and WordPress widgets (e.g., full text search, top n posts, last n posts, tag cloud, …).

Note that for search though, one alternative might be Google Search (or Duck Duck Go, whatever), depending on how well it can handle client-side Web apps :)

In addition, the build/CLI could also generate content hashes. Content hashes could be used to quickly detect which bits of the content are out of date or new and need to be synchronized locally.

There you have it, the gist of my next OSS project :)

I’ll stop this post here as it describes the high level idea and I’ll publish some additional posts to go more in depth over some of the concepts presented above.


Modern Web Development – Part Two

Wednesday, February 17th, 2016

In the first part of this series, I’ve explained how I re-discovered the state of the Web platform and specifically of the JavaScript universe.

Around June, I changed my mind about AngularJS and thought that Angular 2 could arrive on time for our project (hint: it didn’t), so I decided to tag the current state of my personal project and tried to actually start developing my site using it.

I spent some time during my holidays to migrate my app to Angular 2. During that time, I banged my head against the wall so many times it still hurts; not because of Angular 2, but because of RxJS and Reactive Programming; those made me feel really stupid for a while :)

Also during that time, I spent time improving my build. The build story was starting to itch me real bad, so at some point I put my project aside and decided to extract the build to a separate project and concentrate on that for a while. That effort led to the creation of modernWebDevBuild” (MWD for friends). MWD was my take at providing a reusable build for creating modern web applications. You could argue that that solution is not modern anymore but hey, I can’t stop time ;-)

If you look at the feature list of modernWebDevBuild, you’ll see that it’s basically Web Starter Kit on steroids with support for TypeScript, tslint, karma, etc.

I’ve put some effort into making it flexible enough so that it doesn’t put too many constraints on the client project structure and I’m pretty sure that, with some help of the community, it could become much more malleable and could be reused across many more projects, independently of whether those are based on Angular 1, Angular 2 or something else.

A while after, I’ve also created a Yeoman generator called modernWebDevGenerator to make it easy to scaffold new projects using modernWebDevBuild. The generated projects include many personal choices (e.g., Angular 2, TypeScript, SystemJS, JSPM, sass, jshint and a rule set, jscs and a rule set, …) and style guidelines (e.g., component approach for Angular and SASS code), but most if not all can be stripped away easily.

In my opinion, modernWebDevBuild was a good shot at providing a reusable build for front-end web development. I’ve used it for multiple projects and could update it easily without having to worry about the build or having to maintain a ton of build-related dependencies and whatnot. That was a relief: fixing an issue meant fixing it once in one place, much better!

For me, the idea of having a complete build as a dependency of a project is something I find immensely valuable.

Recently though, with the project at work (where we’ll use AngularJS for now) we’ve evaluated different solutions for bundling, module loading & build tasks in general which led to the decision of  using webpack. So far, it’s been a blast. I’m not going to explain in detail what webpack is as there are already more than enough articles over it out there, but IMHO it’s the clear winner at the moment. The most important for me is that it has a very active/vibrant community around it busy maintaining & developing tons of plugins. Those plugins add support for pretty much anything that you might need in your front end build. You need transpilation? Check. You need autoprefixing? Check. You need cache busting? Check… well you get the idea.

We’ve decided to fork the Angular 2 Webpack Starter Kit of AngularClass as it was the closest to what we needed to have.

With our project template, our goal is to integrate the whole stack that we’ve decided to use (e.g., Redux, RxJS, JSData, webpack for module bundling/loading, …) and use that template as basis for our next projects.

The thing is that I’d still like to extract the webpack build to a separate project (or at least a part of it). Again, I really believe that it should be possible to provide a reusable build configuration as long as it is flexible enough to accommodate for general use cases. Ultimately the discussion boils down to pragmatism versus the pleasure of reinventing your own wheel each time. Personally, I like round wheels and if one is flat then I don’t want to fix all my cars. What about you?

In the next post, I’ll explain what my new goal is for my site; as I said, I took a different route for a while because I had lots to learn, but now it’s about time for me to go back to my initial goal :)


Modern Web Development – Part one

Wednesday, February 17th, 2016

Since April last year, I’ve been plunging again in the world of Web development.. and what fun it has been! In this series of posts, I’m going to summarize the stuff I’ve done last year in order to hop back on the train and I’ll describe what I’ve learned along the way.

At the time, I published two blog posts, which were my way of condensing my vision for an important project at work aiming to modernize the way we create Web applications by going towards a client-side architecture combined with RESTful Web Services on the back-end.

When I started looking back at how the Web platform had evolved during the 2012-2015 period, the main things I had on my mind were:

  • mobile first & responsive web design
  • client side Web application architecture (which I personally consider to be the part of Web 3.0 — seriously, why not?)
  • the new specs that had reached broad support in modern Web browsers and were gaining a lot of traction
  • the offline first idea that these specs made more realistic

I wanted to learn more about AngularJSnode.jsnpm and sass but that was about it. I remember that at first, I had no precise idea yet about the build tool and the build steps that I wanted/needed… I hadn’t even heard about ES6 yet!

Since then, I’ve learned a ton about ES2015, TypeScript, module systems, module loaders, JS frameworks & the tooling around, front-end state management solutions, front-end build systems, project boilerplates, css style guides, quality assurance for front-end apps, unit & e2e testing libraries, … and the integration of it all…

The funny thing is that… I failed to deliver.

Initially, my personal goal was to create a responsive client-side Web app exploiting the RESTful API of my WordPress installation to replace my current theme, but I changed my mind along the way… So far, my site hasn’t changed one bit. I did improve some things though, but that was more around security than anything else.

So what made me change my mind and where did I spend my time?

At first, I was concentrated on the task at hand and I looked at how the HTML5 boilerplate had evolved as I knew that it was one of the best starting points around for creating modern Web apps. My idea was simple: use HTML5 boilerplate or InitializR to get ModernizR… and add some good old script tags… :p

I started with HTML5 boilerplate, but shortly after, I stumbled upon Web Starter Kit which was fresh out of Google’s oven, was based on HTML5 boilerplate and had some really cool features.

It came out of the box with a nice build which included support for JSCS (JS code style), JSHint (JS code quality), autoprefixing, BrowserSync (if you don’t know that one, DO check it out!), sass and ES6 (that was still the name at that point) with the help of Babel, …

 I really liked their setup and decided to use it as basis for my project; and that’s where my trajectory deviated :)

Given that I’m quite curious, I spent a while deconstructing Web Starter Kit’s build so that I could really understand what made it tick. That made me discover npm, gulp and the whole ecosystem of gulp plugins.

I really enjoyed doing so as it has helped me better grasp the necessary build steps for modern Web apps:

  • transpile code (ts->js, sass->css, …)
  • check quality
  • check style
  • create a production build (bundle, minify, mangle, …)
  • execute unit tests
  • execute end to end tests

At that moment, I was happy with the build as it stood so I continued to focus on developing my app. I took a good look at what ES6 was, what it meant for JavaScript, its ecosystem and how Babel helped (was it still called 6to5 then?). Learning about ES6 features took me a long while and I’m still far from done, but it was well worth it. ES2015 is such an huuuuuuuuuuuge step forward for the language.

I also took a glance at Angular 2 which was still in alpha state. It looked interesting but I believed that it would never be ready in time for our project at work (and it wasn’t). Still, I did spend a few days toying around with the alpha just to get to understand the basic principles.. and I must say that I really really loved what I saw!

That quick research spike also made me discover TypeScript.

Having a strong Java & OO background, TypeScript (TS) directly got me excited. I’m a strong believer in strong (heh) typing, and the fact that TS already supported many ES6 features that weren’t natively supported by Web browsers yet was very appealing to me.

Moreover, having dozens of Java developers in our development teams at work, TypeScript seemed really ideal for us as it supports many features and idioms that our developers are very familiar with (classes, interfaces, generics, strong typing, decorators, …).

If you want to learn more about TypeScript, I definitely recommend the Typescript Deep Dive.

At that point, tsconfig.json wasn’t there yet and the most evident choice to integrate the necessary build step was gulp, as advertised by Dan Walhin’s excellent blog post. If I had read more about npm I might have gone a completely different path (i.e., used npm scripts only).. ^^.

At that point, I had to deviate from what Web Starter Kit offered me in order to add build tasks for TypeScript, tslint, etc. Fiddling with the build made me realize that it was quite brittle, so I refactored it quite a lot and tried to improve things (e.g., separate the build tasks in different files, extract the configuration settings, ensure that it would not break the build on each error, etc). I remember that I wanted to contribute back to Web Starter Kit but realized too late that I had made too many changes at once for them to be able to integrate easily (silly me, bummer).

I went pretty far with actually as at some point, I was using TypeScript to output ES6 code that I then sent through Babel, just so that I could use async/await and other things that TypeScript wasn’t able to transpile to ES5… :)

The exercise helped me see how “immature” and “fragile” the whole JavaScript ecosystem was. What I mean by that is that there seems to be only moving parts and each of those parts don’t necessarily keep happy with each other. Not only do too few people really understand what semver actually means and respect it, but everything that shines bright gets replaced faster than the speed of light :)

As a technologist, I love the pace it imposes for the fun and innovation it brings to the table, but it’s also frustrating for many reasons and (should be) quite scary for enterprises (to some degree). People talk about JavaScript fatigue, which is quite a fun way to put it and I can certainly understand the idea now.

One example that I thought a lot about is the fact that each and every front-end project seems to have its own build chain and build configuration that lives within the project, in complete isolation and has to be maintained.

Of course each and every project has its specificities so there really can’t be ONE rigid & reusable solution to rule them all, but the idea of duplicating so much effort needlessly across a whole community of developers violates the DRY principle as much as anything ever could.

Just try and imagine how many people must have used some Yeoman generator to scaffold projects, which now all have separate builds with tasks that all do the same things but are all defined 20.000 times in a gazillion different ways using variable and unreliable dependency versions… :)

When you scaffold a project using a generator, you end up with a snapshot of the template and of the build provided by the generator at that point in time and then it’s up to you to keep your version up to date and to integrate all improvements and bug fixes, assuming you have time to follow that… you poor thing!

Being part of a core software development team at work, my focus is most often on finding reusable solutions to common problems, limiting effort duplication and what not and thus, the front-end universe’s situation seems quite sad in that regard.

Another point that struck me was how limited the main package management solution was. npm is nice and all, but not being able to define some parent/generic/reusable configuration (e.g., like parent pom files in Maven) is kind of surprising. Again, the DRY principle probably corresponds to DO Repeat Yourself in the frontend universe. I’m sure that front-end experts will tell me that you can work around all that in countless ways, but that’s exactly the issue: I shouldn’t have to invent my solution for a general issue people should be concerned about.

To conclude on a positive note though, I do believe that all the tooling DOES bring added value because it makes it possible to manage dependencies correctly, define build steps which execute tests, generate coverage reports (e.g., using Istanbul), generate production builds etc.

This piece is getting a bit long, so I’ll continue my little story in part two!

 


OVH et les headers HTTP

Friday, January 15th, 2016

Si un soir d’hiver, il vous prend l’envie d’envoyer des headers HTTP à votre back-end hébergé chez OVH (i.e., si vous êtes aussi cinglés que moi), alors ma petite histoire devrait vous intéresser (en tout cas la conclusion)!

Comme j’ai une forte tendance à vouloir expérimenter, j’ai mis en place un petit système de jetons basés sur les JSON Web Tokens (JWT), de façon à pouvoir en générer à la volée, vérifier leur validité, les renouveler, etc.

Comme je n’ai toujours pas de serveur dédié (à vot’ bon coeur :p), j’ai implémenté ça en PHP (cfr mon post précédent) et j’ai uploadé ça sur un hébergement OVH.

J’avais évidemment tout développé/testé en local et j’étais plutôt content de moi. Or voilà, une fois déployé sur OVH, mon premier essai a été un échec total. Tellement foireux même que j’ai crû à une éclipse lunaire.

Après avoir retourné le bouzin pendant une bonne demi heure, je viens de me rendre compte qu’OVH ne passe pas les headers HTTP sans les chatouiller un peu au passage.

En effet, mon joli header “Authorization” disparaît pûrement et simplement à l’arrivée, tandis qu’une version plus exotique telle que “X-Authorization” devient quand à elle “X_Authorization”.

Alors je m’imagine bien qu’OVH fait ça pour de super bonnes raisons (que je suis curieux de découvrir), mais j’avoue que pour le coup ils ont réussi à me donner la nausée :)

Bref, vous êtes prévenus!


PHP composer and… Bash!

Sunday, December 20th, 2015

Bash bash bash!

It’s been a very long while since I’ve last played with PHP.
I’m not really willing to start a new career as PHP integrator, but it’s still cool to see that the language and the tooling around has evolved quite a lot.

Atwood‘s law states that any application that can be written in JavaScript will eventually be written in JavaScript. One could also say that any language will ultimately get its own package manager (hello npm, NuGet, Maven, …).

So here I am, needing multiple PHP libraries and willing to try a PHP package manager :).

Apparently, composer is the coolest kid around in PHP-land. As you know I still like BASH … on Windows, so here’s a quick guide to get PHP and composer available in your Windows bash universe.

First, you need to download the PHP binaries for Windows; you can get those here (always prefer the x64 version).
Once you have the archive, unzip it where you wish then, in the folder, make a copy of “php.ini-development” and call it php.ini. That’s the configuration file that php will load each time it runs on the command line.

Edit php.ini and in it you need to uncomment the following things (for starters):

  • extension_dir = “ext”
  • extension=php_openssl.dll

With the above, you’ll have SSL support and PHP will know where to find its extensions.

Now, create a folder in which you’ll place PHP extensions. In my case, I’ve created a “php_plugins” folder and placed it right next to the folder containing the PHP binaries (I like to keep things clean).

Next, open up you bash profile and add something along those lines:

alias php7='export PHP_HOME=$DEV_SOFT_HOME/php-7.0.1-Win32-VC14-x64;append_to_path ${PHP_HOME}; export PHP_PLUGINS_HOME=$DEV_SOFT_HOME/php_plugins;'
alias php='php.exe'

Make sure to call ‘php7’ at some point in your profile so that PHP is actually added to your path. Personally, I have a “defaults” alias in which I list all the things that I want to be loaded whenever my shell is loaded:

alias defaults='php7; ...'

# Initialization
defaults # Load default tools

Close and reopen your shell. At this point you should have php at your disposal anywhere you are (eeeewwwww scary :p).

Now you’re ready to get composer. Just run the following command to download it:

curl -sS https://getcomposer.org/installer | php

Once that is done, you should have a “composer.phar” file in the current folder; grab it and move it to your “php_plugins” folder.

Finally, edit your bash profile again and add the following alias:

alias composer='php $PHP_PLUGINS_HOME/composer.phar'

Close and reopen your shell. Tadaaaaa, you can type “composer” anywhere and get the job done.. :)


Installing node and npm on Ubutun 15+

Friday, December 18th, 2015

In case you would want to use one of my recent projects (e.g., ModernWebDevGenerator or ModernWebDevBuild) on Ubuntu (or any other OS btw), you’ll need nodejs and npm.

If you’re using ubuntu and go the usual way (i.e., sudo apt-get install…) then you’re in for a bad surprise; you’ll get node 0.1x.y and also a very old npm release.

Actually, the best way to get nodejs and npm on Ubuntu is to use the node version manager (nvm).

nvm can be used to install and keep multiple versions of node in parallel, which is very useful, especially when you have to test your node-based project on multiple versions.

The installation is very straightforward:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash

After that, close and reopen your terminal. You now have ‘nvm’ at your disposal.

nvm install 4.0
nvm install 5.0
nvm use 5.0

Just with the above, you get two versions of node (along with npm) installed. As you can see, you can use ‘nvm use’ to change the active version easily.

That’s it!


Use bash to decompile Java class files recursively

Tuesday, December 8th, 2015

Here’s a quick one. As you *might* know, I like Bash (even though I’m a Win* user..), so here’s an alias I’ve added recently:

export JAD_HOME=...
append_to_path $JAD_HOME
alias jad='(jad.exe)&'
jadr() { ("jad.exe" "-d" "." "-s" "java" "-r" "**/*.class")& }

With the above, jad will execute ‘jad’ and ‘jadr’ will recursively decompile all Java class files in the current/sub folders.


So fond of fonts

Tuesday, October 6th, 2015

I can’t say that I’m in love with typography, but I do enjoy writing (code or otherwise) using a good editor and… a good looking font.

I’ve recently stumbled upon the Hack font, which has its roots in the open source world and derives from Bitstream Vera & DejaVu. I immediately liked it; it feels good to change stuff once in a while… :)  I might still choose to switch back to Consolas, but for now I’m very pleased with Hack and it gave me a reason to mess around with Bash yet again ^^.

Of course, this alone is not a sufficient justification for a blog post! As I’ve described in an earlier post, I always try to maximize the ‘portability’ of my development environment and overall configuration and changing fonts should be no exception ;-)

I do not install fonts manually in the OS; I prefer to put my fonts in a central folder of my CloudStation share (i.e., along with the rest of my configuration & tools) so that it gets replicated on all my devices (I also do the same with tons of other stuff including wallpapers).

A major issue with this is that customizing fonts can be done in plenty applications but each has its own specificities, either they give you a lot of control or you have to go through hoops to achieve what you want. More specifically, many applications will only allow you to select fonts that are available through the OS’s font system (i.e., that are registered) while others will require additional flags or even worse, will want you to copy the font files around.

Under Windows, installing new fonts requires administrator privileges due to the security risks (laugh all you want :p). Thus even if I was to register the fonts, I couldn’t do so at work which is a bummer.

Fortunately, there are programmatic ways to register fonts in a user’s session without administrator privileges. I’ve found two programs that can do this from the command line:

I’ve found regfont to be better  as it is a bit more *nix friendly, comes with a 64-bit executable and is less verbose than RegisterFont (it could use a –silent switch though). 

Using regfont, you can easily register a new font in your user session using the following:

regfont.exe --add cool.ttf

You can also add a complete folder in one go using a wildcard. As you might already know, I’m a bit of a bash fan, so indeed I added a few more aliases to my profile to automate the registration of my custom fonts whenever my bash profile is loaded. It adds a bit to the overall startup time but it’s still quite reasonable.

First things first, since I wanted to keep a clean organization in my fonts folder, I couldn’t use the wildcard flag of regfont as it doesn’t look for font files recursively. For this reason, I needed to find the files myself (using the find command) and execute regfont once for each file.

Since the find command returns *NIX paths, I needed to convert those to WIN* paths; this was easy enough with the help of StackOverflow (as always ^^):

winpath() {
	if [ ${#} -eq 0 ]; then
		: skip
	elif [ -f "$1" ]; then
		local dirname=$(dirname "$1")
		local basename=$(basename "$1")
		echo "$(cd "$dirname" && pwd -W)/$basename" \
		| sed \
		  -e 's|/|\\|g';
	elif [ -d "$1" ]; then
		echo "$(cd "$1" && pwd -W)" \
		| sed \
		  -e 's|/|\\|g';
	else
		echo "$1" \
		| sed \
		  -e 's|^/\(.\)/|\1:\\|g' \
		  -e 's|/|\\|g'
	fi
}

Later in my profile, I’ve added the following for registering the fonts:

export MY_FONTS_FOLDER=$CLOUDSTATION_HOME/Configuration/Dev/Fonts
...
export REGISTER_FONT_HOME=$TOOLS_HOME/RegisterFont
append_to_path $REGISTER_FONT_HOME

register_font(){ ("$REGISTER_FONT_HOME/regfont" "--add" "$1")& } # alternative "RegisterFont.exe" "add"
alias registerfont='register_font'
...
# Register all my fonts for the current user session
# Works also if the user is not local administrator
# Reference: http://www.dailygyan.com/2008/05/how-to-install-fonts-in-windows-without.html
register_fonts(){
	SAVEIFS=$IFS # save the internal field separator (IFS) (reference: http://bash.cyberciti.biz/guide/$IFS)
	IFS=$(echo -en "\n\b") # change it to newline
	fontsToRegister=`find $MY_FONTS_FOLDER -type f -name "*.ttf"` # recursively find all files matching the original extension

	for fontToRegister in $fontsToRegister; do
		fontToRegisterWinPath=`winpath $fontToRegister`
		#echo $fontToRegisterWinPath
		register_font $fontToRegister
	done
	unset fontToRegisterWinPath
	unset fontToRegister
	unset fontsToRegister
	IFS=$SAVEIFS # restore the internal field separator (IFS)
}

I then simply invoke the register_fonts function near the end of my profile, just before I call clear.

With this in place, whenever my profile is loaded, I know that my fonts are registered and usable in most applications.

Just as a side note, here’s how you can manually install a custom font for use with Java-based applications such as IntelliJ, WebStorm, Netbeans, etc: you need to copy the font files to the jre/jdk lib/fonts folder.

As a second side note, ConEmu will load the first ttf file it encounters in its folder and make that one available for use.

As a third and last side node, I couldn’t find a way to load a custom font with Sublime Text 3, it only seems to be able to list system-registered ones…

So.. which font are you most fond of?

 


ConEmu is my new console replacement

Friday, August 7th, 2015

TL;DR: ConEmu is the BEST console for Windows power users!

Update 2015-08-24:

A recent update to ConEmu has added support for a feature I’ve requested last month, the ability to automatically restore the ConEmu console on the currently active screen (i.e., where the mouse is located), this makes ConEmu even more awesome! :D


 

In a previous post about my Windows dev environment configuration, I’ve explained that I was using AutoHotKey in combination with Console2 to get a quake-like console on Windows. Since then, I discovered ConEmu… and I ain’t going back!

I’ve recently switched from Console2 to ConEmu and because of this change, I no longer need AutoHotKey to show/hide the console since ConEmu show/hide can be bound to a global hotkey (i.e., I can get the same behavior). Altough, I still use AutoHotkey in order to start ConEmu when pressing ‘²’ in case ConEmu isn’t started already.

ConEmu has a gazillion features, one of which being the holy grail for me: an actual Quake-like console with animated dropdown and support for image backgrounds :D. It’s not my goal to describe all it can do but do yourself a favor, just try it out.

Basically the rest of my configuration is as explained in my earlier post apart from the fact that I now use ConEmu rather than Console2. In fine, I’m still using Bash :)

Here’s a link to my ConEmu configuration file

ConEmu configuration highlights:

  • Main
    • Font
      • Consolas
      • 16
      • Clear Type
  • Main > Size & Pos
    • Full screen
    • Centered (not important actually)
    • Long console output: 9999
    • Restore to active monitor (MUST HAVE if you use my configuration). See my update of 2015-08-24 above)
  • Main > Appearance
    • Always on top
    • Auto scrollbars (hidden after a small delay)
    • Quake style slide down (
    • Auto-hide on focus lose
  • Main > Background
    • custom background image (dark.jpg)
  • Main > Tab bar
    • Always show
    • Font
      • Consolas
      • 14
    • Console (text)
      • <%c> %d
      • console id
      • current working directory
  • Main > Confirm
    • No confirmation for new consoles/tabs
    • No confirmation for tab closing
  • Main > Update
    • automatic check on startup
    • Release type: latest
  • Startup
    • {Bash::Git bash} (can’t live without my Bash shell :p)
  • Startup > Tasks
    • {Bash::Git bash}
      • set as default task for new console
      • set as default shell
  • Features
    • Sleep in background
    • Log console output (great!)
  • Features > Text cursor
    • Active console
      • Block
      • Color
      • Blinking
  • Features > Colors
    • Scheme: Solarized Git (I’d love to have a Seti_UI one here)
    • Fade when inactive
  • Features > Transparency
    • Active window transparency: ~90%
  • Features > Status bar
    • Shown
    • Font
      • Consolas
      • 14
    • Selected columns
      • Console title
      • Synchronize cur dir (not sure what this one does)
      • Caps Lock state
      • Num Lock state
      • Active console buffer
      • System time
  • Keys & Macro
    • ²: Minimize/Restore (Quake-style hotkey also)
    • F1: Create new console or new window
  • Keys & Macro > Controls
    • Send mouse events to console
    • Skip click on activation
    • Skip in background
    • Install keyboard hooks
  • Keys & Macro > Mark/Copy
    • Detect line ends
    • Bash margin
    • Trim trailing spaces
    • EOL: CR+LF
    • Text selection: Left Shift
    • Copy on Left Button release
    • Block (rectangular) selection: Left Alt
    • Copying format: Copy plain text only
  • Keys & Macro > Paste
    • All lines
    • Confirm
    • First line Confirm pasting more than 200 chars

Here’s the new version of my AutoHotKey script. Now it:

  • starts ConEmu if not running already
  • lets the ‘²’ key press pass through if ConEmu is running (so as to let ConEmu show/hide the console window
; ConEmu script (start it if it ain't running)
; ConEmu class: VirtualConsoleClass (reference: https://github.com/koppor/autohotkey-scripts/blob/master/ConEmu.ahk)
; Change your hotkey here
;SC029 == ²
SC029::

DetectHiddenWindows, on
IfWinNotExist, ahk_class VirtualConsoleClass
{
	Run "C:/CloudStation/Programs/tools/ConEmu/ConEmu64.exe"
	WinWait ahk_class VirtualConsoleClass
}
else{
	; let the key pass through if ConEmu is active
	; reference: http://www.autohotkey.com/board/topic/2121-hotkey-pass-through/
	Suspend, On
	Send,{SC029}
	Suspend, Off
	return
}
DetectHiddenWindows, off
return

Bonus: here’s the link to the background images that I use (I don’t claim any rights on these ^^).