Free space on Raspberry Pi

I have been using a 16GB SD card (I know, could be larger) in a Raspberry Pi for a few years now and never had a problem but recently I started working in a side project and decided to use Docker on this Pi. Because of this I almost filled the SD card in just a few months.

In this post I’m going to give you a few commands that should help you to reclaim some space in your SD card and continue your experiments or side projects. I take no responsibility for any undesired data loss and I ask you to do the proper research about any of the commands posted here. Enjoy!

Live reload in .NET Core

This week I was looking for a way to do live reloading in ASP.NET Core projects.

Don’t judge me, but I actually never cared that much about live reloading, I lived life in a constant state of stopping and starting applications every after a few changes. What changed is that after working with React for a few months I really liked the idea of reflecting changes from your code in the application instantly (well, almost).

Omegle clone using SignalR

A few days ago I was looking through SignalR and I had the idea to build an Omegle clone. The Omegle one-on-one random chat have a good fit with SignalR, so I decided to try it.

Talking about my implementation in more detail, the two most important parts of my application are the SignalR Hub call ChatHub and the chat.js file where I added SignalR hub client connection code.

In ChatHub the methods OnConnected and OnDisconnected were overridden from the Hub base class so I could add logic for when a new user connects to chat with someone or when disconnects (abruptly or not). Every connection is stored in a static variable Chats that are going to be deleted in case the application closes. I also created a Send method for when an user sends a message to the other user.

Bulk inserting data into SQL Server using C#

In the last few days I had a question: what is the most fastest method to bulk insert data into a SQL Server database using C#? I decided to gather up all methods that I could find and do a very simple performance test to decide which one is the fastest.

Here are my results for inserting 10000 rows over 500 iterations:

MethodTime
SqlBulkCopy class137.022 ms
bcp utility146.876 ms
Table-Valued Parameter150.900 ms
Simple.Data208.320 ms
XQuery235.490 ms

My configuration:

SonarQube configuration tutorial

This post will be a simple tutorial to install, configure and use SonarQube to analyse your project code quality. This tutorial will be directed to C# and JavaScript projects in a Windows environment.

1- Download SonarQube

2- Create a SQL Server database

If you don’t have SQL Server installed download SQL Server Express, a free and limited SQL Server edition option (SQL Server editions comparison here).

Run the following command:

CREATE DATABASE SonarQube;

Just after this command the collation from the recently created database needs to be changed as recommended in the SonarQube website:

Quick tips for building a API using Nancy

Hello! I’m writing this brief post to help everyone that is using Nancy for the first time to not make the same mistakes that I did. I’m not even remotely interested in covering all possible aspects involved in developing a web application using Nancy, I just thought I’d share some of my mental notes gathered a few months ago. So, here we go.

Know how to properly use CORS

If you are using CORS avoid to use the wildcard in the Access-Control-Allow-Headers CORS header because he can have unpredictable behavior.

Defining cross cutting concerns using the MediatR library

Hello! A few months ago I did a freelance gig in which I found myself having trouble to define where exactly to put things like logging, authentication, persistence common logic and so on. These elements are somehow detached from the core business logic and are very similar or exact the same in every application. If you decide to insert them in all your methods you are going to have a lot of repeated and unmaintainable code very fast.

TypeScript + Webpack

Hey, hello! As always, it’s been a long time since I posted. Anyway, probably nobody cares besides me so I just going to straight to the point to be discussed in the post, a simple integration between TypeScript and Webpack.

First of all, this post assumes you already know a little about JavaScript and already heard about - or used - a task-runner like Grunt or Gulp.

Defining TypeScript

In a nutshell TypeScript is a javascript-based kind of language that compiles to JavaScript. TypeScript most important feature is being statically typed, bypassing JavaScript dynamic nature and allowing the development of big, scalable applications more easily.

Resumo do primeiro dia do BrazilJS 2015

Daí pessoal, tudo certo? Resolvi fazer este post com um pequeno resumo das palestras do primeiro dia do BrazilJS 2015. É importante destacar que tudo aqui escrito vem da minha experiência do evento e de tudo aquilo que pude absorver e/ou achei interessante o bastante para comentar.

Espero que atenda as tuas expectativas!

Palestra 1 - Christian Heilmann - ES6 - Baseline para a web moderna?

O Chris procurou falar sobre dois pilares bastante discutidos entre desenvolvedores JavaScript: a nova versão do ECMAScript, o ES6 e sobre comos precisamos depositar todos os nossos esforços em trazer a maior quantidade de boas funcionalidades para o browser ao invés de ficar “apenas” criando frameworks, bibliotecas e trabalhando com JavaScript em ambientes fechados como no NodeJS. Alguns pontos interessantes que ele levantou:

Using dependency injection in MongoDB CSharp Driver

Hello! So, it seems that I delayed once again new posts in here. Since I promise to no one that I need to post here on regular basis I don’t think that I need to apologize, hehe (just kidding). So, as the title says I here to talk a little about dependency injection and post a code snippet about using DI on MongoDB CSharp Driver basic classes.

Dependency Injection

If you don’t want to know or already know the concept behind dependency injection, just jump to the code. As you may know dependency injection helps us programmers to control code dependencies easier. When you use dependency injection (or DI) depending on the language that you are using you just need to use an attribute, annotation or something else that helps to inject (like the name says, doh!) the dependencies into your code without the need to instantiate or set the objects manually.