Featured Posts

<< >>

MySQL common commands

Some mySQL commands you want to keep under you hand. Connecting to a mySQL server: mysql -h host_address -u user -p Viewing all the databases: show databases; Select a database to use: use mydatabase; show db tables (db must be selected): show tables; describe the table content: describe new_table; Selecting all the users in the [...]

Remove the “proudly powered by wordpress” footer

watch here: In this tutorial I used the Notepad++ application, that can be found here.

Removing default window nib in a window based application

When creating a window based application in Xcode4, it usually create an unwanted nib file that represents the default clear white window. Note: your class names will probably be different then mine, try to keep up, it not that hard. Some times we want to remove it and replace it with are own view controller, [...]

Serial port reader

This is a simple Serial reader. You can select the port and start listening on it. Most useful for RFID readers. Download here.

Auto login for windows

Auto login is a small utility I wrote to enable users to automatically login to there winXP machine. The current user need only to enter his password, and that’s all. Note:this was not tested on Win7. Download.  

Enabling the notification panel in unity

The problem? Unity does not show the notification panel. This is a big issue, since some applications reside only there,and without this applet, we can’t call them back after starting them, close them or configure them (yes, we can kill them, but this is something else). we are going to use the command for this [...]

Disabling menu integration in Ubuntu 11.10

If you want to have unity on, but you want to have the menu for each window independent, you need to remove the indicator-appmenu package: sudo apt-get remove indicator-appmenu This will leave unity on, while enabling regular window menu. If you want to set it per application, please visit here.

Who is locking my folder

Sometimes, you need to change or remove a folder. but what to do when you get this pesky message saying that the folder “was being used by another process”? well, if Windows complains, it is usually right. more then that, it is usually NOT the antivirus. If you suspect it is, here is how to [...]

Closing Android socket

Assume we have a Socket that is connected to a server. Usually, we will use a secondary thread to read from the socket in a blocking connection. If the user want to terminate the connection, in Java, we can call socket.close(). But not in Android (well, we can, but it will do nothing). While the [...]

MySQL common commands

Some mySQL commands you want to keep under you hand.

Connecting to a mySQL server:
mysql -h host_address -u user -p

Viewing all the databases:
show databases;

Select a database to use:
use mydatabase;

show db tables (db must be selected):
show tables;

describe the table content:
describe new_table;

Selecting all the users in the system:

select host, user, password from mysql.user;

Creating a user:
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';

where you can omit theIDENTIFIED BY if password is not required (but it usually is).

Deleting a user:
DROP USER user;

Assigning a password:

UPDATE mysql.user SET Password=PASSWORD('newpass')
  WHERE User='bob' AND Host='%.loc.gov';
FLUSH PRIVILEGES;

or

GRANT USAGE ON *.* TO 'bob'@'%.loc.gov' IDENTIFIED BY 'newpass';

grant privileges:
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
where you can replace ALL PRIVILEGES with any privilege that you like.

Revoking privileges:

revoke all privileges  on databasename.* from user;
again, you can replace ALL PRIVILEGES with any privilege that you like.

Show user privileges:

show grants for 'user'@'host';

Remove the “proudly powered by wordpress” footer

watch here:

In this tutorial I used the Notepad++ application, that can be found here.

Removing default window nib in a window based application

When creating a window based application in Xcode4, it usually create an unwanted nib file that represents the default clear white window.

Note: your class names will probably be different then mine, try to keep up, it not that hard.

Some times we want to remove it and replace it with are own view controller, here is how:

  1. delete the default MainWindow.nib. You can totally delete it, assuming you have no information in it.
  2. Click on the project (above the files – blue strip) and select the target. on the right, go to info, locate the “main nib file base name” line and remove it entirely. You can run your application now with no errors (and no output…).
  3. I assume that you have created a view controller. if not create it now. Go to your app delegate file header and import the header for your master view.
  4. declare a property for that controller and synthesize it on the m file.
  5. now we need to create the default window: self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; add this to the application didFinishLaunchingWithOptions function. BTW – the reason that we didn’t get an exception so far is because once the main nib is deleted, the entire application function will not be called.
  6. next, create the nib file: mainController=[[SwitchViewController alloc]initWithNibName:@”MainView” bundle:nil];
  7. then, assign the master controller to the window: [self.window setRootViewController:mainController];
  8. Now, the application is not even aware at this point of its delegate. This is bacause we delete the main nib file, so changes must also be done to the main.m file, hiding sometimes in the supporting files folder. this is actually very simple – just feed the UIApplicationMain function the delegate it deserves! So, instead of the default UIApplicationMain(argc, argv, nil, nil); replace the last nil with your class delegate name, like so: UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

Who it’s working

NSStringFromClass gives a string… from the class. which is what this function requires, in case there is no nib file that loads that data for us.

 

Serial port reader

This is a simple Serial reader. You can select the port and start listening on it.

Most useful for RFID readers.

Download here.

Auto login for windows

Auto login is a small utility I wrote to enable users to automatically login to there winXP machine. The current user need only to enter his password, and that’s all.

Note:this was not tested on Win7.

Download.

 

Enabling the notification panel in unity

The problem? Unity does not show the notification panel. This is a big issue, since some applications reside only there,and without this applet, we can’t call them back after starting them, close them or configure them (yes, we can kill them, but this is something else).

we are going to use the command for this – there is an options for GUI, but it’s simpler.

just under the terminal, using your own username (no need for sudo or root) use this command:

gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"

Now, you might see the “all” part. This does mean that you can select only certain applications to go there, if you want them.

Disabling menu integration in Ubuntu 11.10

If you want to have unity on, but you want to have the menu for each window independent, you need to remove the indicator-appmenu package:

sudo apt-get remove indicator-appmenu

This will leave unity on, while enabling regular window menu.
If you want to set it per application, please visit here.

Who is locking my folder

Sometimes, you need to change or remove a folder. but what to do when you get this pesky message saying that the folder “was being used by another process”?

well, if Windows complains, it is usually right. more then that, it is usually NOT the antivirus. If you suspect it is, here is how to disable most antivirus programs.

So, to get to the process that blocking you from moving the file, you need some help. my best solution for this is the Process Explorer. This is a great tool. now to fine the offending process, you just click find and insert the name of the folder. you will get the process ID and name of the process that blocks it. You can even kill (terminate) the problematic process.

Now, make sure you do not need any data contains in this process, because once you killed it… well, it’s dead, and the data can not be rescued.

Closing Android socket

Assume we have a Socket that is connected to a server. Usually, we will use a secondary thread to read from the socket in a blocking connection.

If the user want to terminate the connection, in Java, we can call socket.close(). But not in Android (well, we can, but it will do nothing). While the thread is still alive and waiting, close() will not be executed and the connection will remain active. So, what can be done?

One way is to terminate the thread. This is obviously not a very good way, and denied the thread from executing its final code correctly.

The second and the right one, is simply to call Socket.shutdownInput() method. This will create a disconnection for the waiting thread, the thread will die according to plan and your application will run just fine!

Main differences between Android and iOS development

If you want to develop, or hire a developer(ahhhm…) to develop mobile application, these are the two big choices. Other options are: Nokia Symbian, Windows mobile, the RIM blackberry and some other platform that are not used by the major public.

For the sake of this document, I’ll focus only on the first two, which are the dominant ones at the moment. I will go point by point, specifying the differences between these two.

Why developing an application?

Before reading more, do you even need an application? If what you want can be achieve with a web site, you might want to stick to that, and wave the application. If what you need is an information page, web page will do the trick, however, there are many reasons to build a custom application:

  1. Information control – if you have a lot of information on a site (Facebook, anyone?) most devices will have a hard time rendering heavy web content.
  2. Usefulness. if you want to use the phone additional capabilities.
  3. Speed – apps will run faster and performs better.
  4. User access -the user will access application more – that’s obvious.
  5. Special GUI features – This is one of the main reasons to have an app – you want to enable the users to interact in an easy, fun, and fast way.
  6. Real world applications that can not be done on a web page, and there are many examples of this – server controllers, diet calculators, camera viewers, security monitors and so on.
  7. Marketing value – it looks  much more professional to have your client downloads your application and have your icon on there desktop. many banks and internet provider do just that, even they can saddle for a web page. The application gives a certain “extra” touch.

If you answered yes to one of the above, you need an application.

 

Market

Both iOS and Android have an open market where the users can select and install programs, either free or paid for. In both cases you must register in order to publish your application to the public. In both cases payed application will require extra setup. Company account will take longer to set up, in both. However, apple  setup usually takes longer, in both scenarios. You can have an already registered developer post your application for you (especially if this is a free one) however, it will appear under his account.

Development

iPhone uses Objective C which is horrible (sorry, but it is true), crippled language, that in spite of what some people say is not really object oriented. Why did Apple still using it is beyond me. Apple uses Xcode as development IDE, and, apple development can be done only on Apple computers (if not considering some third party tools). Apple have only one product, iPhone and if the iOS version is right, the application will run – as long as the iOS installed is higher or equal to the application.

The Android on the other hand, uses Java which is 100% object oriented, uses eclipse as the IDE, that can be installed on any Major OS – Windows, Linux and Mac (yes, even Mac). However, Java is Java, and it does not output machine code, so it might take a longer to load since it does need re-compiling. The Java platform was selected in order to support a wide range of phones, and it does.

giving these differences, Apple application might be more expensive to develop.

Permissions

Both OS limit the permissions a developer can have, But in a very, very different way. on Apple, the iOS will enable you to access the internet, create a local private DB and files, get the GPS location (the user have to approve this) access to the contact list (user have to approve this), send (but not receive) a text message and thats about all. If you see application that can do more, it is running on a jail broken device, in which you can do whatever you want, but we are not referring to these. for most applications these limitation are OK, and they can execute well. on Android, you have to define permissions when writing the application. The user will see them when he or she installs the application and can decide then if he wants to install it or not. If the developer didn’t ask for a certain permission – he won’t be getting it later on. In Android, developer have to ask for permission to do almost anything, including accessing the internet. However, he can also get access to GPS data (same as iPhone) SMS data (not applicable on iPhone) Calls data (not applicable on iPhone), can start services at boot time (not applicable on iPhone) and change many system aspects (not applicable on iPhone). The beauty of it all – the user view all of these permissions at install time. if he doesn’t approve, he can wave installing this application. If he choose to install it, he agree to give that application the permissions it asked for, and he will not be bothered with them later on.

Deployment

To deploy an apple iOS application, you must have an apple ID. You must code sign your application with apple and post it to the app store (there are some cases that you can distribute them yourself, but only for a small user group). In Android, you can send your application by mail, have it on a web site (many vendors do) without any contact with Google. to publish to Google market, you do need to have an account. The signing process however, is much simpler, as the signing up process.

Ratification

On Apple, every application submitted to the app store is going through a ratification process, in which the application is reviewed be apple. The amount of time taking to do that varies, and only after the application was approved it will go to the store. This process is done for every application, and will be done repeatably for every update this application may have. On Android, the application will be submitted automatically. if the users won’t like it, they will just remove it…