Database

MySQL date range, case study

Just stumble upon situation where I need to find out if specific date in a date range.

I’ve try using lower than with greater than operator and use between in second attempt.

Quick mysql shell mode icon smile MySQL date range, case study

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\alam>cd c:\appserv\mysql\bin

 

C:\AppServ\mysql\bin>mysql -uroot -p

Enter password: *******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 116
Server version: 5.0.45-community-nt-log MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> select curdate();

+————+
| curdate()  |
+————+
| 2008-02-11 |
+————+
1 row in set (0.00 sec)

mysql> use pendidikan;

Database changed

mysql> select * from stmik_periode_krs where curdate()>=tgl_mulai and curdate()
<=tgl_akhir and aktif=’Y';

+—-+————+————+————+——-+————+————–
+———-+——-+
| id | tgl_mulai  | tgl_akhir  | petugas    | jenis | tgl_buka   | tahun_ajaran
| semester | aktif |
+—-+————+————+————+——-+————+————–
+———-+——-+
| 10 | 2008-02-11 | 2008-02-13 | sri_hayati | sp    | 2008-01-23 | 2007/2008
| 3        | Y     |
+—-+————+————+————+——-+————+————–
+———-+——-+
1 row in set (0.00 sec)

mysql>

mysql> select * from stmik_periode_krs where curdate() between tgl_mulai and tgl

_akhir and aktif=’Y';

+—-+————+————+————+——-+————+————–
+———-+——-+
| id | tgl_mulai  | tgl_akhir  | petugas    | jenis | tgl_buka   | tahun_ajaran
| semester | aktif |
+—-+————+————+————+——-+————+————–
+———-+——-+
| 10 | 2008-02-11 | 2008-02-13 | sri_hayati | sp    | 2008-01-23 | 2007/2008
| 3        | Y     |
+—-+————+————+————+——-+————+————–
+———-+——-+
1 row in set (0.01 sec)

mysql>

Both work well, I just have to adjust my computer clock for trying the result.

Linux

Ubuntu 7.10 Desktop Course – Free Course Material

Ubuntu 7.10 Desktop Course material has been release for free, both student and instructor can get the material immediately :

Student Guide : download here
Instructor Guide : download here
Enjoy the course icon smile Ubuntu 7.10 Desktop Course   Free Course Material
Source

 

Unix

No ALTQ support in kernel

ftp# pfctl -d

No ALTQ support in kernel
ALTQ related functions disabled
pf disabled

ftp# pfctl -e -f /etc/pf.conf

No ALTQ support in kernel
ALTQ related functions disabled
altq not defined on rl0
altq not defined on rl0
/etc/pf.conf:34: errors in queue definition
pfctl: Syntax error in config file: pf rules not loaded

what happen?

No support for ALTQ in kernel icon smile No ALTQ support in kernel

How to enable that?

Hmm…. in FreeBSD FAQ icon smile No ALTQ support in kernel

I’ve set that in previous version, is it because of recent upgrade that I’ve done?

Yes, you can start from examining your kernel :

ftp# uname -v

FreeBSD 6.3-PRERELEASE #0: Wed Jan  2 13:54:29 WIT 2008

nike@rasyid.net:/usr/obj/usr/src/sys/GENERIC

ups, GENERIC . latest cvsup to RELENG_6 make that happen icon smile No ALTQ support in kernel

Ok, time to see the kernel archives :

ftp# cd /usr/src/sys/i386/conf/

ftp# ls

.cvsignore      GENERIC         Makefile        PAE             TITAN
DEFAULTS        GENERIC.hints   NOTES           SMP             XBOX

ftp# tail -f TITAN

#If you Want ALTQ you will also need these

#ALTQ Support
options         ALTQ
options ALTQ_CBQ        # Class Bases Queueing
options ALTQ_RED        # Random Early Drop
options ALTQ_RIO        # RED In/Out
options ALTQ_HFSC       # Hierarchical Packet Scheduler
options ALTQ_CDNR       # Traffic conditioner
options ALTQ_PRIQ       # Priority Queueing

my bad, I have to reconfigure kernel to use TITAN icon smile No ALTQ support in kernel

ftp# cd /usr/src
ftp# make buildkernel KERNCONF=TITAN
ftp# make installkernel KERNCONF=TITAN

ftp# reboot

sighh….. my bad…my bad.

By the way to enable ALTQ support in kernel add these lines :

#ALTQ Support
options         ALTQ
options ALTQ_CBQ        # Class Bases Queueing
options ALTQ_RED        # Random Early Drop
options ALTQ_RIO        # RED In/Out
options ALTQ_HFSC       # Hierarchical Packet Scheduler
options ALTQ_CDNR       # Traffic conditioner
options ALTQ_PRIQ       # Priority Queueing

distro news

Distro News 2008, January – Week 2 & 3

 Distronews for week 2 and 3, conutinously of previous post :

1. Frugalware linux,  Version 0.8.2 Pre 2

    Download Iso : frugalware-0.8pre2-i686-dvd1.iso

2. Linux Ubuntu, Version 8.04 Alpha 3

    Download Iso : hardy-desktop-i386.iso | kubuntu | edubuntu

3. Linux Parsix, version 1.0r0 Test 3

    Download Iso : parsix_1.0r0-test-3-i386.iso

4. Mandriva Linux , version 2008.1 Alpha 2

   Download Iso : mandriva…one-KDE-int-cdrom-i586.iso | mandriva…one-GNOME-int-cdrom-i586.iso | mandriva…free-dvd-i586.iso

5. Voltalinux, version 2.0

   Download Iso : voltalinux2.0.iso

6. Linux GoblinX, version  2.6 RC1

   Download Iso : GoblinX-2.6.rc_01.iso

7. Linux StartCom MultiMedia Edition version 5.0.7

   Download Iso : Kessem-i386-DVD-rc1.iso

8. Linux TinyMe Test 7

  Download Iso : tinyme-test-7-KD.i586.iso

9. pfSense 1.2 RC4

  Download Iso : pfSense-1.2-RC4-LiveCD-Installer.iso.gz

10. Scientific Linux 5.1

  Download Iso : SL-51-011508-i386-DVD.iso

11. Linux Trinity Rescue Kit 3.3 Beta, Build 310

  Download Iso : trinity-rescue-kit.3.3-build-310.iso

12. Zenwalk Linux 5.0

  Download Iso : zenwalk-5.0.iso

13. openSUSE 11.0 Alpha 1

 Download Iso : openSUSE-11.0-Alpha1-DVD-i386.iso | openSUSE-11.0-Alpha1-DVD-x86_64.iso

14. FreeBSD 6.3

 Download Iso :  6.3-RELEASE-i386-disc1.iso

15. Foresight Linux 2.0 Alpha 3

 Download Iso :  foresight-1.9.9.alpha3+20080114-x86-dvd1.iso | foresight-1.9.9.alpha3+20080114-x86_64-dvd1.iso

PHP

101 CodeIgniter Resources

CodeIgniter already attract my attention since version 1.5, we even try to build application based on it.

Beside its clear documentation, their user support awesome too.

I’ll try to collect every resource that might useful to share with others who want to learn codeigniter.

This post will be update regularly as soon as I get another resource icon smile 101 CodeIgniter Resources

CodeIgniter Main Page

1. Download site

2. User Guide

3. Wiki

4. Forum

CodeIgniter Video Tutorials

1. Hello world, introduction to CodeIgniter

2. Create a blog in 20 minutes

3. Derek Allard Video

CodeIgniter Books

1. CodeIgniter for Rapid PHP Application Development 101 CodeIgniter Resources

CodeIgniter Tutorials

1. Introduction to Code Igniter: Part 1 by Godbit, learn about CI structure. starting the case of making form.

2. Introduction to Code Igniter: Part 2 by Godbit, form continued.

3. Introduction to Code Igniter: Part 3 by Godbit, CI interact with database.

4. Pagination with Code Igniter by Godbit, make navigation easy with paging in CI.

5. Code Igniter Template Tutorial by Eric Barnes, separate logic with presentation.

6. Templating with CodeIgniter, templating study case.

7. Using Zend Framework components in Code Igniter, integration zend framework into CI.

8. Building an RSS Feed in Code Igniter, Derek Allard show howto build RSS with CI.

9. Using Oracle with PHP and CodeIgniter, Oracle and CI teamed together. I use oracle xe instead.

10. Forms in CodeIgniter Views, use don’t repeat yourself concept icon smile 101 CodeIgniter Resources

11. Checking CodeIgniter out of the Subversion Repository, Derek show how to use subversion of CI.

12. SimplePie RSS class and CodeIgniter, simplepie and CI work together.

13. Building a Complete CodeIgniter Application: Part 1, by Jim O’Halloran. Build feedignitation from scratch.

14. Building a Complete CodeIgniter Application: Part 2, by Jim O’Halloran.

15. Building a Complete CodeIgniter Application: Part 3, by Jim O’Halloran. Eliminate security problems.

Last Update : January 09 2008

Latest news : Code Igniter 1.6 released!, read more from DerekAllard blog.

Blog

Step by step : adding free hit counter for your website / blog

I’ve seen so many website or blog added Web Counters in their website how to do that ?

Well I try to explain it in step by step mode to make it easy  to understand:

1. Find provider first, for this tutorial I choose HitcounterExperts. Go the their website and click on link ‘create a counter‘ or click the picture   Step by step : adding free hit counter for your website / blog

2. Choose one of style provided there, just click on the image or ‘see more’ link to see other variation.

 Step by step : adding free hit counter for your website / blog

3. Pick the style, just click on the picture.

 Step by step : adding free hit counter for your website / blog

4. Fill all required information, like this one. Click on ‘Generate Counter Code

 Step by step : adding free hit counter for your website / blog

5. Copy and paste created code to your website / blog.

 Step by step : adding free hit counter for your website / blog

6.  For wordpress blog, you can find file ‘footer.php’ and paste the code. Followed by upload it to the host.

Finish

 

distro news

Distro News 2008, January – Week 1

Whats new in this week?

My friend in Australia ask me that question, we known each other after long discuss around linux and unix world.

His question refer to newest distro news, I refer him to distrowatch. I myself like distrowatch but as iso maintainer in our campus I prefer to make my own summary. Start from this year, I try to make continous post around linux/unix iso.

Ok, start from week 1 in January 2008 :

1. Linux Trixbox, released version : 2.4.0

Download iso : trixbox-2.4.0.iso (656MB)

2. Linux Mint, released version : 4.0 Fluxbox CE Beta 028

Download iso : LinuxMint-4.0-Fluxbox-BETA-028.iso (513MB) and LinuxMint-4.0-Debian-ALPHA-023.iso (695MB)

3. Mepis Antix, released version : 7.0.1

Download iso : antiX-M7.01-base.iso (installable LiveCD using fluxbox, 177MB), antiX-M7.01.iso, (309MB)

4. SME Server, released version : 7.3

Download iso : smeserver-7.3-i386.iso (529MB)

5. Kanotix, released version : 2007 RC 7

Download iso : KANOTIX-2007-THORHAMMER-RC7.iso (701MB).

6. Gobolinux, released version : 014

Download iso : GoboLinux-014-i686.iso (667MB)

Source : Distrowatch

Unix

Maia-mailguard, user powered mail spam blocker

"Help, my mail inbox still full of spam, you said that you already set a spam blocker in mail server?"

My friend ask me about his mailbox icon smile Maia mailguard, user powered mail spam blocker

My bad, I don’t socialize how to use maia-mailguard for email user.

Maybe, some of you already know that too but don’t know what to do to minimize spam in your inbox with maia-mailguard.

It’s just quick way to set your preference and dissappointing mail spammer icon smile Maia mailguard, user powered mail spam blocker

1. Login to your maia-mailguard, the address provided by sysadmin.

Username is your current email address.

Password is your current email password.

  Maia mailguard, user powered mail spam blocker

read more »

PHP

Make lowercase followed by uppercase data

Question :

I have table A with field id, name and address. The data in name field seem not consistent, big letter name sometime found in record. How to update that field with uppercase in name field. For example :

                 id              name                                       address

                 1               FreAKHolicz  wORker            the moon

                 2              tHE atMOSFER bluEZ            nowhere

FreAKHolicz  wORker must change to Freakholicz Worker

Answers :

1. Looping

2. Use strtolower() function followed by ucwords() function.

example code :

<?

$query=mysql_query("select id,name from table A");

while(list($id,$name)=mysql_fetch_row($query))

{

//change to lower case

$name1=strtolower($name); // will make FreAKHolicz  wORker  into freakholicz worker

//change to uppercase

$name2=ucwords($name1); // will make freakholicz worker into Freakholicz  Worker

//now using $name2 as variable to update name field

$update=mysql_query("update A set name=’$name2′ where id=’$id’");

}

?>

since it’s looping, all good record also examined by scripts until no record left, using another conditional condition would bring another result.

P.S :

  • Use ucfirst() to change only first alfabet
  • Its possible using many function in one operation such as :  $name2=ucwords(strtolower($name));

Software

how to do chmod in windows?

[phpbay]nintendo wii,2[/phpbay]

How to do chmod 644 in windows? my friend ask me that question when he try to install oscommerce in his windows xp.

hmmm…..

IMHO, thereis no chmod in windows but they have ‘properties‘ to play with, for example :

1. Pick one file to experiment with.

 how to do chmod in windows?

 

2.  Right click on selected file then choose ‘properties’

 how to do chmod in windows?

 

3. select ‘Read-only’

 how to do chmod in windows?

4. done, just choose ‘Read-only’ then click ‘Apply’ to make equivalent to chmod +r

p.s : 7 = 4 + 2 + 1

4 = read

2 = write

1 = execute

 

Unix

/dev/null: No such file or directory

Mayday….mayday, my /dev/null no longer exist help me…..

mknod /dev/null c 2 2
chmod 666 /dev/null

from man of mknod :

c ->      Type of device.  If the device is a block type device such as a
             tape or disk drive which needs both cooked and raw special files,
             the type is b.  All other devices are character type devices,
             such as terminal and pseudo devices, and are type c.

mknod name [b | c] major minor [owner:group]

NAME
     null — the null device

DESCRIPTION
     The null device accepts and reads data as any ordinary (and willing) file
     – but throws it away.  The length of the null device is always zero.

FILES
     /dev/null

Fiuhhhh…… icon wink /dev/null: No such file or directory