Culpritz's Blog

Computer, Networking, Programming, Photoshop articles, tips & more.

DeskAlarm – A free light-weight alarm utility for your desktop

This was my university project, its an useful Windows utility for creating alarms and reminders with any message you want. With DeskAlarm you can easy create Alarms that will display at your given time or on daily basis with your custom message. DeskAlarm can be use to create multiple alarms, reminders and alert messages.

Download Page:
https://sourceforge.net/projects/deskalarmtool/


Object Oriented Programming Concepts: Intro

In this article series i am going to discuss common concepts of Object Oriented Programming called OOP. We will compare OOP techniques & concepts with the real world, so it will be easy to understand for novice or even professional programmers.

What is Procedural Programming?

Procedures, also known as routines, subroutines, methods, or functions simply contain a series of computational steps to be carried out. A procedural programming language provides a programmer a means to define precisely each step in the performance of a task. The programmer knows what is to be accomplished and provides through the language step-by-step instructions on how the task is to be done.

Procedural programming is often a better choice than simple sequential or unstructured programming in many situations which involve moderate complexity or which require significant ease of maintainability.

What is Object Oriented Programming?

OOP or Object Oriented Programming is a good programming practise to create manageable projects more easily. OOP gives you facilities to create reusable objects that you or other developers can use in their projects without reinventing them again and again.

An object-oriented program may thus be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects and can be viewed as an independent ‘machine’ with a distinct role or responsibility. The actions (or “operators”) on these objects are closely associated with the object.

The most important distinction is whereas procedural programming uses procedures to operate on data structures, object-oriented programming bundles the two together so an “object” operates on its “own” data structure.

Where it comes from?

Objects as programming entities were introduced in the 1960s in Simula 67, a programming language designed for performing simulations, created by Ole-Johan Dahl and Kristen Nygaard of the Norwegian Computing Center in Oslo. (They were working on ship simulations, and were confounded by the combinatorial explosion of how the different attributes from different ships could affect one another. The idea occurred to them of grouping the different types of ships into different classes of objects; each class of objects being responsible for defining its own data and behavior.). The ideas of Simula 67 influenced many later languages, especially Smalltalk and derivatives of Lisp and Pascal. The Smalltalk language, which was developed at Xerox PARC (by Alan Kay and others) in the 1970s, introduced the term object-oriented programming to represent the pervasive use of objects and messages as the basis for computation.

More recently, a number of languages have emerged that are primarily object-oriented yet compatible with procedural methodology, such as Python and Ruby. Probably the most commercially important recent object-oriented languages are Visual Basic.NET (VB.NET) and C#, both designed for Microsoft’s .NET platform, and Java, developed by Sun Microsystems.[who?] VB.NET and C# both support cross-language inheritance, allowing classes defined in one language to subclass classes defined in the other language.

Article by Hasan Hameed

HelloWorld in PHP in 15 different ways

Here i am demonstrating “traditional HelloWorld” examples in PHP using different ways like function, objects etc.. This will be helpful for beginners to understand the basic concepts of PHP used in practicle life.

    Basic

  1. Simple HelloWorld using echo()
        echo "HelloWorld";    // echo() is same as print()
    
  2. Using short open tags (if enabled in php.ini)
    <?= "Hello World" ?>
    
  3. Using Variable
        $var = "HelloWorld";
        echo $var;
    
  4. Using Arrays

  5. Using numeric arrays
        $array = array("HelloWorld");
        echo $array[0];
    
  6. Using associative arrays
        $array = array("greeting"=>"HelloWorld");
        echo $array["greeting"];
    
  7. Using multidimensional arrays
        $array = array("subarray"=>array("HelloWorld"));
        echo $array["subarray"][0];
    
  8. Using Functions

  9. By calling a function
        // definition
        function sayHello() {
            echo "HelloWorld";
        }
        // call
        sayHello();
    
  10. Passing argument by value to a function
        // definition
        function sayHello($arg) {
            echo $arg;
        }
        // call
        $var = "HelloWorld";
        sayHello($var);
    
  11. Passing argument by reference to a function
        // definition
        function sayHello(&$arg) {
            $arg = "HelloWorld";
        }
        // call
        $var = "";
        sayHello($var);
        echo $var;
    
  12. Using returned value from function

        // definition
        function sayHello() {
            return "HelloWorld";
        }
        // call
        echo sayHello();
    
  13. Using Objects

  14. Using constructor of “Greet” class
        // class
        class Greet
        {
            public function __construct() {
                echo "HelloWorld";
            }
        }
        // initiate object
        $obj = new Greet();
    
  15. Using destruction method of “Greet” class
        // class
        class Greet
        {
            public function __destruct() {
                echo "HelloWorld";
            }
        }
        // initiate then destroy object
        $obj = new Greet();
        unset($obj);    // cause print
    
  16. Using public method & private property of “Greet” class
        // class
        class Greet
        {
            private $var = "HelloWorld";
    
            public function sayHello() {
                echo $this->var ;
            }
        }
        // initiate object then call method
        $obj = new Greet();
        $obj->sayHello();
    
  17. Using static method & static property of “Greet” class
        // class
        class Greet
        {
            private static $var = "HelloWorld";
    
            public static function sayHello() {
                echo self::$var ;
            }
        }
        // call satic method without initiating class object
        Greet::sayHello();
    
  18. Using children class’s method to call its parent class’s protected propertry
        // our parent class
        class Greet
        {
            protected $var = "HelloWorld";
        }
    
        // our child class
        class Do_Greet extends Greet
        {
            public function sayHello() {
                echo $this->var ;    // accessing parent property (if private it will cause error)
            }
        }
    
        // we have to initiate children class object
        $obj = new Do_Greet();
        $obj->sayHello();
    
  19. Using children class’s static method to call its parent class’s protected static propertry
        // our parent class
        class Greet
        {
            protected static $var = "HelloWorld";
        }
    
        // our child class
        class Do_Greet extends Greet
        {
            public static function sayHello() {
                echo parent::$var ;    // accessing parent static property (if private it will cause error)
            }
        }
    
        // without initiating class call its static method
        Do_Greet::sayHello();
    

There are many other ways too but i’ve listed some common ones used in PHP. Feel free to share them!

Useful htaccess Tricks for all

Apache module ‘mod_rewrite’ must be installed & ‘Rewrite Engine’ must be set to ‘On’ for these tricks to work;

# enable rewriting
RewriteEngine on

Missing trailing slashes fix:

Options +FollowSymlinks
RewriteCond %{REQUEST_URI}\\/%{HTTP_HOST}/www. ^/+(.+/)?[^.]*[^/]\\(/)(([^.]{4,}|[^w.]?[^.][^w.]?[^.]?[^w.]?)\..+/(www\.)|.*)$ [OR,NC]
RewriteCond %{HTTP_HOST}/www. ^(/)?(#)?(/)?(([^.]{4,}|[^w.]?[^.][^w.]?[^.]?[^w.]?)\..+/(www\.))$ [NC]
RewriteRule ^ http://%6%{HTTP_HOST}%{REQUEST_URI}%2 [L,R=301]

Change default index.html page:

DirectoryIndex mypage.html

Custom error pages:

>ErrorDocument 400 /MySite/errors/400.php
ErrorDocument 401 /MySite/errors/401.php
ErrorDocument 403 /MySite/errors/403.php
ErrorDocument 404 /MySite/errors/404.php
ErrorDocument 500 /MySite/errors/500.php

Prevent viewing of a specific file:

><files settings.php>
order allow,deny
deny from all
</files>

Prevent viewing of a specific extention:

<files *.extention>
order allow,deny
deny from all
</files>

Prevent execution of specific scripts:

">Options -ExecCGI
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi

Show download file prompt:

>AddType application/octet-stream .mp3 .mpeg .mov .pdf .doc

Disable directory browsing:

Options All -Indexes
IndexIgnore *

Disable display of specific files in directory:

IndexIgnore *.jpg *.mp3 *.mpeg

Remove www:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]

Einstein caught on color camera

Einstein color picture

I got this picture from my grand father’s photo album. He was a fellowman of Great Albert Einstein.

He took this picture from the first color camera of the work made by a famous scientist, and this was awarded as the first color picture of the world.

Sorry i forgot to add that the name Hasan that he is writing on green board is my grand father’s name.

Follow

Get every new post delivered to your Inbox.