Monday, March 6, 2017

Not able to login on Fedora 25

I got a new laptop at work place and it came with some other linux OS (other than Fedora). I installed Fedora 25 and when I tried to login, it started throwing me out each and every time. Still the problem is there, but here is a work around:

Reason: Something is crashing with X server

Solution Tried:
1. Ctrl + Alt + Fx (Fx F2 F3 F4 etc.)
2. Login as user from command line
3. type and enter:
     startx

It is a temporary solution, will update here as soon as I fill find one.

Friday, February 24, 2017

Convert Code to HTML

Recently, I was looking for some tool to covert Code to HTML so that when I include the code snippet in the blog or website it should look pretty and readable. I was seeking an open source solution and I came across HILITE.ME Here is the url:
https://github.com/alexkay/hilite.me

And the web:
http://hitlite.me


Example:

1
2
3
4
5
6
7
package main

import "fmt"

func main() {
       fmt.Println("Hello World")
}

Thursday, January 12, 2017

Programming: A lookup table example in C

Sometimes it is better to replace a code snippet performing calculations by a lookup table. The use cases are:
1. When the result of calculation is always a member of predefined set of numbers
2. When input is a set of predefined integers

For such cases it is easy and convenient to define an array and use it. one such example is (the code can be found here):
#include <stdio.h>
int main(void) {
int lookupTable[4][5] = {
{ -1, 9, 4, -1, 0 },
{-1, -1, 9, -1, 4},
{-1, -1, -1, -1, 5},
{-1, -1, -1, -1, 9}
};
int row, columns;
for(row=0; row < 4; row++) {
for(columns = 0; columns < 5; columns++){
printf("Row %d Columns %d Value %d\n", row, columns, lookupTable[row][columns]);
}
}
return 0;
}