Posts Tagged ‘ code ’

Upgrading to CodeIgniter 2.0


As soon as I saw the tweet from EllisLab that CodeIgniter 2.0-dev was available on BitBucket I instantly converted PyroCMS to run on it. I got it all working in a few hours after LOTS of headbanging, mouse throwing and blaspheming. All the bugs I found along the way have since been fixed in the 2.0 branch by the Ellis developers or myself.

While this does not mean everything is running perfectly, at the time of writing all the worrying bugs are squashed so it should be safe for us to have a play.

Grab those new files

Download the new files from BitBucket.

What goes where

Slight change in the folder structure for some of you, the application/ folder and the system/ folder now sit next to each other.

So move your application folder up one level to sit next to system/ then delete that system/ folder. That has killed off CodeIgniter 1.7.2. Bye!

Now you need to copy the new downloaded system/ folder to the empty gap where the old one was.

Sadly that is not entirely it. You must also copy the following files from the new download to your installation:

  • index.php
  • application/config/foreign_chars.php
  • application/config/profiler.php

Noticed that your controllers and models are broked?

CodeIgniter Controllers and Models used to be defined extend like this:

class Blog_model extends Model

Now in CodeIgniter 2.0 you write:

class Blog_model extends CI_Model

Update 10/11/2010: Remember to do this for Controllers too. Instead of Foo extends Controller, you must now write Foo extends CI_Controller and all parent::Controller() calls must be changed to parent::__construct()!

Let’s not argue about why, what, who, where, when, the fact is you have to do this. It can be achieved with some simple Find & Replace over your folder if your IDE/Text editor will allow it. For most applications (especially ones built primarilry during the 1.7.x era) you are nearly there now. Unless you use plugins or the old Validation class…

Advertisements

Malang [Googlemap Embed]


I have no idea about the topic, I just try to embed a google map. Hahahaha thanks for tutorial dude. I love API Programing.



Install Vista/7 from USB Drive [100% Working]


This guide works 100% for Vista & Windows 7 unlike most of the guides out there. I have seen many sites/blogs that have “Install Vista from USB guide” but either with incomplete steps or not working guide. I have also seen some guides that don’t’ use proper commands in this guide. After spending many hours I have come up with this 100% working guide.

I just did this method on one of my friends machine and installed the new Windows 7 BETA. The main advantage is that by using USB drive you will be able to install Windows 7/Vista in just 15 minutes. You can also use this bootable USB drive on friend’s computer who doesn’t have a DVD optical drive.

The method is very simple and you can use without any hassles. Needless to say that your motherboard should support USB Boot feature to make use of the bootable USB drive.

Requirements:
*USB Flash Drive (Minimum 4GB)
*Windows 7 or Vista installation files.

Follow the below steps to create bootable Windows 7/Vista USB drive using which you can install Windows 7/Vista easily.
1. Plug-in your USB flash drive to USB port and move all the contents from USB drive to a safe location on your system.
2. Open Command Prompt with admin rights. Use any of the below methods to open Command Prompt with admin rights.
*Type cmd in Start menu search box and hit Ctrl+ Shift+ Enter.
Or
*Go to Start menu > All programs > Accessories, right click on Command Prompt and select Run as administrator.
3. You need to know about the USB drive a little bit. Type in the following commands in the command prompt:

First type DISKPART and hit enter to see the below message.

 

 

 

Next type LIST DISK command and note down the Disk number (ex: Disk 1) of your USB flash drive. In the below screenshot my Flash Drive Disk no is Disk 1.

 

 

 

 

4. Next type all the below commands one by one. Here I assume that your disk drive no is “Disk 1”.If you have Disk 2 as your USB flash drive then use Disk 2.Refer the above step to confirm it.

So below are the commands you need to type and execute one by one:

SELECT DISK 1

CLEAN

CREATE PARTITION PRIMARY

SELECT PARTITION 1

ACTIVE

FORMAT FS=NTFS

(Format process may take few seconds)

ASSIGN

EXIT

Don’t close the command prompt as we need to execute one more command at the next step. Just minimize it.

5. Next insert your Windows7/Vista DVD into the optical drive and check the drive letter of the DVD drive. In this guide I will assume that your DVD drive letter is “F” and USB drive letter is “G” (open my computer to know about it).
6. Maximize the minimized Command Prompt in the 4th step.Type  the following command now:
D: CD BOOT and hit enter.Where “F” is your DVD drive letter.
CD BOOT and hit enter to see the below message.
7. Type another command given below to update the USB drive with BOOTMGR compatible code.
BOOTSECT.EXE /NT60 G:
Where “H” is your USB drive letter. Once you enter the above command you will see the below message.
8. Copy your Windows 7/Vista DVD contents to the USB flash drive.
9. Your USB drive is ready to boot and install Windows 7/Vista. Only thing you need to change the boot priority at the BIOS to USB from the HDD or CD ROM drive. I won’t explain it as it’s just the matter the changing the boot priority or enabling the USB boot option in the BIOS.

Note: If you are not able to boot after following this guide means you haven’t set the BIOS priority to USB. If you got any problem in following this guide feel free to ask questions by leaving comment.

Over Heat


Making a decision in your life is not easy as tip up a hand. Desktop based or web based programing, both of them always bothering my mind. What you think??

Factorial.java


Dedicated to someone who made me feel like I’m a bad guy.. >.<

The main idea of using recursive method to calculate the factorial is call back the method till n=1. The method has the fuction to calculate n*(n-1). LOL, I’m so sorry if you cant sleep tonight because of this code. 🙂

import java.util.*;

/**
 * Factorial.java
 *   A recursive program to calculate the factorial
 *   of a number.
 *   n! = n * (n-1) * (n-2) * ... * 1
 *
 *   A recursive definition of factorial is:
 *   n! = 1          if n <= 1
 *      = n * (n-1)! if n > 2
 *
 * @author Sofa Zainuddin
 * @author Computer Science, Brawijaya University
 * @version 1/15/2011
 */
public class Factorial {
    public static void main (String[] args) {

        Scanner in= new Scanner(System.in);
	int theNum, theFact;

	System.out.println("This program computes the"+
        "factorial of a number.");
	System.out.print("Enter a number: ");
	theNum=in.nextInt();

	theFact = fact(theNum);

	System.out.println(theNum + "! = " + theFact + ".");
    }

    /**
     * Calculate the factorial of n.
     *
     * @param n the number to calculate the factorial of.
     * @return n! - the factorial of n.
     */
    static int fact(int n) {

	// Base Case:
	//    If n <= 1 then n! = 1.
	if (n <= 1) {
	    return 1;
	}
	// Recursive Case:
	//    If n > 1 then n! = n * (n-1)!
	else {
	    return n * fact(n-1);
	}
    }
}

Morning Head Error Report!!!


import java.util.*;

public class Lesson1 {
public static void main (String [] args){
System.out.println(“Hello world”);
}
}

06:49 PM, I can’t recognize my self. Yeah, just like “pain in the ass”, all I can remember is “Hello world”, my first Java code. C’mon wake up boy, start to think of it. Ok enough with my squawk.

Last night I get my ambition back, lol I dont know why. I have an ambition to develop a Java program, especially in database. This is my first goal: no error report, runing nicely, friendly GUI for user.

My mood: totally not sure about this project 😦 . J-creator> File> New File> Project_One. Ok, time to start.