samiuljahan's blog

there's always room for improvement

Python Primer

leave a comment »

Recently I’ve started to play with Python. I’ve heard a lot about this language before.  Recently I’ve just completed my  ‘Hello World’ program  🙂

You can get Python from here. I use python’s interactive shell as well as PyDev plugin for Eclipse to write codes

#This is a comment
#version 3.0
print("Hello World!"); #semicolon is not required but I use this
  • Commenting code
#This is a comment
  • Assigning values
x = 5 #5 is assigned to x
print (x) #prints 5
print (type(x)) # outputs <class 'int'>
x, y = 0, 1
x, y = y, x
print(x,y) # prints 1, 0
  • Conditions
#traditional conditions
x , y = 10, 20
    if x < y :
       print ('X is less than Y') # prints 'X is less than Y'

#conditional expressions
x, y = 0, 1
z = "less than" if x < y else "not less than"
print (z) #prints 'less than'
  • Writing a function
#defining a function
def myFunc():
    print('This is a function in python')
#invoking the function
myFunc() # prints 'This is a function in python'
  • Writing a class
class Language:
    def __init__(self, name = 'Python'):      #constructor
        self.name = name
    def showName(self):
        return self.name
scripting = Language()                       #an instance of the Language class
print(scripting.showName())                  #as you've guessed :), it prints 'Python'

procedural = Language('C')                     #another instance of the Language class
print(procedural.showName())                #now it prints 'C' 🙂
  • Getting Input from the User
hawkingsFound = input('Enter what hawkings found lately? :)') #prompts the user 'Enter what hawkings found lately? :)' , user enters 'girls are mysterious'
print(hawkingsFound) # it prints 'girls are mysterious' 🙂

Written by সামিউল(samiul)

January 7, 2012 at 4:42 pm

How to calculate the time required for a block of code in C/C++?

leave a comment »

Here are a small code snippets with which you can calculate the execution time of a certain block of codes in C/C++.

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
clock_t startm, stopm;
#define START if ( (startm = clock()) == -1) {printf("Error calling clock");exit(1);}
#define STOP if ( (stopm = clock()) == -1) {printf("Error calling clock");exit(1);}
#define PRINTTIME printf( "%6.3f seconds used by the processor.", ((double)stopm-startm)/CLOCKS_PER_SEC);
int main() {
     START;//start the timer
     //code blocks which execution time will be counted begins here
     int n;
     for(n = 0; n<=65535; n++)
     {
        printf("%d\n", n);
     }
     //code blocks which execution time will be counted ends here
     STOP;//end the timer
     PRINTTIME;//print the time
     return 0;
}

The program will print total 65536 numbers line by line and at the end it’ll print the total seconds e.g 5.109 seconds, it took to print the numbers
—–courtesy: http://kennethfinnegan.blogspot.com/2008/03/timing-events-in-c.html

Written by সামিউল(samiul)

September 10, 2011 at 6:18 pm

Basic Programming Quiz 0010

leave a comment »

Examine the code snippets given below—-

#include <stdio.h> 
int main()
{ 
    char ch;
    while((ch = getchar()) != '\0')
    putchar(ch);
    return 0;
}

What does the program display?

Look at another code snippets—-

#include <stdio.h> 
int main()
{ 
    while( putchar(getchar( )) != '\0' ) ;
    return 0;
}

Now, what does it display?
Is there any difference in program execution between these two code snippets?

Written by সামিউল(samiul)

September 10, 2011 at 11:12 am

Basic Programming Quiz 0001

leave a comment »

Examine the code snippets given below—-

#include <stdio.h> 
int main()
{ 
  int x;
  x = 10;
  if(x == 10) { 
    int x; 
    x = 99; 
    printf("Inner x: %d\n", x);
  }
  printf("Outer x: %d\n", x); 
  return 0;
}

What does the program displays?

Written by সামিউল(samiul)

September 9, 2011 at 8:47 pm

Neptune and Uranus may have oceans of diamonds!

leave a comment »

[tweetmeme]
Scientists have said that the our solar system may have oceans of diamonds.

According to ABC News, a new report has suggested that oceans of liquid diamond icebergs, could be floating on Neptune and Uranus.

The research is based on the first detailed measurements of the melting point of diamond.

Read the rest of this entry »

Written by zahidhasanaupee

January 20, 2010 at 4:23 pm

“High-Speed” Networks Are No Faster Than “Low-Speed” Networks

leave a comment »

hi speed internet
[tweetmeme]
All computer networks operate at the same speed. They send and receive data at roughly 186,000 miles per second. So,what makes those wonderful “broadband” Internet connections seem so “fast”? After all,the transmission speed is limited by the laws of physics. The answer is that computer networks use various methods to represent data on the communications link. For example,the character “U” in my name could possibly be represented by a code of eight bits (binary 0s and 1s).

Read the rest of this entry »

Written by সামিউল(samiul)

January 19, 2010 at 6:11 pm

Knowing(2009)

leave a comment »

mv5bmtmymjgymdiym15bml5banbnxkftztcwnjg3mjaymg_002
[tweetmeme]

Director:

Alex Proyas

Writers:

Ryne Douglas Pearson (screenplay) and
Juliet Snowden (screenplay)

Release Date:

20 March 2009 (USA)

Genre:

Action | Mystery | Sci-Fi | Thriller

Tagline:
Knowing is Everything…

Download Link(rmvb229mb):

Read the rest of this entry »

Written by সামিউল(samiul)

April 4, 2009 at 6:06 pm

Posted in 2009, movie

Tagged with , , , ,

গুগল ছাড়লো এন্ড্রয়েড ফোন

leave a comment »

Big G (Google ;) ) & T-Mobile stick together and release the first Android operated Phone. So, What the hell is that Android ) ? Aha! Its a Open Source mobile OS (like Symbian) by Google.

Check it out – http://code.google.com/android/

And for the Android Phone Specification goto – http://www.t-mobileg1.com/g1-android-details-leak.aspx

Blogged with the Flock Browser

Tags: , , , , , ,

Written by সামিউল(samiul)

October 9, 2008 at 10:06 pm

Posted in Uncategorized

মজার ছবি

with 4 comments

মজার একটি ছবি
ছবিটি পুরোপুরি দেখুন
এরপর এর থাম্বনেল ভিও দেখুন
থাম্বনেল ভিও নিচে দেওয়া হল
মেয়েটির পাশে কি ছেলেটিকে দেখা যাচ্ছে?
ছবিটি ডাওনলোড করেও থাম্বনেল ভিও দেখতে পারেন
আরো ছবির জন্যে ক্লিক করুন

ক্লিক

প্রথম প্রকাশঃ
সা।ইন

Written by সামিউল(samiul)

October 9, 2008 at 8:01 pm

কী লগার এর হাত থেকে নিরাপদ থাকা

leave a comment »


ইন্টারনেট ব্যাবহার করার সময় আমাদের সবারই অনেক ফরম পূরণ করতে হয়।পাসওয়ার্ড দেওয়ার দরকার হয়।এক ধরনের সফটওয়্যার আছে যেগুলো সিস্টেমে গোপনে অবস্থান করে এবং ইউজারের প্রতিটি কীস্ট্রোক লগ করে।

অনেক সময় সাইবার ক্যাফেতে আমাদের ব্রাউজ করতে হয়।সাইবার ক্যাফের পিসিগুলিতে এসব কি কী লগার সফটিয়্যার থাকতে পারে।একটি সফটওয়্যার ব্যাবহার করে আমরা এসব কী লগার বাইপাস করতে পারি।

সফটওয়্যারটির নাম Neo’s SafeKeys.

.০৬ কেবির এ সফটিয়্যারটি পেন ড্রাইভে বহনযোগ্য। সফটিয়্যারটি রান করলে একটি ছোট্ট মাউস বেসড কী বোর্ড স্ক্রীনে দেখা যাবে।তারপর কী বোর্ডে পাসওয়ার্ড ক্লিক করতে হবে।তারপর পাসওয়ার্ড সিলেক্ট করে ড্র্যাগ করে এনে আপনি যেখানে পাসওয়ার্ড দিতে চান সেখানে ছেড়ে দিতে হবে।

তাহলে আপনার ফরমের পাসওয়ার্ড ফিল্ডটি পূরণ হয়ে যাবে।এখান থেকে সফটওয়্যারটি ডাঊনলোড করে নিতে পারেন। এটি শুধু উইন্ডোজএ কাজ করে।


লেখাটি বিজ্ঞানী.কমে প্রকাশিত।

http://biggani.com/content/view/777/120/

Written by সামিউল(samiul)

March 11, 2008 at 11:00 am

Posted in tips

Flash drives ready to jump in capacity

leave a comment »

In the wake of a series of technical announcements from flash memory supplier SanDisk, larger-capacity solid-state drives are on the way.Flash memory is gaining as asandisk replacement for hard drives in ultra-thin, ultra-small notebooks such as the MacBook Air and Asus Eee PC. Why? Flash uses less power, generates less heat, and has faster access times than hard drives. The Air, for example, offers a 64GB flash-based SSD as an option while the Eee PC is sold standard with flash storage.There is a big catch, though. High-capacity SSDs are expensive. Prohibitively so. The flash drive in the pricier $3,098 Air is the main culprit in the gaping $1,300 price difference with the lower-cost hard-drive model ($1,799).Update: Historically, flash memory has had

Read the rest of this entry »

Written by সামিউল(samiul)

February 27, 2008 at 11:35 am

ওপেনসোর্সে ত্রিমাত্রিক পৃথিবী

leave a comment »

গুগল্ এবং উইন্ডোজ লাইভ আমাদেরকে স্যাটেলাইট ব্যবহার করে ভূ-পৃষ্ঠের ত্রিমাত্রিক ছবি দেখায়। কিন্তু উক্ত প্রোগ্রামগুলি ছিলো শুধুমাত্র উইন্ডোজের জন্য আর সেজন্যই লিনাক্স ও ম্যাক ব্যবহারকারীরা একটু হলেও মন খারাপ করে ছিলো। এখন মন খারাপের দিন শেষ, কারন ওপেনসোর্সে উন্নত করা হয়েছে ভূ-পৃষ্ঠের ত্রিমাত্রিক ছবি দেখার সফটওয়্যার “গালা” বিশেষ করে ম্যাক এবং লিনাক্স ব্যবহারকারীদের জন্য। অনেকদিন থেকে গুগল্ আর্থ-এর উপর গবেষণা চালিয়ে তৈরী করা হয়েছে “গালা” সম্পুর্ন গুগল্-এর সার্ভারের উপর নির্ভর এই সফটওয়্যারটিতে তথ্য পরিবেশিত হয় গুগল্-এর মতই। উইন্ডোজ ব্যবহারকারীদের জন্য তেমন একটা মনোযোগ না দেয়ার জন্য উইন্ডোজ সংস্করণটি তেমন একটা ভালো নয়। তবে ম্যাক বা লিনাক্স ব্যবহারকারীরা http://gaia.serezhkin.com/ থেকে বিনামূল্যে গালা ডাউনলোড করে ব্যবহার করতে পারেন

Written by সামিউল(samiul)

February 27, 2008 at 11:25 am

Posted in opensource