# Halil KaskavalciTech & Programming Blog

6Jan/160

## HowTo: Set default username for ssh remote hosts

If your local username is different than your remote host it may be frustrating to type that username at each connection. Luckily, ssh comes with a config file that we can adjust.

25Dec/152

## HowTo: Using multiple git repositories under the same directory

If you are to work under two different repositories with different commit history, you may either,

1. Copy the changes between multiple git repo folders, back and forth.
2. Use the same directory separately for different repositories.

First one easy enough but it gets frustrating as the project evolves. Today I'll tell you how to use any number of repositories under the same directory.

22Oct/150

# What is a System Monitor?

System monitors show various system indicators like HDD, Network, and CPU usage. If you want to learn more about your computer, it's a must have tool.

I guide you to install conky, which is extremely powerful and customizable system monitor tool.

26Sep/150

# What is this?

This is a list of git aliases (shortcuts) to use git more efficiently. I get this valuable git config from my lovely manager Mike Veldink from Siemens AG, a special thanks to him. You can just paste this into git shell.

26Sep/150

# What is a Syntax Highlighter

Syntax highlighter helps you embed some code into your blog post and highlight it so that user will see it as if he/she is reading your code from an editor.

Here is a highlighted code:

Here is raw:

@echo off
SET TEMPFILE="%TEMP%\%RANDOM%.TXT"
echo ATTACH VDISK>>%TEMPFILE%
DISKPART /s %TEMPFILE%
del %TEMPFILE%

See the difference?

3Jun/152

## How To: Specialize template functions using IBM Rational Rhapsody

In this How To, I will guide you to create specialized template functions within IBM Rational Rhapsody.

12Apr/150

## HowTo: Attach VHD files upon startup – Windows 7

Unfortunately there is no build-in easy way to do that. Fear not, with some scripting we can handle this.

• Create a batch file and modify the path to VHD.
•  Save the script to your path of preference.

• Click on Create Task on the right tab.
• Give a name to the task. Click on Change User or Group and choose Administrators for the group.

• Click on Triggers. Choose At Startup

• Click on Actions. Create New Action. Point to batch file you created earlier.

• Save the task. When you restart your computer, VHD will automatically mounted.
8Apr/150

## HowTo : Use system-wide proxy in linux and set up a local proxy server

Let's say you have a board (beaglebone, raspberry pi, etc) and you want to connect internet by using a proxy server. Your work network may not allow this little guy or you may be in a closed-network with one gateway -- proxy.

# Use system-wide proxy

First, let's see how to configure system-wide proxy in linux. Most programs honor http_proxy environmental variable. Let's add them permanently in the system.

Open the file /etc/environment

Add the following lines, update as necessary.

Great! However, you will notice, apt-get  will not work. You need to change one more file for that.

Open the file /etc/apt/apt.conf

Add following lines, update as necessary.

# Set up local proxy server

Cntlm is a great proxy server written in C. Install it to your machine.

• Specify any proxy that you have in your nework. (Proxy tag).
• Give a proxy port (Listen tag).
• Give permission to a certain address range (Allow tag). You can use CIDR notation. (i.e. 192.168.0.0/16).

Cntlm should register itself as a service. You can run it explicitly by calling Start Cntlm Authentication Proxy.

Voila, your proxy server should be running now.

Tagged as: , , No Comments
1Apr/150

## What I learned from Floating Points

OK I confess, I didn't read the legandary What Every Computer Scientist Should Know About Floating-Point Arithmetic by Goldberg. It's a must-read however sometimes you just need to find your answer, rather than master on a topic, like floating points. Here, I'll list the things I learned from working with FPs, in case you are looking for an answer too.

## Floating point is less than FLT_MIN, double is less than DBL_MIN. How is it possible?

Looking for an underflow error? How would you decide if underflow has occured. Underflow is defined by number computed is less than minimum number representable. Documentation of strtod states the following:

If the correct value would cause underflow, the function returns a value whose magnitude is no greater than the smallest normalized positive number and sets errno to ERANGE.

We expect a number which is less than or equal to FLT_MIN or DBL_MIN. Let's check what exactly those macros are.

FLT_MIN : The value of this macro is the minimum normalized positive floating point number that is representable in type float. It is supposed to be no more than 1E-37. Source.

DBL_MIN : Same as FLT_MIN, for double.

In that case, you may ask what is minimum normalized value? Normalized numbers do not have leading zeros in decimal representation of a float. For instance,

Normalized : 1.17549e-038 (FLT_MIN)

Subnormal : 0.0017549e-41 (same number)

As you can see, even though FLT_MIN_EXP, exponent of minimum float is 38, we can write smaller numbers than it by allowing subnormal numbers. So, when you have a string represents a float smaller than FLT_MIN, it may be still representable and could smaller than FLT_MIN. Let's look at the code:

The output:

MIN FLOAT test
Min possible :  1.17549e-038
str:            1.17549430e-39
Error:          Range error
Converted:      1.17549e-039
Normal :        True
Comparison:     smaller

But wait, how? The number is smaller than FLT_MIN by all terms, exponent is smaller than FLT_MIN_10_EXP and it is still normal? Let's take a close look on the both numbers. My favorite tool for examine floats is IEEE-754 Analysis by Michael Lubow.

Let's check how FLT_MIN is represented in memory.

DecimalHEXExponent (Binary)Exponent (Decimal)Significand (Decimal)
1.17549e-0370x021FFFD900000100-1231.24999535084
1.17549e-0380x007FFFE000000000-1260.99999618530
1.17549e-0390x000CCCC900000000 -1260.19999921322

See the pattern? Exponent is in its minimum. We can't lower the number any further, that's why we hit FLT_MIN_10_EXP limit. (Why it is not -38? Because it is base2. 2-126=1.175494e-38.) However something else changes, the significand.

Well, that seem subnormal. Why isnormal()  didn't return false then? Good question, and I don't have the answer. What I see from the tests, isnormal() doesn't return false until the number 1.17549430e-46.

A word about errno for underflow. Standard library is not obligated to raise ERANGE when underflow occurs. Do not count on it if you will support multiple compilers.

2Mar/150

## Eclipse build disregards Makefile, creates folder Default

If you change your toolchains and save, then you will realize your makefile changes will make no effect and Eclipse will create a mysterious folder named Default, based on PWD environmental variable. This is due to a bug in Eclipse that enabled automatic makefile creation when you change toolchains.

To disable it, Go to project properties > C/C++ Build and disable "Generate Makefiles automatically"