About John Roach

Currently attending Hacettepe University Electrical and Electronics Engineering. Student, programmer, amatuer poet and writer. His hobbies include chess, playing the piano and writing stories.

Playing cards is fun

For some reason I remembered my probability class back in the university. The class was fairly fun while also being an integral part of another un-fun class telecommunications. The calculation of the probability getting a straight in poker is being used in many ways in telecommunications. This brings another facet of playing cards doesn’t it? Playing cards can sometimes be fun.

Fork me on GitHub

How to add images to DataGridView cell using C# and Windows Forms

There are many ways to skin this old cat. When choosing the way, you must first decide when should the adding of images take place. I chose to add images during sorting.

Let us assume you already added some data to gridview via datatable using ;

   1: dataGridView1.DataSource = siparis_tablo_guncel;

So now you know we have a filled up dataGridView.

Now let us assume in the dataGridView1 we want to add images according to the data within the 6th column. So what we first need to do is to create an image column by writing;

   1: DataGridViewImageColumn img = new DataGridViewImageColumn();

   2:  

   3: img.Name = "img";

   4: img.HeaderText = "Image Column";

   5: img.ValuesAreIcons = true;

   6:  

   7: dataGridView1.Columns.Add(img);

Now we have a image column. With the name “img” with the header “Image Column” As you can see in the 5th line I have stated that my images are actually icons. The reason I did this was that I found out that icons take up less space and flickers less. You can if you want change this option as you see fit.

Now let us get cracking and add those images according to the columns;

   1: int number_of_rows = dataGridView1.RowCount;

   2: for (int i = 0; i < number_of_rows; i++)

   3: {

   4:     if (dataGridView1.Rows[i].Cells[6].Value.ToString() == "true")

   5:     {

   6:         Icon image = SUT.Properties.Resources.succcess_icon;

   7:         dataGridView1.Rows[i].Cells["img"].Value = image;

   8:     }

   9:     else

  10:     {

  11:         Icon image = SUT.Properties.Resources.cancel_icon;

  12:         dataGridView1.Rows[i].Cells["img"].Value = image;

  13:     }

  14: }

 

I hope this has been informative. Please do tell if you see any mistakes and wish to make suggestions.

Have fun!

Installing node.js 0.6.2 on Fedora 16

 

The logo of the Node.js Project from the offic...

Image via Wikipedia

This one was a little hard. I got lots of help so I decided to post it online since it doesn’t exist on the internet yet… I wonder why….

The simple step by step instruction:

  1. sudo yum install git

  2. git clone --depth 1 git://github.com/joyent/node.git
    
  3. cd node
  4. git checkout v0.6.2
  5. sudo yum install openssl-devel
  6. sudo yum install gcc # you can skip this if you already have gcc
  7. sudo yum install gcc-c++ # you can skip this if you already have gcc-c++
  8. ./configure       [ thank you Ed for the heads up! ]
  9. make -j2
  10. make install
  11. export PATH=$PATH:/usr/local/bin:/usr/local #this is to add usr local to your path wher nodejs was installed
  12. sudo visudo
  13. Find Defaults secure_path=/sbin:/bin:/usr/sbin:/usr/bin
    go to the end “a” for append, type “:/usr/local/bin”, ESC, “:wq”
  14. curl http://npmjs.org/install.sh |sudo sh #installing npm a very good too to install nodejs packages
    P.S. : This step is outdated as of node.js 0.6.3 since node.js 0.6.3 comes out with npm
  15. sudo yum install mongodb #installing mongodb
  16. #go to the dir where you wish to code and use npm!!
  17. npm install mongodb
  18. npm install mongoose
  19. npm install express
  20. npm install coffee-script
  21. npm install stylus
  22. npm install underscore
  23. npm list
    /home/john/someproject
    ├── coffee-script@1.1.3
    ├─┬ express@2.5.1
    │ ├─┬ connect@1.8.0
    │ │ └── formidable@1.0.7
    │ ├── mime@1.2.4
    │ ├── mkdirp@0.0.7
    │ └── qs@0.3.2
    ├── mongodb@0.9.7-0
    ├─┬ mongoose@2.3.13
    │ ├── colors@0.5.1
    │ ├── hooks@0.1.9
    │ └── mongodb@0.9.6-23
    ├─┬ stylus@0.19.3
    │ ├── cssom@0.2.0
    │ ├── growl@1.1.0
    │ └── mkdirp@0.0.7
    └── underscore@1.2.2

Vacation or time spent trading horror stories

On vacation. Reading “The Call of Cthulhu” … Spooky…

I quote :

The most merciful thing In the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of infinity, and it was not meant that we should voyage far. The sciences, each straining in its own direction, have hitherto harmed us little; but some day the piecing together of dissociated knowledge will open up such terrifying vistas of reality and of our frightful position therein, that we shall either go mad from the revelation or flee from the deadly light into the peace ar.d safety of a new dark age.

My new workplace

 

I have just started working in RENKO LTD.. I probably mentioned this before. I am quite busy these days so sorry for the lagging updates. I will be posting some new code and ready code reviews. Also since I finished school (yeah baby I got my diploma!!! Open-mouthed smile ) I will also post all my old home works. For now please enjoy the simple slideshow above.

If you come to Ankara, Turkey on a weekday you could probably find me at ;

 

Map picture

 

 

So please be patient while I upload my old home works.  And please feel free to browse through www.rentech.com.tr a great place to find physics lab equipment in Turkey.