You are currently browsing the category archive for the 'Uncategorized' category.
“Be of love (a little) more careful than of anything.” [E.E.Cummings]
and i’d say a lot.. not little..
we’ll give you your last antibiotic drip at 4.30, and then you can go home. will there be anybody picking you up?
no
no
so you will be going home alone?
yes
hehe, d’oh
——————
okay, once this is finished, we’ll discharge you. is there anybody coming to pick you up?
no
why do these people keep on asking the same question?
…
…
what’s with the face?
…
…
what?
…
…
oh, come on.. *skim*skim* ..certificate.. *skim*skim* ..bla bla.. *skim*skim* ..march 2008! See, you’ve worked for more than a year here, you must’ve seen LOTS of people going home from the hospital by themselves rite?
——————
okay we’ll discharge you now. this is the summary of your treatment, this is your prescription, and this is your mc. is there anybody outside picking you up?
no
gosh, what is the matter with all of these people? i don’t need anybody picking me up, i’m perfectly fine, see, i can get up by myself..oooww..my head.. gosh, it must be because i was sleeping all the time.. it’ll go away in no time.. now, if you’ll excuse me, i’ll get my bag and..what..the..hell..is inside this bag??aww my back..shoot,i know i should’ve taken those painkillers.. anyways.. see you later..
——————
hi, you’ve signed the medicare right? so there’s no need for any payment right now.
okay thanks
okay thanks
…
…
yes?
are you going by yourself?
yes
what is the matterr??? i mean, it’s not like i don’t have anyone, as a matter of fact, I told my family and friends not to come. besides, this is singapore, it’s like, hello? people are faaaarr too busy to take care of others, except of course for that auntie in the front bed who seemed to have visitors all the time, and that grandma in bed 10, but he’s a grandma, surely people will come, she might as well be dead anytime soon (*knock2 on wood), and this girl in bed 5, but that’s her boyfriend i supposed, so it’s only natural that he came.. so, there! see, there is this uncle in bed 6, and..and..and i’m sure there are a lot more in the other row, like bed 1 or bed 2..i think i saw some patients there..i think..
are you sure you’re okay to go alone?
yes, of course
shut up
okay then, have a good rest.
thanks
whatever
——————
gosh i hate hospital
i miss u
“you know that i could use somebody,
you know that i could use somebody,
someone like you,
and all you know,
and how you speak“
[kings of leon]
June wiki..not late this time, just written in the very last minutes :p ..enjoy.. ;*
For some applications, it might be important to ensure that only one instance of that application can run at one time in a particular machine. The example is an application that during it’s running time modifies a stored data, whether it’s in the registry or database. Several instances of this application running at the same time might result in data corruption.
There are some known method to achieve such behavior, some are generic and some other are language specific. In this article, several methods will be discussed.
Creating a lock file with process id
During it’s initialization, an application were to create a file. If the file is not exist, that means there aren’t any other instances of this application which are already running. Just before the application closes, it should delete the file in order to allow the application to run again later. Inside the file, the application should write the it’s process id. This process id is important to avoid trouble if the application crashes and does not exit normally. In such case, the application might not delete the file before it closes. Next time the application is run, it will notice that the lock file still exists, thus assuming that there’s another instance of the application already running. This will prevent the application to run again forever, except if the file is deleted manually. With the existence of the process id, when the application tries to run and notice that the lock file exists, it can check for the process id and see whether that particular process id is still up and running. If it does, the application exit, otherwise, the application would modify the file to contain the new process id.
Creating a file, reading the content, writing, and deleting it should not be a problem. However, most of us might not be to familiar to read a process id of an application, thus it might require a little exploration.
Creating a lock file and open the file
This method is probably a little simpler compared to the previous one. This does not include detecting process id of the application. You will only need to create, delete, open a stream, and close a document. The idea is the application keeps the stream of the file open during its lifetime, to avoid other instance from deleting it. When another instance starts, it will search for the lock file and tries to delete it. Since the file is open, the instance will not be able to delete it, and it will know that another instance is already running, hence exit. When the application crashes, the open stream from the file will automatically be closed, thus the next instance will be able to run.
Creating a lock file and lock the file
In Java, you can specifically lock a file and release it when you’re done. This lock will automatically released if your application exits, even when it’s due to crash. Here’s the example of locking and releasing the lock of a file using Java:
try {
File file = new File("filename");
FileChannel channel = new RandomAccessFile(file, "rw").getChannel();
FileLock lock = channel.lock();
lock = channel.tryLock();
lock.release();
channel.close();
} catch (Exception e) {
//do nothing
}
Creating a port listener
In all of the previous methods, when an instance cannot run because another instance is already running, the instance can exit. Another modification to that is probable is the instance can show a message box notifying user that another instance of the application is already running. To even make it better, you might want to open and bring forward the window of the already running instance. If you want to do this, then probably this method is a good choice. The idea of this method is to make your application listens to a particular port. When you try to listen to a port that has already been listened to, then you will receive an exception. This means, another instance is already running. Then, to make the already running application open its windows, bring the windows to focus, or whatever you would like it to do, you send messages through the port. Just make sure that when you implement the listener, you implement them to react accordingly to the message they receive from the port. This method, despite of its attractiveness to allow you to send message to the already running instance, also have a drawback. Even though we can specify the application to listen to a rarely used port, there still be chances that another application is using the exactly same port, which will prevent out application to ever run.
Use port listener and lock file
Another method you can use is combining the port listener and a lock file. The application should first check whether the lock file exists, if it’s doesn’t exist, the application will try to search for an open port, create the lock file, write the port number in the lock file and listens to the port. On termination of the application, the application should then release the listener and deletes the file. Another instance of the application will check the existence of the lock file. Once it found the lock file, it tries to listen to the port number written in the file. If it succeeded, it means the previous instance might terminates abnormally, but is not running anymore, thus it can run. Otherwise, it means the previous instance is still running and thus the new instance should exit.
Other methods
Other than these methods, you might also be able to fine methods, including the language specific ones, here are some examples:
- For .NET
Ahaha, tiba-tiba postingannya gini.. Jadi, di kantor sebulan sekali gw harus menulis di wiki lokal sana. Karena menulis buat gw merupakan suatu hal yang tidak terjadi secara alamiah sehingga menghabiskan waktu dan tenaga, sayang dong kalo adanya di wiki lokal aja. Jadi di tulis disini juga. Selain itu, sekarang gw uda telat blm nulis, bsk senin ga ke kantor, jadi ditulis disini supaya asisten saya saudari miri bisa memasukannya ke wiki, bukankah begitu mir?hihihi.. becanda mir..makasi yaaaa.. salam buat live update..kasitau kalo ito marah2 karena gabisa baca kode gw yg brantakan..hii, deg2an.. Baiklah, enuff chit chat, mari kita mulai tulisan cupu sok2 technicalnya:
To develop a desktop application that requires an internet connection, we might need to create a connection using proxy. Though in some cases we can ask user to provide the proxy setting that we need to use, in many other cases, the user themselves might not know the proxy setting that they are using. In such cases, detecting the proxy setting automatically might just be the answer. In this article, we will discuss on how to detect the proxy setting in Windows.
Proxy settings in windows
To know what the available proxy settings in Windows are, we can see the settings in the Internet Explorer. There are several options available:
1. Automatically detect settings.
2. Use automatic configuration script.
3. Use a proxy server for your LAN (manual configuration).

Where the information are stored
Information about this setting can be retrieved in the registry.
The registry key you should be looking for are available in the following location:
HKEY_CURRENT_USER>Software>Microsoft>Windows>CurrentVersion>Internet Settings
How to determine the setting
Different proxy settings will create different keys or different values in the registry as follows:
ProxyEnable:this key can be set to 0 or 1. The value 1 specifies that the manual configuration is used.ProxyServer:if we specify manual configuration, the Address and Port of the proxy server is specified in this key with the format of<server address>:<server port>(i.e. “127.0.0.0:8080″)ProxyOverride:for manual proxy settings, sometimes some local addresses will require you to bypass the proxy in order to be able to establish the connection. This key specifies which addresses are suppose to be bypassed. Different addresses are separated with a semicolon.AutoConfigURL:when we specify to use an automatic configuration file for the proxy, the address to the automatic configuration file is available as a value in this key. The configuration file is a Proxy Auto Configuration (.pac) file. This file contains javascript functiona which will determine which proxy to use to connect to a particular server address.
Implementation tips
- Reading Registry. To implement automatic detection of proxy setting in Windows, first, we need to be able to read the registry. For Java, we can use library such as the jRegistryKey to read and write to the registry.
- Using .pac file. As a .pac file contains javascripts, it is most likely that we will not be able to use the file directly except if we create our on interpreter for javascript. However, a library is already available to parse such file, such as the pacparser. This library is a C library which allows you to retrieve the proxy that you should use to connect to a particular server address according to the .pac file.







Recent Comments