What is dependency injection?

April 18, 2018 Leave a comment

See this blog post: Dependency Injection Demystified. In short: “Dependency injection means giving an object its instance variables.”. For a slightly longer explanation, read the blog post.

Reddit comments are here.

Advertisements
Categories: programming Tags: , ,

C# is awesome

April 12, 2018 Leave a comment

I started to play with C# and I really enjoy it. I found a great book that explains the concepts very well: The C# Player’s Guide by RB Whitaker. I found the 2nd edition in our library but it also has a 3rd edition.

I started a C# project, which is a collection of custom extensions. You can find it here: https://github.com/jabbalaci/JabbaCustomExtensions-for-C-Sharp.

I also have a little utility (written in Python) that facilitates C# development under Linux in the command-line: https://github.com/jabbalaci/C-Sharp-CLI-Helper.

I’m playing with C# under Linux. JetBrains has a cross-platform IDE for .NET called Rider. It works very well for me.

Links

Categories: book, csharp

[manjaro] edit PKGBUILD and install a package

March 30, 2018 Leave a comment

Problem
You try to install a package with “yaourt pkg_name” but the installation fails. How to edit the PKGBUILD file manually and then install the package?

Solution

$ cd /tmp
$ yaourt -G pkg_name
$ cd pkg_name
# modify the file PKGBUILD with your favourite text editor
$ makepkg -i

Where “pkg_name” is the name of the package you want to install.

Categories: manjaro Tags: , ,

pretty print a C# source code

March 29, 2018 Leave a comment

Problem
I wanted to print the page at https://learnxinyminutes.com/docs/csharp/, but the produced PDF was black and white, i.e. the syntax highlighting was lost. How to print a source code with colors?

Solution
I tried several browsers, several editors, but nothing worked. Then I found a LaTeX solution. The necessary files and the produced PDF output are here: https://github.com/jabbalaci/blog-assets/tree/master/20180329-print-CSharp-code.

I put here the LaTeX source:

\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
%% Define your header here.
%% See http://texblog.org/2007/11/07/headerfooter-in-latex-with-fancyhdr/
\fancyhead[CO,CE]{C\# Summary}

\usepackage[usenames,dvipsnames]{color}  %% Allow color names

%% The listings package will format your source code
\usepackage{listings}
\lstdefinestyle{customasm}{
  belowcaptionskip=1\baselineskip,
  xleftmargin=\parindent,
  language={[Sharp]C},
  breaklines=true, %% Wrap long lines
  basicstyle=\footnotesize\ttfamily,
  commentstyle=\itshape\color{Gray},
  stringstyle=\color{Black},
  keywordstyle=\bfseries\color{OliveGreen},
  identifierstyle=\color{blue},
  xleftmargin=-8em,
  showstringspaces=false
}
\begin{document}

\lstinputlisting[style=customasm]{src.cs}

\end{document}

The LaTeX tip is from here.

Categories: csharp, latex Tags:

[steam] get a game for a cheaper price

March 25, 2018 4 comments

Problem
You want to buy a game on Steam for a cheaper price. There are sales on Steam but you don’t want to check it every day.

Solution
There is a very simple way to get notified when the desired game becomes cheaper. Log in to Steam and add the game to your wishlist. I thought that the wishlist was just a simple list and never clicked on it but it’s more than that! When a game on your wishlist becomes cheaper, you get an e-mail notification. It’s that simple.

I wanted to build a web app. for this purpose :) Then I talked about it with a friend and he told me that the Steam wishlist can do that…

Categories: games Tags: ,

Xbox 360 controller not detected

March 16, 2018 Leave a comment

Problem
I have a wired Xbox 360 controller that stopped working. Windows 7 doesn’t recognise it and it appears as an “unknown device”.

Solution
I tried everything: uninstall and reinstall the driver; reinstall the USB drivers that I got on a DVD for the motherboard; plug it in another USB slot. Nothing. After 1.5 hours, I found the solution: the cord has an inline release and it was not entirely connected… Damn. But the good news is that it works again :)

Lesson learned: if you have a problem with the controller, first check the inline release.

inline_release

Steam API

March 12, 2018 Leave a comment

Question
Let’s take this game: Fallout: New Vegas. How to get data about it using the Steam API?

Answer
http://store.steampowered.com/api/appdetails/?appids=22490

Unfortunately it doesn’t contain the overall review of the game (“very positive”, “overwhelmingly positive”, etc.).

Links

Categories: games Tags: ,