The 1st Dollar From Google

Asyikkkkkk, tadi pagi saya cek account adsense saya menunjukan angka $1.21. Kecil sih, tapi khan lumayan juga lama2 kan jadi bukit.

$1.21 itu saya dapet setelah sebulan (Saya mulai aktif ngeblog sejak Mei 2007). 
Yah awal2 sebulan sedolar sih lumayan, nanti khan trafficnya juga meningkat (Amin).

Mudah2an bertahan terus sampe $100 n dapet deh cek dari Google. Asal jangan sampai ke suspend aja nih.

Oiya buat yg bingung apa itu adsense baca ini ya
http://harry-christian.blogspot.com/2007/05/google-adsense-apa-sih-itu.html

Gmail Storage Really 2.8 GB ?

Sudah seminggu ini account Gmail saya mengalami bouncing dari berbagai milis dikarenakan over quota. Memang saya cukup banyak menerima email dari berbagai milis, akan tetapi saya tidak yakin masa quota sebanyak itu bisa penuh.

Ok saya berpikir positif bahwa mungkin saja banyak email yang ada attachmentnya sehingga bikin full inbox saya.

Lalu saya hapus sebagian besar email saya sehingga kosong, tapi hingga hari ini tetap saja meteran inbox saya menunjukan "You are currently using 2857 MB (99%) of your 2857 MB"

Saya sudah melaporkan problem ini ke Googgle dan saya lihat ternyata banyak juga yang mengalami masalah quota ini.

Dan akhirnya saya jadi bertanya2 sendiri benarkan Gmail storagenya 2.8 GB ?

FOREPLAY - INTERPLAY - AFTERPLAY

FOREPLAY - INTERPLAY - AFTERPLAY

Dr. Moeslan Saradhawarni, Sp.OG, MARS, mengibaratkan hubungan intim seperti halnya makan. Selera terbit karena bentuk makanannya, warnanya, baunya, rasanya, dan cara penyajiannya.

Hubungan seksual juga begitu. Misal, lingkungannya. Jangan melakukannya di sebelah kamar yang ramai sekali. Suasana ruangannya sendiri harus mendukung.

Kemudian, penampilan suami maupun istri harus oke. Janganlah istri pakai daster butut, tanpa make up dan rambut diikat karet, atau suami baru pulang dari bengkel belum mandi lalu minta. Prakondisi seperti itu tak memenuhi syarat.

Setelah situasi, kondisi, penampilan mendukung, derajat rangsangan kian bertambah. Nah, bukankah makin terangsang akan makin cepat mencapai klimaks? Bahkan wanita kadang-kadang bisa mencapai orgasme pada waktu foreplay itu sendiri. Bagaimana tanda-tandanya, dari segi fisik (misal matanya memejam sambil merintih), dan reaksi tubuhnya, dan vaginanya yang berlendir. Kalau sudah terangsang seperti itu, pada waktu itulah saatnya melakukan penetrasi.

Nah, pada waktu penetrasi, jika suami sudah dapat mengendalikan diri, maka ia akan tahu kapan istrinya orgasme. Kalau sudah lebih pintar lagi, si suami bisa mengatur jika ia ingin istrinya orgasme 2 — 3 kali atau bahkan lebih, baru ia ejakulasi. Itu bisa dikendalikan, tentu cara-caranya banyak jika mau konsultasi dengan dokter.

Setelah ejakulasi, kalau memang Anda merasa puas dan bisa memuaskan istri, itu tak cukup dengan hanya berbalik badan lalu tidur mendengkur. Lanjutkan dengan belaian, memijat-mijat lengan, ditambah kata-kata pujian dan rayuan. Itu akan meninggalkan kesan yang mendalam pada pasangan, sehingga ia akan senang hati melakukannya lagi untuk ronde berikutnya.

Latihan Mengendalikan Ejakulasi

Dr. Moeslan memberi tips latihan menahan ejakulasi, yang basisnya adalah latihan kegel, sebagai berikut:

1. Saat bangun pagi hari, berdiri di kamar mandi, punggung menempel ke dinding, kaki jinjit. Berkemihlah sedikit, lalu tahan (hitung 10 - 20 kali), keluarkan lagi sedikit, tahan lagi, begitu terus sampai tuntas.

2. Nantinya, saat berhubungan seksual, otot panggul akan berkontraksi, sehingga ketika akan ejakulasi bisa ditahan seperti menahan kencing. Sewaktu menahan ejakulasi, istri jangan melakukan goyangan erotis, supaya penis tidak terangsang dulu.

3. Latihlah terus-menerus, hingga Anda bisa mengendalikan dan mengatur kapan ejakulasi akan dilepas.

JBoss AS 4.2 released


New features in JBoss AS 4.2 include:

* Tomcat 6.0, which adds support for JSP 2.1 and Servlet 2.5
* JavaServer Faces 1.2 integration
* JBoss Transactions (Arjuna) JTA 4.2.3 as the default transaction monitor
* The latest Enterprise JavaBeans (EJB) 3.0 implementation
* Support for Hibernate 3.2.3

Download at http://labs.jboss.com/jbossas/downloads?action=a&windowstate=normal

Free E Book

Link2 buat download ebook gratis.
 http://www.flazx.com
http://www.blueportal.org



Anger Management

Sabtu kemarin saya mengalami masalah dengan orang yang saya sayang. Problemnya amat sangat sepele. Tapi ya karena hal yg sepele itu saya sampai membuat hati ce saya terluka dengan omongan saya. Memang harus saya akui kalau saya sudah emosi terkadang kata2 saya suka keterlaluan dan tergolong kasar.
Kata2 saya menjadi tidak terkendali dan seolah2 itu bukan diri saya yang sebenarnya.

Hal ini sebenarnya amat jarang terjadi selama ini. Ini bisa terjadi karena mungkin saya sudah berhubungan dengan hal yang menyinggung hati dan perasaan saya. Selama ini saya jika ada masalah selalu stay cool dan anggap saja angin lewat. Tapi jika menyangkut orang yang disayang tentu lain cerita. Ce saya tidak kasih kabar saja, saya bisa dongkol dan jengkel.

Dan kebetulan banget hari itu juga, di TransTV ada film lucu Anger Management yang dibintangi Adam Sandler yang kocak banget. Ceritanya ttg orang
yang pemarah, pencemburu, kasar dll. Lalu dia mengikuti terapi sehingga menjadi lebih baik.

Inti yang saya dapat dari film tersebut adalah :
1. Jangan memendam emosi, tetapi salurkanlah dengan positif (Misal berteriak keras2 dilantai paling atas kantor anda).
2. Tanggapi sesuatu dengan santai dan penuh rasa humor.
    Jika terdapat suatu masalah, maka atasi dengan rasa humor yang tinggi sehingga anda akan  
    bisa menyelesaikan masalah dengan kepala jernih dan tidak dipenuhi emosi.

Saya akhirnya berjanji akan mencoba merubah sifat buruk saya ini kepada ce saya. Doakan semoga saya berhasil

5 Tools for Ruby development

Nice article to Ruby Newbie

Ruby, the dynamic, interpreted programming language that adopts a pure object-oriented approach, has been gaining popularity among programmers. While many of Ruby's new converts are primarily developing Web applications, Ruby has a great history (much of it in Japan) as a separate language in its own right. Only recently are developers in the West beginning to understand the significant advantages Ruby has over other scripting languages such as Perl and Python, or even more established enterprise-level languages such as Java.

If you are one of those who recently boarded the Ruby bandwagon, you may not be sure which of the many available Ruby tools and libraries are most helpful to your development. This article looks at five essential tools and libraries that Ruby developers should have in their arsenal to be able to get the most out of the language.

1. RubyGems
In general, RubyGems provides a standard way to publish, distribute, and install Ruby libraries. It allows library developers to package their products so that installation becomes a one-line process. The resulting packages are simply called "gems." Likewise, RubyGems makes it easy for developers to get up and running with a whole swath of libraries quickly.

Like many packaging and installation systems for other languages (and even operating systems), RubyGems will detect dependencies and install them before installing the desired library, making it a no-brainer process to get a certain library running.

RubyGems currently isn't a standard part of the Ruby installation, but it likely will be in the future. For now, you have to download it separately, but the process is extremely simple. You need only open an archive and run a single Ruby file inside.

Beyond basic installation of most third-party Ruby libraries, RubyGems also makes managing the libraries installed on your computer simple. It provides a basic command line interface for uninstalling and upgrading libraries. You can even use this interface to install multiple versions of the same library on a single machine, enabling you then to address these separately (specifically by version, if necessary) by applications. This makes RubyGems even more powerful than, say, the popular CPAN system for Perl.

The primary reference and documentation site for RubyGems is rubygems.org.



2. A Good IDE or Text Editor
As with developing in other programming languages, Ruby developers rely on a myriad of different IDEs and text editors for development work. Because of the different platforms and preferences of each developer, it's impossible to recommend a single option, so this article quickly covers a few alternatives.

RADRails
RADRails was one of the first serious Ruby-specific IDEs. Despite the name, RADRails is not only for Rails applications. It, in fact, is generally useful for developing Ruby applications. Based upon the popular Eclipse IDE, RADRails is cross-platform (Windows, Linux, and OS X) and open source. Although other IDEs have now become popular, RADRails is still a good Ruby-specific choice.

jEdit
Like RADRails, jEdit is an open source, cross-platform IDE. Unlike RADRails, it isn't Ruby-specific at all. It is a general programmer's text editor. What earns jEdit a spot on this list is its "Ruby Editor Plugin," a plugin that adds a number of Ruby- (and Rails-) specific abilities to the editor, including syntax and error highlighting, integrated documentation, and auto-indentation.

Find more information about the Ruby Editor Plugin at rubyjedit.org.

Ruby In Steel
Ruby In Steel is a professional-grade Ruby IDE for Microsoft Visual Studio (MSVS) 2005. It features not only code completion, but also full Microsoft-style IntelliSense features on Ruby code. While it's not cheap ($199US), a free limited-feature edition and a free thirty-day trial make Ruby In Steel appealing to new Ruby developers who particularly appreciate the MSVS IDE.

TextMate
TextMate is an editor available only on Mac OS X. Its use by most of the core team of Rails developers has led to its strong adoption among OS X-based Ruby developers. Like jEdit, TextMate is a general programmer's text editor with a significant number of available Ruby-specific extensions. Depending on the current exchange rate, TextMate costs approximately $50US. TextMate's developer, Allan Odgaard, has been helping another developer produce a Windows clone called E (a.k.a. E-TextEditor).



3. Instant Rails
Most Ruby developers who have Ruby on Rails Web application framework installed went through the lengthy process of installing RubyGems, installing the Rails gems, and then setting up their environments. It doesn't need to be such a complex procedure, however. Two tools enable you to install a Rails application on a new computer quickly.

For Windows users, a single application called Instant Rails enables them to install and run an Apache Web server, Ruby, the MySQL database engine, and the Rails framework all at once.

Instant Rails gets a Rails application up and running with only a couple of clicks. This can be ideal if you need to deploy a Rails application to a client or on a remote machine where installing Ruby and Rails is not appropriate.

There are plans to port Instant Rails to Linux, BSD, and Mac OS X in the future, but currently Mac OS X users have an alternative called Locomotive. Like Instant Rails, Locomotive provides an all-in-one Rails deployment system within a single application.

4. Mongrel – A HTTP Server Library
Mongrel is an HTTP server tool and library for Ruby. On the surface, it doesn't sound particularly exciting, but its benefits are compelling. Ruby already comes with a HTTP server library known as WEBrick, but it's extremely slow. Mongrel's speed and reliability are head and shoulders above WEBrick and other alternatives, so installing it allows your Rails applications to run much faster. In fact, Mongrel is now used in the majority of Rails deployments, so it's a useful tool to learn. Additionally, you can use Mongrel directly from your Ruby code to develop your own HTTP server programs.

Installing Mongrel takes only a minute with RubyGems (using a mere gem install mongrel command). It has separate builds for Windows- and UNIX-related platforms due to the need to compile some external C code.

Of the five tools this article covers, Mongrel is the only library. As such, it serves as a great example of how to package, market, and document a library. Mongrel's popularity rests not just on its performance, but also on the way creator Zed Shaw has engaged the community and thoroughly documented the library. If you view Mongrel's source code, you'll find almost as many comments as lines of code.



5. An RSS Feed Reader for Community Interaction
One of the interesting things about Ruby is its community. As a language that gained widespread popularity in the West in only the past few years, Ruby developers have taken advantage of new technologies like blogs to build the community and share their knowledge.

Most of the best Ruby developers have blogs and reading them can extend the knowledge of a novice Ruby developer substantially. Indeed, the strong, evangelical blogging community is one of the main reasons Rails has taken off in the past couple of years. So having a quick and easy way to keep up with several Ruby blogs is key. As nearly all blogs publish an RSS feed, an RSS application or access to an online RSS reader provides a lot of value for any Ruby developer.

The most popular online RSS reader is Google Reader, but client-side readers exist for all platforms. On Windows, a good, free RSS reader is SharpReader. On Mac OS X, NewsFire is a good one. A good place to find Ruby blogs worth reading regularly is Ruby Inside. Visit the site and subscribe to the blogs in the "Choice Blogs" sidebar.

Keeping up to date with Ruby blogs means you'll not only come across the best tutorials and Ruby posts as they're written, but you'll also begin to connect with the community and get a feel for how to extract value from it.

My Eclipse 5.5 released

Genuitec has released MyEclipse 5.5 Enterprise Workbench, a commercial Eclipse plugin. MyEclipse 5.5 has a wide array of new features, many tailored for the Java EE 5 environment. Genuitec and TSS are also providing ten free licenses for TSS readers who enter a drawing - see the bottom of this post for the link.

Features

* Platform support
o Microsoft Vista support
o Eclipse 3.2.2 compatible
o Upgraded MyEclipse-WebTools, an enhanced and professionally supported version of Eclipse WTP 1.5.3 with many MyEclipse improvements and bug fixes
* SNAPs Non-Eclipse Integration and Improvements, which allows developers to work on files without associated Eclipse projects; therefore, you could use MyEclipse' JSF editor to work on a project from NetBeans
* Java EE 5 Projects
o Create Java EE 5 Web, EJB and Enterprise (EAR) projects with integrated library support
o EJB Projects include integrated JPA and DB Explorer support
o Much more
* EJB3 - Enterprise Java Beans
o Create Stateless, Stateful, Entity and Message enterprise beans
o Wizards for creating all
o Code-assist and validation of Java annotations
o Reverse-engineer Entity and Stateless session bean facades from MyEclipse Database Explorer
* MyEclipse Java Persistence Tools (including JPA, Toplink, Hibernate)
o Add JPA Capabilities to any Java project
o Integrates with MyEclipse Database Explorer for database connections and metadata access
o JPA entity annotation validation
o JPA properties editors and Java Persistence perspective
o Much more
* Visual JSF Page Designer
o All new JSF Visual Page Designer for WYSIWYG editing of advanced JSF components
o Supports Drag-and-Drop style editing of all standard JSF components
o Preview mode of JSF design page
o JSF and faces-config.xml creation wizards
o Much more
* MyEclipse Derby Database
o Integrated Derby database server with preconfigured JDBC driver
o Sample schema is immediately accessible by all DB and JPA tools
* Matisse4MyEclipse Swing Visual Designer upgrades, availability as a standalone plugin
* Facelets support
* XHTML support
* MyEclipse UML improvements
* Improved internationalization
* New Application Server Connectors (Glassfish V2, Geronimo 2, Oracle 10, Weblogic 10)
* All-in-One Installer reduces download volume by 50%
* Much more!


http://www.myeclipseide.com/

Date time best practise in SQL Server

Nice article for DBA's

When can you use arithmetic operators in date/time calculations in SQL Server? When are the date/time functions provided by Microsoft the better option? Follow a few scenarios that demonstrate when arithmetic operators are safe and when they are risky.

few months ago, I received a message from quite an experienced DBA and database programmer asking me whether I knew a nice trick for manipulating date/time data without using Microsoft SQL Server's date/time functions—something like GETDATE() + 10. It reminded me of a few internet forum discussions about the same subject in which participants were irked by the fact that Microsoft missed such a convenient feature. I decided that the topic deserved a deeper discussion. This article is the result.

How Is This Possible?
Try running the following example with the SQL Server DATEADD() function:


SELECT GETDATE();
SELECT DATEADD(dd, 1, GETDATE());
SELECT GETDATE() + 1;

Results:

2007-03-15 16:21:41.630
2007-03-16 16:21:41.630
2007-03-16 16:21:41.630

As you can see, both the DATEADD() function and an addition operation that uses a plus sign (+) produce exactly the same result: they add one day to a current day and time. You'd expect that from DATEADD(), but why does an addition operation produce the same result? For the answer, you must explore the SQL Server date/time storage internals.

As you know, the datetime data type occupies eight bytes: four to store the number of days before or after January 01, 1900 and four more for the number of 3.33ms clock ticks since midnight. The smalldatetime data type needs only four bytes as it is less precise than datetime; it stores the number of days since January 01, 1900 and the number of minutes since midnight. All the numbers are stored as integers. So when you run SELECT GETDATE() + 1, you actually add datetime data to the integer number. Since the datetime data type has higher precedence, the integer number 1 (as an addend with lower precedence) has to be implicitly converted to a data type of the addend with higher precedence.

The following example converts "1" to datetime and then treats it as one day since Jan 01, 1900:


SELECT CAST(1 as datetime);

Results:

1900-01-02 00:00:00.000

When you run SELECT GETDATE() + 1, you add two datetime values that internally are interpreted as integers. As a result an addition operation that uses a plus sign (+) becomes perfectly valid. For example, all the following statements will be correct:


SELECT GETDATE();
SELECT DATEADD(dd, 1, GETDATE());
SELECT GETDATE() + 1;
SELECT GETDATE() + 'Jan 02, 1900';

Results:

2007-03-16 23:01:37.420
2007-03-17 23:01:37.420
2007-03-17 23:01:37.420
2007-03-17 23:01:37.420

Notice that usage of the addition operator (+) in date/time calculations requires at least one datetime addend, which also has to be an addend with the highest precedence.

Try the following example:


SELECT DATEADD(dd, 1, 'Mar 17, 2007');
SELECT 'Mar 17, 2007' + 1;
SELECT 'Mar 17, 2007' + 'Jan 02, 1900';
SELECT GETDATE() + 1 + 'Jan 02, 1900';

As you can see, the first SELECT that uses SQL Server's DATEADD() function recognizes dates written as varchar and produces the correct result. The second SELECT fails with the error: "Conversion failed when converting the varchar value 'Mar 17, 2007' to data type int." This happens because varchar addend has lower precedence and must be implicitly converted to the integer data type. In this case such a conversion is impossible.

The third SELECT works, but doesn't make any sense. It just concatenates two varchar expressions. The forth SELECT is very interesting. Since second and third addends have lower precedence than the first one, they need to be implicitly converted to a datetime data type. Each of them will be interpreted as one day. Therefore two days will be added to the reult of the GETDATE() function.



First Pitfalls
At this point, you may start to believe that using addition or subtraction operators in date/time calculations is completely safe. It isn't. For example try to calculate the interval between two dates (in days) using the first and second approaches as follows:


DECLARE @dt1 datetime, @dt2 datetime;
SELECT @dt1 = 'Mar 17, 2007 09:09:00', @dt2 = 'Mar 17, 2007 22:09:00';
SELECT DATEDIFF(dd, @dt1, @dt2);
SELECT CAST((@dt2 - @dt1) as int);

Results:

0
1

The results calculated by SQL Server's DATEDIFF() function and those using the subtraction operator are different. The first (0) is correct, the second (1) is wrong. Why? Well, when you convert a datetime value to the integer, the result will be rounded to the nearest integer. How it will be rounded depends on time portion of the datetime value. Consider the following example:


DECLARE @dt3 datetime, @dt4 datetime;
SELECT @dt3 = 'Mar 17, 2007 11:59:59.994', @dt4 = 'Mar 17, 2007 11:59:59.997';
SELECT CAST(@dt3 AS int);
SELECT CAST(@dt4 AS int)
SELECT CAST(CAST(@dt3 AS int) AS datetime);
SELECT CAST(CAST(@dt4 AS int) AS datetime);

Results:

39156
39157
2007-03-17 00:00:00.000
2007-03-18 00:00:00.000

As you can see, two time stamps with a 3ms interval were taken just before noon. If you convert the two date values to integers and then reconvert the results back to date values, you'll see a difference of one day. Similarly, two datetime values representing different days (Mar 16 and Mar 17) can be incorrectly converted to the same date, like this:


DECLARE @dt3 datetime, @dt4 datetime;
SELECT @dt3 = 'Mar 16, 2007 12:00:01.000', @dt4 = 'Mar 17, 2007 11:59:59.994';
SELECT CAST(@dt3 AS int);
SELECT CAST(@dt4 AS int)
SELECT CAST(CAST(@dt3 AS int) AS datetime);
SELECT CAST(CAST(@dt4 AS int) AS datetime);

Results:

39156
39156
2007-03-17 00:00:00.000
2007-03-17 00:00:00.000

Now, consider one more example. Suppose you have a table where you store sales transactions that each have an ID, time, and amount. You want to find the total amount and number of transactions per day, which is a very common task. Since your table is very large, you decide to speed up your query by grouping your transactions by date interval, not by date. But instead of using the SQL Server DATEDIFF() function, you decide to use an "advanced" approach: converting datetime data to integer or calculating the interval using simple arithmetic subtraction.

Here's what can happen in this scenario:


SET NOCOUNT ON;
IF OBJECT_ID('sales', 'U') IS NOT NULL
DROP TABLE sales

CREATE TABLE sales(
transactionID int,
transactionTime datetime,
amount decimal(4,2));

INSERT INTO sales VALUES(1, 'Mar 17, 2007 08:00:23', 24.34);
INSERT INTO sales VALUES(2, 'Mar 17, 2007 10:33:23', 88.54);
INSERT INTO sales VALUES(3, 'Mar 17, 2007 12:00:44', 12.12);
INSERT INTO sales VALUES(4, 'Mar 17, 2007 14:23:23', 43.25);
INSERT INTO sales VALUES(5, 'Mar 17, 2007 16:45:22', 76.34);
INSERT INTO sales VALUES(6, 'Mar 17, 2007 17:11:22', 51.11);
INSERT INTO sales VALUES(7, 'Mar 17, 2007 19:45:23', 30.99);

SELECT COUNT(*) AS #Trans, SUM(amount) AS totalAmount
FROM sales
GROUP BY DATEDIFF(dd, 0, transactionTime);

SELECT COUNT(*) AS #Trans, SUM(amount) AS totalAmount
FROM sales
GROUP BY CAST(transactionTime AS int);

SELECT COUNT(*) AS #Trans, SUM(amount) AS totalAmount
FROM sales
GROUP BY CAST((transactionTime - 0) AS int);

Results:

#Trans totalAmount
----------- ---------------------------------------
7 326.69

#Trans totalAmount
----------- ---------------------------------------
2 112.88
5 213.81

#Trans totalAmount
----------- ---------------------------------------
2 112.88
5 213.81

SQL Server DATEDIFF() produces the correct result because it works with dates like a FLOOR() function. It cuts the time portion of each date and manipulates only days. If you chose the other approach of converting to integers or direct subtraction, each datetime value would be rounded to the nearest integer, taking into account the time portion of the datetime value. This is why the second and third SELECT statements produce the wrong results.



Arithmetic Operations on Time Portion of Date/Time Data
So far this article has discussed the arithmetic operations on the date portion of data/time values. So when you try to run SELECT GETDATE() + 1, the second addend is implicitly considered the number of days that have to be added to the value returned by the GETDATE() function. But what if you want to add one hour or one minute to the current datetime value? Using the SQL Server DATEADD() function you can do that very easily, but using addition or substraction operators will be tricky.

Let's examine how to do that. One day consists of 24 hours or 1,440 minutes or 86,400 seconds. So if you run the following statement:


SELECT GETDATE() + 1/24

You probably will get the current datetime plus one hour. In reallity, however, you cannot use just 1/24 because both dividend and divisor are integers, and the result of dividing them will be zero. You need to convert the integers to decimal or float data types as follows in order to get the correct result:


-- How to add one hour
---------------------------------------
SELECT GETDATE()
SELECT DATEADD(hh, 1, GETDATE())
SELECT GETDATE () + CAST(1 AS dec(9,4))/ CAST (24 AS dec(9,4))
SELECT GETDATE () + CAST(1 AS dec)/ CAST (24 AS dec)
SELECT GETDATE () + CAST (1 AS float)/ CAST (24 AS float)

Results:

2007-03-25 20:31:13.870
2007-03-25 21:31:13.870
2007-03-25 21:31:13.867
2007-03-25 21:31:13.870
2007-03-25 21:31:13.870


-- How to add one minute
---------------------------------------
SELECT GETDATE()
SELECT DATEADD(mi, 1, GETDATE())
SELECT GETDATE () + CAST(1 AS dec(9,4))/ CAST (1440 AS dec(9,4))
SELECT GETDATE () + CAST(1 AS dec(18,9))/ CAST (1440 AS dec(18,9))
SELECT GETDATE () + CAST (1 AS float)/ CAST (1440 AS float)

Results:

2007-03-25 20:35:15.127
2007-03-25 20:36:15.127
2007-03-25 20:36:15.123
2007-03-25 20:36:15.127
2007-03-25 20:36:15.127


-- How to add one second
---------------------------------------
SELECT GETDATE()
SELECT DATEADD(ss, 1, GETDATE())
SELECT GETDATE () + CAST(1 AS dec(9,4))/ CAST (86400 AS dec(9,4))
SELECT GETDATE () + CAST(1 AS dec(18,9))/ CAST (86400 AS dec(18,9))
SELECT GETDATE () + CAST(1 AS dec(24,18))/ CAST (86400 AS dec(24,18))
SELECT GETDATE () + CAST (1 AS float)/ CAST (86400 AS float)

Results:

2007-03-25 20:42:26.617
2007-03-25 20:42:27.617
2007-03-25 20:42:27.613
2007-03-25 20:42:27.613
2007-03-25 20:42:27.613
2007-03-25 20:42:27.617


-- How to add one second, using variables
------------------------------------------

DECLARE @dec1 dec(24,18), @dec2 dec(24,18), @dec3 dec(24,18), @dt datetime
SELECT @dec1 = 1, @dec2 = 86400, @dt = GETDATE();
SELECT @dec3 = @dec1 / @dec2;

SELECT @dt
SELECT DATEADD(ss, 1, @dt)
SELECT @dt + @dec3
SELECT @dt + CAST (1 AS float)/ CAST (86400 AS float)

Results:

2007-03-25 20:49:16.817
2007-03-25 20:49:17.817
2007-03-25 20:49:17.813
2007-03-25 20:49:17.817

As you can see from the last example, the SQL Server function DATEADD() works perfectly, but an addition operator may cause a problem. For example, when you try to add one hour or one minute, you need to find a sufficient precision for decimal data type. Otherwise, the result will be slightly inaccurate. However, when you try to add one second, applying an addition operator and decimal conversion, you won't be able to get the exact result at all.

On the other hand, the float conversion looks precise and safe for the time calculations with an addition operator, but if you start to use it you may run into a problem: duplicates and missing values. To illustrate and understand the problem, create and populate an auxillary table:


SET NOCOUNT ON;
DECLARE @max int, @cnt int;
SELECT @cnt = 10000;

IF EXISTS(SELECT * FROM sysobjects
WHERE ID = (OBJECT_ID('sequence')) AND xtype = 'U')
DROP TABLE sequence;

CREATE TABLE sequence(num int NOT NULL);
INSERT INTO sequence VALUES(1);
SELECT @max = 1;
WHILE(@max <= @cnt)
BEGIN
INSERT INTO sequence
SELECT @max + num FROM sequence;
SELECT @max = MAX(num) FROM sequence;
END

When you run this script, it will insert 16,384 sequential numbers into the table sequence. (The number 16,384 doesn't have any special meaning. It was selected for illustration purposes only.)

Now, generate the sequence of hours using the auxillary table and SQL Server's date/time function as follows:


IF EXISTS(SELECT * FROM sysobjects
WHERE id = OBJECT_ID('test'))
DROP TABLE test;

SELECT num, DATEADD(hh, num, 'Dec 31, 2006 23:00:00') dt
INTO test
FROM sequence;

SELECT * FROM test;

Results:

num dt
----------- -----------------------
1 2007-01-01 00:00:00.000
2 2007-01-01 01:00:00.000
3 2007-01-01 02:00:00.000
. . . . . . . . . . . . . . . . . .
3099 2007-05-10 02:00:00.000
3100 2007-05-10 03:00:00.000
. . . . . . . . . . . . . . . . . .
16381 2008-11-13 12:00:00.000
16382 2008-11-13 13:00:00.000
16383 2008-11-13 14:00:00.000
16384 2008-11-13 15:00:00.000

The function DATEADD() works as expected and generates a sequence of datetime values with one-hour intervals.

Now, try to roll up the sequence you just generated using the same the SQL Server DATEADD() function:


SELECT DISTINCT DATEADD(hh, -num, dt) FROM test

Results:

2006-12-31 23:00:00.000

The last result proves that SQL Server's date/time function generates date/time values properly. In order to test the solution that uses an arithmetic operator (+), run the following example:


DECLARE @time float
SELECT @time = CAST(1 as float)/CAST(24 as float)

IF EXISTS(SELECT * FROM sysobjects
WHERE id = OBJECT_ID('test'))
DROP TABLE test;

SELECT num, (CAST('Dec 31, 2006 23:00:00' AS datetime) + @time * num) dt
INTO test
FROM sequence;

SELECT * FROM test;

num dt
----------- -----------------------
1 2007-01-01 00:00:00.000
2 2007-01-01 01:00:00.000
3 2007-01-01 02:00:00.000
4 2007-01-01 03:00:00.000
5 2007-01-01 03:59:59.997
6 2007-01-01 05:00:00.000
7 2007-01-01 05:59:59.997
8 2007-01-01 07:00:00.000
9 2007-01-01 08:00:00.000
10 2007-01-01 08:59:59.997
. . . . . . . . . . . . . . . . . .
16380 2008-11-13 11:00:00.000
16381 2008-11-13 11:59:59.997
16382 2008-11-13 12:59:59.997
16383 2008-11-13 14:00:00.000
16384 2008-11-13 14:59:59.997

You will find that an addition operator produces inaccurate results. Sometimes they differ from the expected ones by 3 ms. If you try to roll up the sequence of generated date/time values, you will get more than one date/time "seed" value (as in the following example) and that is incorrect:


SELECT DISTINCT DATEADD(hh, -num, dt) FROM test

Results:

2006-12-31 22:59:59.997
2006-12-31 23:00:00.000

You may say that +/- 3 ms precision is acceptable for most applications, but look how that seemingly tiny problem can produce a bigger one:


SELECT CONVERT(varchar(100), dt, 100)
FROM test
ORDER BY num

Results:

Jan 1 2007 12:00AM
Jan 1 2007 1:00AM
Jan 1 2007 2:00AM
Jan 1 2007 3:00AM
Jan 1 2007 3:59AM
Jan 1 2007 5:00AM
Jan 1 2007 5:59AM
. . . . . . . . . .
Nov 13 2008 5:59AM
Nov 13 2008 6:59AM
Nov 13 2008 8:00AM
Nov 13 2008 8:59AM
Nov 13 2008 9:59AM
Nov 13 2008 11:00AM
Nov 13 2008 11:59AM
Nov 13 2008 12:59PM
Nov 13 2008 2:00PM
Nov 13 2008 2:59PM

This example uses a CONVERT() function to produce a different date/time format. As a result, inaccuracies in the generated values increased from 3 ms to 1 minute and became unacceptable. However, this is not the only problem. If you try to generate the sequences of minutes or seconds, things become even worse. Look at this example:


DECLARE @time float
SELECT @time = cast(1 as float)/cast(1440 as float)

IF EXISTS(SELECT * FROM sysobjects
WHERE id = OBJECT_ID('test'))
DROP TABLE test;

SELECT num, (CAST('Dec 31, 2006 23:59:00' AS datetime) + @time * num) dt
INTO test
FROM sequence;

SELECT * FROM test;

Results:

num dt
----------- -----------------------
1 2007-01-01 00:00:00.000
2 2007-01-01 00:01:00.000
. . . . . . . . . . . . . . . . . .
1579 2007-01-02 02:17:59.997
1580 2007-01-02 02:19:00.000
1581 2007-01-02 02:19:59.997
. . . . . . . . . . . . . . . . . .
16382 2007-01-12 09:01:00.000
16383 2007-01-12 09:01:59.997
16384 2007-01-12 09:03:00.000

As you can see, there are inaccuracies in the generated values again. In addition, when you try to convert these values to another format as follows, you will get duplicated or missing dates:


SELECT CONVERT(varchar(100), dt, 100)
FROM test
ORDER BY num

Results:

Jan 1 2007 12:00AM
Jan 1 2007 12:01AM
. . . . . . . . . .
Jan 2 2007 12:00AM
Jan 2 2007 12:00AM
Jan 2 2007 12:02AM
Jan 2 2007 12:02AM
Jan 2 2007 12:04AM
Jan 2 2007 12:04AM
. . . . . . . . . .
Jan 12 2007 9:00AM
Jan 12 2007 9:01AM
Jan 12 2007 9:01AM
Jan 12 2007 9:03AM

For instance, there are two values "Jan 02, 2007 12:02AM", but the value "Jan 02, 2007 12:03AM" is missing.

If you want to see the list of all duplicates, you can run the following query:


SELECT COUNT(*), CONVERT(varchar(100), dt, 100)
FROM test
GROUP BY CONVERT(varchar(100), dt, 100)
HAVING COUNT(*) > 1
ORDER BY 2

Finally, you can generate the sequence of seconds using the same approach:


DECLARE @time float
SELECT @time = cast(1 as float)/cast(86400 as float)

IF EXISTS(SELECT * FROM sysobjects
WHERE id = OBJECT_ID('test'))
DROP TABLE test;

SELECT num, (CAST('Dec 31, 2006 23:59:59' AS datetime) + @time * num) dt
INTO test
FROM sequence;

SELECT * FROM test;

Results:

num dt
----------- -----------------------
1 2007-01-01 00:00:00.000
2 2007-01-01 00:00:01.000
3 2007-01-01 00:00:02.000
4 2007-01-01 00:00:03.000
5 2007-01-01 00:00:03.997
6 2007-01-01 00:00:05.000
7 2007-01-01 00:00:06.000
8 2007-01-01 00:00:07.000
9 2007-01-01 00:00:08.000
10 2007-01-01 00:00:08.997
11 2007-01-01 00:00:09.997
. . . . . . . . . . . . . . . . . .
16382 2007-01-01 04:33:00.997
16383 2007-01-01 04:33:02.000
16384 2007-01-01 04:33:03.000


SELECT CONVERT(varchar(100), dt, 120)
FROM test
ORDER BY num

Results:

2007-01-01 00:00:00
2007-01-01 00:00:01
2007-01-01 00:00:02
2007-01-01 00:00:03
2007-01-01 00:00:03
2007-01-01 00:00:05
. . . . . . . . . .
2007-01-01 04:32:55
2007-01-01 04:32:56
2007-01-01 04:32:56
2007-01-01 04:32:58
2007-01-01 04:32:59
2007-01-01 04:33:00
2007-01-01 04:33:00
2007-01-01 04:33:02
2007-01-01 04:33:03

This last example has the same problems as the previous one. In addition, using arithmetic operators for date/time manipulations can lead to other errors, weird results, degradation in performance, and more problems than are discussed here. You can avoid all these problems by using the SQL Server's date/time functions.



Bonus Benefits Beyond Bad Results
SQL Server's date/time functions not only help you avoid the errors, but they also make the programmer's life much easier and more convenient. If, for example, you need to generate the fifth day of each month in the year 2007, you can do that easily using the DATEADD() function:


SELECT DATEADD(mm, num - 1, 'Jan 05, 2007') AS [5th_Day]
FROM sequence
WHERE num <= 12

Results:

5th_Day
-----------------------
2007-01-05 00:00:00.000
2007-02-05 00:00:00.000
2007-03-05 00:00:00.000
2007-04-05 00:00:00.000
2007-05-05 00:00:00.000
2007-06-05 00:00:00.000
2007-07-05 00:00:00.000
2007-08-05 00:00:00.000
2007-09-05 00:00:00.000
2007-10-05 00:00:00.000
2007-11-05 00:00:00.000
2007-12-05 00:00:00.000

The beauty of this query is in its convenience. You do not need to know how many days are in each specific month or in the year. The logic and calculations are already included into the SQL Server functions and are transparent to you. Trying to use the arithmetic operator (+) for the same task would require implementing that logic yourself, which would increase the development and debugging time and potentially raise the chance of errors.

So should you use arithmetic operators in date/time calculations in SQL Server? No. Although it's possible to use arithmetic operators with dates for very simple operations such as GETDATE() + 1—because SQL Server will convert the 1 to a date internally—you're better off avoiding using arithmetic operators with dates altogether. If you use them in more complex date/time calculations, you will need to be very careful and conscientious.

Eclipse on Vista, v 3.3 M6

Quotes from eclipse magazine,

Eclipse 3.3 M6 has been released, with animpressive list in New and Noteworthy.With this release Eclipse now runs onVista (Windows Presentation Foundationor the WPF). SWT is now exploiting more of the nativefeatures of the Vista platform. For example, usingnative double buffering on Vista win32 makes paintingin double-buffered canvases twice as fast. As ChrisAniszczyk further points out, SWT has “gone wild” withsupport for WPF, JavaXPCOM, and OLE improvements.The Platform also has a new look. Previous milestoneshave included a presentation titled “3.3 Presentation(Experimental)”. Its features are now part of the defaultpresentation.

Other new features include:
1. Improved min/max workflow
2. Help will now display a series of links called breadcrumbsat the top of each document that appears in the table ofcontents, allowing for easier navigation and morecontextual information
3. Categorised help search
4. Jetty-based implementation of the OSGi HTTP serviceadded to the Platform SDK along with the bundles thatprovide JSP and extension registry support
5. PDE now supports plug-in refactoring by providing theability to rename a plug-in ID and update all referencesto it in downstream plug-insPDE also provides three templates (Interactive, Browser,Extensible) for creating custom splash screens, completewith code, images and XML mark-up

The release has also added new features to the JDT,including improved null check detection, workspace relativepaths for Javadoc location and more

Visit http://www.eclipse.org

Idol

Seorang direktur bank datang memberikan sebuah pertanyaan menohok, "Kenapa, ya, di Indonesia banyak trainer yang menjadi motivator? Apa masyarakat kita memang sudah sedemikian loyo, kurang semangat, sehingga perlu dimotivasi terus-menerus?" Rupanya beliau agak keberatan dengan sikap salah satu manajernya yang ketagihan memanggil trainer khusus motivator untuk memacu semangat para staf penjualan di bank itu. Menurut dia, tugas motivator itu mestinya dilakukan sang manajer sendiri.

Mendengar cerita itu, terus terang hati saya mencelat juga. Soalnya, protes beliau bisa berbahaya bagi lahan rezeki saya. Maklum, saya sendiri sering dipanggil perusahaan untuk memberikan sesi motivasi di berbagai pertemuan tahunan, raker, dan sebagainya.

Malah, minggu lalu, saya diundang ke Surabaya untuk memberikan motivasi di hadapan lebih dari 3.000 mahasiswa tentang berjiwa dan bersemangat entrepreneur. Sungguh spektakuler. Sepertinya para peserta sangat haus dengan minuman yang disebut motivasi.

Menurut seorang teman, profesi trainer motivator kurang dikenal di negara-negara seperti Jepang, Cina, dan Korea. Kalau memang benar begitu, harap maklum saja, karena memang di tiga negara itu, semangat dan motivasi berjuang sebagai entrepreneur memang sudah sangat tinggi. Jadi, mungkin saja profesi motivator tidak akan laku di sana.

Namun pertanyaan yang tetap menghantui saya adalah: apakah kita terbukti memang kurang percaya diri dan miskin semangat? Saya teringat satu pengalaman unik belum lama ini. Seperti kita ketahui, saat ini sedang musim "idol". Pertarungan menjadi "American Idol" dan "Indonesian Idol" telah dimulai dengan tahap seleksi.
Beberapa kali saya menonton proses seleksi awal "American Idol" di televisi. Cukup menarik, memang, karena "American Idol" boleh dibilang menjadi fenomena unik. Malah, di acara beken Larry King, muncul beberapa kali interviu dengan alumnus "American Idol". Beberapa peserta yang berhasil masuk final, dan menang, menceritakan bagaimana "American Idol" menjadi sebuah gerbang unik yang berhasil mengubah hidup mereka.

Situasi ini ternyata jauh berbeda dengan di Indonesia. Peserta dan peminat "Indonesian Idol" ternyata tidak sebanyak di Amerika. Padahal, jumlah penduduk Indonesia dan Amerika sebenarnya rada-rada mirip dan mendekati. Malah, menurut gosip, peserta "Indonesian Idol" dari tahun ke tahun makin surut.
Satu hal yang sangat menarik, lebih dari separuh perserta tampil apa adanya. Mereka sangat kurang percaya diri. Saat diminta bernyanyi, banyak yang matanya menjauhi pandangan mata para juri secara langsung. Mereka menghindari eye contact. Kebanyakan pandangan mata mereka ke langit-langit. Malah ada satu perserta yang gagap dan mengatakan takut.

Para peserta kita juga jauh lebih sopan. Kalau ditolak, masih bisa mengucapkan terima kasih dan tersenyum. Jarang sekali yang berani protes atau ngotot berdebat dengan para juri. Beda dengan peserta "American Idol". Betapa sering kita melihat para peserta begitu emosional apabila ditolak. Tak jarang mereka juga berdebat dan mempertanyakan keputusan juri. Banyak peserta yang gagal itu penasaran dan kelihatan betul semangatnya yang menggebu-gebu. Sementara peserta "Indonesian Idol" kebanyakan pasrah saja kalau ditolak.

Jangan-jangan, ini memang fenomena yang mengaramkan kita selama ini. Jangan-jangan, prestasi olahraga kita susah maju juga disebabkan semangat juang yang tipis. Bahwa kita lebih mudah dan gampang menyerah.

Cerita dan sukses para alumnus "American Idol" memang banyak yang sangat spektakuler. Ada yang berhasil mendadak menjadi artis besar dan memenangkan Grammy sekaligus. Ada yang melompat main film dan juga pentas Broadway. "American Idol", bagi mereka, berhasil menjadi "pengungkit" yang melontarkan karier. Istilahnya, banyak alumnus "American Idol" yang berhasil membuat sebuah lompatan besar.

Beda dengan alumnus "Indonesian Idol" yang sukses dan kemudian pelan-pelan memudar. Tanpa sempat punya karier yang spektakuler. Demikian juga cerita atlet-atlet kita yang berprestasi, jarang di antara mereka yang bisa menciptakan lompatan besar ketika mereka beken dan populer. Ketika mereka memasuki usia senja, malah banyak yang memiliki kehidupan sangat sulit.

Barangkali hidup ini alurnya harus kita simak dengan strategis. Kalau saja kita mengalami prestasi kecil dan sukses kecil, mestinya bisa kita jadikan momentum yang melontarkan kita ke posisi yang lebih baik. Istilah kata, hidup ini harus bergaya dongkrak. Setiap ada kesempatan, kita dongkrak sedikit demi sedikit. Terus-menerus hingga ke atas.

Kata Mpu Peniti, janganlah hidup bergaya mercon atau kembang api. Satu bunyi keras, kemudian padam dan sunyi. Atau kembang api yang membawa kita tinggi hanya untuk sekian detik, dan seterusnya gelap.
Itu sebabnya, setiap kali memberikan pelatihan yang lebih bersifat motivasi, saya selipkan beberapa strategi bisnis yang mudah dan lugas, agar menjadi elemen inspirasi yang melengkapi motivasi. Saya tidak ingin motivasi itu jadi semangat yang mirip kembang api. Cuma tahan sesaat, setelah itu gelap gulita.

Original post by
Kafi Kurnia
peka@indo.net.id
[Intrik, Gatra edisi 16 Kamis, 1 Maret 2007]

Calon MA (Mahasiswa Asyiieekkk)

Kemarin seperti biasa dengan santai dan perasaan riang saya cek http://binusmaya.binus.ac.id dengan niat mau cek nilai. Sapa tau nilai ArKom uda keluar.

Eh diliat2 ada private message nongol, saya klik aja deh. Ternyata bad news banget buat saya.

Ga taunya tgl 9 Mei kemarin Binus tuh autodebet uang sks, dan karena saldo saya ga cukup (Lagi cekak buat bayar uang gedung sekolah dd), maka gagal deh autodebetnya.

Karena selama ini saya uda keenakan mahasiswa paket jadi nyantai2 aja kalo gagal, toh nanti ada kesempatan autodebet lagi. Ternyata Binus kali ini tega banget ngasih sanksi akademis buat peserta mahasiswa yang lagi isi KRS. Sanksi nya berupa terlambat isi KRS (Tadinya 22 Mei, jadi 11 Juni) sama tidak boleh ikut batal tambah. Maklum baru kali ini sih isi KRS jadi lengah deh, ga nyangka bakal kayak gini.

Jadiiii kayaknya harapan untuk skripsi di semester 9 nanti tertutup sudah. Yah doain aja moga2 masih ada jalan deh.

Rahasia si Untung Angsa (Gladstone)

Kita semua pasti kenal tokoh si Untung di komik Donal Bebek. Berlawanan dengan Donal yang selalu sial. Si Untung ini dikisahkan untung terus. Ada saja keberuntungan yang selalu menghampiri tokoh bebek yang di Amerika bernama asli Gladstone ini. Betapa enaknya hidup si Untung. Pemalas, tidak pernah bekerja, tapi selalu lebih untung dari Donal. Jika Untung dan Donal berjalan bersama, yang tiba-tiba menemukan sekeping uang dijalan, pastilah itu si Untung. Jika Anda juga ingin selalu beruntung seperti si Untung, dont worry, ternyata beruntung itu ada ilmunya.


Professor Richard Wiseman dari University of Hertfordshire Inggris, mencoba meneliti hal-hal yang membedakan orang2 beruntung dengan yang sial. Wiseman merekrut sekelompok orang yang merasa hidupnya selalu untung, dan sekelompok lain yang hidupnya selalu sial. Memang kesan nya seperti main-main, bagaimana mungkin keberuntungan bisa diteliti. Namun ternyata memang orang yang beruntung bertindak berbeda dengan mereka yang sial.


Misalnya, dalam salah satu penelitian the Luck Project ini, Wiseman memberikan tugas untuk menghitung berapa jumlah foto dalam koran yang dibagikan kepada dua kelompok tadi. Orang2 dari kelompok sial memerlukan waktu rata-rata 2 menit untuk menyelesaikan tugas ini. Sementara mereka dari kelompok si Untung hanya perlu beberapa detik saja! Lho kok bisa?


Ya, karena sebelumnya pada halaman ke dua Wiseman telah meletakkan tulisan yang tidak kecil berbunyi "berhenti menghitung sekarang! ada 43 gambar di koran ini". Kelompol sial melewatkan tulisan ini ketika asyik menghitung gambar. Bahkan, lebih iseng lagi, di tengah2 koran, Wiseman menaruh pesan lain yang bunyinya: "berhenti menghitung sekarang dan bilang ke peneliti Anda menemukan ini, dan menangkan $250!" Lagi-lagi kelompok sial melewatkan pesan tadi! Memang benar2 sial.


Singkatnya, dari penelitian yang diklaimnya "scientific" ini, Wiseman menemukan 4 faktor yang membedakan mereka yang beruntung dari yang sial:


1. Sikap terhadap peluang.
Orang beruntung ternyata memang lebih terbuka terhadap peluang. Mereka lebih peka terhadap adanya peluang, pandai menciptakan peluang, dan bertindak ketika peluang datang. Bagaimana hal ini dimungkinkan?
Ternyata orang-orang yg beruntung memiliki sikap yang lebih rileks dan terbuka terhadap pengalaman-pengalam an baru. Mereka lebih terbuka terhadap interaksi dengan orang-orang yang baru dikenal, dan menciptakan jaringan-jaringan sosial baru. Orang yang sial lebih tegang sehingga tertutup terhadap kemungkinan- kemungkinan baru.


Sebagai contoh, ketika Barnett Helzberg seorang pemilik toko permata di New York hendak menjual toko permata nya, tanpa disengaja sewaktu berjalan di depan Plaza Hotel, dia mendengar seorang wanita memanggil pria di sebelahnya: "Mr. Buffet!" Hanya kejadian sekilas yang mungkin akan dilewatkan kebanyakan orang yang kurang beruntung. Tapi Helzber berpikir lain. Ia berpikir jika pria di sebelahnya ternyata adalah Warren Buffet, salah seorang investor terbesar di Amerika, maka dia berpeluang menawarkan jaringan toko permata nya. Maka Helzberg segera menyapa pria di sebelahnya, dan betul ternyata dia adalah Warren Buffet.
Perkenalan pun terjadi dan Helzberg yang sebelumnya sama sekali tidak mengenal Warren Buffet, berhasil menawarkan bisnisnya secara langsung kepada Buffet, face to face. Setahun kemudian Buffet setuju membeli jaringan toko permata milik Helzberg. Betul-betul beruntung.


2. Menggunakan intuisi dalam membuat keputusan.
Orang yang beruntung ternyata lebih mengandalkan intuisi daripada logika. Keputusan-keputusan penting yang dilakukan oleh orang beruntung ternyata sebagian besar dilakukan atas dasar bisikan "hati nurani" (intuisi) daripada hasil otak-atik angka yang canggih. Angka-angka akan sangat membantu, tapi final decision umumnya dari "gut feeling".


Yang barangkali sulit bagi orang yang sial adalah, bisikan hati nurani tadi akan sulit kita dengar jika otak kita pusing dengan penalaran yang tak berkesudahan. Makanya orang beruntung umumnya memiliki metoda untuk mempertajam intuisi mereka, misalnya melalui meditasi yang teratur. Pada kondisi mental yang tenang, dan pikiran yang jernih, intuisi akan lebih mudah diakses. Dan makin sering digunakan, intuisi kita juga akan semakin tajam.


Banyak teman saya yang bertanya, "mendengarkan intuisi" itu bagaimana?
Apakah tiba2 ada suara yang terdengar menyuruh kita melakukan sesuatu?
Wah, kalau pengalaman saya tidak seperti itu. Malah kalau tiba2 mendengar suara yg tidak ketahuan sumbernya, bisa2 saya jatuh pingsan.
Karena ini subyektif, mungkin saja ada orang yang beneran denger suara.


Tapi kalau pengalaman saya, sesungguhnya intuisi itu sering muncul dalam berbagai bentuk, misalnya: - Isyarat dari badan. Anda pasti sering mengalami. "Gue kok tiba2 deg-deg an ya, mau dapet rejeki kali", semacam itu. Badan kita sesungguhnya sering memberi isyarat2 tertentu yang harus Anda maknakan. Misalnya Anda kok tiba2 meriang kalau mau dapet deal gede, ya diwaspadai saja kalau tiba2 meriang lagi. - Isyarat dari perasaan. Tiba-tiba saja Anda merasakan sesuatu yang lain ketika sedang melihat atau melakukan sesuatu. Ini yang pernah saya alami. Contohnya, waktu saya masih kuliah, saya suka merasa tiba-tiba excited setiap kali melintasi kantor perusahaan tertentu. Beberapa tahun kemudian saya ternyata bekerja di kantor tersebut. Ini masih terjadi untuk beberapa hal lain.


3. Selalu berharap kebaikan akan datang.
Orang yang beruntung ternyata selalu ge-er terhadap kehidupan. Selalu berprasangka baik bahwa kebaikan akan datang kepadanya. Dengan sikap mental yang demikian, mereka lebih tahan terhadap ujian yang menimpa mereka, dan akan lebih positif dalam berinteraksi dengan orang lain. Coba saja Anda lakukan tes sendiri secara sederhana, tanya orang sukses yang Anda kenal, bagaimana prospek bisnis kedepan. Pasti mereka akan menceritakan optimisme dan harapan.


4. Mengubah hal yang buruk menjadi baik.
Orang-orang beruntung sangat pandai menghadapi situasi buruk dan merubahnya menjadi kebaikan. Bagi mereka setiap situasi selalu ada sisi baiknya. Dalam salah satu tes nya Prof Wiseman meminta peserta untuk membayangkan sedang pergi ke bank dan tiba-tiba bank tersebut diserbu kawanan perampok bersenjata. Dan peserta diminta mengutarakan reaksi mereka. Reaksi orang dari kelompok sial umunya adalah: "wah sial bener ada di tengah2 perampokan begitu". Sementara reaksi orang beruntung, misalnya adalah: "untung saya ada disana, saya bisa menuliskan pengalaman saya untuk media dan dapet duit". Apapun situasinya orang yg beruntung pokoknya untung terus.


Mereka dengan cepat mampu beradaptasi dengan situasi buruk dan merubahnya menjadi keberuntungan.
Sekolah Keberuntungan. Bagi mereka yang kurang beruntung, Prof Wiseman bahkan membuka Luck School.
Latihan yang diberikan Wiseman untuk orang2 semacam itu adalah dengan membuat "Luck Diary", buku harian keberuntungan. Setiap hari, peserta harus mencatat hal-hal positif atau keberuntungan yang terjadi.
Mereka dilarang keras menuliskan kesialan mereka. Awalnya mungkin sulit, tapi begitu mereka bisa menuliskan satu keberuntungan, besok-besoknya akan semakin mudah dan semakin banyak keberuntungan yg mereka tuliskan. Dan ketika mereka melihat beberapa hari kebelakang Lucky Diary mereka, mereka semakin sadar betapa beruntungnya mereka. Dan sesuai prinsip "law of attraction", semakin mereka memikirkan betapa mereka beruntung, maka semakin banyak lagi lucky events yang datang pada hidup mereka.


Jadi, sesederhana itu rahasia si Untung. Ternyata semua orang juga bisa beruntung. Termasuk termans semua.


Siap mulai menjadi si Untung?

Pahami tujuan hidup

Pahami Tujuan Hidup

People with goals succeed because they know where they're going.

Orang-orang yang mempunyai suatu target berhasil mencapai sukses, sebab mereka mengetahui kemana arah langkah mereka."
Earl Nightingale
Bayangkan jika kita melihat seekor kucing yang mengejar seekor tikus.
Kemana pun tikus berlari maka kucing itu pun akan memperhatikan dengan pandangan yang sangat tajam dan sewaktu-waktu dengan sigap menyergap sang tikus. Tingkah kucing yang berlari kian kemari mengejar tikus tentu suatu pemandangan yang wajar.

Namun persepsi kita akan berbeda jika salah satu di antara kedua binatang tersebut tidak kelihatan. Misalnya saja hanya kucingnya yang nampak, sedangkan tikusnya tidak. Maka tingkah kucing itu tentu membuat kita tertawa. Sebab kita tidak mengetahui sasaran yang sedang dibidik oleh kucing tersebut.

Kiasan di atas dapat diartikan bahwasanya manusia mempunyai keunikan bakat dan kemampuan yang berbeda-beda. Oleh sebab
itu, di antara manusia juga mempunyai perbedaan tujuan hidup. Si A misalnya boleh merasa aneh dengan tingkah laku Si B, sebab Si A tidak mengetahui tujuan yang hendak dicapai oleh Si B.

Henry Ford mempunyai bakat dan tujuan hidup yang berbeda dengan Walt Disney, Andrew Carnegie, dan lain sebagainya. Henry Ford mempunyai tujuan memproduksi dan mendistribusikan mobil berkualitas secara masal. Sedangkan Walt Disney mempunyai tujuan hidup membahagiakan orang lain melalui hiburan. Lalu Andrew Carnegie ingin memproduksi dan medistribusikan baja ke seluruh dunia, dan masih banyak contoh lainnya. Faktanya, orang-orang yang sukses di dunia itu pasti mempunyai tujuan hidup.

Masing-masing di antara kita tentu juga mempunyai tujuan hidup.
Tetapi saya heran mengapa tujuan hidup sebagian besar manusia di dunia ini tidak mampu berperan penting dalam mencapai kesuksesan .
Setelah sekian lama saya mengamati, rupanya penyebab utama tujuan hidup itu tidak dapat berfungsi sebagai langkah penting untuk mencapai kesuksesan adalah ketidakmampuan kita sendiri dalam memahami dan mendefisikan tujuan hidup tersebut.

Sebagian besar di antara kita memang mempunyai tujuan hidup, tetapi terkadang jumlah tujuan hidup itu bisa sampai ratusan. Sifat tujuan hidup itu pun masih rancu atau tidak terperinci secara pasti. Agar hal itu tidak terjadi, maka sebaiknya buatlah konsep mengenai tujuan hidup untuk jangka waktu tertentu, misalnya untuk 1 minggu ke depan, 1 bulan atau satu tahun ke depan.

Pengambilan keputusan merupakan tahap selanjutnya yang sangat penting. Untuk itu berpikirlah lebih dalam, jernih dan terkontrol sebelum benar-benar memutuskan apa tujuan hidup Anda. Sebuah pepatah bijak mengatakan, "Your decisions determine your direction, and your direction determines your destiny. ?Keputusanmu menentukan arah tujuan, dan tujuanmu menentukan keberuntunganmu." Karena itu Anda akan memerlukan lebih banyak informasi agar dapat memutuskan sebuah tujuan hidup yang paling tepat.

Sebagai contoh adalah keputusan Nelson Mandela. Berdasarkan
pengalaman dan latar belakang kehidupannya, ia memilih tujuan hidup membebaskan rakyat Afrika Selatan dari tekanan politik rasialisme.
Sejak tahun 1942, ia sering terlibat aksi-aksi dan organisasi politik. Kehidupan Nelson berubah sebagai konsekuensi atas
keputusannya terjun ke dunia politik.

Sepanjang tahun 1950-an, Mandela selalu menjadi korban tekanan
kekuasaan. Nelson dipenjarakan bertahun-tahun, berpindah-pindah dari penjara pulau Robben, Pollsmoor di Cape Town, dan penjara Victor Verster. Ia baru dibebaskan pada tanggal 11 Februari 1990.

Nelson berhasil menerima hadiah Perdamaian Nobel pada tahun 1993 dan terpilih menjadi Presiden Afrika Selatan untuk masa jabatan 10 Mei 1994 hingga Juni 1999. Semua berawal dari keputusannya memperjuangkan hak asasi manusia dan persamaan ras di Afrika Selatan sebagai tujuan hidup. Karena itu membuat keputusan mengenai apa tujuan hidup Anda merupakan langkah yang sangat penting.

Setelah membuat keputusan mengenai tujuan hidup, maka langkah
berikutnya adalah menuliskan tujuan hidup tersebut. Menuliskan tujuan hidup dimaksudkan untuk memudahkan Anda memahaminya.
Jika tujuan hidup itu ditulis, itu artinya Anda
sudah menciptakan instruksi yang jelas mengenai apa yang harus Anda lakukan danbagaimana mengembangkan rencana berikutnya.

Langkah-langkah tersebut sangat efektif digunakan untuk dapat
memahami tujuan hidup. Pemahaman terhadap tujuan hidup sangat penting sebab proses pencapaian tujuan hidup berkembang dari pemikiran hingga menjadi sketsa, dari sketsa ke tindakan, dan dari tindakan ke pencapaian yang sesungguhnya. Goethe mengatakan, "Hal terbesar di dunia ini bukanlah dimana Anda berdiri, melainkan kemana Anda akan pergi." Itu artinya, jika Anda mampu menetapkan,memahami dan memperjelas tujuan hidup, maka kemungkinan untuk meraih sukses juga akan lebih besar.

Sumber: Pahami Tujuan Hidup oleh Andrew Ho.

Ruby on Rails First Impression

Weekend kemarin saya iseng2 coba Ruby on Rails (RoR) untuk membuat contoh aplikasi sederhana. Ternyata sangat gampang banget, saya aja takjub dengan RoR ini. Bener2 cool.
Buat yg mau coba belajar bhs pemrograman, RoR ini sangat recommended. Dan bagi yang sudah menguasai bahasa pemrograman, tapi ingin mencari 2nd language RoR ini jg recommended.

Apa itu Ruby ?
Ruby merupakan bahasa pemrograman yang murni OOP. Ruby merupakan kombinasi dari Smalltalk, Pyhton, dan Perl. Pertama kali diperkenalkan pada tahun 1990 di Jepang dan mulai populer di dunia 2 - 3 tahun belakangan ini. Di Indonesia bahasa ini tergolong baru, dan saat ini belum ada perusahaan yang mengimplementasikan bahasa ini.

Apa itu Ruby on Rails ?
Ruby on Rails dikenal juga dengan RoR atau Rails saja merupakan framework open source yang berbasiskan Ruby untuk mendevelop aplikasi berbasis web. Keunggulan Rails dilansir dari situs resminya http://www.rubyonrails.org :
1. Less code
2. Less configuration
3. Faster development time

Nah saya mencoba membuat aplikasi cookbook, yaitu aplikasi sederhana untuk membuat resep dan kategorinya. Aplikasi ini cuma CRUD (Create, Retrieve, Update, Delete) untuk resep dan kategori. Sangat sederhana, saya tidak akan menjelaskan secara detail karena keterbatasan waktu, jadi saya hanya menceritakan pengalaman saya saja. Untuk membuat aplikasi yang seperti diatas (cookbook) kita cukup :
1. Mengenerate struktur direktori kita dengan syntax "rails cookbook", maka rails akan mengenerate kerangka aplikasi untuk kita.
2. Mengenerate class model, di class model kita tidak perlu definisikan atribut2 sesuai database kita (Seperti ORM di Java) cukup menulis syntax "ActiveRecord::Base" saja.
3. Mengenerate class controller lalu tambahkan satu syntax "scaffold:recipe"

Salah satu fitur Rails yang menarik adalah English Plural. Misalnya didatabase kita nama tabel nya adalah recipes (Ada huruf s dibelakang) maka Controller dan Model cukup kita namai Recipe, Rails dengan pintar mengenalinya.

Selesai sudah. Aplikasi CRUD sudah tercipta. Mudah bukan ?
Bandingkan dengan Java dimana kita harus menciptakan POJO, formnya, action nya, CRUDnya dll. Rails ini mengingatkan saya akan salah satu framework Java yaitu Gen and Run yang merupakan table driven programming. Jika kita menambah field didatabase maka form nya otomatis akan bertambah mengikuti table tersebut.

Bola Masuk Ke Kantung Kertas

Seorang pemain profesional bertanding dalam sebuah turnamen golf. Ia baru saja membuat pukulan yang bagus sekali yang jatuh di dekat lapangan hijau. Ketika ia berjalan di fairway, ia mendapati bolanya masuk ke dalam sebuah kantong kertas pembungkus makanan yang mungkin dibuang sembarangan oleh salah seorang penonton. Bagaimana ia bisa memukul bola itu dengan baik?

Sesuai dengan peraturan turnamen, jika ia mengeluarkan bola dari kantong kertas itu, ia terkena pukulan hukuman. Tetapi kalau ia memukul bola bersama-sama dengan kantong kertas itu, ia tidak akan bisa memukul dengan baik. Salah-salah, ia mendapatkan skor yang lebih buruk lagi. Apa yang harus dilakukannya?

Banyak pemain mengalami hal serupa. Hampir seluruhnya memilih untuk mengeluarkan bola dari kantong kertas itu dan menerima hukuman. Setelah itu mereka bekerja keras sampai ke akhir turnamen untuk menutup hukuman tadi.

Hanya sedikit, bahkan mungkin hampir tidak ada, pemain yang memukul bola bersama kantong kertas itu. Resikonya terlalu besar. Namun, pemain profesional kita kali ini tidak memilih satu di antara dua kemungkinan itu.

Tiba-tiba ia merogoh sesuatu dari saku celananya dan mengeluarkan sekotak korek api. Lalu ia menyalakan satu batang korek api dan membakar kantong kertas itu. Ketika kantong kertas itu habis terbakar, ia memilih tongkat yang tepat, membidik sejenak, mengayunkan tongkat, wus, bola terpukul dan jatuh persis ke dalam lobang di lapangan hijau. Bravo! Dia tidak terkena hukuman dan tetap bisa mempertahankan posisinya.

Smiley...! Ada orang yang menganggap kesulitan sebagai hukuman, dan memilih untuk menerima hukuman itu. Ada yang mengambil resiko untuk melakukan kesalahan bersama kesulitan itu. Namun, sedikit sekali yang bisa berpikir kreatif untuk menghilangkan kesulitan itu dan menggapai kemenangan.

How good we are could find out the best of us in solving problem, especially during under pressure ??

Java FX introducing

Dalam konfrensi JavaOne yang berlangsung di San Fransisco, Sun memperkenalkan JavaFX.
JavaFX saat ini ada 2 yaitu :
1. JavaFX Script
2. JavaFX Mobile
JavaFX ini diprediksi merupakan alternatif dari Ajax. JavaFX ini dirilis untuk menjawab kebutuhan market yang membutuhkan content yang kaya, interaktif, dan secure.

Saya tidak bermain di bidang mobile karena itu saya akan membahas JavaFX Script saja.
Keunggulan JavaFX Script menurut Sun adalah :
1. Mempercepat waktu development
2. Kaya kontent yang bisa berjalan di platform apapun
3. Didukung komunitas yang sangat besar
4. Coding yang lebih sedikit

CMIIW JavaFX Script ini bisa digunakan untuk aplikasi desktop saja. Saat ini saya belum sempat mencobanya, nanti setelah saya coba akan saya posting lagi.

https://openjfx.dev.java.net/

Oracle JDeveloper 11g preview

Oracle has release JDeveloper 11g preview and available for download. This update brings many updates, including updated JUnit 4 support, a new profiler that leverages the JVM's hooks, better database support, extra web services support, editor support for JavaScript, better performance, and more.

The weakness of Oracle JDeveloper 11g is cannot deploy to other webserver than Oracle AS.

http://www.oracle.com/technology/products/jdev/11/index.html

Nulis blog sambil dibayar dengan Google Adsense

Kabar baik bagi anda blogger mania. Sekarang kita bisa menyalurkan hobby nulis kita sekaligus dibayar oleh Google lewat program google Adsense.

A. Apa itu Google Adsense ?
Google adsense merupakan program iklan yang dipasang di blog kita.

B. Bagaimana caranya ?
1. Buat blog dahulu
Daftar di situs www.blogger.com (gratis).

2. Perkaya isi blog kamu
Masukan artikel artikel yang menarik di blog kamu (minimal 15 - 20 artikel) dan harus dalam bahasa inggris (untuk pertama kali), karena saat mendaftar ke google adsense google akan mereview isi blog kamu.

3. Buat account di Google Adsense
Cukup klik logo disamping kanan blog ini yang bertuliskan "Get revenue with Google Adsense".
Di form pendaftaran akan ditanya situs mana yang mau di daftarkan, masukan alamat situs blog kamu misalnya http://www.harry-christian.blogspot.com jgn lupa untuk masukan alamat kamu dengan benar karena penting untuk google mengirim pembayaran kealamat kamu.

4. Promosikan blog kamu agar makin banyak visitor yang datang.

C. Apa saja jenis iklan yang bisa dipasang di blog kita ?
1. Content
Merupakan iklan iklan yang BERHUBUNGAN dengan situs kita. Misal blog kita lebih banyak bercerita tentang film, maka iklan iklan yang muncul juga banyak berhubungan dengan film.

2. Referral
Saat ini ada 3 jenis iklan referral, yaitu
*. Adsense, kita akan dibayar jika ada orang yang mendaftar account adsense melalui blog kita
*. Adword, kita akan dibayar jika ada orang yang mendaftar account adword melalui blog kita
*. Firefox, kita akan dibayar jika ada yang mendownload firefox melalui blog kita

3. Search
Search engine untuk search ke web maupun ke blog kita.

D. Cara memasukan iklan adsense ke blog kita
Ada 2 cara :
1. Login ke blogger.com, klik "layout".
Klik "Add new page element", pilih jenis "Adsense"
2. Login ke www.google.com/adsense pilih tab "Adsense Setup". Pilih jenis iklan yang kita inginkan ikuti langkah selanjutnya untuk mendapatkan code iklan kita.
Setelah itu ke blog kita klik "Add new page element" pilih jenis HTML/Java Script paste code yang tadi kesini

E. Cara pembayaran
Google akan membayar kita dengan cek yang akan dikirim ke alamat rumah kita.
Google akan membayar jika kita sudah mencapai angka tertentu (Saya tidak ingat antara 50$ atau 100$).

E. Do dan Don't
Do :
*. Publish website kita sebanyak mungkin ke temen2 kita.
*. Buat konten blog yang menarik dalam bahasa inggris sebanyak mungkin
*. Sering2 tukeran link blog ketemen2
*. Penempatan banner yang strategis dan menarik.

Don't
*. Cara curang mengklik iklan sendiri
Google tidak bodoh, Google bisa mendeteksi dari IP address, Mac address, Cookie kita dll. Jika kita bandel blog kita akan diban
*. Membuat / Mencari program bot untuk otomatis mengklik situs kita.
Sekali lagi google tidak bodoh, jika blog kita di akses ribuan kali dalam hitungan menit sistem google akan mendeteksi ketidak wajaran.


To Ruby or not to be ? That is the question

Jumat kemarin, saya mengikuti mata kuliah kapsel dengan topik RM (Requirment Management). Topik ini sih membosankan, saya sampai ngantuk dengernya. Yang membuat saya tertarik diakhir mata kuliah speaker nya menyinggung sedikit tentang Ruby on Rails yang notebene merupakan barang baru di Indonesia. Sempat di review sedikit keunggulan Ruby dibanding Java antara lain line of code yang sedikit, memory usage yang efesien dibanding Java yang rakus memory, All about OOP murni, tidak lagi ada primitif data type seperti int, double. Semua adalah class di Ruby.

Hal ini membuat semangat saya untuk mempelajari Ruby bangkit kembali. Memang saya denger Ruby uda cukup lama, sekitar setaun yang lalu. Akan tetapi waktu itu saya belum termotivasi buat belajar sehingga e-book ruby yang sudah saya download akhirnya didiamkan begitu saja dikomputer. Waktu itu abis install juga cuma test interactive console nya aja, abis itu ya uda lupa deh.

Setelah denger speakernya bilang bahwa bahasa ini akan menjadi trend dimasa depan dan bisa jadi topik skripsi, saya jadi tertarik untuk mempelajarinya lagi. Mudah mudahan permohonan untuk bisa skripsi di semester 9 mendatang dikabulkan, jadi bisa sekalian belajar ruby buat skripsi.

Dota math guide

This article from www.dotaportal.com is very amazing. The creator must be genius in math :p


DotA Mathematics

This is a guide to show you the mathcraft of some commonly argued issues. Reading this will not instantly boost your DotA skills overnight, but will give you a rough idea on what to do and what not to do in more general situations. Having some forms of mathcraft in mind, you will make less logical mistakes in terms of selecting items and skills for heroes. The guide will be written in Q and A form. More important phrases and conclusions will be highlighted in ORANGE, and calculations to support the arguments will be separated so that those who trust me on the mathematics can skip those and read the conclusion. Enjoy!

Contents

1: Introduction to the concept of EHP (Effective Hit Points)

2: Introduction to the concept of Effective Damage

3: Introduction to the concept of DPS (Damage Per Second)

4: Application of EHP, Effective Damage, and DPS

5: The most argued topic: Buriza or Monkey King Bar?

6: How good is Hyperstone?

7: Armor reduction skills, how good/ bad are they?

8: How to optimize my DPS?

9: Maelstrom — n00b item or useful?


Read more at
http://halfhuman-dotamania.blogspot.com/2007/05/dota-math-guide.html

Sun Java System Web Server 7.0 Update 1 is ready to download

Sun Java System Web Server 7.0 Update 1 is ready to download.

This Technology Preview of Sun Java System Web Server 7.0 Update 1 provides developers with an updated Java container supporting the latest Java standards including the Web Developer's Pack. It also provides bug fixes, performance enhancements, and administration improvements.

This Technology Preview is for development and testing purposes only. It is not certified for use in a production environment.


http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=8&PartDetailId=SJWS-7.0U1-G-F&TransactionId=Try

stored procedure tuning for sql server

more article to sql server database programming.


Whenever a client application needs to send Transact-SQL to SQL Server, send it in the form of a stored procedure instead of a script or embedded Transact-SQL. Stored procedures offer many benefits, including:

* Reduced network traffic and latency, boosting application performance.
* Stored procedure execution plans can be reused, staying cached in SQL Server's memory, reducing server overhead.
* Client execution requests are more efficient. For example, if an application needs to INSERT a large binary value into an image data column not using a stored procedure, it must convert the binary value to a character string (which doubles its size), and send it to SQL Server. When SQL Server receives it, it then must convert the character value back to the binary format. This is a lot of wasted overhead. A stored procedure eliminates this issue as parameter values stay in the binary format all the way from the application to SQL Server, reducing overhead and boosting performance.
* Stored procedures help promote code reuse. While this does not directly boost an application's performance, it can boost the productivity of developers by reducing the amount of code required, along with reducing debugging time.
* Stored procedures can encapsulate logic. You can change stored procedure code without affecting clients (assuming you keep the parameters the same and don't remove any result sets columns). This saves developer time.
* Stored procedures provide better security to your data. If you use stored procedures exclusively, you can remove direct SELECT, INSERT, UPDATE, and DELETE rights from the tables and force developers to use stored procedures as the method for data access. This saves DBA's time.

Keep in mind that just because you use a stored procedure does not mean that it will run fast. The code you use within your stored procedure must be well designed for both speed and reuse. [6.5, 7.0, 2000, 2005] Update 6-6-2005

*****

One of the biggest advantages of using stored procedures over not using stored procedures is the ability to significantly reduce network traffic. And the more network traffic that can be reduced, the better the overall performance of your SQL Server-based applications.

Here are some examples how stored procedures reduce network traffic:

* When an application executes a stored procedure, only a simple, small RPC (remote procedure call) is made from the client to SQL Server. But if the application is not using stored procedures, but sending Transact-SQL code directly from the client to SQL Server, network traffic cab often very high. For example, if the amount of Transact-SQL code is 500 lines (and this would not be all that unusual), then it would take hundreds of network packets to transmit the Transact-SQL code from the client to SQL Server. On the other hand, if the 500 lines of Transact-SQL code are in a stored procedure, this code never has to travel the network, as it is already located on the server.
* When an application needs to retrieve one or more rows from SQL Server and then takes some action on this data, such as INSERTing, UPDATing, or DELETing rows in the database based on the data retrieved, network traffic is significantly reduced if all this code is stored in a stored procedure. As before, it only takes a single RPC call to execute a stored procedure. But if all the code to perform these steps is not in a stored procedure, but located in the application, network traffic can be high. For example, first, the application has to send the Transact-SQL code to SQL Server (lots of potential network traffic). Then SQL Server has to return the result set back to the client, then the client has to use the data, and then send additional requests (INSERT, UPDATE, DELETE) to SQL Server, and then SQL Server has to respond back to the client, and so on, until the task is completed. As you can see, this can generate a lot of network traffic. But if all the work is being done from within a stored procedure, network traffic is greatly reduced.
* Along the same lines as above, putting the business logic of your application in stored procedures can help your application's performance. By locating virtually all of the processing on SQL Server, round-trip network traffic is greatly reduced, helping boost performance.

The goal should be to limit network traffic from the client to SQL Server to simple RPCs, and limit the traffic from SQL Server to the client as finished results. [6.5, 7.0, 2000] Updated 12-6-2005

*****

To help identify performance problems with stored procedures, use the SQL Server's Profiler Create Trace Wizard to run the "Profile the Performance of a Stored Procedure" trace to provide you with the data you need to identify poorly performing stored procedures. [7.0] Updated 12-6-2005

*****

By default, every time a stored procedure is executed, a message is sent from the server to the client indicating the number of rows that were affected by the stored procedure. Rarely is this information useful to the client. By turning off this default behavior, you can reduce network traffic between the server and the client, helping to boost overall performance of your server and applications.

There are two main ways to turn this feature off. You can also turn this feature off using a server trace setting, but it is unnecessary as there are easier ways, as described here.

To turn this feature off on at the stored procedure level, you can include the statement:

SET NOCOUNT ON

at the beginning of each stored procedure you write. This statement should be included in every stored procedure you write.

If you want this feature turned off for your entire server, you can do this by running these statements at your server:

SP_CONFIGURE 'user options', 512
RECONFIGURE

You may or may not want to do this for your entire server, as it affects every transaction on your server. For example, some application programs need the count information, otherwise they will not work. If this is the case, you don't want to turn this option for the entire server, but just for the stored procedures you write.

Most commonly, the first statement is used as it is more flexible, and only affects those stored procedures you write. [6.5, 7.0, 2000] Updated 12-6-2005

*****

Keep Transact-SQL transactions as short as possible within a stored procedure. This helps to reduce the number of locks, helping to speed up the overall performance of your SQL Server application.

Two ways to help reduce the length of a transaction are to: 1) break up the entire job into smaller steps (or multiple stored procedures) so each step can be committed as soon as possible; and 2) take advantage of SQL Server statement batches, which acts to reduce the number of round-trips between the client and server. [6.5, 7.0, 2000, 2005] Updated 6-6-2005

*****

When a stored procedure is first executed (and it does not have the WITH RECOMPILE option), it is optimized and a query plan is compiled and cached in SQL Server's buffer. If the same stored procedure is called again from the same connection, it will used the cached query plan instead of creating a new one, often saving time and boosting performance. This may or may not be what you want.

If the query in the stored procedure is exactly the same each time, and the query plan is the same each time, then this is a good thing. But if the query within the stored procedure is dynamic (for example, the WHERE clauses changes from one execution of the stored procedure to the next), then this may not be a good thing, as the query may not be optimized when it is run, and the performance of the query can suffer greatly. This can happen because changes in the query plan may occur, and if you run an incorrect cached query plan for what is essentially a new query, it may not be appropriate and it may cause performance to suffer greatly.

If you know that your query's query plan will vary each time it is run from a stored procedure, you will want to add the WITH RECOMPILE option when you create the stored procedure. This will force the stored procedure to be re-compiled each time it is run, ensuring the query is optimized with the correct query plan each time it is run. Yes, this will circumvent the reuse of cached query plans, hurting performance a little, but it is more desirable than reusing incorrect query plans. [6.5, 7.0, 2000] Updated 12-6-2005

*****

Many stored procedures have the option to accept multiple parameters. This in and of itself is not a bad thing. But what can often cause problems is if the parameters are optional, and the number of parameters varies greatly each time the stored procedure runs. There are two ways to handle this problem, the slow performance way and fast performance way.

If you want to save your development time, but don't care about your application's performance, you can write your stored procedure generically so that it doesn't care how many parameters it gets. The problem with this method is that you may end up unnecessarily joining tables that don't need to be joined based on the parameters submitted for any single execution of the stored procedure.

Another, much better performing way, although it will take you more time to code, is to include IF...ELSE logic in your stored procedure, and create separate queries for each possible combination of parameters that are to be submitted to the stored procedure. This way, you can be sure you query is as efficient as possible each time it runs. [6.5, 7.0, 2000] Updated 12-6-2005

*****

Here's another way to handle the problem of not knowing what parameters your stored procedure might face. In fact, it will probably perform faster than the tip listed above.

Although the above tip is a good starting point, it's not complete. The problem are the query plans, the pre-compilation of stored procedures, that SQL Server does for you. As you know, one of the biggest reasons to use stored procedures instead of ad-hoc queries is the performance gained by using them. The problem that arises with the above tip is that SQL Server will only generate a query-plan for the path taken through your stored procedure when you first call it, not all possible paths.

Let me illustrate this with an example. Consider the following procedure (pre-compilation doesn't really have a huge effect on the queries used here, but these are just for illustration purposes):

CREATE PROCEDURE dbo.spTest (@query bit) AS
IF @query = 0
SELECT * FROM authors
ELSE
SELECT * FROM publishers
GO

Suppose I make my first call to this procedure with the @query parameter set to 0. The query-plan that SQL Server will generate will be optimized for the first query ("SELECT * FROM authors"), because the path followed on the first call will result in that query being executed.

Now, if I next call the stored procedure with @query set to 1, the query plan that SQL Server has in memory will not be of any use in executing the second query, since the query-plan is optimized for the authors table, not the publishers table. Result: SQL Server will have to compile a new query plan, the one needed for the second query. If I next call the procedure with @query set to 0 again, the whole path will have to be followed from the start again, since only one query-plan will be kept in memory for each stored procedure. This will result in sub-optimal performance.

As it happens I have a solution, one that I've used a lot with success. It involves the creation of what I like to call a 'delegator'. Consider again spTest. I propose to rewrite it like this:

CREATE PROCEDURE dbo.spTestDelegator (@query bit) AS
IF @query = 0
EXEC spTestFromAuthors
ELSE
EXEC spTestFromPublishers
GO

CREATE PROCEDURE dbo.spTestFromAuthors AS
SELECT * FROM authors
GO

CREATE PROCEDURE dbo.spTestFromPublishers AS
SELECT * FROM publishers
GO

The result of this restructuring will be that there will always be an optimized query-plan for spTestFromAuthors and spTestFromPublishers, since they only hold one query. The only one getting re-compiled over and over again is the delegator, but since this stored procedure doesn't actually hold any queries, that won't have a noticeable effect on execution time. Of course re-compiling a plan for a simple 'SELECT *' from a single table will not give you a noticeable delay either (in fact, the overhead of an extra stored procedure call may be bigger then the re-compilation of "SELECT * FROM AnyTable"), but as soon as the queries get bigger, this method certainly pays off.

The only downside to this method is that now you have to manage three stored procedures instead of one. This is not that much of a problem though as the different stored procedures can be considered one single 'system', so it would be logical to keep all of them together in the same script, which would be just as easy to edit as a single stored procedure would be. As far as security is concerned, this method shouldn't give you any extra headaches either, as the delegator is the only stored procedure directly called by the client, this is the only one you need to manage permissions on. The rest will only be called by the delegator, which will always work as long as those stored procedures are owned by the same user as the delegator.

I've had large successes using this technique. Recently I developed a (partial full-text) search engine for our reports database, which resulted in a stored procedure that originally ran about 20 seconds. After employing the above technique, the stored procedure only took about 2 seconds to run, resulting in a ten-fold increase in performance! [6.5, 7.0, 2000] Contributed by Jeremy van Dijk. Updated 6-21-2004

*****

While temporary stored procedures can provide a small performance boost in some circumstances, using a lot of temporary stored procedures in your application can actually create contention in the system tables and hurt performance.

Instead of using temporary stored procedures, you may want to consider using the SP_EXECUTESQL stored procedure instead. It provides the same benefits on temporary stored procedures, but it does not store data in the systems tables, avoiding contention problems. [7.0, 2000] Updated 6-6-2005

*****

If you are creating a stored procedure to run in a database other than the Master database, don't use the prefix "sp_" in its name. This special prefix is reserved for system stored procedures. Although using this prefix will not prevent a user defined stored procedure from working, what it can do is to slow down its execution ever so slightly.

The reason for this is that by default, any stored procedure executed by SQL Server that begins with the prefix "sp_", is first attempted to be resolved in the Master database. Since it is not there, time is wasted looking for the stored procedure.

If SQL Server cannot find the stored procedure in the Master database, then it next tries to resolve the stored procedure name as if the owner of the object is "dbo". Assuming the stored procedure is in the current database, it will then execute. To avoid this unnecessary delay, don't name any of your stored procedures with the prefix "sp_". [6.5, 7.0, 2000] Updated 6-12-2006

*****

Before you are done with your stored procedure code, review it for any unused code that you may have forgotten to remove while you were making changes, and remove it. Unused code just adds unnecessary bloat to your stored procedures, although it will not negatively affect performance of the stored procedure. [6.5, 7.0, 2000] Updated 6-12-2006

*****

For best performance, all objects that are called within the same stored procedure should all be owned by the same object owner, preferably dbo, and should also be referred to in the format of object_owner.object_name.

If the object owner's are not specified for objects, then SQL Server must perform name resolution on the objects, which causes a performance hit.

And if objects referred to in the stored procedure have different owners, SQL Server must check object permissions before it can access any object in the database, which adds unnecessary overhead. Ideally, the owner of the stored procedure should own all of the objects referred to in the stored procedure.

In addition, SQL Server cannot reuse a stored procedure "in-memory plan" over if the object owner is not used consistently. If a stored procedure is sometime referred to with its object owner's name, and sometimes it is not, then SQL Server must re-execute the stored procedure, which also hinders performance. [7.0, 2000, 2005] Updated 6-6-2005

*****

When you need to execute a string of Transact-SQL, you should use the sp_executesql stored procedure instead of the EXECUTE statement. Sp_executesql offers two major advantages over EXECUTE. First, it supports parameter substitution, which gives your more options when creating your code. Second, it creates query execution plans that are more likely to be reused by SQL Server, which in turn reduces overhead on the server, boosting performance.

Sp_executesql executes a string of Transact-SQL in its own self-contained batch. When it is run, SQL Server compiles the code in the string into an execution plan that is separate from the batch that contained the sp_executesql and its string.

Learn more about how to use sp_executesql in the SQL Server Books Online. [7.0, 2000] Updated 6-12-2006

*****

* If you include a WITH RECOMPILE clause in a CREATE PROCEDURE or EXECUTE statement.
* If you run sp_recompile for any table referenced by the stored procedure.
* If any schema changes occur to any of the objects referenced in the stored procedure. This includes adding or dropping rules, defaults, and constraints.
* New distribution statistics are generated.
* If you restore a database that includes the stored procedure or any of the objects it references.
* If the stored procedure is aged out of SQL Server's cache.
* An index used by the execution plan of the stored procedure is dropped.
* A major number of INSERTS, UPDATES or DELETES are made to a table referenced by a stored procedure.
* The stored procedure includes both DDL (Data Definition Language) and DML (Data Manipulation Language) statements, and they are interleaved with each other.
* If the stored procedure performs certain actions on temporary tables.

[7.0, 2000] Updated 04-03-2006

*****

One hidden performance problem of using stored procedures is when a stored procedure recompiles too often. Normally, you want a stored procedure to compile once and to be stored in SQL Server's cache so that it can be re-used without it having to recompile each time it is used. This is one of the major benefits of using stored procedures.

But in some cases, a stored procedure is recompiled much more often than it needs to be recompiled, hurting your server's performance. In fact, it is possible for a stored procedure to have to be recompiled while it is executing!

Here are three potential problems you want to look out for when writing stored procedures.

Unnecessary Stored Procedure Recompilations Due to Row Modifications and Automated Statistics Update

If your database has the "Auto Update Statistics" database option turned on, SQL Server will periodically automatically update the index statistics. On a busy database, this could happen many times each hour. Normally, this is a good thing because the Query Optimizer needs current index statistics if it is to make good query plan decisions. One side effect of this is that this also causes any stored procedures that reference these tables to be recompiled. Again, this is normal, as you don't want a stored procedure to be running an outdated query plan. But again, sometimes stored procedures recompile more than they have to. Here are some suggestions on how to reduce some of the unnecessary recompilations:

* Use sp_executesql instead of EXECUTE to run Transact-SQL strings in your stored procedures.
* Instead of writing one very large stored procedure, instead break down the stored procedure into two or more sub-procedures, and call then from a controlling stored procedure.
* If your stored procedure is using temporary tables, use the KEEP PLAN query hint, which is used to stop stored procedure recompilations caused by more than six changes in a temporary table, which is the normal behavior. This hint should only be used for stored procedures than access temporary tables a lot, but don't make many changes to them. If many changes are made, then don't use this hint.

Unnecessary Stored Procedure Recompilations Due to Mixing DDL and DML Statements in the Same Stored Procedure

If you have a DDL (Data Definition Language) statement in your stored procedure, the stored procedure will automatically recompile when it runs across a DML (Data Manipulation Language) statement for the first time. And if you intermix both DDL and DML many times in your stored procedure, this will force a recompilation every time it happens, hurting performance.

To prevent unnecessary stored procedure recompilations, you should include all of your DDL statements at the first of the stored procedure so they are not intermingled with DML statements.

Unnecessary Stored Procedure Recompilations Due to Specific Temporary Table Operations

Improper use of temporary tables in a stored procedure can force them to be recompiled every time the stored procedure is run. Here's how to prevent this from happening:

* Any references to temporary tables in your stored procedure should only refer to tables created by that stored procedure, not to temporary tables created outside your stored procedure, or in a string executed using either the sp_executesql or the EXECUTE statement.
* All of the statements in your stored procedure that include the name of a temporary table should appear syntactically after the temporary table.
* The stored procedure should not declare any cursors that refer to a temporary table.
* Any statements in a stored procedure that refer to a temporary table should precede any DROP TABLE statement found in the stored procedure.
* The stored procedure should not create temporary tables inside a control-of-flow statement.

[7.0, 2000] Updated 04-03-2006 More from Microsoft

*****

To find out if your SQL Server is experiencing excessive recompilations of stored procedures, a common cause of poor performance, create a trace using Profiler and track the SP:Recompile event. A large number of recompilations should be an indicator if you potentially have a problem. Identify which stored procedures are causing the problem, and then take correction action (if possible) to reduce or eliminate these excessive recompilations. [7.0, 2000] Updated 04-03-2006

*****

Stored procedures can better boost performance if they are called via Microsoft Transaction Server (MTS) instead of being called directly from your application. A stored procedure can be reused from the procedure cache only if the connection settings calling the stored procedure are the same. If different connections call a stored procedure, SQL Server must load a separate copy of the stored procedure for each connection, which somewhat defeats the purpose of stored procedures.

But if the same connection calls a stored procedure, it can be used over and over from the procedure cache. The advantage of Transaction Server is that it reuses connections, which means that stored procedures can be reused more often. If you write an application where every user opens their own connection, then stored procedures cannot be reused as often, reducing performance. [7.0, 2000] Updated 04-03-2006

*****

Avoid nesting stored procedures, although it is perfectly legal to do so. Nesting not only makes debugging more difficult, it makes it much more difficult to identify and resolve performance-related problems. [6.5, 7.0, 2000] Updated 04-03-2006

*****

If you use input parameters in your stored procedures, you should validate all of them at the beginning of your stored procedure. This way, if there is a validation problem and the client applications needs to be notified of the problem, it happens before any stored procedure processing takes place, preventing wasted effort and boosting performance. [6.5, 7.0, 2000] Updated 6-12-2006

*****

When calling a stored procedure from your application, it is important that you call it using its fully qualified name. Such as:

exec database_name.dbo.myProcedure

instead of:

exec myProcedure

Why? There are a couple of reasons, one of which relates to performance. First, using fully qualified names helps to eliminate any potential confusion about which stored procedure you want to run, helping to prevent bugs and other potential problems.

But more importantly, doing so allows SQL Server to access the stored procedures execution plan more directly, and in turn, speeding up the performance of the stored procedure. Yes, the performance boost is very small, but if your server is running tens of thousands or more stored procedures every hour, these little time savings can add up. [7.0, 2000] Updated 6-12-2006

*****

If a stored procedure needs to return only a single value, and not a recordset, consider returning the single value as an output statement. While output statements are generally used for error-checking, they can actually be used for any reason you like. Returning a single value as at output statement is faster than returning a single value as part of a recordset. [6.5, 7.0, 2000] Updated 6-12-2006

*****

One way to help ensure that stored procedures are reused from execution to execution of the same stored procedure is to ensure that any SET options, database options, or SQL Server configuration options don't change from execution to execution of the same stored procedure. If they do, then SQL Server may consider these same stored procedures to be different, and not be able to reuse the current query plan stored in cache.

Some examples of this include when you change the language used by the stored procedure (using SET) and if you change the Dateformat (using SET). [7.0, 2000] Updated 6-12-2006

*****

If you find that a particular stored procedure recompiles every time it executes, and you have determined that there is nothing you can do about the recompiles, and if that stored procedure is very large, consider the following option. Try to determine what part or parts of the stored procedure is causing the recompiles. Once you have done this, break out this troublesome code into its own stored procedure, and then call this stored procedure from the main stored procedure. The advantage of this is that is it takes much less time to recompile a smaller stored procedure than a larger stored procedure. [7.0, 2000] Updated 6-12-2006