Featured Post

ListView with Sections/Separators

Edit: ListView tutorial part 2 is about clickable widgets in ListView items Take a look! If you’ve ever used ListView, and i bet you had, then you will have noticed that it is not very handy if you want to display a huge amount of data. I found a few...

Read More

Execute MySQL from Sublime Text 2

Posted by Bartinger | Posted in Tutorials | Posted on 17-05-2013

Tags: , ,

1

Oh dear, it has been over a year since my last post. I shouldn’t be so lazy. Enough said, lets blow the dust of this blog and start being more productive again.

If you want to execute a sql file directly from Sublime Text 2 and want to see the result (or the error) in the console you need to create a build system. This is easily done with Tools > Build System > New Build System… Then paste this JSON:


{
 "cmd": ["/opt/lampp/bin/mysql", "-u", "root", "-e", "source $file", "-t"],
 "selector": "source.sql"
}

A little bit of explanation. I’m using lampp (XAMPP for Linux), so the command is the path to my mysql binary. If you have a symbolic link or your mysql installation is somewhere else just replace it. The -u attribute stands for the user which is in my case root. I haven’t set a password  and a host because I’m running this on my local machine. You can add a password with -p and a host with -h. The -e stands for execute, source that the statement comes from a file and $file is a Sublime variable which will be replaced with the current file you’re editing. Last but not least the -t option formats the output of a select in a beautifully designed table. You can add -D <db_name> to automatically select a database, however I prefer the USE <db_name> at the beginning of the sql file. The selector is used when you set your build system to automatic to find the correct build system for your file.

Now save it, open a sql file or create a new one. With Ctrl + B you execute the build command and the output should be printed into the console. (View > Show Console)

Example:


USE awesomedb;
SELECT * FROM users;

Output:


+----+-------------------+----------------------------------+--------+
| id | email             | password                         | active |
+----+-------------------+----------------------------------+--------+
| 28 | user1@email.com   | 5f4dcc3b5aa765d61d8327deb882cf99 |      1 |
| 29 | user2@example.com | 5f4dcc3b5aa765d61d8327deb882cf99 |      1 |
| 45 | user3@random.com  |                                  |      0 |
+----+-------------------+----------------------------------+--------+

Source:

http://seant23.wordpress.com/2011/09/03/sublime-text-2-execute-mysql-query/

http://dev.mysql.com/doc/refman/5.5/en/mysql-command-options.html

http://sublimetext.info/docs/en/reference/build_systems.html

The Blackberry PlayBook – Like a half full or half empty glass

Posted by Bartinger | Posted in All | Posted on 03-04-2012

Tags: , , , , ,

0

BlackBerry PlayBook boxI recently received a Playbook from Blackberry due their developer promotion. They wanted  more developers to code apps for their platform so they sent a free tablet to everyone who published an app on the App World in a certain time. I was one of the lucky developers who struggled themselves through the publishing and approving progress and I received the Playbook a few days after they had sent it to FedEx.

I really was looking forward to use it because I always wanted a tablet, though I wasn’t expecting too much of it. I own it now since 4 days and wanted to share my thoughts about it. Warning: I probably will often compare it to the Android platform because I’m an Android enthusiast and I use it daily.

Installing BlackBerry PlayBook simulator on Ubuntu

Posted by Bartinger | Posted in All, Tutorials | Posted on 29-02-2012

Tags: , , , , ,

0

screenshot of PlayBook simulator on UbuntuYou may heard of the extended Free PlayBook offer from BlackBerry. If not, basically if you upload an app, no matter in which language you write or have written your app, they will offer you a free PlayBook when your app gets approved. So I wanted to take the chance and grab one of these, even though it’s not an Android tablet :)
So I took an old little game I wrote a year ago and struggled myself through the progress of signing, testing and uploading. In every single step was something really annoying but I just describe the testing part.
I’m running Ubuntu and I wanted to test my little app on the simulator before I upload it to know if it actually runs. Unfortunately the didn’t provide the resources for Linux, but there is a little workaround to get them anyway.
The first thing you need is the VMWare Player. When the download is finished make it executable with the following command.
 chmod 777 /path/to/VMWare-Player-bundle-file 
After that you can execute it with
  sudo /path/to/VMWare-Player-bundle-file 
Then go through the installing progress. Shouldn’t be too hard.
The next step is a little bit harder and requires more time (and probably nerves) On the main page is just the Windows and Mac version, of the PlayBook 2.0 simulator. After searching the developer site I found the resources of the PlayBook for all platforms. http://us.blackberry.com/developers/resources/simulators.jsp Unfortunately after installing and running I noticed, that this is a old version. It’s 1.0.8 :(
But there’s a way to get the files for your favorite operating system. What you need is another pc (or if you’re lucky you installed Windows on your pc too) and download the file for this platform. So if you have access to a Windows pc download the exe from here and execute it. This will just execute a bunch of files to a directory you specified. Take this files on an usb stick, go back to your Ubuntu pc and copy them to /home/name/VMWare/BlackBerryPlayBookSimulator2 (or any other place)

Then open VMWare and press “Open a Virtual Machine” browse to the directory and open the vmx file. The last thing you have to do is to set up eclipse to run your app (Window > Preferences > BlackBerry > BlackBerry Tools SDK and click on “Add…”), but this part is documented enough here.

I hope it works for you and if not don’t hesitate to leave a comment.

Excluding URLs from the security-constraint in App Engine

Posted by Bartinger | Posted in All | Posted on 01-01-2012

1

I was playing and searching around for how to exclude a URL from the security constraint in the web.xml file in App Engine. For my application everyone has to be authenticated to access anything in the application and I don’t want to add every URL to the pattern. So my first security constraint is just the url-pattern to “/*” and the role-name to “*” too.


<security-constraint>
   <web-resource-collection>
      <url-pattern>/*</url-pattern>
   </web-resource-collection>
   <auth-constraint>
      <role-name>*</role-name>
   </auth-constraint>
</security-constraint>

If you now want to exclude one or more URLs you just have to add another security-constraint and without the auth-constraint tag. This will exclude these URLs.


<security-constraint>
   <web-resource-collection>
      <url-pattern>/dataReceiverServlet</url-pattern>
   </web-resource-collection>
</security-constraint>

Am I the only one, who is annoyed by Fragments

Posted by Bartinger | Posted in All | Posted on 26-12-2011

1

I’m currently “rewriting” Smart Phone to make a nice tablet layout and implement all the new features for the 1.4 release. So I started (I know a little bit late) to taking a look at fragments porting the layouts to fragments. Then my first problem appears. The text color doesn’t change to black when i set the theme to Theme.Light (or Theme.Holo.Light for v11 and above) in the application tag. I posted a question at StackOverflow. (I temporarily fixed this by setting the textcolor to black manually)

Then I ran into another problem. Fragments isn’t able to show a Aialog. If you’ve ever opened or used Smart Phone you might know that it has a ton of custom dialogs. I didn’t want to port all the Dialogs to FragmentDialogs, so I made a kinda listener interface in the Fragment which tells Activity to open a dialog. So I had the business logic in the Activity again. Later I remembered, the logic of an Fragment has to be in the Fragment, because when someone opens Smart Phone on a tablet he sees 2 Fragments in one Activity. On a phone you get just 1 Fragment and the second one is in another Activity. So what I’ll have to do is porting all my custom dialogs to FragmentDialogs, which will lead to a bunch of more problems.

After that, I continued writing at my second activity which displays all the conditions, settings and plugins in one list. I thought it would look neat if i separate these three types in three lists and put them in a ViewPager with pretty indicators at the top. I found the ViewPagerIndicator library by Jake Wharton on GitHub which is exactly what i needed. This will be my second Fragment. It should include the indicator and the ViewPager with the three lists. This isn’t really a problem now, I’m just not quite sure how I should write it, to make it scale-able and efficient. It should be a custom Fragment working like that: Fragment > ViewPagerIndicator, ViewPager > ListView, ListView, ListView

While wracking my brain about that another problem came up to my mind. On a phone I have 2 Activities. First one is a list of profiles and the ActionBar displays a “+” to add a new profile and a share button which fires the share intent. A click on a profile opens the second Activity. A list of conditions, settings and plugins. Now the ActionBar displays a pen for renaming and a colored rectangle to change the color indicator (a 1.4 feature). On a tablet i display these two Fragments in one Activity. I could just merge the ActionBar buttons, but that would overload it and I also think confuse the user. So I need the redesign the ActionBar for tablets and think of a new way to display all the actions.

I also noticed that the first Activity loads twice as long as usual, since I packed the layout into a Fragment. It could be my code, which isn’t efficient enough, but all I did is copied the existing code into a Fragment. All these problems appeared in just 2 days of trying to port my app to support Fragments. I don’t know if I’m the only one who had to face so many problems or am I just stupid.

SP 1.4 sneak peak

Posted by Bartinger | Posted in All, Projects | Posted on 26-10-2011

Tags: , ,

0

SP color stripesIt has been a while since I continued working in Smart Phone, because I had a lot other things to do and I also had some problem with the new ADT r14 plugin for Eclipse. But after a few days racking my brain about it, I fixed the library projects and was able to continue coding. Now I want to share the upcoming features of SP with you.

Clickable widgets in ListViews

Posted by Bartinger | Posted in Tutorials | Posted on 19-10-2011

Tags: , , ,

2

Clickable widgets in ListView items - screenshotI know I lately didn’t blog as much as I should, but I’m trying to be more active again.

Some time ago, I wrote another ListView tutorial for Cre8ingApps, which is btw a great blog and community about mobile news and development. I decided to write another ListView tutorial, because I think, it’s the most used UI widget and nearly included in every application.

So what is this tutorial about?

As the title says, it’s about clickable widgets, in our case ImageViews, in list items. Take a look at the screenshot to know what I’m talking about. So if you’re interested go ahead, try it and if you have any questions || suggestions, just leave them below.

CLICK ME to get to the tutorial and the source code is available here: Widgets in ListViews tutorial (780)

SP 1.3 is out

Posted by Bartinger | Posted in All | Posted on 22-09-2011

0

Smart PhoneI just published he new version of Smart Phone. I made some big improvements in this version.

The screen bug which turns on the screen every 5 minutes on some devices is now gone. I also worked hard on the location condition, I completely rewrote the location service and improved it a lot.

The biggest change in this version is the new ability to activate profiles manually through the new widget. Place the 1×1 widget on your home screen and there’ll appear a list of all profiles when you press the widget. By pressing one of the profiles it will acquire its settings.

I also published  a new plugin in the Market. The StartApp plugin launches an installed application on your phone or tablet. Download it here:

https://market.android.com/details?id=at.bartinger.startapp

It’s also open source. Grab the code here: https://github.com/Bartinger/StartApp-plugin-for-SmartPhone

That’s it! Have a smart day :)

Get Minecraft 1.8 pre-release

Posted by Bartinger | Posted in All, Tutorials | Posted on 10-09-2011

Tags: , , ,

0

Can’t wait for the next Minecraft update? Mojang released (not the official release) a Minecraft 1.8 pre-release update. Notch is happy for you to try it.

Final release at: 12th of September

How to get and install it:

  1. Download the new minecraft. jar  http://assets.minecraft.net/1_8-pre/minecraft.jar
  2. Go to your .minecraft/bin folder
    • Windows: %appdata%/.minecraft/bin
    • Linux: ~/.minecraft/bin
    • OS X:  ~/Library/Application Support/.minecraft
  3. remove or rename the existing minecraft.jar and copy the downloaded one in the bin folder
  4. Start Minecraft and have fun.
More after the break.

Google+ and some invites

Posted by Bartinger | Posted in All | Posted on 06-09-2011

Tags: , ,

0

If you still don’t have a Google+ profile, really want one, don’t know anyone who could invite you and can’t find an “invite link” somewhere on the web. Although I don’t think so but if that’s the case I’m sharing my link with you

https://plus.google.com/i/BT_5I2gqZL0:XdhHyKqGNJU

I really really like Google+ so far. Before it came out I spent about 70% on Facebook and 30% of my social media time on Twitter. But since Google+ is so awesome I spend about 60% on Google+, 20% on Facebook and 10% on Twitter. Sorry Twitter :P I follow to many people on Twitter so I lost the Overview of my timeline. Maybe if I organize my tweeps and unfollow some people, I’ll use it more often.

The principle of circles is great. Share the information with just the right people. Like in life. I think your boss shouldn’t see the photos of last weekend.

The next awesome feature is called Hangout. I had a couple of Hangouts with some Android developer at Google. Reto Meier holds weekly hangouts called Android Developer Relations Hangout where you can ask them questions. I also had some Hangouts with people of the Google+ Team and I joined the Longest Hangout  a couple of times.