Boost your dev productivity with cmder + ConEmu

Unix world and awesome tmux

In unix world there is a nice ‘tool’ ‘tmux’ - terminal multiplexer.

With ‘Terminal Multiplexer’, you can nicely split up screen and have multiple terminals visible in front of your eyes. While working with python, on one of the screens I had vim running, then there was a screen for interactive Python plus small terminal to issue git commands. I could easily jump between ‘screens’ and also have different work spaces hidden behind the tabs. This setup can be then stored in the file and loaded up on demand. It provides a similar functionality to *.sln and *.csproj files in Visual Studio, but without big IDE that tends to crash and have a painful start up speed.

It’s a pretty neat tool to work with. The user experience is something you need to get used to, but if you are spending some time in command line world, the learning curve won’t be that big.

Windows world with cmder / ConEmu

In windows world, a single window with cmd.exe / msysgit running is mostly all you need. There is a powerful Visual Studio ( with Community edition we don’t even have to worry about complex MS licensing ). Using VS and it’s extension you can just use GUI like interface to do many different tasks. I was surprised that some of my colleagues, for git management, do use either VS extension or SourceTree (recommended). I am using mostly cmd line + git gui.

At JustGiving we are using chef to maintain our infrastructure code, I also need to modify varnish files from time to time. I could do all of that in Notepad++ or even Visual Studio, but in my drive to become ‘friends’ with cmd line i really got used to the ‘gui-less’ world. I don’t want to say that this approach is a must have for productive work, because it would be a lie. Gui interfaces are fine and great, it is just a matter of preference.

Tmux on Unix made a great impression on me and I wanted similar experience in the MS world. First stop, running tmux on Windows. It is doable, cygwin environment gives you that, but colleagues at work showed me a better tool - cmder. Cmder is an extension for ConEmu which is a console emulator. After some configuration it looks like this. Pretty neat eh ?

 

My current config has 2 tabs.

  • 1st with vim instance running, to edit notes stored on dropbox  
  • 2nd with vim for editing files and coding + 2 msysgit instances and 1 cmd line running

This setup gives me a nice environment for editing files not related to Visual Studio and .NET. Another neat functionality are customized Tasks. I am using those to store different project workspaces.  One task equals one workspace. Thanks to that I can easily start another ‘project’ and initialize it by opening specific folders and specific files in Vim. It is a lot faster than doing everything manually.

To get this setup:

  • Settings -> Startup -> Tasks
  • create new predefined task with + sign
  • And add this code

What does those commands do ?

1. Creates new screen and opens Vim in my Dropbox folder context
2. Creates new screen with Vim pointing to D:\
3. Initializes shell in new window and splits current screen into 75%/25% Horizontaly

4. Initializes shell in new window and splits up the existing window into 33.3%/66.6% Vertically

5. Initializes shell in new window and splits up the existing window into 50%/50% Vertically

 

I have barely scratched the surface of the ConEmu and cmder awesomeness. Its functionality is more powerful than just split screen functionality.

EDIT:

Jakub Jedryszek asked a couple of good questions:

How to install cmder as an extension to ConEmu ?

It is simple. Standalone version of cmder already contains ConEmu. Installation is simple, download, unpack run -> http://bliker.github.io/cmder/

How to configure vim with plugins on windows and which version to use ?

You can install GVim which is vim with Gui-like interface for Windows. One of the plugins in the screen is NerdTree. To install it you just need to copy paste this file NERD_tree.vim to C:\Program Files (x86)\Vim\vimfiles\plugin. If you have multiple plugins then pathogen.vim is also recommended.

For starters with vim, it is better to start with vim-tutorial then move to vim as a Notepad replacement. Another step is VsVim. It is really a great, stable extension for Visual Studio that plays nicely with R#. I have been using VsVim for past 3 years and it was always great. I am also using Vimium which adds vim like feel to Chrome.

Are you using vim to amend / create commits description in git ?
If you have msysgit installed and you use cmd line then by default you will use vim, and yes I am using it 85% of the time, around 15% is done with git gui and rarely tortoise-git. Tortoise is mostly handy for git history checkup or blame, but lately it has been replaced by github :)

EDIT 2:

It is recommended by Maximus5 to update ConEmu to new version. Current cmder contains ConEmu version 140707(preview) while the newest ConEmu is 150309.
List of changes is massive.. To update ConEmu, get the new package from https://code.google.com/p/conemu-maximus5/ and copy its content to ‘your cmder installation’/vendor/conemu-maximus5 folder.

More Links:

  • http://www.hanselman.com/blog/ConEmuTheWindowsTerminalConsolePromptWeveBeenWaitingFor.aspx
  • ConEmu docs

Docker here docker there docker everywhere – Getting started with docker in .NET with F#

If you are in IT world, you surely heard or read about docker. There was / is a huge hype about this technology. It looks like this one might actually survive the initial ‘It’s awesome phase’. I was looking for some info about docker. It was confusing to get to know what docker really is. Too much marketing buzz words everywhere. In this post I will sum up all my notes about how to start with docker in .NET and F#. It will be like learning journey that might end as a simple tutorial on where to start.

Docker ? 

My first encounter with docker was through simple tutorial . It’s a online interactive shell emulation that lets you execute some of the commands and get the basics of docker. Sadly, after finishing it you are left out with more questions than answers.

You can start by reading official site docs. The most important thing to note is that docker is a kind of a runtime that enables you to create images that you can run on top of it.This concept is just like Virtual Machines, there are however differences. Docker is not creating full complete OS instance, instead it is creating lightweight containers that do share the kernel but are still isolated and separated from each other more. This process is more efficient both in time and memory space. It is easier and faster to create smaller containers instead of full VM’s. There are however some cons, you won’t get full isolation but who really needs that ? Other problem is … Windows is currently not supporting those small containers, we can only run Unix beacuse docker is using ‘Linux Containers‘. You can still run docker on Windows, but you can’t create windows images. Microsoft promised to provide this support in new Win version.

Running Docker on Windows

To start using docker on windows go to – https://docs.docker.com/installation/windows/. Boot2Docker is all you need to get started. This tool will install VirtualBox, configure small Unix VM that you will use docker from and there is also a nice utility tool that will connect you to your virtual machine.

Boot2Docker is a little unstable, while testing I encountered one issue with never ending docker loading. It looks like there are some with issues – https://forums.docker.com/t/boot2docker-hangs-then-crashes/401 . I had to reinstall Boot2Docker multiple times to get it working.

F# + docker

I want to create my first simple image that I will be able to use and write some F# code, compile and run it.There are existing images with F# that you can just download and start using, but in order to learn I want to create my own image. In order to do this I will define a docker file with set of instructions that define how to construct an image. Those instructions are stored in DockerFile without extensions or dots. Thankfully Boot2Docker does have vi on board so I can use it to create this file.

1. touch DockerFile – will create me a file

First instruction would be to get me a Unix distro that I will run everything on top off.

2. To build image

[crayon-55369d403e77b/]

Yey it works, behind the scenes it gets the debian DockerFile and goes from instruction to instruction creating a debian runtime. I could possibly write my own ‘debian’ image, but that would involve me learning about how to build Unix distro. Instead of that I can just point to external image and build on top of it. That is one of the beautiful things about docker. You can mix / match different images and build more complex ones using the basic ones.

3. In order to compile F# app i will need mono and fsharp compiler

[crayon-55369d403e77b/]

-y – “Always Yes” so if there is any prompt in ‘apt-get’ installer just say yes
-q – Quiet – makes the log less verbose

4. Building image

I got some errors from apt-get missing packages and the logs says to add – ‘apt-get update’. This is supposed to update the ‘apt-get’ list of packages.

[crayon-55369d403e77b/]

‘sudo docker build’ – and couple minutes later you should have a nice image with debian + mono + fsharp.

5. Switching to more specialized image 

Sadly in my case I got lot of errors while downloading ‘mono-complete’. Instead of building mono on my own, I have decided to change the base image and use some Unix distro with mono on board. Running ‘docker search mono’. Gave me a list of all the potential images, I decided to use ‘mono’.

[crayon-55369d403e77b/]

Notice that I installing vim, I need some basic text editor to create first F# hello world app.

6. What now ? - Starting container
I have base image, there is no container yet. What is a container you may ask ? Container is a running instance of imageTo start interacting with container, you need to start some app on it. Most basic one is interactive shell, that will also enable me to work on top of container

[crayon-55369d403e77b/]

7. Testing out F#

Lets see if fsharp is here fsharpi should start F# interactive.

[crayon-55369d403e77b/]

Yey, it’s here. To exit just type quit#;;

8.  Creating folder + hello world source file

I need folder and hello.fsx file

[crayon-55369d403e77b/]

9. Hello World App

[crayon-55369d403e77b/]

10. Compiling app

[crayon-55369d403e77b/]

11. Running Hello World App

[crayon-55369d403e77b/]

Uff, done. That wasn’t that hard. Now, you might ask so what ? You just compiled Hello World app … I can do this on my local machine, yep but this brief tutorial is just a starting point, I have started exploring docker, because, I want to play with akka.net and F#. In next posts I will post more things about how to use docker to create multiple akka actors and how to write some simple distributed app. That will be fun, cause it is a new world for me. Docker is more complicated than that. It is quite sophisticated and you can create complex images with many dependencies

 

edit:
You can use vagrant with docker
Docker Misconceptions
Pawel Sawicz just send me a nice link with some anty-hype opinion about docker
Another nice link with some docker problems + a solution 

Fuel your personal growth with feedback

TL;DR; Feedback is crucial for your career. Be proactive, get out of your closet and ask for it!

Last week, I have read Michal Sliwon post “A recipe for a happy software development team”. It’s a great read with some eye opening thoughts. I encourage you to read it.

One of the things that stood out for me, is how Michal and his team use feedback. As chance would have it, 2 weeks ago I asked for a feedback in my Company. It has been a year, since I joined the team. Surely, that’s enough time to tell me if I am a good team player and problem solver. In a year, you can make just enough mistakes, and good stuff too, to show who you are.

Before I started in IT, all the feedback I got were ‘grades’ at University / School. Grades are fine if you need a system for fast evaluation of multiple people but it always felt naive and ‘not enough’. How can you evaluate someone based on simple predefined grade system ? How can you help someone ‘find the way’ using this system ? I always imagined that on Uni, I would have some 1-on-1 meetings with teachers or at-least someone will try to mentor me. Nope, education system is like a factory. You get in, you get out and in the end you enter the dangerous world of grown ups, not knowing the importance of giving and receiving ‘Feedback’. Some people are even expecting similar grade systems in workplace. You know do this and that and you will be there ? There are some companies that are very transparent in their ‘promotion’ system ( Buffer, Fog Creek Software ). That’s just compensation systems, even with it there is still place for proper feedback process. Btw, I am all into transparent workplaces, this is the way to go. Lack of feedback greatly lowers your chances and negatively affects your growth. By growth, I don’t only mean career related things but also your growth as a human being.

In my first company, I was quite keen to receive my first feedback. Being a Junior Dev felt like a little kid in a maze, not knowing really what is happening around you. Feedback was important to me, I was waiting for it. Now, imagine my surprise when I got no feedback at all. And so you work without any guidance, trying to figure out on your own what kind of ‘team-player’ you are. There was one message, company did not fire me so, “hey they have to be happy right” ? Wrong! Approach like that is similar to grading system, it’s not enough. What kind of lesson you can get from just knowing that you are good enough to stay at your company ? Probably none. Back then I was just a ‘kid’, having proactive attitude was something completely alien to me. I was hoping that my first manager, would be my guide in this dangerous world of all these grown-ups and their politics. Sadly it did not happen. I felt betrayed and started managing career on my own. Yeah you can do that to a certain degree, but it’s not the same. You can’t evaluate yourself. Your point of view is flawed. You know ego, ego, ego. There is also impostor syndrome which causes different anomalies and can affect the way you are thinking about the world. So in short you need feedback from someone else. Now, I was lucky, I found mentors in the community, in form of books, blogs, I have talked to people on twitter, facebook, meetups etc. but it would be a lot simpler if I would ask for feedback on my own. What’s the lesson here ? Being pro active is really crucial, no one will manage your career for you. Get out of your closet and ask for Feedback!

Why

So much talking about feedback and there was no why. Here it is.

1. IT is changing really fast, you can’t keep up with all these technologies. Ideally me and you, we would have a lot of time to research and explore various technologies, but yep time is a limited resource and we can’t do everything at once. But hey two heads are better than one. Having someone who could give you some feedback about various techs is really beneficial.

2. Technical expertise. You can’t be an expert in all of the technologies. Having someone, somewhere with experience in certain technology can save your time and money ( and hundreds of ‘F’ words for sure ).

3. To consider yourself as a mature person, you need to ‘nurture’ your personality. Yes, It is a hard, long process, you might not even see the changes. That’s where you need external feedback. Ideally someone close to you. Friend ? Team-mate ? Friend can influence you personal life while team-mate can pinpoint career related stuff. For instance if you are dreaming about becoming senior / tech lead or architect, ideally you would find someone in this position. Hist tips and suggestion will speed up your growth into that position.

4. Life is full of dangers and those dark caves that you don’t want to go in. Having a mentor and guide that could give you some feedback is really beneficial. Imagine how much time and effort you would save if someone would told you that some route in career is a waste of time.

5. Getting feedback is a great way to learn how to give feedback. This can lead to awesome opportunities to meet intelligent people. If you are a person who is pro active in giving feedback, there are people that will greatly appreciate that. In the end you can gain contacts, friends, new opportunities. We are a social creatures and building your personal network is one of the most important things in your career.

In next post, how and where to get feedback ?

Little fix. In next post, I will write about how to get feedback and where to look for it.

From 2014 into 2015 – tech plans

A lot has happened in the last year 2014.

  • I moved to London which was not that easy task. Moving abroad proofed more difficult than, I thought and those estate agents … I don’t want to start.
  • Started working for an awesome company JustGiving. I am glad and happy that, I can work with so many awesome people on projects that have an impact. It is really good to work for Tech4Good company.
  • Finally, I invested heavily into learning about functional programming.
  • Spent a lot of time organizing my TDD knowledge, couple of books + one nice workshop with Roy Osherove.
  • I did some talks in Polish / English dev groups.
  • Organized dotnetconf.pl with Pawel and Jakub.

What I want to do in 2015 ?

  • Again, functional programming all the way. This is the ‘thing’, I want to go for now and see what happens. It was really refreshing to learn about it and use it in some practical projects.
  • DDD, I need to gain more knowledge about it. It was always there, I have read blue book by EE but I think, I wasn’t mature enough to really grasp it. I have heard good things about Implementing DDD by VV, probably will start with this book.
  • Speaking activities, I need to do more speaking to learn from my mistakes and get better.
  • Artificial Intelligence, AI will be a great source of problems complex enough so that, I can use functional programming with it. I always wanted to start learning about AI, it is something that really interests me, apart from history and sci-fi. Will see what happens, I have already started last year by refreshing my knowledge from uni and gaining little ‘foothold’ in this broad and complex subject. You will see some posts about AI for sure.

F# and Nancy – beyond Hello World

I have been trying to find some examples on how to create a web app using F# with Nancy. Most of the tutorials on the web cover simple “Hello World!” app, only the basics. In this post, I want to go beyond “Hello World” and show real life examples.

F# and Nancy – Where to start ?

Most basic app “Hello World”, is simple.

[crayon-55369d404246b/]

Nancy will automatically load up the App class. To those familiar with Nancy on C# it looks almost the same. The only noticeable difference is the lambda function declaration, plus different syntax for inheritance. Also there is this weird smile face ‘:>’ at the end. This is just a up-casting operator. For some reason Get function has to return object. In F# you also use different syntax for list / array indexing. Instead of Get["/"], you need to use Get.["/"]

GET Examples

[crayon-55369d404246b/]

POST

[crayon-55369d404246b/]

To extract the parameters I had to cast the input param, which is of obj type, to Nancy.DynamicDictonary. It doesn’t look great but there is other way.

[crayon-55369d404246b/]

How to achieve syntax like that – parameters?name ?

[crayon-55369d404246b/]

This part of code is creating new “let-bound operator”. It hides the casting logic and makes the code look cleaner.

Error Codes

[crayon-55369d404246b/]

Views

[crayon-55369d404246b/]

Syntax is simple and looks basically the same as in C#. There is only one little detail. By default Nancy looks for views in /Views folder. Currently in VS F# project there is no way to create folders from within VS. In order to do this I had to manually, create folder, add file and edit *.fsproj file. Hopefully this will be fixed in the future.

[crayon-55369d404246b/]

More details

ModelBinding

In C# syntax, you would normally use the base method Bind to perform the binding. This method is an extension method and in order to have an access to it, I had to include ModelBinding.

[crayon-55369d404246b/]

The type to bind

[crayon-55369d404246b/]

And the code to bind to the model.

[crayon-55369d404246b/]

Unfortunately, it won’t work like that. My “TestModel” type is missing default parameter-less constructor and Nancy is throwing “No parameter less constructor defined for this object” Exception.

[crayon-55369d404246b/]

There is a constructor, no Exception, but the value is not bound and is always empty. To fix this, I had to go and look through Nancy code. By default Nancy is binding to property. My val declaration is not a property.

[crayon-55369d404246b/]

Syntax for properties is a little different, but nothing serious here. I need to make my value mutable so I can modify the state.

The Application OnError pipeline

To modify the Pipeline I had to add include Nancy.Bootstrapper it has IApplicationStartup interface which can be used to hook into OnError pipeline

[crayon-55369d404246b/]

Nancy will automatically pick-up this class. The syntax for interface implementation is different, a lot. There is no += operator when working with Events and I had to use ADD method. With this example I got an exception “unable to resolve type AppStartup”. It was a problem of missing parameter less constructor.

[crayon-55369d404246b/]

The End

Those examples are not really showing the power of F#. This power lays in domain-business logic, not in simple endpoint declaration. It is also the OOP approach with F# syntax. There are other web frameworks that have more functional approach. You can check Fancy which is a nice wrapper around Nancy. In a future, I might do a comparison with some purely functional web framework.

dotnetconf.pl 2014

I feel empowered and motivated, dotnetconf.pl and also Software Architects conf gave me a huge energy boost. Thank you everyone for being with us on dotnetconf.pl. For those of you who don’t know, dotnetconf.pl is an online conference, from Polish speakers to Polish developers. You can watch presentations here.

Last Saturday we have organized 2nd edition of this event and it looks like there will be another one. We don’t know when, I know that ideally, you the viewers, would like it to be sooner than later. As of now the plan is to do them yearly, but we might consider a conference on a 6 month basis plus smaller events per 3 months. It all depends on the demand and the audience. Pawel has also an idea to start audio cast, something like hanselminutes, with speakers discussing various topics from our dev world.

While, I was writing this post someone else was also thinking about audio cast idea and … today Maciej Aniserowicz has started his podcast ( Check it out it’s great ). Due to this we might pursue a different idea, maybe something like pair programming on stream, twitch, we might try it on 15th November doing game of life in Haskell / F# for Global Code Retreat. Would there be any interest in something like that ?

The conference chat was full of discussions. That’s great, really great and there is this small idea, proposed by one of the attendees, to start a conference a week before a live event like DevDay. With such a date, all the topics started online, could be followed in real life. Wouldn’t that be great ? The soo called “Hallway Track” doesn’t fit to the online format. However if you have any ideas on how to do something like that, then PM me :)

Unfortunately you weren’t able to watch Basia’s talk, we had issues with google hangout. We have been testing everything twice and it was ok and the suddenly it stopped being ok. Basia’s talk is going to be recorder and sent to all of you, soon be patient :)

Overall conference was great, I hope that you also enjoyed it. Still there are things that we can change / improve.

  • backup speakers, ready to step up if there is a problem
  • backup option for streaming, that might be hard, any suggestions ?
  • missed opportunities to attract bigger audience
  • Q/A system, some semi automated script
  • implement a way to quickly notify everyone that there are issues
  • some script to notify all the channels that new stream is starting
  • because of SignalR and static pages we weren’t able to update the agenda
  • simple voting system on the site

We might do more, we are open for suggestions. Feel free to send us a message with anything. Even comment that my thumbs ups and down on camera are childish, is a helpful one :)

Thank you for all the feedback. You are the best :)
Feel free to comment here and discuss some of the things that i just mentioned.

Game programming with F#, C# and SFML – GameLoop

I am a F# apprentice. The best way to learn new language is to do some project. That’s why I have started to code one game idea that was following me for some time.

Core concept:

  • sci-fi setting
  • roguelike
  • inspired by:
    • dwarf fortress
    • prison architect
    • cataclysm dda

Because I don’t care about the graphics but the game-play, the graphic I am going to use will be an ASCII styles tile set. You know symbols, characters, letters and some simple graphic, just like in old MUD games.

For graphic layer, I am going to use SFML and it’s .NET wrapper. It’s quite good and I know a bit about it. In the past I have been using SDL wrapper which was also fine. At the beginning I am mostly going to focus on 2D tile rendering and some ray casting to calculate field of view. I really like the way it’s done in Cataclysm DDA, so I ll try to emulate it.

Apart from coding the game and its logic, the most difficult part will be to use F#. I am a little worried about its stateless world. I have heard about monads and how you can manage state with them, but still its going to be difficult for apprentice like me.

To start with something, I have decided to do my first simple game loop and render window.

Couple of interesting things in this code.

“:?>” operator

If I have some class that inherits the System.Object ( Default behavior in .NET ).

[crayon-55369d404246b/]

“:?>” downcast – it will cast Object to Something. This operation is performed on run time.

The “:?>” operator performs a dynamic cast, which means that the success of the cast is determined at run time. A cast that uses the “:?>” operator is not checked at compile time; but at run time, an attempt is made to cast to the specified type.

“:>” upcast – it will cast Something to Object. This operation is performed on compile time.

The “:>” operator performs a static cast, which means that the success of the cast is determined at compile time. If a cast that uses “:>” compiles successfully, it is a valid cast and has no chance of failure at run time.

More about casting in F# world

Pattern matching ( F# switch )

[crayon-55369d404246b/]

From my understating it’s something like a switch but with more powerful options and possibilities. My example is a simple true, false switch.

() is an empty method just to do nothing and stop recurrence.

|> is a pipe lining operator, concept i know from the unix world, ignore is just information that i want to ignore the value that mainLoop() is returning.

More about pattern matching

Recurrent loop – rec keyword

The Game Loop has to be infinite. In functional approach you don’t use loops, like while(true), instead you have to use recurrence. In C# you can just call function from within the function. In F# you can do the same, however you need to mark function with rec keyword ? Why ? The answer is complex and if you want to know it check this link and this one

Get out of your comfort zone – Vim the social connector

I am a .Net developer, mostly. Sure, I am exploring Python, node.js and other technologies, still my work is mostly related to C# and recently I am having fun with F#. I can say that as of now I am tied to one platform and I mostly attending meetups and conferences slightly related to it.

comfort zone

Recently I have gone to one of the meetups and I had opportunity to chat with awesome PHP programmers. Boy that was fun. MS technology stack for them is considered as an evil one, with evil solutions and evil approach to opensource. Just like my image of PHP is full of ‘script kids’ lack of software engineering etc. Of course that image is far from reality.

I was really surprised how .Net developers are perceived :

  • we don’t know framework details because intelisense is doing everything for us
  • editor is doing everything for us, we are just drag n dropping controlsa
  • MS stack is an evil panda
  • we are using TFS because that’s a technology from MS
  • we are not trying other tools that the MS approved ones

As you can see the gap is huge. Now the problem is how to find a connection with someone from the other platform ? There is always a topic about domain,or other technologically independent stuff like DDD, TDD, BDD. But what about other stuff like tools ? Well we have Visual Studio and I have heard that PHPStorm from JetBrains is quite popular. Ahh there is git, yes git is fun and could be a source of endless discussion. What else … VIM, ha I am using Vim. It is so unusual that a .Net dev is a Vim fanatic that it might be this little cherry on top of the cake. They were really surprised. Even better I used emacs extensively on my university so legendary emacs vs vim discussion started. We shared our thought on vim, emacs tooling, I told them why i prefer Vim than Visual Studio.

What I learned. Hmm, I have to get out of my comfort zone more. One platform approach is a dead end. There are soo many people using different technologies that i might miss them or i wont be able to find a topic to talk to them. I have been also trying to follow rule, “Always say yes!” :) this one is hard to follow.

So whats next ?

  • Swift – I would need a mac … but finally i would have a nice topic to talk with @mihcall
  • Rails and Ruby – this would give me a basis to talk to @andrzejkrzywda and @mpraglowski

A lot of choices, a lot people. In the end no matter what you choose there will always be someone interesting to talk to. So get up and learn some new technology, move out of your comfort zone.
As a follow up to this topic, watch Martin Mazur talk from dev day 2012.