Archive for February, 2012

When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed. You can avoid this using several methods — executing the job with nohup, or making it as batch job using at, batch or cron command.

This quick tip is for beginners. If you’ve been using nohup for a while, leave us a comment and tell us under what situations you use nohup.

In this quick tip, let us review how to make your process running even after you logout, using nohup.

Nohup stands for no hang up, which can be executed as shown below.

nohup syntax:

# nohup command-with-options &

Nohup is very helpful when you have to execute a shell-script or command that take a long time to finish. In that case, you don’t want to be connected to the shell and waiting for the command to complete. Instead, execute it with nohup, exit the shell and continue with your other work.

To View ~/Library in Lion

Posted: February 20, 2012 in iOS

If you’re the kind of user who rarely visits ~/Library, but you’d like to be able to open it if the need arises, these methods are for you.


You can use the Go menu’s Go To Folder command for occasional access to ~/Library.

Use Go To Folder The Go To Folder command, in the Finder’s Go menu (also accessible by pressing Shift+Command+G), has long been a quick way to access invisible folders such as /Volumes and /usr; it’s now useful for accessing your Library folder, as well. Just type ~/Libraryand click Go to view the folder in the current Finder window.

(more…)

To Enable Finder ShowAllFile in Lion

Posted: February 20, 2012 in iOS

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Many iOS apps use HTTP to communicate to a web server, because it’s easy, convenient, and well-supported.

However, in some cases you might find the need to go a bit lower level than HTTP, and communicate using TCP sockets to your own custom server.

The advantages of doing this are several:

  • You can send just the exact data you need to send – making your protocol lean and efficient.
  • You can send connected clients data whenever you want, rather than requiring the clients to poll.
  • You can write socket servers without a dependency of a web server, and can write in the language of your choice.
  • Sometimes you just have to use sockets, if you are connecting to a legacy server!

In this tutorial, you’ll get some hands-on experience writing an iPhone app that communicates to a TCP socket server using NSStream/CFStream. Also, you’ll write a simple socket server for it to connect to, using Python!

The iPhone app and chat server will implement chat functionality, so you can chat between multiple devices in real-time!

This tutorial assumes you have a basic familiarity with Python and iOS programming. If you are new to Python programming, check out the official Python tutorial. If you are new to iOS programming, check out some of the iOS tutorials on this site first.

Without further ado, let’s do some socket programming!
(more…)

Before you do any work with the external storage, you should always call getExternalStorageState() to check whether the media is available. The media might be mounted to a computer, missing, read-only, or in some other state. For example, here’s how you can check the availability:

boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
    // We can read and write the media
    mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
    // We can only read the media
    mExternalStorageAvailable = true;
    mExternalStorageWriteable = false;
} else {
    // Something else is wrong. It may be one of many other states, but all we need
    //  to know is we can neither read nor write
    mExternalStorageAvailable = mExternalStorageWriteable = false;
}

This example checks whether the external storage is available to read and write. The getExternalStorageState() method returns other states that you might want to check, such as whether the media is being shared (connected to a computer), is missing entirely, has been removed badly, etc. You can use these to notify the user with more information when your application needs to access the media.

Sometimes, it is easier load a image from other directory (sdcard, for example) than load a image from drawable because for this last case, the image should be stored in the directory res/drawable first and packaged along with the apk files.

To load a image from a directory, it should be converted to the drawable first. Here comes a piece of code which can help:

File file = new File (“/sdcard/1.jpg”);
ImageView imageView = (ImageView) findViewById(R.id.icon);
imageView.setImageDrawable(Drawable.createFromPath(file.getAbsolutePath()));

(more…)

Smart Measure Android App

Posted: February 7, 2012 in Android Dev
Smart measure – มาใช้แอพวัดความสูงกัน

ก่อนอื่นเลยต้องบอกว่า แอพนี้น่าจะเหมาะกับคนที่ต้องการใช้อุปกรณ์ในการประเมินความสูงในงานต่างๆ เพราะว่าถ้าคนทั่วๆไปคงไม่ค่อยได้ใช้แน่นอนครับ แต่ที่เอามาเขียนรีวิวให้อ่านกันนั้น แค่ต้องการให้ทราบถึงเทคโนโลยีในตอนนี้ว่ามันสามารถทำได้นะครับ วันนี้ผมจะมาแนะนำแอพที่ใช้วัดความสูง มีชื่อว่า Smart Measure

Smart measure เป็นการพัฒนาแอพเพื่อการใช้งานทางด้านการวัดค่าต่างๆของกลุ่มนักพัฒนาชื่อว่า Smart tools Co.,Ltd. ไม่ว่าจะเป็นการวัดค่าความสูง, ความกว้าง, วัดระยะทาง หรือแม้แต่กระทั่งพื้นที่ โดยการคำนวนผ่านทาง Image processing ผ่านกล้องในมือถือหรืออุปกรณ์เราอีกที

คุณสามารถดาวน์โหลดแอพนี้ได้จาก Android Market ตามลิงก์ด้านล่างนี้เลยครับ

[เวอร์ชั่นฟรี] : https://market.android.com/detai … ature=search_result

[เวอร์ชั่น Pro] : https://market.android.com/detai … ature=search_result

ผมแนะนำให้ลองใช้งานตัวฟรีก่อนนะครับ ถ้าใช้งาน OK แล้ว ค่อยดาวน์โหลดตัวโปรมาใช้งานนะครับ คิดว่ามีลูกเล่นเพิ่มอีกมาก
(more…)

This article describes the file naming conventions for the Slippy Map application.

  • Tiles are 256 × 256 pixel PNG files
  • Each zoom level is a directory, each column is a subdirectory, and each tile in that column is a file
  • Filename(url) format is /zoom/x/y.png

The slippy map expects tiles to be served up at URLs following this scheme, so all tile server URLs look pretty similar.

Contents

[hide]

(more…)

Java Math Quick Reference

Posted: February 2, 2012 in Java Dev
  • contains static constants E and PI
E:    2.718281828459045
PI:   3.141592653589793
  • contains methods for common mathematical operations ie abs, sin, exp, round, etc.
  • all methods are static
  • the Math class cannot be instantiated
  • methods involving angles use radians vs degrees and minutes
  • all methods, except round(), return a double
  • all methods take at least one double as an argument, except random which takes no arguments
  • the following methods are overloaded to return and handle int, long and float
    • static type abs(type a)
    • static type max(type a, type b)
    • static type min(type a, type b)

(more…)

Google Mapping and Conversion

Posted: February 2, 2012 in Android Dev

Disclaimer: This is for informational purposes only. Google owns the map tiles. So don’t try to profit from them. Besides, Google might (and probably will) change their algorithms some day.

This page describes how to harness the beautiful map data provided publicly on google maps. These C# routines were created by analyzing Google’s own obfuscated javascript libraries.

Google maps tiles are stored simply by X,Y coordinates, together with a zoom level. Zoom levels range from 17 (most area) to 0 (most detailed). As of now, the tiles are each 256×256 pixels. Each successive zoom level has 4 times as many map tiles (2x in the X direction, and 2x in the Y direction) as the previous level. The number of map tiles for each zoom level are given by this simple formula:

x = 0 to 2^(17-zoom)
y = 0 to 2^(17-zoom)

Of course, the number of pixels is 256 times this number, since the tiles are each 256 pixels to a side.
(more…)