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.

Advertisements
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: ,

[mongodb] invalid GPG signatures

February 8, 2018 Leave a comment

Problem
I have an Ubuntu 14.04 LTS box with MongoDB. When I tried to update the packages, I got a similar error:

W: GPG error: http://repo.mongodb.org trusty/mongodb-org/3.2 Release: The following signatures were invalid: BADSIG D68FA50FEA312927 MongoDB 3.2 Release Signing Key 
WARNING: The following packages cannot be authenticated!
mongodb-org-shell mongodb-org-server mongodb-org-mongos mongodb-org-tools mongodb-org E: There are problems and -y was used without --force-yes

Solution

sudo apt-key list | \
 grep "expired: " | \
 sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' | \
 xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys

Full explanation of this is here. In a nutshell: update expired keys from Ubuntu key server.

[manjaro] installation fails, unknown public key

January 17, 2018 Leave a comment

Problem
I couldn’t update a package due to the following error:

==> Validating source files with sha256sums...
    gcc-7.2.1-20171224.tar.xz ... Passed
    gcc-7.2.1-20171224.tar.xz.sig ... Skipped
    isl-0.18.tar.bz2 ... Passed
==> Verifying source file signatures with gpg...
    gcc-7.2.1-20171224.tar.xz ... FAILED (unknown public key BBE43771487328A9)
==> ERROR: One or more PGP signatures could not be verified!
==> ERROR: Makepkg was unable to build mingw-w64-gcc.
==> Restart building mingw-w64-gcc ? [y/N]
==> --------------------------------------
==> ==> ERROR: unable to update

Solution
I asked this on reddit and /u/SuperGrip kindly provided the solution:

This is a common issue when an apps key is not included in the ArchLinux Keyring, to solve this issue you can add the key manually by running the following command: gpg --recv BBE43771487328A9

For further information check the package comments on the AUR site. https://aur.archlinux.org/packages/mingw-w64-gcc/

Categories: manjaro Tags: , , , ,

DigitalOcean has new droplet plans

January 17, 2018 Leave a comment

DigitalOcean has some new droplet plans (more info here). The cheapest droplet was 5 USD, and you got 512 MB RAM and 20 GB SSD for this price. Now, for the same price you get 1 GB RAM and 25 GB SSD.

If you have a standard droplet, you can upgrade it for free. I did it today and it was just one click :) Of course, I made a snapshot first, but the upgrade went smoothly, so after some testing I removed the snapshot.

If you want to try DigitalOcean, here is my referral link: https://m.do.co/c/01da80980c60. If you sign up through this link, you also support me :)

Alternatives

Categories: linux Tags: ,