tag:blogger.com,1999:blog-24985089135360959792024-02-07T21:35:56.950-08:00It's Meaningful, It's Useless, It's Your CallVersion 2 of Odonk2RacerBlog @ odonk2racerblog.blogspot.com, check it out!M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-2498508913536095979.post-3212820037533758732013-05-06T06:43:00.000-07:002013-05-06T06:47:07.909-07:00A Little Variation of Good 'Ol J2ME Analog Clock<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7gGyDGRnbLKSBzYULrIU0wzK4QG-0nF42wR9uTx1erVBlEdY_ZV7XxbdYf94ri9MOz3q8j11DTCvQpU2IzeDmtL07JfbTcVirXYVRTudW95idgbXsXEFaxTiXEASkx8JoYxVJhgb9qsc/s1600/analog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7gGyDGRnbLKSBzYULrIU0wzK4QG-0nF42wR9uTx1erVBlEdY_ZV7XxbdYf94ri9MOz3q8j11DTCvQpU2IzeDmtL07JfbTcVirXYVRTudW95idgbXsXEFaxTiXEASkx8JoYxVJhgb9qsc/s320/analog.png" width="184" /></a></div>
<br />
If you manage to get here by typing "analog clock j2me" or some sort in Google, chances are you have five or more tabs opened in your browser. It's just that an analog clock is pretty much a common thing around, with J2ME being no exception.</div>
<div style="text-align: justify;">
That's why this time I'll take a little spin on the analog clock and give it a way to make the thing run faster - or so I hope. In this post we will see how - instead of the usual sine & cos function (or method, whatever) - to use arrays containing values that corresponds to certain sine & cos value of an angle in an analog clock program using J2ME.</div>
<div style="text-align: justify;">
<br /></div>
<h4>
Why Array?</h4>
<div style="text-align: justify;">
If you have done this before using the sine & cos function, you may ask "Why reinvent the wheels?". You see, the wheels are really a staple of human creativity, as it allow us to move heavy things such as a carriage with much ease than before. That's why, to improve it's usefulness, many improvements are made to the wheels itself, such as using rubber instead of just wood or iron as the outer shell to maximize friction while maintaining the same reliability, and also...</div>
<div style="text-align: justify;">
Wait, why are we talking about wheels? Okay, so using sine & cos function, the same goal can be achieved (which is making a line spin, seriously) but if there's one thing we all know about mobile phone: <b>it's slow</b>. Okay, maybe not that slow, but it still run very slowly compared to PCs. So, instead of telling the phone to calculate sine & cos value of an angle every second (which is the same sixty values, anyway) we will give the phone a set of numbers, perfectly ordered from 0 to 360 degrees value of sine & cos, and then told the phone to "skim the catalog" instead. It will be much faster to simply look up a value from a table than calculating it all the way (even humans know it). A lecturer in my college told me about this - and even manage to give an assignment about it (guess which one it is, haha).<br />
<a name='more'></a></div>
<div style="text-align: justify;">
<br /></div>
<h4>
The Code</h4>
<div style="text-align: justify;">
Since it's an analog clock, it will be wise to leave the "ticking" task to a Thread, since the "ticking" will happen forever and we'll still need the MIDlet to hear our Commands. I'm using a Canvas to draw the clock, but if you have a better idea you can go green light (whatever it's supposed to mean).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The MIDlet:</div>
<div style="text-align: justify;">
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">import javax.microedition.lcdui.*;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">import javax.microedition.midlet.*;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">public class WatchMidlet extends MIDlet</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> Display theDisplay = null;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> WatchCanvas theCanvas = null;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> TimeTicker theTicker = null;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public WatchMidlet()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> super();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void startApp()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theCanvas = new WatchCanvas(this);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theTicker = new TimeTicker(this);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theTicker.start();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (theDisplay == null)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theDisplay = Display.getDisplay(this);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theDisplay.setCurrent(theCanvas);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void pauseApp()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void destroyApp(boolean unconditional)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void quitApp()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theTicker.setAlive(false);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> destroyApp(true);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> notifyDestroyed();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void tick()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theCanvas.detik();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">}</span></div>
<div>
<br /></div>
<div>
The Thread:</div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">public class TimeTicker extends Thread</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> boolean isAlive = true;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> WatchMidlet theMidlet = null;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int tickTime = 1000;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public TimeTicker(WatchMidlet w)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> super();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> this.theMidlet = w;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void run()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> while (isAlive)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> try</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> Thread.sleep(tickTime);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> } catch (Exception e)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theMidlet.tick();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void setAlive(boolean val)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> this.isAlive = val;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">}</span></div>
</div>
<div>
<br /></div>
<div>
The Canvas:</div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">import javax.microedition.lcdui.*;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">public class WatchCanvas extends Canvas implements CommandListener</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> Command exitCommand = new Command("Exit", Command.EXIT, 0);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> WatchMidlet theMidlet;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> double sin[] =</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 0.00, 0.10, 0.21, 0.31, 0.41, 0.50, 0.59, 0.67, 0.74, 0.81,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 0.87, 0.91, 0.95, 0.98, 0.99, 1.00, 0.99, 0.98, 0.95, 0.91,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 0.87, 0.81, 0.74, 0.67, 0.59, 0.50, 0.41, 0.31, 0.21, 0.10,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 0.00, -0.10, -0.21, -0.31, -0.41, -0.50, -0.59, -0.67, -0.74, -0.81,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> -0.87, -0.91, -0.95, -0.98, -0.99, -1.00, -0.99, -0.98, -0.95, -0.91,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> -0.87, -0.81, -0.74, -0.67, -0.59, -0.50, -0.41, -0.31, -0.21, -0.10,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 0.00</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> };</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> double cos[] =</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 1.00, 0.99, 0.98, 0.95, 0.91, 0.87, 0.81, 0.74, 0.67, 0.59,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 0.50, 0.41, 0.31, 0.21, 0.10, 0.00, -0.10, -0.21, -0.31, -0.41,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> -0.50, -0.59, -0.67, -0.74, -0.81, -0.87, -0.91, -0.95, -0.98, -0.99,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> -1.00, -0.99, -0.98, -0.95, -0.91, -0.87, -0.81, -0.74, -0.67, -0.59,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> -0.50, -0.41, -0.31, -0.21, -0.10, 0.00, 0.10, 0.21, 0.31, 0.41,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 0.50, 0.59, 0.67, 0.74, 0.81, 0.87, 0.91, 0.95, 0.98, 0.99,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 1.00</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> };</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int[] theta =</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 5, 4, 3, 2, 1, 0, 59, 58, 57, 56,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 55, 54, 53, 52, 51, 50, 49, 48, 47, 46,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 45, 44, 43, 42, 41, 40, 39, 38, 37, 36,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 35, 34, 33, 32, 31, 30, 29, 28, 27, 26,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> 25, 24, 23, 22, 21, 20, 19, 18, 17, 16,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> };</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int indexS = 0, indexM = 0, indexH = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int length = 100;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int length2 = 50;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int centrX = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int centrY = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int prevSecX = 0, prevMinX = 0, prevHourX = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int prevSecY = 0, prevMinY = 0, prevHourY = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int currSecX = 0, currMinX = 0, currHourX = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int currSecY = 0, currMinY = 0, currHourY = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> boolean begin = true;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public WatchCanvas(WatchMidlet w)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> super();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> this.theMidlet = w;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> addCommand(exitCommand);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> setCommandListener(this);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void paint(Graphics g)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (begin)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> centrX = getWidth() / 2;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> centrY = getHeight() / 2;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currSecX = pointX(0, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currSecY = pointY(0, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevSecX = centrX;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevSecY = centrY;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currMinX = pointX(0, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currMinY = pointY(0, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevMinX = centrX;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevMinY = centrY;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currHourX = pointX(0, length2);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currHourY = pointY(0, length2);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevHourX = centrX;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevHourY = centrY;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.setColor(255, 255, 255);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.fillRect(0, 0, getWidth(), getHeight());</span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.setColor(0, 0, 0);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> for (int i = 1; i <= 12; i++)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if(i == 12)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawString("12",</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pointX(0, length), pointY(0, length),</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> Graphics.BASELINE | Graphics.HCENTER);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> } else</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawString(String.valueOf(i),</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> pointX(i * 5, length), pointY(i * 5, length),</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> Graphics.BASELINE | Graphics.HCENTER);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> begin = false;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.setColor(255, 255, 255);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawLine(centrX, centrY, prevSecX, prevSecY);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawLine(centrX, centrY, prevMinX, prevMinY);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawLine(centrX, centrY, prevHourX, prevHourY);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.setColor(0, 0, 255);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawLine(centrX, centrY, currSecX, currSecY);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.setColor(0, 255, 0);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawLine(centrX, centrY, currMinX, currMinY);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.setColor(255, 0, 0);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> g.drawLine(centrX, centrY, currHourX, currHourY);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void commandAction(Command c, Displayable d)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (c == exitCommand)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> theMidlet.quitApp();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void detik()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> indexS++;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (indexS == 60)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> indexS = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> menit();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevSecX = currSecX;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevSecY = currSecY;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currSecX = pointX(indexS, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currSecY = pointY(indexS, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> this.repaint();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void menit()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> indexM++;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (indexM == 60)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> indexM = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> jam();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevMinX = currMinX;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevMinY = currMinY;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currMinX = pointX(indexM, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currMinY = pointY(indexM, length);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> this.repaint();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> public void jam()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> indexH++;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (indexH == 60)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> indexH = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevHourX = currHourX;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> prevHourY = currHourY;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currHourX = pointX(indexH, length2);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> currHourY = pointY(indexH, length2);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> this.repaint();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int pointX(int clockNum, int handLength)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> return centrX + (int) (handLength * cos[theta[clockNum]]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> int pointY(int clockNum, int handLength)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> return centrY - (int) (handLength * sin[theta[clockNum]]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">}</span></div>
</div>
<div>
<br /></div>
<div>
If you do it right it should look something like this:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhsTvGTGIQLXs3NrSWLq1_j6vE1lxxxKs-Cws5ZP5cCkoCrmIGeb3cG9EAeudWTOtCwDCBvPysu0W0SL2Yq7jLErGbQ7EcIYVV5Weomiv9WYoO-5Mf2sQAjrNIQ75w3qopuBqHzK2G8rA/s1600/analog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhsTvGTGIQLXs3NrSWLq1_j6vE1lxxxKs-Cws5ZP5cCkoCrmIGeb3cG9EAeudWTOtCwDCBvPysu0W0SL2Yq7jLErGbQ7EcIYVV5Weomiv9WYoO-5Mf2sQAjrNIQ75w3qopuBqHzK2G8rA/s320/analog.png" width="184" /></a></div>
<div>
<br /></div>
<div>
You may say the result is exactly the same with the "function" way, but the truth will be told when you let this application and another - that uses the sine & cos function - run for a while (I recommend in a phone, not an emulator). You will see a significant difference in performance after running both methods for approximately an hour.</div>
<div>
<br /></div>
<div>
You can find the complete project (in NetBeans) <a href="http://www.4shared.com/rar/5AoKHpYc/UnusualClockeyHands.html?">here, in this link, where you click.</a></div>
<div>
<br /></div>
<div>
There will be two MIDlets: one is the clock above and the other, is...<br />
Let's just say <b>you've been warned</b>.</div>
</div>
M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-54383462064978100822012-09-25T08:22:00.001-07:002013-05-06T06:47:46.608-07:00Port Scanner with JavaHello guys, it's been a while. Let's continue.<br />
<br />
(Yeah, that's it. I'm not a big fan of being talkative. Sue me.)<br />
<br />
In this post, I'm about to show you how easy it is to make simple port scanner application using our everyday - lo and behold - Java SE language.<br />
<br />
The idea is simple; just check all the ports available, one by one, and if you got lucky (you know what I mean) we memorize the port number. In this code example, we use the Socket class from the client to try to connect to all the ports available in a host (Too many "to"? Sue me).<br />
<br />
The only drawback from this simple source code is that it runs very slow. Hell, it takes one port a second to scan on my AMD C-60 netbook. You don't like it? Well, I did say this is a simple program. You still don't like it? Sue me.<br />
<br />
And since this is - again - a simple program, I only used the basic text interface, so you might want to run this app from DOS mode or the Terminal Linux equivalent. Why? It makes you look cool, working on text-based program and such. You don't like it? Sue me.<br />
<a name='more'></a> <br />
<br />
Okay, here's the code:<br />
<br />
import java.net.*;<br />
import java.io.*;<br />
<br />
/**<br />
*<br />
* @author Fariz<br />
*/<br />
public class PortScanner<br />
{<br />
<br />
public static void main(String[] args)<br />
{<br />
Socket theSocket = null;<br />
BufferedReader reader = null;<br />
int numPortScanned = 0, numPortOpened = 0, startPort = 0, endPort = 65535;<br />
int listPortOpened[] = new int[65537];<br />
String destinationAddress = null;<br />
<br />
//initialize the opened port list by marking them with "closed" value, I used -1 on this<br />
for (int p = 0; p < listPortOpened.length; p++)<br />
{<br />
listPortOpened[p] = -1;<br />
}<br />
<br />
<br />
try //enter the required information (target host and port range)<br />
{<br />
reader = new BufferedReader(new InputStreamReader(System.in));<br />
System.out.print("Enter hostname or IP Address: ");<br />
destinationAddress = reader.readLine();<br />
<br />
System.out.print("Enter first port: ");<br />
startPort = Integer.parseInt(reader.readLine());<br />
<br />
System.out.print("Enter last port: ");<br />
endPort = Integer.parseInt(reader.readLine());<br />
} catch (Exception e)<br />
{<br />
e.printStackTrace();<br />
}<br />
<br />
numPortScanned = startPort;<br />
System.out.println("");<br />
<br />
//check all the freaking ports<br />
while (numPortScanned <= endPort)<br />
{<br />
try<br />
{<br />
System.out.println("Connecting to " + destinationAddress + " on port " + numPortScanned + "...");<br />
theSocket = new Socket(destinationAddress, numPortScanned);<br />
numPortOpened++;<br />
System.out.println("Port IS OPEN.");<br />
<br />
//if it's opened, remember the port number<br />
listPortOpened[numPortScanned] = numPortScanned;<br />
<br />
//check the next port<br />
numPortScanned++;<br />
theSocket.close();<br />
} catch (Exception e)<br />
{<br />
System.out.println("Port is closed.");<br />
<br />
//if the port's closed, simply skip it<br />
numPortScanned++;<br />
listPortOpened[numPortScanned] = -1;<br />
}<br />
}<br />
<br />
//show all the opened ports<br />
if (numPortOpened == 0)<br />
{<br />
System.out.println("\nNo port opened in " + destinationAddress + ", better luck next time!.");<br />
} else<br />
{<br />
System.out.println("\nFound in " + destinationAddress + ", there are " + numPortOpened + " ports opened: ");<br />
for (int i = 0; i < listPortOpened.length; i++)<br />
{<br />
if (listPortOpened[i] != -1)<br />
{<br />
System.out.print(listPortOpened[i] + " ");<br />
}<br />
}<br />
System.out.println("\n");<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
Enjoy!M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-66608205898066151382011-11-10T06:59:00.001-08:002013-05-06T06:48:25.346-07:00"Text Moving" Web Application Using Java Applet (jApplet)<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
One of the reason why Java becomes a very popular language is because it can run on multiple platforms, be it a PC, mobile phone, or even in a web browser!<br />
<br />
In this post, you will see one simple application that can run in a Chrome browser (or any other browser with JRE available) which involves buttons, text, event-handling and of course: the Java Applet form.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDICIDND1Wq1AJX_V6UyGbOzVp-c-bafDA6e55-5ABOBrKA2MVxznJ6paEFoVoU6SkP66Xz7IGswnPcPsRBCea0GV-Gdii-rj6T3xbZDMPnRyCEwEpkiTqiZPerwlSgE6kpkM5Xm8vIhw/s1600/MovingTextApplet.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDICIDND1Wq1AJX_V6UyGbOzVp-c-bafDA6e55-5ABOBrKA2MVxznJ6paEFoVoU6SkP66Xz7IGswnPcPsRBCea0GV-Gdii-rj6T3xbZDMPnRyCEwEpkiTqiZPerwlSgE6kpkM5Xm8vIhw/s400/MovingTextApplet.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The "Text-Moving" Application Running on Chrome</td></tr>
</tbody></table>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
</div>
<div style="text-align: justify;">
The application above is used with eight different buttons, each representing directions. When each button is pressed, the text on the center will move to the direction the button is representing, so pressing "Up" button will make the text move up, "Down" button to go down, and so on.<br />
<a name='more'></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Here's some important point of the source code to show you how it works. In order for the application to be able to run on a browser, we must use the jApplet form.</div>
<br />
<br />
<br />
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
int xPos = 0;<br />
int yPos = 0;<br />
int delta = 10;</div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
public void getPos()<br />
{<br />
xPos = jLabel1.getX();<br />
yPos = jLabel1.getY();<br />
}</div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
<br /></div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
private void upButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
yPos = yPos - delta;<br />
jLabel1.setLocation(xPos, yPos);<br />
} <br />
<br />
private void upRightButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
yPos = yPos - delta;<br />
xPos = xPos + delta;<br />
jLabel1.setLocation(xPos, yPos);<br />
} <br />
<br />
private void rightButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
xPos = xPos + delta;<br />
jLabel1.setLocation(xPos, yPos);<br />
} <br />
<br />
private void downRightButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
xPos = xPos + delta;<br />
yPos = yPos + delta;<br />
jLabel1.setLocation(xPos, yPos);<br />
} </div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
private void downButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
yPos = yPos + delta;<br />
jLabel1.setLocation(xPos, yPos);<br />
} </div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
private void downLeftButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
xPos = xPos - delta;<br />
yPos = yPos + delta;<br />
jLabel1.setLocation(xPos, yPos);</div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
} </div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
private void leftButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
xPos = xPos - delta;<br />
jLabel1.setLocation(xPos, yPos);</div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
} </div>
<div style="font-family: "Courier New",Courier,monospace; text-align: left;">
private void upLeftButtonMouseClicked(java.awt.event.MouseEvent evt) <br />
{ <br />
getPos();<br />
xPos = xPos - delta;<br />
yPos = yPos - delta;<br />
jLabel1.setLocation(xPos, yPos)</div>
<div style="text-align: left;">
<span style="font-family: "Courier New",Courier,monospace;">}</span></div>
M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-83805581966173556132011-09-28T09:34:00.000-07:002013-05-06T06:48:47.991-07:00The Seed of HonestyOnce upon a time (no, it's not a fairy tale), there was a CEO from a successful, multinational, billion-dollar company who is nearing his retirement age and in a need of finding a replacement. So, in order to find someone worthy enough to continue his legacy, he called all of his employee - from the top-level executive to "just-ordinary" employee - and told them to gather in one place (mess hall, probably).<br />
<br />
After all the future inheritors gathered, he gave each one of them a seed of a plant (yes, they don't know what plant it is).<br />
"<span style="color: #3d85c6;"><span style="color: black;"><span style="color: #3d85c6;">Take care of the seed, raise them properly to a full-grown plant, and one year from now we will gather back here to show me what you have grown. Anyone with the best plant will take my position as a CEO, therefore taking the chance to lead one of the most successful company in the world</span></span><span style="color: #3d85c6;">.</span></span>", said the CEO. <br />
<br />
And they all set out to grow the best plant. One of the ordinary employee, Rahmat, also did the same. Everyday he watered the seed, gave it nutrients and did everything he can to make the seed grow (which is fairly difficult since he didn't know what plant it is).<br />
Unfortunately, it wouldn't. The seed didn't even change it's shape, never mind growing into a full-grown plant of whatever plant it is. Even after 6 months, when all the other top-level and better-educated executives talked proudly about how they seed grew beautifully (even though each plant was of different kind), Rahmat's seed didn't even make a hint of it - it's simply lying dormant in the vase he bought for it.<br />
<br />
<div style="color: #cc0000;">
<span style="font-size: small;"><b>Ultimately, he felt that he had failed.</b></span><br />
<a name='more'></a></div>
<br />
Nevertheless, he continued to grow the seed. His intention just changed from doing it for the highly prized position to simply keeping the seed fresh, so it wouldn't look dead when he brought it back to the CEO. Once he thought of simply bringing a different vase with a different plant - a full-grown one - just so he wouldn't be embarassed. But his wife encourage him to brought the truth, not wanting to see his husband stray himself from his honesty.<br />
<br />
<div style="color: #6aa84f;">
And on the 12th month of the "quest for legacy", everyone gathered back at where they did it the last time. All the executives and the employees brought their vases - with a full-grown plant - in it, boasted to all their friends and colleagues how hard it was for them to grow such plant. And as mentioned before, most of those plants were surprisingly of different kind.</div>
<div style="color: #6aa84f;">
Rahmat brought his vase and his failed-to-grow seed, putting it between all the full-grown plant. Everyone else was shocked, amazed of how dare of him to bring "failure" in front of their CEO.</div>
<div style="color: #6aa84f;">
Rahmat simply put his head face-down, afraid to even look straight. Not even when the CEO walked around the plants, inspecting each and every of them.</div>
<br />
Finally, the CEO catch sight of Rahmat's vase, then went to further inspecting the dormant seed in it. Then he looked at Rahmat, and after asked if it was his vase - after which Rahmat simply nodded - the CEO grabbed his shoulder and said loudly:<br />
<br />
<span style="font-size: large;"><b>"Congratulations. Let us all give applause to our next CEO."</b></span><br />
<br />
Everyone was shocked (again), stared at Rahmat and the great CEO who surprisingly shake his hand with a big smile, his eyes clearly reflecting great happiness, as if he is a parent seeing his long-lost boy for the first time.<br />
<br />
As soon as the CEO realized he was the only person clapping his hand in the room for the next 5 seconds, he explained the true purpose of the test:<br />
<br />
"<span style="color: #0b5394;">In case you didn't notice, from the very beginning I only gave you a </span><b style="color: #3d85c6;">dead seed</b><span style="color: #0b5394;">. A seed which I've been boiling in hot water, in a rate that I made sure the seed was already dead, not capable of growing into anything. No matter how much treatment you gave it, it will still be the dead seed, just like the one I gave you a year earlier. Just like this one.</span>", said the CEO while showing everyone Rahmat's now prized vase.<br />
<br />
"<span style="color: #0b5394;">And yet, you all brought to my face a full-grown plant. And worse - most is different then the rest. I'm pretty sure I gave you all one kind of seed, and unless you are God yourself, how in the world would you grow something from a dead seed?</span>", the CEO asked. Everyone else just face their head down, their eyes told the other one of their tricky plan: just buy a full-grown one and call it even. That explained the "biodiversity".<br />
<br />
"<span style="color: #0b5394;">So all of you tried to deceive me, maybe believing that I am not aware of the dead seed or maybe you just do that out of your impatience. But not this man, <b>Rahmat</b>. A man who held high his honesty and honor. A man from now on you will call, The CEO.</span>", the former CEO concluded his highly-effective recruitment plan.<br />
<br />
Moral of the story? Don't lie. At all costs.<br />
<br />
Based on the story at <u style="color: #6fa8dc;">http://www.kaskus.us/showthread.php?t=8417185</u><span style="color: #3d85c6;"><span style="color: black;"> with changes.</span></span>M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-3773886441542445692011-02-06T05:05:00.001-08:002013-05-06T06:49:27.197-07:00Curhat soal komputer ( atau lebih tepatnya laptop)Sial banget gw !<br />
<br />
Ceritanya gini:<br />
Kemarin kan gw pinjem laptop sekolah, maksudnya buat ada acara dari speedy gitu, jadi tuh laptop pertama gw dapet, ngeselin bener.<br />
Alhasil, dengan penuh keyakinan (dan kegoblokan) gw install ulang dah tu laptop.<br />
Pertama mau nginstall XP aja gitu khan, biar lebih humanis. Eh pas udah masuk ke Setupnya, si Setup jahannam itu bilang dengan tenangnya: "Setup cannot find any harddisk"<br />
<br />
<br />
<div style="text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-jp0_yTc1-bv3SFEhtwjcOA6tjhLiCtf2gZZnN9N4G9jgzCV0m0BzZhNBXtogZJcyEHMxhzB1F0V454EN6SFCY6UqnXGjuzZ_R_zJSGpBjiEWDNvJgDd6MKAa7lPcwPn_d9sxHK96Nh7q/s1600-h/aspire+4710.jpeg"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5285103459713607442" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-jp0_yTc1-bv3SFEhtwjcOA6tjhLiCtf2gZZnN9N4G9jgzCV0m0BzZhNBXtogZJcyEHMxhzB1F0V454EN6SFCY6UqnXGjuzZ_R_zJSGpBjiEWDNvJgDd6MKAa7lPcwPn_d9sxHK96Nh7q/s320/aspire+4710.jpeg" style="cursor: pointer; display: block; height: 128px; margin: 0px auto 10px; text-align: center; width: 158px;" /></a></div>
<div style="text-align: center;">
<span style="font-size: 85%;">Aspire 4710 : harddisknya diseret jadi tersangka ke pengadilan</span></div>
<br />
Pada saat itu yang dalam pikiran gw cuma pengen masukin tangan gw ke dalam monitor, cengkeram si Setup itu, tarik dia keluar trus jitak kepalanya sampai tewas. Tapi berhubung Setup itu cuma sebuah program komputer idiot berkecepatan tinggi ya gw cuma bisa ngelus dada doank.<br />
<br />
Akhirnya setelah menghabiskan 5 jam mengelus2 dada (nggak ding, cuma hiperbola) gw putuskan untuk mancing si harddisk. Gw coba format pake CD Ubuntu, abis ntu CD Ubuntu nya gw keluarin, masukin lagi XP. Eh si Setup idiot berkecepatan tinggi itu ngomong lagi dengan bahasa yang lebih halus: "Setup cannot find any harddisk".<br />
<br />
Wah gerem luar biasa gw. Akhirnya daripada gw kena poin kejahatan (menganiaya laptop sekolah) mendingan gw ngalah. Gw install Vista dan ternyata... berhasil dengan mulus !<br />
Bwahahaha... Untunglah Setup Vista agak sedikit lebih terdidik daripada Setup XP, bisa tau yang mana harddisk yang mana idung.<br />
<a name='more'></a><br />
<br />
Tetapi seperti kata orang silat, "di atas langit masih ada langit". Di atas masalah gw dengan Setup XP yang terbelakang itu, ada lagi masalah baru : gw gak punya driver Vista !!<br />
Alhasil gw langsung terbang ke salah satu warnet di daerah Sumber (anak Medan pasti tau).<br />
Di sini lah muncul niat jahat birokrasi : pas gw masuk ke <a href="http://www.blogger.com/support.acer-euro.com">support.acer-euro.com</a>, katanya "Access Denied : Administrator don't allow you to send this request for now".<br />
Dasar ***tiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiit*** , lo kira gw mau buka yang nggak-nggak ?<br />
<br />
<div style="text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_OdoYjMfymC_4ItnK4ABTDAFeURfusDYQDH2OU_kpD1k1YX49Ti7iiUAmNpj3QjNl_svghwHo7QYnlN5ctxdQx4xQUl8Xue8M0983H7a4xq_nvtyQ9L1sVZLqyQAHmw6bdICQJU4JgAEE/s1600-h/untitled.JPG"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5285103005281196626" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_OdoYjMfymC_4ItnK4ABTDAFeURfusDYQDH2OU_kpD1k1YX49Ti7iiUAmNpj3QjNl_svghwHo7QYnlN5ctxdQx4xQUl8Xue8M0983H7a4xq_nvtyQ9L1sVZLqyQAHmw6bdICQJU4JgAEE/s320/untitled.JPG" style="cursor: pointer; display: block; height: 133px; margin: 0px auto 10px; text-align: center; width: 320px;" /></a><br />
<span style="font-size: 85%;">Ini dia pesan kesalahan dari dunia lain itu<br />
</span></div>
<br />
Yah sekarang inilah gw : pusing, pening, rambut keriting (padahal botak gw)<br />
Bete-bete ah..M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-26435480923688445142011-02-06T04:59:00.001-08:002013-05-06T06:49:54.181-07:00Tips mempercepat PC andaBiasanya setelah menekan tombol "Power" pada PC, Anda akan memiliki cukup waktu untuk menyeduh secangkir kopi atau teh akibat lamanya waktu yang dibutuhkan oleh komputer Anda untuk <i>boot</i>. Apalagi jika PC Anda memiliki segudang aplikasi yang secara otomatis menyala, mungkin selain kopi, Anda bisa sekalian mandi dan membuat sarapan terlebih dahulu.<br />
<br />
Tanpa adanya peningkatan kinerja perangkat keras yang signifikan, memang tidak banyak yang bisa Anda lakukan untuk mempercepat <i>boot</i> Windows. Tetapi masih ada cara untuk mempercepat waktu yang dibutuhkan oleh <i>desktop</i> untuk mencapai kondisi "siap bekerja". Mari kita simak beberapa cara di bawah ini, baik yang menggunakan kemampuan yang memang sudah tersedia dan aplikasi dari luar.<br />
<br />
Ketika Anda menginstal aplikasi baru pada komputer Anda akhir-akhir ini, tidak sedikit yang langsung menjadikan dirinya sebuah program <i>startup</i>; entah untuk mengecek <i>upgrade</i> atau sekedar mengingatkan pengguna bahwa aplikasi tersebut telah di-instal sebagai ikon pada bagian kanan bawah PC seperti aplikasi <i>chat</i> seperti <a href="http://udaramaya.com/berita/3320/0/Skype_40_Beta_Dirilis_Fokus_ke_Video">Skype</a>.<br />
<br />
<br />
<center>
<img src="http://i191.photobucket.com/albums/z193/udaramaya/speed_up_startup_1.jpg" /><a name='more'></a></center>
<br />
Masalahnya muncul saat Anda menginstal banyak aplikasi yang jarang digunakan, tetapi mereka tetap muncul pada proses <i>startup</i>, hal ini sangat memakan siklus CPU, memori dan waktu. Cara mudah mengatasinya adalah hapus aplikasi-aplikasi yang memang tidak Anda gunakan. <br />
<h3>
Hapus Semua <i>Startup Item</i></h3>
Walau banyak program yang dapat membersihkan aplikasi <i>startup</i>, sebenarnya Anda bisa melakukan hal itu secara manual tanpa menggunakan aplikasi tambahan.<br />
<br />
Tempat terbaik, teraman dan paling mendasar untuk mulai melakukan hal ini adalah pada grup program "Startup" di "Start Menu" Windows. Navigasikan tetikus ke bagian "Startup" dan lihat program apa saja yang muncul. Klik kanan pada program yang tidak perlu aktif saat <i>startup</i> dan pilih "delete".<br />
<br />
<br />
<center>
<img class="right" src="http://i191.photobucket.com/albums/z193/udaramaya/speed_up_startup_2.jpg" /></center>
<br />
Setelah melakukan proses tersebut, tiba saatnya mengeluarkan jurus pamungkas. Windows juga bisa mengaktifkan program secara otomatis dari tempat lain. Klik Start Menu, pilih "Run" lalu ketik "msconfig" dan tekan [ENTER] untuk masuk ke dalam fungsi konfigurasi sistem Windows. Pindah kepada tab "Startup" untuk melihat daftar yang lebih komprehensif tentang apa saja yang menyala secara otomatis. Coba lihat tampilannya di bawah ini.<br />
<br />
<br />
<center>
<img src="http://i191.photobucket.com/albums/z193/udaramaya/speed_up_startup_3.jpg" /></center>
<br />
Daftar tersebut memang terlihat rumit dan membingungkan. Apa itu "ctfmon" atau "RTHDCPL"? Kolom "command" yang terkadang memuat lokasi aplikasi, terkadang juga bisa memberikan petunjuk tentang isi aplikasi tersebut. Seperti biasa, Google selalu menjadi sahabat Anda dalam situasi seperti ini.<br />
<br />
Dari sini Anda bisa menghilangkan tanda centang pada aplikasi yang tidak Anda inginkan untuk menyala pada proses <i>startup</i>. Jangan menghilangkan tanda centang pada aplikasi yang tidak Anda mengerti, mulailah pada aplikasi yang Anda tahu dan tidak digunakan. Sebagai contoh, Jika Anda bukan pengguna berat dari iTunes atau Quicktime, tapi aplikasi tersebut sebenarnya terinstalasikan pada PC untuk penggunaan kadang-kadang, Anda bisa menghilangkan tanda centang pada "QTTask" dan "iTunesHelper" dan kedua aplikasi ini tidak akan lagi muncul secara otomatis ketika Anda me-<i>restart</i> komputer.<br />
<br />
Anda bisa menyalakan kedua aplikasi tersebut kembali dengan mengunjungi "msconfig" dan lakukan prose di atas kembali. Menggunakan "msconfig" memang membutuhkan sedikit keberanian dan pengetahuan dari pengguna Windows. Tapi, masih ada cara lain untuk melakukan proses yang sama dengan menggunakan aplikasi pihak ketiga dan aplikasi-aplikas pembersih. <br />
<h3>
Unduh <a href="http://udaramaya.com/berita/3826/0/Daftar_Aplikasi_GratisOpen_Source_Terbaik_untuk_Optimisasi__Konfigurasi_Windows">Program Optimisasi Windows</a></h3>
Sebenarnya ada banyak aplikasi lain yang memiliki kemampuan untuk mengatur "startup", tapi mari kita lihat pada dua yang terbaik saja.<br />
<br />
<a href="http://www.ccleaner.com/">CCleaner</a> (yang merupakan singkatan dari "<i>Crap Cleaner</i>") bisa memeriksa sistem Anda untuk banyak hal yang berlebih dan menyingkirkannya. Klik tombol "Tools", kemudian tombol "Startup" untuk mencapainya. Seperti Anda lihat, aplikasi ini menawarkan informasi lebih banyak dari "msconfig" di atas dan bisa membantu memberikan penjelasan atas program yang ada. Anda bisa menonaktifkan dan menghapus segala hal dari <i>startup</i> menggunakan tombol-tombol tersebut.<br />
<br />
<br />
<center>
<img src="http://i191.photobucket.com/albums/z193/udaramaya/speed_up_startup_4.jpg" /></center>
<br />
Jika Anda tidak ingin menginstalasikan <i>software</i> lain untuk membersihkan sistem Anda, <a href="http://systemexplorer.mistergroup.org/">System Explorer</a> datang dalam versi <i>portable</i> dengan "startup manager" yang kaya fitur, lengkap dengan <i>registry</i>, pengecek virus <i>online</i> dan bahkan pencarian Google untuk nama file. Pada tab "system", klik tab "startup" untuk melihat apa yang menyala secara otomatis pada PC Anda. Barikut adalah tampilannya:<br />
<br />
<br />
<center>
<img src="http://i191.photobucket.com/albums/z193/udaramaya/speed_up_startup_5.jpg" /></center>
<br />
Seperti Anda lihat, hanya dengan klik-kanan, Anda bisa langsung menuju <i>registry editor</i> atau melakukan pencarian pada ProcessLibrary.com atau Google untuk sebuah aplikasi. Selain itu, perusahaan pembuat program dan <i>file path</i> juga dimasukkan, menawarkan lebih banyak informasi tentang sebuah aplikasi dan apa yang bisa Anda lakukan untuk mematikannya.<br />
<br />
Selain Ccleaner dan SystemExplorer, masih ada lagi alternati seperti MZ Ultimate Tweaker dan RegToy. <br />
<h3>
Tunda Proses Startup Aplikasi</h3>
Tentunya bukan hanya satu program saja yang mengakibatkan lambatnya <i>startup</i> PC Anda, melainkan merupakan hasil kumulatif dari semuanya. Anda bisa saja memeriksa daftar <i>startup</i> dan menyadari kalau Anda memang membutuhkan semuanya. Tetapi mungkin saja Anda tidak membutuhkan semuanya untuk dimulai pada saat yang bersamaan ketika Anda ingin mengecek email pada Outlook atau mengerjakan sebuah laporan buru-buru.<br />
<br />
Aplikasi <a href="http://www.r2.com.au/software.php?page=2&show=startdelay">Startup Delayer</a> bisa menunda proses "startup" aplikasi mulai dari 20 detik, beberapa menit, bahkan sampai ke satuan jam sehingga Anda bisa mulai bekerja sementara PC Anda memulai semua program <i>startup</i> secara bertahap. Apabila misalnya kita tidak membutuhkan proses <i>Java Updater</i> untuk dimulai setiap kali PC dinyalakan, kita dapat menunda <i>startup</i> program ini beberapa menit setelah PC dinyalakan.<br />
<br />
<br />
<center>
<img src="http://i191.photobucket.com/albums/z193/udaramaya/speed_up_startup_6.jpg" /></center>
<br />
<h3>
Jangan Percaya dengan Mitos</h3>
Banyak sekali mitos, kesalahan persepsi dan petunjuk tentang cara mempercepat proses <i>boot</i> PC yang beredar. Anda harus hati-hati dalam memilah-milah mana yang benar. Jika Anda mempelajari lebih dalam mengenai tips online untuk mengoptimalkan Windows, Anda akan menemukan cara tentang menghapus <i>paging gile</i>, membersihkan <i>registry</i>, mengatur untuk penggunaan <i>core</i> PC secara manual dan banyak lagi tips lainnya. Sebelum Anda melakukannya, coba dulu cek artikel yang sangat menarik tentang <a href="http://lifehacker.com/5033518/debunking-common-windows-performance-tweaking-myths">mitos optimisasi Windows Lifehacker</a>.<br />
<br />
Sumber :<span style="font-style: italic;"> </span><cite>udaramaya.com/berita/4777/0/Panduan_Lengkap_untuk_Mempercepat_<wbr></wbr>Startup_PC_Anda</cite>M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-6754579525728130582011-02-06T04:57:00.000-08:002011-02-06T05:09:05.590-08:00Beberapa ciri-ciri komputer Windows yang terserang virusBerikut salah satu ciri-ciri Komputer Yang Terjangkit Virus (khusus Windows):<br />
<br />
1. Komputer Anda berjalan lebih lambat dari biasanya.<br />
2. Menu Run, Search disembunyikan oleh virus.<br />
3. CTRL+ALT+DEL tidak bisa digunakan.<br />
4. Regedit dan MSCONFIG di disabled<br />
5. Folder asli pada komputer anda disembunyikan dan diganti dengan file virus.<br />
6. Menu Folder Options di Windows Explorer hilang.<br />
7. Komputer sering berhenti atau tidak merespon.<br />
8. Komputer tiba-tiba restart atau crash dan ini terjadi beberapa menit sekali.<br />
9. Aplikasi komputer tidak berjalan dengan semestinya dan sering error.<br />
10. Muncul File dengan Icon Folder tetapi mempunyai file type .exe<br />
11. Hardisk atau disk drive tidak bisa diakses.<br />
12. Aktivitas print tidak bekerja dengan semestinya.<br />
13. Sering terjadi pesan error yang aneh dan tidak biasanya.<br />
14. Sering terlihat menu atau dialog box yang rusak.<br />
15. Terdapat Duplikasi nama folder di dalam folder tersebut.<br />
16. Komputer selalu mengeluarkan pesan dari mana virus ini berasal.<br />
<br />
Jika komputer anda mengalami salah satu ciri-ciri diatas, berarti ada kemungkinan komputer anda terkena virus, segera update antivirus anda dan scan komputer anda<br />
untuk membersihkan virus tersebut.<br />
<br />
Sumber : http://finderonly.com/2008/12/02/ciri-ciri-komputer-yang-terjangkit-virus/M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-49230302884064035432011-02-06T04:55:00.000-08:002011-02-06T05:10:01.548-08:00Aplikasi rahasia yang disembunyikan dalam Windows XPUntuk menjalankan Aplikasi-aplikasi di bawah ini :<br />
Buka command prompt dan Ketikkan nama programnya (contoh :cleanmgr.exe) atau klik Start -> Run dan Ketikkan nama programnya (contoh :cleanmgr.exe).<br />
<br />
1. Disk Cleanup = <b>cleanmgr.exe</b><br />
Digunakan untuk cleanup disk<br />
<br />
2. Character Map = <b>charmap.exe</b><br />
Digunakan untuk mencari karakter yang tidak umum<br />
<br />
3. Dr Watson = <b>drwtsn32.exe</b><br />
Digunakan untuk troubleshooting (debugging) di PC.<br />
<br />
4. DirectX Diagnostic Tool = <b>dxdiag.exe</b><br />
Digunakan untuk diagnosis perangkat multimedia anda<br />
<br />
5. Private Character Editor = <b>eudcedit.exe</b><br />
Digunakan untuk membuat karakter baru di windows anda<br />
<br />
6. IExpress Wizard = <b>iexpress.exe</b><br />
Digunakan untuk membuat self-extracting / self-installing package. seperti file Zip<br />
<br />
7. Microsoft Synchronization Manager = <b>mobsync.exe</b><br />
Digunakan untuk membuat sincronisasi.<br />
<br />
8. Clipboard Viewer = <b>clipbrd.exe</b><br />
Digunakan untuk melihat konten dari Windows clipboard<br />
<br />
9. Windows Media Player 5.1 = <b>mplay32.exe</b><br />
Digunakan untuk membuka Windows Media Player versi 5.1<br />
<br />
10. ODBC Data Source Administrator = <b>odbcad32.exe</b><br />
Digunakan untuk keperluan database<br />
<br />
11. Object Packager = <b>packager.exe</b><br />
Digunakan untuk memasukkan objek kedalam file.<br />
<br />
12. System Configuration Editor = <b>sysedit.exe</b><br />
Digunakan untuk mengubah system.ini dan win.ini<br />
<br />
13. Syskey = <b>syskey.exe</b><br />
Digunakan untuk konfigurasi account di windows.<br />
<br />
14. Microsoft Telnet Client = <b>telnet.exe</b><br />
Digunakan untuk melakukan koneksi internet sebelum ada browser.<br />
<br />
15. Driver Verifier Manager = <b>verifier.exe</b><br />
Digunakan untuk monitoring driver di windows anda<br />
<br />
16. Windows for Workgroups Chat = <b>winchat.exe</b><br />
Digunakan untuk chatdalam workgroup<br />
<br />
17. System Configuration Utility = <b>msconfig.exe</b><br />
Digunakan untuk mengontrol program startup<br />
<br />
18. System Monitor = <b>perfmon.exe</b><br />
Digunakan untuk memonitor PC anda.<br />
<br />
19. Program Manager = <b>progman.exe</b><br />
Merupakan warisan dari Windows 3.x desktop shell<br />
<br />
20. Group Policy Editor = <b>gpedit.msc</b><br />
Digunakan untuk mengatur group policy dan otorisasi, apabila Anda menggunakan Active Directory.<br />
<br />
21. Remote Access Phone Book = <b>rasphone.exe</b><br />
Merupakan aplikasi seperti buku telepon<br />
<br />
22. Registry Editor = <b>regedt32.exe</b> [juga <b>regedit.exe</b>]<br />
Digunakan untuk tweaking dan editing registry windows<br />
<br />
23. Network shared folder wizard = <b>shrpubw.exe</b><br />
Digunakan untuk membuat shared folder dalam jaringan<br />
<br />
24. File siganture verification tool = <b>sigverif.exe</b><br />
Digunakan untuk verifikasi signature<br />
<br />
25. Volume Control = <b>sndvol32.exe</b><br />
Digunakan untuk menampilkan sound control di System TrayM. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0tag:blogger.com,1999:blog-2498508913536095979.post-47125198895975291232011-02-06T04:49:00.000-08:002011-02-06T04:49:39.289-08:00The OpeningSelamat datang di blog milik M. Fariz Akbar.<br />
This is my first post on my first blog (actually it's the second but the first one is not really a blog), so if there's anything that doesn't look like a blog, well pardon me :D<br />
<br />
Anyway, enjoy my first blog.<br />
Be it meaningful or useless, it's your call.M. Fariz Akbarhttp://www.blogger.com/profile/17481699107996264165noreply@blogger.com0