tag:blogger.com,1999:blog-35099781146337087982022-11-25T04:14:48.736-08:00Random SnippetsCode Snippets and Hints for HTML, PHP, Java, MySQL, Xcode etc...stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.comBlogger56125tag:blogger.com,1999:blog-3509978114633708798.post-71364306636923447282014-09-12T14:32:00.001-07:002014-09-12T14:32:41.417-07:00Got a Broken Smartphone? Repair it at Best PriceI recently dropped my <a href="https://www.apple.com/iphone-5s/specs/">iPhone 5S</a> and the screen broke. It was still usable, but it really bothered me.
So I went off to the Internet to find a local repair shop. While doing so I found that there are actually online stores that allow you to send in your phone and get it shipped back to you once it is repaired, without the hustle to actually go to a brick and mortar store.
Bonus is most of those send in phone repairs shops are cheaper than the local vendors. You can even get a free diagnosis from most of the shops first, before committing to anything.
<br/><br/>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-UcKaM7LF_Dw/VBNjwrRWtSI/AAAAAAAASEI/BrDNEJLukJw/s1600/phonerepaircompare-home.png" imageanchor="1" ><img border="0" src="http://1.bp.blogspot.com/-UcKaM7LF_Dw/VBNjwrRWtSI/AAAAAAAASEI/BrDNEJLukJw/s400/phonerepaircompare-home.png" /></a></div>
<br/>
After some more research I found a really helpful portal called <a href="http://www.phonerepaircompare.com">PhoneRepairCompare.com</a>. They have a overview for virtual all current phone models (iPhone and <a href="http://www.android.com">Android</a>, e.g. Samsung, HTC, Nokia, LG etc.) with price comparison and history of price development of multiple online phone repair shops.
<br/><br/>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-EJQlzbKdHN4/VBNjwhb-9HI/AAAAAAAASEE/KzCH5h2KRc0/s1600/phonerepaircompare-iphone5s-battery-compare.png" imageanchor="1" ><img border="0" src="http://3.bp.blogspot.com/-EJQlzbKdHN4/VBNjwhb-9HI/AAAAAAAASEE/KzCH5h2KRc0/s400/phonerepaircompare-iphone5s-battery-compare.png" /></a></div>
<br/>
Additionally they have a free database of local repair shops, in case you rather go straight to a store.
My phone is working again and I know what to do next time around. Any repair shop is <a href="http://www.phonerepaircompare.com/free-phone-repair-shop-signup">free to sign up for their store and location</a>.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-24339374139974389002012-12-11T08:45:00.000-08:002012-12-11T08:45:11.224-08:00FleamarkAd.com - Buy and Sell to Friends via FacebookI am involved in a cool project that just launched - <a href="http://www.fleamarkad.com">FleamarkAd.com</a>. FleamarkAd is a classified Ads platform that completely integrates with Facebook.
To signup and post ads you only need a Facebook account. Through your settings you have the option to share the Ad to only certain friends on Facebook, to a certain Facebook group or as well to everybody on the Internet.
<br/><br/>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-lqArw3G9xVc/UMdgqrVgSiI/AAAAAAAARB4/ToO6h0asV6c/s1600/Flearmarkad%2B-%2BClassified%2BAds%2Bon%2BFacebook%2BScreenshot.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="217" width="320" src="http://4.bp.blogspot.com/-lqArw3G9xVc/UMdgqrVgSiI/AAAAAAAARB4/ToO6h0asV6c/s320/Flearmarkad%2B-%2BClassified%2BAds%2Bon%2BFacebook%2BScreenshot.png" /></a></div>
Going through Facebook with your account and exposing certain offers only to certain people adds a certain trust to your products. On the other hand you know exactly who you are dealing with when selling or buying.
Right now until January 31st 2013 there is <a href="http://www.fleamarkad.com/tausche-falsches-geschenk-gegen-iphone-5.html">contest</a> to win one of two iPhone 5 for people that join or like the app.
Additionally there is a cool feature that allows you to print your ads so that you can put them up on boards in your School etc.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-21519470636565865222011-11-04T10:24:00.000-07:002011-11-04T10:24:35.603-07:00Blackberry JDE: Validate Email Address With Regex<p>There is no build in solution in the Blackberry JDE to validate an Email address. A common approach would be to use regular expressions with a Pattern Match approach.<br />
</p><p>Unfortunately the Pattern and Match classes are also missing in the JDE.<br />
</p><p>There is a third party Regex project for Java ME called Regexp-me.<br />
<a href="http://code.google.com/p/regexp-me/">http://code.google.com/p/regexp-me/</a><br />
Check out the source files and integrate them into your Blackberry Java project.<br />
</p><p>Below example describes how to utilise the RE class.<br />
</p><pre name="code" class="objc">public static boolean validateEmail(String email) {
if(email.length() == 0) {
return false;
}
String pttn = "^\\D.+@.+\\.[a-z]+";
RE regex = new RE(pttn);
if(regex.match(email)) {
return true;
}
return false;
}
</pre><p>That's it. Let me know if you have any problems with the instructions.<br />
</p>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-21214203724491676342011-10-25T08:17:00.000-07:002011-10-25T08:17:53.584-07:00Free Joomla 1.6+ Amazon Component<p>Recently I wanted to integrate Amazon products as ads on my Joomla 1.6 Website. After hours of testing and research I decided to go with the <a href="http://www.1sr.de/fsramazon-joomla-amazon-modul-komponente-plugin-kostenlos/free-joomla-amazon-module-component-plugin.html">free FSR Amazon Component for Joomla 1.6+</a>.<br />
</p><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-wLM-OIJpyjE/TqbTAkyl0jI/AAAAAAAAN5E/3HCVG8Bl1CE/s1600/free-fsramazon-joomla-amazon-component-plugin-module.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="400" width="299" src="http://4.bp.blogspot.com/-wLM-OIJpyjE/TqbTAkyl0jI/AAAAAAAAN5E/3HCVG8Bl1CE/s400/free-fsramazon-joomla-amazon-component-plugin-module.jpg" /></a></div><br />
<p>With help of the component you can utilize the Amazon Web Service (AWS) to integrate Amazon product ads with your Joomla CMS 1.6 or 1.7.<br />
The component comes with an easy to use backend part that allows you to integrate single products or product groups.<br />
</p><p>Below a feature list of the fsramazon Component:<br />
</p><ul><li><br />
AWS configuratiton<br />
</li>
<li><br />
Partnernet (Amazon Advertising) Konfiguration<br />
</li>
<li><br />
Farb-Konfiguration<br />
</li>
<li><br />
Produktdetail Konfiguration<br />
</li>
<li><br />
Erstellung von Seo optimierten Seiten<br />
</li>
</ul><p>Below the description of the <a href="http://www.1sr.de/fsramazon-joomla-amazon-modul-komponente-plugin-kostenlos/free-joomla-amazon-module-component-plugin.html">official Website</a>:<br />
</p><p><b>fsramazon - free joomla amazon component (plugin/module)</b><br/><br />
Fsr Amazon is a component which can be used with the content management system (cms) joomla. With the help of this component products of amazon platforms can be integrated into joomla pages via amazon web service (» aws) and amazons » product advertising API. Not only displaying products in index and item (detail) pages is implemented, but also amazons affiliate program can be used in Fsr Amazon component to earn money.<br />
</p>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-73147028112447109802011-10-20T05:59:00.000-07:002011-10-20T05:59:43.818-07:00Blackberry JDE: Eclipse I/O Error: Cannot run program "jar": CreateProcess error=2<h3>The Problem</h3><p>At one point when I've created a new Screen in my Blackberry JDE Eclipse project I received an error:<br />
</p><b>Eclipse I/O Error: Cannot run program "jar": CreateProcess error=2</b><br />
<p>I searched the Internet for solutions and several people stated that this happend for them after the exceeded a certain number of files in their project. After trying different things I found the below solution working for me.<br />
</p><h3>The Solution</h3><p>The easiest fix for this error is to <b>copy the jar.exe from the Java JDK binary folder to JRE binary folder.</b><br />
</p><p>The files is normally under:<br />
C:\Program Files (x86)\Java\jdk1.6.0_27\bin\jar.exe <br />
</p><p>The version number can be different. But since Blackberry JDE only runs under 32 bit Java/Eclipse is has to be the Java version in the (x86) Program Folder.<br />
</p><p>Paste the file into:<br />
C:\Program Files (x86)\Java\jre6\bin\jar.exe<br />
</p>That's it.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-13618849802060021832011-08-09T11:32:00.000-07:002011-08-09T11:39:20.412-07:00Xcode4: CSV Parser for iPhone/iPad iOS<h3>Introduction</h3><p>I had to dig a while to find a Objective C CSV Parser I like and that has decent performance on a mobile device. One problem is that most of those parsers are originally written for Mac OS and they are not all easily transferable.<br />
</p><p>The <a href="http://michael.stapelberg.de/cCSVParse">cCSVParse</a> from Michael Stapelberg is one of those lightweight CSV parsers. Since the website is entirely in German I will write a little summary and provide example for the English speakers on the Web.<br />
</p><h3>Installation</h3><h4>1. Download the library</h4><p>Either clone the project from Git.<br />
git://code.stapelberg.de/cCSVParse<br />
</p><p>Or download the archive from the <a href="http://michael.stapelberg.de/cCSVParse">CSV Parser Project Homepage</a>. Scroll down to "Herunterladen" and click the link.<br />
</p><h4>2. Copy the files in your project</h4><p>Copy the parseCSV.h and parseCSV.m into your project. Make sure you have checked the copy function in Xcode.<br />
</p><h4>3. Change the library for iOS use</h4><p>Open the parseCSV.h and replace:<br />
<p style="color: red;">#import <Cocoa/Cocoa.h><br />
</p>with:<br />
<p style="color: red;">#import <UIKit/UIKit.h><br />
</p></p><h3>Example of how to use the CSV Parser</h3><br />
<pre class="objc" name="code">#import "parseCSV.h"
...
- (void)parseMyCSVFile{
CSVParser *parser = [CSVParser new];
//get the path to the file in your xcode project's resource path
NSString *csvFilePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"csv"];
[parser openFile:csvFilePath];
NSMutableArray *csvContent = [parser parseFile];
for (int i = 0; i < [csvContent count]; i++) {
NSLog(@"content of line %d: %@", i, [csvContent objectAtIndex:i]);
}
[parser closeFile];
}
</pre>
stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-87555320503357562502011-07-13T11:51:00.000-07:002011-07-13T11:51:22.754-07:00Xcode 4: Fatal: Not a git repository<h3>Introduction</h3><br />
Recently I created a new project and at some point I uploaded it to SVN. I am not quite sure how to reproduce this situation but somehow the versioning support of Xcode 4 decided to interpret the project as a git repository.<br />
<br />
Each time I tried to copy a file per drag and drop into my project I got following error: <br />
<b>fatal: Not a git repository (or any of the parent directories): .git</b><br />
<br />
The result was that the file got copied into the project folder, but the reference didn't get set in the project. I had to go into the folder and drag and drop the file again and uncheck the copy option this time, so that the reference gets set.<br />
<br />
<h3>The Solution</h3><br />
1. Open Xcode and go to Window > Organizer<br />
2. Find under repositories your project. It might be two entries if you use something like SVN.<br />
3. Make sure it says "<b>Type</b> Git"<br />
4. Mark the repository entry and hit backspace or delete (on mac)<br />
5. Donestphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-15681640991577022942011-06-28T09:40:00.000-07:002011-06-28T16:22:36.998-07:00How to use JavaScript in Joomla 1.6 Custom HTML Module<h3>Introduction</h3><p>Recently I tried to use a custom HTML module in Joomla 1.6. <br />
There are a few problems with using this to get pure HTML displayed as you have copied it from somewhere to display a widget or something. <br />
Even more complicated is to get JavaScript to work in the module. By default the <script> tag gets stripped out.<br />
</p><h3>Be able to use pure HTML</h3><p>By default any user in your Joomla backend (administration area) use the TinyMCE. When you create the Custom HTML Module the text field on the bottom left will also use this Editor. The problem is that this is a WYSIWYG editor(<strong>W</strong>hat <strong>Y</strong>ou <strong>S</strong>ee <strong>I</strong>s <strong>W</strong>hat <strong>Y</strong>ou <strong>G</strong>et). That means you basically enter regular text like in Word and the editor will translate it into the according HTML code. If you paste HTML into the editor it will not interpret the code as HTML.<br />
</p><p>There are two options to bypass that problem.<br />
</p><h4>1. Go into HTML mode</h4><p>The TinyMCE editor has a button HTML that lets you edit HTML. If you use this option you can past pure HTML there. Be aware that when you hit "Update" the Editor window only shows the interpreted code. So you don't see all the HTML tags anymore.<br />
</p><h4>2. Turn of the Editor</h4><p>I personally prefer the second option. If you worked a bit with HTML it will make sense for you too. Editors like TinyMCE still produce kind of messy code and things not always look like I want them.</p><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-IefZ8X8nu0c/TgoDxkoeuEI/AAAAAAAAN2g/Q15H3kElNW4/s1600/Screen%2Bshot%2B2011-06-28%2Bat%2B9.38.49%2BAM.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="186" width="400" src="http://1.bp.blogspot.com/-IefZ8X8nu0c/TgoDxkoeuEI/AAAAAAAAN2g/Q15H3kElNW4/s400/Screen%2Bshot%2B2011-06-28%2Bat%2B9.38.49%2BAM.png" /></a></div><p>To turn of the editor for your user perform the following steps:<br />
<ul><li>1. Go to Users > User Manager.</li>
<li>2. Click on your user's name</li>
<li>3. On the right select at Editor "Editor - None"</li>
<li>4. Save</li>
</ul>Now when you open a Custom HTML Module you just have a plain text field.<br />
</p><h3>Be able to use JavaScript</h3><p>If you past HTML code in the plain text field of the Custom HTML Module it should work now without problems. When you paste JavaScript though, the <script> tags will get stripped, which will make your JavaScript appear as text on the frontend.<br />
</p><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-BGNo-dmE5YA/TgoD3twtwMI/AAAAAAAAN2o/M7sqwc3d-eQ/s1600/Screen%2Bshot%2B2011-06-28%2Bat%2B9.38.13%2BAM.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="46" width="298" src="http://4.bp.blogspot.com/-BGNo-dmE5YA/TgoD3twtwMI/AAAAAAAAN2o/M7sqwc3d-eQ/s400/Screen%2Bshot%2B2011-06-28%2Bat%2B9.38.13%2BAM.png" /></a></div><p>To change the filtering of JavaScript in your text you can turn of filtering for your admin user like this:<br />
<ul><li>1. Go to Content > Article Manager</li>
<li>2. Click Options</li>
<li>3. In the Popup go to Text Fitlers</li>
<li>4. Depending on what kind of user you are (e.g. SuperUser) change Filter Type to No Filtering</li>
<li>5. Save & Close</li>
</ul></p><h3>Text or Textarea Attribute in Joomla 1.6 Module prevent filtering</h3><p>Another related problem is that in modules you have sometimes attributes you can set. If it is a textarea you want to use HTML or JavaScript here as well, but it all gets filtered, even if you have the above settings applied.<br />
</p><p>A solution here is to modify the module xml file and add teh attribute filter="raw" to the field definition.<br />
</p><p>Now you should have no problem to paste JavaScript and save it in the Custom HTML Module.<br />
Let me know if you have any problems.<br />
</p>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-75185574432706003842011-06-23T09:57:00.000-07:002011-06-23T09:57:58.426-07:00Point Domain to Subfolder in Bluehost for a Joomla 1.6 Installation<h3>Introduction</h3><br />
Bluehost points your primary domain always to the public_html folder. <br />
If you want to install your CMS like Joomla or Wordpress in a subfolder, rather than have all the files in the root, there is no easy build in way at Bluehost.<br />
<br />
After reading through the Internet a trying tons of suggestions I found the solution that works for me and a Joomla 1.6 installation. It is a combination of several snippets I found online.<br />
<br />
<h3>The Solution</h3><br />
Find the .htaccess file in the root folder (public_html) of you Bluehost webspace.<br />
Open the file and add following code. Make sure you read the comments and make the according adjustments.<br />
<br />
<pre class="objc" name="code"># Activate the rewrite engine
RewriteEngine on
# Replace yourdomain.com with your domain name.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Replace 'subfolder' with your subfolder name.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don't touch this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Replace 'subfolder' with your subfolder name.
RewriteRule ^(.*)$ /subfolder/$1
# Replace yourdomain.com with your domain name.
# Replace 'subfolder' with your subfolder name.
# set index.php to whatever necessary for your CMS, for Joomla you don't need to change it
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
</pre><br />
<h3>Permanent Redirect yourdomain.com to www.yourdomain.com</h3><br />
If you want additionally forward yourdomain.com to www.yourdomain.com add following code to the .htaccess right below "RewriteEngine On".<br />
<br />
<pre class="objc" name="code"># use "www", replace yourdomain with your domain name
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
</pre><br />
<h3>Permanent Redirect www.yourdomain.com to yourdomain.com</h3><br />
If you instead want to do the redirect the other way around, add following code to the .htaccess right below "RewriteEngine On".<br />
<br />
<pre class="objc" name="code"># use "www", replace yourdomain with your domain name
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
</pre><br />
<h3>Troubleshooting</h3>Please test after every step if everything is working so that you know at which point the new settings broke everything. <br />
<br />
It also helps to clear the cache on your browser to make sure the current rewrite rules are used.<br />
<br />
If you still have problems with your Joomla, I read it helps to additionally set the live_site parameter in the configuration.php to yourdomain.com.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-21170052167845971652011-06-22T11:32:00.000-07:002011-06-24T09:48:44.732-07:00How to Verify a Joomla 1.6.x Website with Google Webmaster Tools, Bing Webmaster Tools, Yahoo Site Explorer and Alexa<h3>Introduction</h3>This article describes how to verify your website with <a href="https://www.google.com/webmasters/tools/">Google Webmaster Tools</a>, <a href="http://www.bing.com/webmaster">Bing Webmaster Tools</a>, <a href="http://siteexplorer.search.yahoo.com/">Yahoo Site Explorer</a> and <a href="http://www.alexa.com">Alexa</a>, while using the Meta Tags verification method.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-n9yxuCLruGc/TgIwCHxchyI/AAAAAAAAN1o/nwP_XwiyRXk/s1600/logo.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="50" width="60" src="http://1.bp.blogspot.com/-n9yxuCLruGc/TgIwCHxchyI/AAAAAAAAN1o/nwP_XwiyRXk/s320/logo.png" /></a></div><br />
<h3>Downloading the latest Version</h3>You can download it at the Link below.<br />
<br />
Download v1.0 for Joomla 1.6.x:<br />
<a href="https://docs.google.com/uc?id=0B2-WluWSeNCIY2VmZWUyYzktYjcxNC00NjhmLWFiMDctYjUxN2Q5M2U2ZTI2&export=download&authkey=CJD7i6oO&hl=en_US" onclick="_gaq.push(['_trackEvent', 'ZIP File', 'Download', 'J -Webmaster Verify Joomla 1.6']);">plg_j_webmaster_verify_Joomla1.6_v.1.0.zip</a><br />
<br />
<h3>Example</h3><br />
Here is an example of a Joomla 1.6 Website that is using the meta tags:<br />
<br />
<a href="http://www.moving-boxes-portal.com">Moving-Boxes-Portal.com</a><br />
<br />
Let your browser display the source code to see the <meta... entries. (Ctrl+U Windows, Command+Alt+U Mac)<br />
<br />
<h3>Installation for Joomla 1.6</h3><br />
1. Download the Plugin from the Link above.<br />
<br />
2. Go to your Joomla Admin area.<br />
<br />
3. Go to Extensions > Extensions Manager.<br />
<br />
4. Under Install, go to Upload Package File and click "Choose File".<br />
<br />
5. After selecting plg_j_webmaster_verify_Joomla1.6_v.1.0.zip from your harddrive, click "Upload File & Install".<br />
<br />
6. Go into the Plugin under Extensions > Plug-in Manager.<br />
<br />
7. Find the Plugin name System - J-Webmaster Verify and open it.<br />
<br />
8. Enable the Plugin. Enter the verification codes of the accounts you want to verify.<br />
<br />
9. Save and you are done.<br />
<br />
<h3>Get the required Verification Code, Example for Google Webmaster Tools</h3><br />
To be able to use Google Webmaster Tools you need an Google Account, if you have a Google Mail address your are good to go.<br />
<br />
1. Go to <a href="https://www.google.com/webmasters/tools">Google Webmaster Tools Homepage</a><br />
<br />
2. Click "Add a site..." and enter the URL<br />
<br />
3. Select "Alternate Methods"<br />
<br />
4. Select "Add a meta tag to your site's home page"<br />
<br />
5. Copy the part that is in between the quotes after content.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-tqgLH-_TE7M/TgIzFfRONOI/AAAAAAAAN14/Jih9nzdWBw4/s1600/GoogleWebmasterVerificationMetaTag.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="101" width="400" src="http://4.bp.blogspot.com/-tqgLH-_TE7M/TgIzFfRONOI/AAAAAAAAN14/Jih9nzdWBw4/s400/GoogleWebmasterVerificationMetaTag.png" /></a></div><br />
6. Paste the string into the Plugin in your Joomla 1.6 backend under Google Key.<br />
<br />
7. Done<br />
<br />
The other verifications should be similar.<br />
Let me know if you have any problems or questions.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-68453469426031237832011-06-02T10:03:00.000-07:002011-06-10T11:31:37.127-07:00How to add the Google +1 Button to Joomla 1.6<h3>Introduction</h3><p>Recently I published a <a href="http://rndm-snippets.blogspot.com/2011/06/how-to-add-google-plus-one-button-to.html" target="_blank">new Joomla 1.5 module</a> for the <strong><a href="http://www.google.com/webmasters/+1/button/">Google +1 Button</a></strong>. Here now the same module for the all new Joomla 1.6. Integrate the button on your Joomla website without working in the code or change anything in the template.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/--CYG15xRhi0/Tea0E2Ep0DI/AAAAAAAAN1M/TezcK9wxnao/s1600/logo.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="50" width="60" src="http://1.bp.blogspot.com/--CYG15xRhi0/Tea0E2Ep0DI/AAAAAAAAN1M/TezcK9wxnao/s320/logo.png" /></a></div></p><h3>Changelog/Latest Version</h3><h4>Joomla 1.6, Version 1.1, released June 10 2011</h4><ul><li>show total +1 counter ON/OFF beside the +1 Button<br />
</li>
<li>set a target URL for the +1 Button or keep the default (the page the button is embedded)<br />
</li>
</ul><h4>Joomla 1.6, Version 1.0, released June 02 2011</h4><ul><li>change size of the Google +1 Button, small, medium, standard, tall<br />
</li>
<li>add custom CSS with the +1 Button<br />
</li>
</ul><h3>Downloading the latest Version</h3><p>You can download it at the Link below.<br />
<br />
<a href="https://docs.google.com/uc?id=0B2-WluWSeNCIMTBmMDE5MGYtY2ZlNS00ZWJlLWJkNDQtY2JhZTNlZjEzODVj&export=download&authkey=COnpi-MI" onclick="_gaq.push(['_trackEvent', 'ZIP File', 'Download', 'Google +1 Joomla 1.6']);">Download v1.1 for Joomla 1.6.x</a><br />
<br />
Or check out the official <a href="http://extensions.joomla.org/extensions/content-sharing/bookmark-a-recommend/17174" target="_blank">Joomla Extension Website</a> for more infos. <br />
</p><h3>Example</h3><br />
Here is an example on how the Google Plus One Joomla Module looks in action: <br />
<a href="http://www.flopwatch.org" target="_blank">Flopwatch.org</a><br />
<br />
<h3>Installation for Joomla 1.6</h3><p>In Joomla 1.6.x you can just install the new version as described below, there will be no conflict with an old version. In case you had one installed before.<br />
</p><p>1. Download the Module from the Link above.<br />
<br />
2. Go to your Joomla Admin area.<br />
<br />
3. Go to Extensions > Extensions Manager.<br />
<br />
4. Under Install, go to Upload Package File and click "Choose File".<br />
<br />
5. After selecting the mod_j_google_plus_one_for_j1.6.zip from your harddrive, click "Upload File & Install".<br />
<br />
6. Go into the Module under Extensions > Module Manager.<br />
<br />
7. Enable the Module and disable the Title. Make sure you have selected Pages it show up on.<br />
<br />
8. Select the position and size of the button.<br />
<br />
9. Save and you are done.<br />
<br />
</p><br />
<h3>More about the Google +1 Button in a Google Video</h3><p><div style="clear: both;display: block;position: relative;text-align:center;z-index:999;padding: 12px;"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> <br />
<div id="flashdiv1"></div><br />
<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myplayerid1" };
swfobject.embedSWF("http://www.youtube.com/v/OAyUNI3_V2c&hl=pt-br&fs=1&enablejsapi=1&playerapiid=myplayerid1", "flashdiv1", "500", "350", "8", null, null, params, atts);
</script> <br />
</div><script src="/plugins/content/youtubeembed/ga_dpc_youtube.js"></script> <br />
<script>
try{
var ytTracker = new YoutubeTracker();
}catch(e){}
</script> <br />
</p>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-6216653772155253382011-06-01T14:36:00.000-07:002011-06-10T11:29:09.863-07:00How to add the Google Plus One Button to your Joomla 1.5 website<div style="color:red;">New update available, read below.</div><h3>Introduction</h3><p>I wrote a little Module for Joomla 1.5 that supports the new <a href="http://www.google.com/webmasters/+1/button/">Google Plus One Button</a> for your Joomla Website without working in the code or change anything in the template.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/--CYG15xRhi0/Tea0E2Ep0DI/AAAAAAAAN1M/TezcK9wxnao/s1600/logo.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="50" width="60" src="http://1.bp.blogspot.com/--CYG15xRhi0/Tea0E2Ep0DI/AAAAAAAAN1M/TezcK9wxnao/s320/logo.png" /></a></div></p><h3>Download for Joomla 1.6</h3><p>Here you can find the Download and Documentation for the <a href="http://rndm-snippets.blogspot.com/2011/06/how-to-add-google-1-button-to-joomla-16.html">Google +1 Button Module for Joomla 1.6</a>.<br />
</p><h3>Changelog/Latest Version</h3><h4>Joomla 1.5, Version 1.1, released June 10 2011</h4><ul><li>show total +1 counter ON/OFF beside the +1 Button<br />
</li>
<li>set a target URL for the +1 Button or keep the default (the page the button is embedded)<br />
</li>
</ul><h4>Joomla 1.5, Version 1.0, released June 02 2011</h4><ul><li>change size of the Google +1 Button, small, medium, standard, tall<br />
</li>
<li>add custom CSS with the +1 Button<br />
</li>
</ul><h3>Downloading the Extension</h3><p>You can download it at the Link below.<br />
<br />
<a href="https://docs.google.com/uc?id=0B2-WluWSeNCIODk1ZjFjN2YtYjIyNS00M2U4LTk0MjctZjg3YzlhMDdiNmU3&export=download&authkey=CNKC-dAC" onclick="_gaq.push(['_trackEvent', 'ZIP File', 'Download', 'Google +1 Joomla 1.5']);">Download v1.1 Joomla 1.5.x</a><br />
<br />
Or check out the official <a href="http://extensions.joomla.org/extensions/content-sharing/bookmark-a-recommend/17174" target="_blank">Joomla Extension Website</a> for more infos. <br />
</p><h3>Example</h3><br />
Here is an example on how the Google Plus One Joomla Module looks in action: <br />
<a href="http://www.flopwatch.org" target="_blank">Flopwatch.org</a><br />
<br />
<h3>Installation</h3><p>If you have never installed the Google Plus One module before go straight to "Install the new Version" otherwise make sure you uninstall the old version first.<br />
</p><h4>Uninstall the old Version</h4><p>1. Go to your Joomla Admin area.<br />
<br />
2. Go to Extensions > Install/Uninstall.<br />
<br />
3. Go to Modules.<br />
<br />
4. Find and select the entry "mod_j_google_plus_one".<br />
<br />
6. Click Uninstall.<br />
<br />
7. Done.<br />
</p><h4>Install the new Version</h4><p>1. Download the Module from the Link above.<br />
<br />
2. Go to your Joomla Admin area.<br />
<br />
3. Go to Extensions > Install/Uninstall.<br />
<br />
4. Go to Upload Package File and click "Choose File".<br />
<br />
5. After selecting the mod_j_google_plus_one_1.0.zip from your harddrive, click "Upload File & Install".<br />
<br />
6. Go into the Module under Extensions > Modules .<br />
<br />
7. Enable the Module and disable the Title.<br />
<br />
8. Select the position and size of the button.<br />
<br />
9. Save and you are done.<br />
<br />
</p><br />
<h3>More about the Google +1 Button in a Google Video</h3><p><div style="clear: both;display: block;position: relative;text-align:center;z-index:999;padding: 12px;"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> <br />
<div id="flashdiv1"></div><br />
<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myplayerid1" };
swfobject.embedSWF("http://www.youtube.com/v/OAyUNI3_V2c&hl=pt-br&fs=1&enablejsapi=1&playerapiid=myplayerid1", "flashdiv1", "500", "350", "8", null, null, params, atts);
</script> <br />
</div><script src="/plugins/content/youtubeembed/ga_dpc_youtube.js"></script> <br />
<script>
try{
var ytTracker = new YoutubeTracker();
}catch(e){}
</script> <br />
</p>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com2tag:blogger.com,1999:blog-3509978114633708798.post-77000625650276832632011-05-25T09:53:00.000-07:002011-05-25T09:53:53.264-07:00Checkout the all new Hattrick iPhone App - HT-SmartViewerEarlier this year the Lite version was released and now there is Full version of the HT-SmartViewer. The App is written for iPhone it does work on iPad as well though.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-0w8O6E_FWRE/Td0zA8DHBGI/AAAAAAAAN0Y/ld7warA_uDI/s1600/hattrickOrgLogo.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="250" width="210" src="http://2.bp.blogspot.com/-0w8O6E_FWRE/Td0zA8DHBGI/AAAAAAAAN0Y/ld7warA_uDI/s400/hattrickOrgLogo.png" /></a></div><br />
The App is still free of charge and comes with tons of new stuff. Below are links to the articles that write about the features.<br />
<br />
<a href="http://www.ht-smartviewer.com/the-news/60-the-new-ht-smartviewer-1">1. HT-SmartViewer The Home Screen/Social Media</a><br />
<a href="http://www.ht-smartviewer.com/the-news/62-the-new-ht-smartviewer-part-2">2. HT-SmartViewer League Infos Feature</a><br />
<a href="http://www.ht-smartviewer.com/the-news/63-the-new-ht-smartviewer-part-3">3. HT-SmartViewer Match Data Feature</a><br />
<a href="http://www.ht-smartviewer.com/the-news/64-the-new-ht-smartviewer-part-4">4. HT-SmartViewer Match Stats Feature</a><br />
<br />
The App Homepage is here: <a href="http://www.ht-smartviewer.com">HT-SmartViewer Home</a>. The App can be downloaded directly from the Apple AppStore here: <a href="http://itunes.apple.com/us/app/ht-smartviewer/id438066061?mt=8">HT-SmartViewer in the AppStore</a>.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-uDMDmN-fnLE/Td0zZ5NkSiI/AAAAAAAAN0g/RSbUpTtVhps/s1600/New-HT-SmartViewer-Home-Signed-In.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="320" width="214" src="http://3.bp.blogspot.com/-uDMDmN-fnLE/Td0zZ5NkSiI/AAAAAAAAN0g/RSbUpTtVhps/s320/New-HT-SmartViewer-Home-Signed-In.png" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-vro8wkARBvE/Td0zaMkrU0I/AAAAAAAAN0o/dS82N2k68tI/s1600/New-HT-SmartViewer-Match-Screen.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="320" width="214" src="http://3.bp.blogspot.com/-vro8wkARBvE/Td0zaMkrU0I/AAAAAAAAN0o/dS82N2k68tI/s320/New-HT-SmartViewer-Match-Screen.png" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-viJ0YJ8Rwqg/Td0zadYWdQI/AAAAAAAAN0w/XP6zoqZPKXs/s1600/New-HT-SmartViewer-Stats-Screen3.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="320" width="214" src="http://3.bp.blogspot.com/-viJ0YJ8Rwqg/Td0zadYWdQI/AAAAAAAAN0w/XP6zoqZPKXs/s320/New-HT-SmartViewer-Stats-Screen3.png" /></a></div><br />
<br />
Based on user feedback and our own ideas the App will be extendend with new modules like conference, team and youth team infos, national team etc.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-61601698478921081962011-05-10T16:48:00.000-07:002011-05-10T16:48:54.830-07:00Objective C/Xcode 4: Check at runtime whether iOS device supports multitasking<h3>Introduction</h3><br />
When I was recently in search for a code snippet that tells me whether the iOS device that the code is running does support Multitasking I quickly found some answers. All the answers seemed to be missing something though.<br />
<br />
So below the solution I came up with, that satisfies all my requirements to check for multitasking of my iPhone/iPad/iPod device at runtime. <br />
<br />
<h3>Difference between multitasking support of the SDK version and of the device version</h3><br />
Since version 4.0 iOS supports multitasking. Read more about it in this interesting article: <a href="http://www.cocoanetics.com/2010/07/understanding-ios-4-backgrounding-and-delegate-messaging/" target="_blank">Understanding iOS 4 Backgrounding and Delegate Messaging</a>.<br />
<br />
Even though you have iOS 4.x on your iPhone 3G it doesn't support multitasking. Multitasking is supported from iPhone 3GS and iPod touch G3 (both released in 2009) but not previous generations like iPhone 2G or 3G due to hardware limitations. Read more here: <a href="http://www.tipb.com/2010/04/08/apple-announces-multitasking-iphone-40/" target="_blank">Apple announces multitasking for iPhone OS 4</a><br />
<br />
<h3>The Code</h3><pre name="code" class="objc">//get the current device object
UIDevice* device = [UIDevice currentDevice];
//check if the currently running iOS knows the isMultitaskingSupport message (method)
if ([device respondsToSelector:@selector(isMultitaskingSupported)]){
//check if the current device does actually support multitasking
if ([device isMultitaskingSupported]) {
//do some multitasking stuff
} else {
//deal with the lack of multitasking
}
} else {
//deal with the lack of multitasking
}
</pre>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-66305502551374771402011-05-04T12:26:00.000-07:002011-05-05T13:20:37.840-07:00Bugzilla and Gmail: Send mail notifications/alerts via GmailBugzilla is an Issue Tracking System that can send email notifications to its members. Most important Bugzilla sends an Email to the bug reporter or assignee of a bug. Bugzilla does support SMTP to send email notifications. That can be set when you are logged in as an administrator under Administration > Parameters > Email.<br />
<br />
If you want to <strong>configure Bugzilla to use Gmail</strong> you have to consider that Gmail doesn't use standard SMTP, Gmail is using SMTP with TLS. I tried this tutorial <a href="http://www.dawood.in/bugzilla_alerts_using_gmail.html" target="_blank">BugZilla alerts using GMAIL</a>, but I couldn't get it running and I found it somewhat confusing.<br />
<br />
So I digged a little deeper and came up with my own more easy solution using Email::Send::Gmail rather than Email::Send::SMTP::TLS as described in the other tutorial. The steps are done with Bugzilla running on Apache2.2 Server with a Debian Linux OS. The instructions should be similar for other Linux distributions like Ubuntu, Fedora or RedHat Linux. Be awate if you run Bugzilla on a Windows Server especially the folder structure is different.<br />
<br />
<h3>Install the Email-Send-Gmail package for Pearl</h3><br />
If you have Bugzilla installed and running then you have Pearl installed properly. Start the pearl command line.<br />
<pre class="objc" name="code"># perl -MCPAN -e shell
</pre>Run the install package command for Email-Send-Gmail.<br />
<pre class="objc" name="code">cpan[1]> install Email::Send::Gmail
</pre>Confirm all questions with 'yes'.<br />
If everything is done leave the command line.<br />
<pre class="objc" name="code">cpan[2]> quit
</pre><br />
<h3>Optional Fix: Warning (usually harmless): 'YAML' not installed...</h3><br />
I fixed that by entering the below command in the regular command line:<br />
<pre class="objc" name="code"># sudo apt-get install libnet-ldap-perl
</pre><br />
<h3>Confirm Email-Send-Gmail was installed properly</h3><br />
Login as administrator into your Bugzilla and go to Administration > Parameters > Email.<br />
You should be able to select an entry called "Gmail". Select it and save the changes for now.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-rKgFUClhp6M/TcGjwHi0qdI/AAAAAAAAN0Q/z1b6ShR_Akg/s1600/Confirm_Pearl_Email-Send-Gmail_Installation.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="133" width="400" src="http://4.bp.blogspot.com/-rKgFUClhp6M/TcGjwHi0qdI/AAAAAAAAN0Q/z1b6ShR_Akg/s400/Confirm_Pearl_Email-Send-Gmail_Installation.png" /></a></div><br />
<h3>Change Mailer.pm</h3><br />
Now we need to change the Bugzilla Mailer.pm to pass on the right parameters when sending emails via the new pearl package.<br />
<br />
Go to your Bugzilla root folder on your server. For me that is /var/www/bugzilla. <br />
<pre class="objc" name="code"># cd /var/www/bugzilla
</pre>In the subfolder of your Bugzilla root is another folder called Bugzilla. In this folder the Mailer.pm is located. Open it with the editor of your choice, e.g. vim or nano.<br />
<br />
<pre class="objc" name="code"># nano Bugzilla/Mailer.pm
</pre><br />
After the last line that starts with use enter:<br />
<pre class="objc" name="code">use Email::Send::Gmail;
use Email::Simple::Creator;
</pre><br />
The line that says:<br />
<pre class="objc" name="code">if ($method eq "SMTP"){
</pre>change to:<br />
<pre class="objc" name="code">if ($method eq "SMTP" || $method eq "Gmail") {
</pre>Save your settings and you are done here.<br />
<br />
<h3>Configure Bugzilla's Email settings</h3><br />
Now again as an administrator go back to Administration > Parameters > Email in your Bugzilla.<br />
<br />
<i>mailfrom:</i><br />
username@gmail.com or username@your_domain.com (if you use your own domain via Google Applications)<br />
<br />
<i>smtpserver:</i><br />
smtp.gmail.com<br />
<br />
<i>smtp_username:</i><br />
username@gmail.com or username@your_domain.com (if you use your own domain via Google Applications)<br />
<br />
<i>smtp_password:</i><br />
your Gmail password<br />
<br />
<i>smtp_debug:</i><br />
You might want to turn on debug to see if sending mails is working. if not you should get a debug message that should help you better narrowing the error down. When everything is working you can turn debug off.<br />
<br />
Save your changes and you are good to go. Let me know if you run into problems.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com4tag:blogger.com,1999:blog-3509978114633708798.post-86120039541811757992011-04-29T09:57:00.000-07:002011-05-04T11:56:02.545-07:00Xcode4/CoraData: Using LIKE to search SQLite Table - "String starts with"<h3>Problem</h3><br />
I recently had a task where a UITableView should suggest autocomplete for a word I started to type into a UISearchBar/Search Display Controller.<br />
<br />
From the top of my head I came up with the SQL query that I wanted to use:<br />
<br />
<strong>SELECT string FROM table WHERE string LIKE 'S%';</strong><br />
<br />
This query should return all the strings that start with capital S.<br />
<br />
<h3>Solution</h3><br />
For a NSPredicate the query has to look like this:<br />
<br />
<strong>NSString *query = [NSString stringWithFormat:@"String LIKE '%@%%'", startOfString];</strong><br />
<br />
Most important here is that the percent sign needs to be escaped with another percent sign (%%).stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-50642914186257148322011-04-15T12:13:00.000-07:002011-04-15T12:17:54.384-07:00Xcode4: Set Company/Organization Name for specific ProjectsAnother thing that changed in Xcode 4 is how to tell Xcode to use a certain Organization name instead of the default "__MyCompanyName__" or the company name that is tight to your Mac user account. <br />
<br />
Most prominent this value shows up in the comment copyright header when you create a new file in Xcode4.<br />
<br />
<h3>1. Click on your project root in the Project Navigator on the left.</h3><br />
<h3>2. Enable your Utilities view on the right while the project root is marked.</h3><br />
<h3>3. Select the File Inspector. To make sure you are in the right location, the Identity should display your Project Name.</h3><br />
<h3>4. Under Project Document is a text field called Organization. Enter here the Organization name you want to show up for all your new files that get generated in this project.</h3><br />
That's it. Let me know if you have any problems or comments.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-26799169476556371442011-04-10T18:02:00.000-07:002011-04-10T18:02:14.142-07:00Objective C: Adding an Enter/Search Button to Number Pad on iPhone AppsIn my Xcode projects where I needed a button on the Number Pad to initiate the intended action I used this tutorial: <a href="http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key" target="_blank">UIKeyboardTypeNumberPad and missing return key</a>.<br />
<br />
I also implemented the updates described in the Internet that make the hack compatible with either iOS version, below 3.2 and above, including iOS 4, iOS 4.1, iOS 4.2 and iOS 4.3.<br />
<br />
Another improvement compared to the tutorial is that I put the image in the Background of the Button and use a Label in the foreground to be able to use any Label I want and make it localizable.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-enRvmMVYPJo/TaJSvuI7_yI/AAAAAAAANzk/osIACuHvQr0/s1600/number-pad-with-custom-button-hack-result.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="341" width="364" src="http://2.bp.blogspot.com/-enRvmMVYPJo/TaJSvuI7_yI/AAAAAAAANzk/osIACuHvQr0/s400/number-pad-with-custom-button-hack-result.png" /></a></div><br />
<br />
<br />
Below are the steps from the above website with my additions to accomplish the above features:<br />
<br />
<h3>Create and Add the button images to your project</h3><br />
The button will be placed on the number pad in your iPhone or iPad App. To make it look good the button should look like the other number pad buttons when it gets clicked and when not. That means that the button has to states.<br />
<br />
I modified a button from number pad to look like the other buttons. You can use them in your project if you want.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-yRV0c_ZPamo/TaJJc4BTeJI/AAAAAAAANzU/nR5h9TdOpwQ/s1600/doneDown.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="53" width="105" src="http://3.bp.blogspot.com/-yRV0c_ZPamo/TaJJc4BTeJI/AAAAAAAANzU/nR5h9TdOpwQ/s400/doneDown.png" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-yJylWGX-xFI/TaJJc__NJpI/AAAAAAAANzc/7jWKhzGn3nc/s1600/doneUp.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="53" width="105" src="http://1.bp.blogspot.com/-yJylWGX-xFI/TaJJc__NJpI/AAAAAAAANzc/7jWKhzGn3nc/s400/doneUp.png" /></a></div><br />
Call them buttonUp.png and buttonDown.png or whatever you want and copy them in your xcode project.<br />
<br />
<h3>Prepare your ViewController Header (.h)</h3><br />
Make sure you have set your keyboard as the delegate for the UILabel that uses the Keyboard.<br />
<br />
in ExampleViewController.h:<br />
<pre class="objc" name="code">@interface ExampleViewController : UIViewController <UITextFieldDelegate>{
UITextField *textField;
}
...
@property (nonatomic, retain) IBOutlet UITextField *textField;
...
- (void)addButtonToKeyboard;
- (void)keyboardWillShow:(NSNotification *)note;
- (void)keyboardDidShow:(NSNotification *)note;
- (void)buttonClicked:(id)sender;
@end
</pre><br />
<h3>Prepare your ViewController (.m)</h3><br />
<pre class="objc" name="code">- (void)viewDidLoad {
[super viewDidLoad];
...
// add observer for the respective notifications (depending on the os version)
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
} else {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
...
}
- (void) viewWillDisappear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)addButtonToKeyboard {
// create custom button
UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeCustom];
yourButton.frame = CGRectMake(0, 163, 105, 53);
yourButton.adjustsImageWhenHighlighted = NO;
//set font button size and type
yourButton.titleLabel.font = [UIFont boldSystemFontOfSize:16];
//set the label text of the button when its not pushed
[yourButton setTitle:@"SEARCH" forState:UIControlStateNormal];
//set the color of the label text of the button when its not pushed
[yourButton setTitleColor:[UIColor colorWithRed:0.302f green:0.33f blue:0.384f alpha:1.0f] forState:UIControlStateNormal];
//set the background image of the button when its not pushed
[yourButton setBackgroundImage:[UIImage imageNamed:@"buttonUp.png"] forState:UIControlStateNormal];
//set the label text of the button when its pushed
[yourButton setTitle:@"SEARCH" forState:UIControlStateHighlighted];
//set the color of the label text of the button when its pushed
[yourButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
//set the background image of the button when its pushed
[yourButton setBackgroundImage:[UIImage imageNamed:@"buttonDown.png"] forState:UIControlStateHighlighted];
[yourButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard found, add the button
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
[keyboard addSubview:yourButton];
} else {
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
[keyboard addSubview:yourButton];
}
}
}
- (void)keyboardWillShow:(NSNotification *)note {
// if clause is just an additional precaution, you could also dismiss it
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 3.2) {
[self addButtonToKeyboard];
}
}
- (void)keyboardDidShow:(NSNotification *)note {
// if clause is just an additional precaution, you could also dismiss it
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
[self addButtonToKeyboard];
}
}
- (void)buttonClicked:(id)sender{
//lets the number pad disappear after your clicked your custom button
[self.textField resignFirstResponder];
...
//do here what you want after the button was clicked
}
</pre><br />
<h3>Troubleshooting</h3>So far I came across only one problem and that was that my picture where not added properly to my project. Therefore clicking worked, but the buttons didn't show up. You can test this by adding a UIImage view manually to your NIB and see if the image shows in the list of images that you could set.<br />
<br />
Let me know if you have more issues or suggestions.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-34031256249911292312011-03-23T18:45:00.000-07:002011-03-23T18:45:52.795-07:00Objective C/Xcode 4: Encoding Problem with Localizable.strings filesWhen compiling your Xcode project and your are using Localization in the Form of Localizable.strings and can happen that your get one of the following Build Errors. <br />
<br />
<h3>Possible Build Errors</h3>1.<br />
Conversion of string failed. The string is empty. Command /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copystrings failed with exit code 1<br />
<br />
2.<br />
CopyStringsFile<br />
...<br />
Localizable.strings:0: error: validation failed: The data couldn’t be read because it has been corrupted.<br />
<br />
<h3>Causes</h3><br />
These kind of errors can happen if you copy and paste content within Xcode or from external files in your localization files. The consequence is that the encoding of the file changes to for example Western (Mac OS Roman). The Localizable.strings file should be in UTF-16 though.<br />
<br />
<h3>Solution</h3><br />
1.<br />
Like in the picture below, navigate in Xcode to the Localizable.strings location and open it so that you can see all the languages you are supporting.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-jlc7H-EBOYs/TYqfJRchkzI/AAAAAAAANws/djafOE5Iomc/s1600/Screen%2Bshot%2B2011-03-23%2Bat%2B6.28.37%2BPM.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="138" width="203" src="http://3.bp.blogspot.com/-jlc7H-EBOYs/TYqfJRchkzI/AAAAAAAANws/djafOE5Iomc/s400/Screen%2Bshot%2B2011-03-23%2Bat%2B6.28.37%2BPM.png" /></a></div><br />
2. <br />
Left-click on the language file the causes the build error.<br />
<br />
3. <br />
Make sure your Utilities View is showing in Xcode. Activate on the button at mark 1 in Picture below. <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-kSEHUKUThGQ/TYqhJHlkddI/AAAAAAAANw8/SABc6mZD_to/s1600/Xcode%2BUtilities%2BView%2Band%2BEncoding%2BSettings.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="400" width="288" src="http://1.bp.blogspot.com/-kSEHUKUThGQ/TYqhJHlkddI/AAAAAAAANw8/SABc6mZD_to/s400/Xcode%2BUtilities%2BView%2Band%2BEncoding%2BSettings.png" /></a></div><br />
4. <br />
In the Utilities View select the File Inspector. (Small Logo that looks like Page)<br />
<br />
5. <br />
Under Text Settings change the encoding to UTF-16(Marked as 2 in the picture above). The Drop-Down might be grayed out but you can click on it anyways. Click on "Convert" on the Popup.<br />
<br />
That's it your project should now compile again.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com2tag:blogger.com,1999:blog-3509978114633708798.post-48632363887820600462011-03-22T12:36:00.000-07:002011-04-10T18:02:09.813-07:00Objective C/Xcode 4: How to label and internationalize a Round Rect Button (UIButton) programaticallyIf you only support one language it is easy to go into Interface Builder and set the Label of your Round Rect Button. For localization it is not as easy though.<br />
<br />
<h3>How to use localization for UILabels</h3><br />
Text Label elements or UILabels can easily be set to a localized String with this command.<br />
<br />
<pre class="objc" name="code">@synthesize nameLabel;
...
self.nameLabel.text = NSLocalizedString(@"name.label.translation", @"Comment for the name label.");
</pre><br />
<h3>How to <strong>NOT</strong> use localization for UIButtons</h3>Since buttons have different states the label would disappear if you click it and you only set the title like that. <br />
<pre class="objc" name="code">@synthesize myButton;
...
//Wrong
self.myButton.titleLabel = = NSLocalizedString(@"button.label.translation", @"Comment for the button label.");
</pre><br />
<h3>How to <strong>USE</strong> localization for UIButtons</h3>The proper way is to assign the localized string to all states of the UIButton.<br />
<br />
<pre class="objc" name="code">@synthesize myButton;
...
//Correct
NSString *buttonLabelString = NSLocalizedString(@"button.label.translation", @"Comment for the button label.");
[self.myButton setTitle:buttonLabelString forState:UIControlStateNormal];
[self.myButton setTitle:buttonLabelString forState:UIControlStateHighlighted];
[self.myButton setTitle:buttonLabelString forState:UIControlStateDisabled];
[self.myButton setTitle:buttonLabelString forState:UIControlStateSelected];
</pre>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com2tag:blogger.com,1999:blog-3509978114633708798.post-48603275951764810542011-03-09T10:27:00.000-08:002011-03-09T10:27:25.465-08:00iPhone App: HT-SmartViewer Lite now in the AppStoreIts done. My first iPhone App made its way in the AppStore.<br />
<br />
<a href="http://itunes.apple.com/app/ht-smartviewer-lite/id423520311?mt=8" target="_blank">Get it for free now!</a><br />
<br />
The App is a Match Viewer and Statistics App for the free <a href="http://www.hattrick.org">Online Soccer Manager Hattrick</a>. We hope to get people to use it and participate in the process to make it a really great, fun and useful Hattrick App.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-K3sj-8sk3Qc/TXfGdY9_cmI/AAAAAAAANus/qCXhfLHNtXg/s1600/SmartViewer%2BHomescreen.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="400" width="267" src="http://2.bp.blogspot.com/-K3sj-8sk3Qc/TXfGdY9_cmI/AAAAAAAANus/qCXhfLHNtXg/s400/SmartViewer%2BHomescreen.png" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-csnF6r8kwdE/TXfGd04Y2EI/AAAAAAAANu0/-Lg2gtmJvcw/s1600/Watch%2BLive%2BMatch.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="400" width="267" src="http://1.bp.blogspot.com/-csnF6r8kwdE/TXfGd04Y2EI/AAAAAAAANu0/-Lg2gtmJvcw/s400/Watch%2BLive%2BMatch.png" /></a></div><br />
<br />
<br />
Languages supporter are right now English, German, French and Spanish. If you want to see it in a different language feel free to contact us.<br />
<br />
For feedback, news and more go to the <a href="http://www.ht-smartviewer.com" target="_blank">HT-SmartViewer Homepage</a> oder the <a href="http://www.ht-smartviewer.com/forum" target="_blank">HT-SmartViewer Forum</a>.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-5587952821935680132011-02-17T10:43:00.000-08:002011-02-17T10:43:38.829-08:00Objective C: Terminate App when pushing the Home button on iPhone/iPadTo make sure your iPhone or iPad App does not keep running in the background after you used the Home button, this is the way to go. Terminating the app helps saving resources on your device.<br />
<br />
<h3>1. Open your project in Xcode.</h3><br />
<h3>2. Find the Info-iPhone.plist or Info-iPad.plist file.</h3><br />
<h3>3. Left-click once on it to see the Key Value pairs.</h3><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-a-J2KqHtLmM/TV1sAakE7sI/AAAAAAAANsY/DqI1rzaBSec/s1600/Info-iPhone-plist-before.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="171" width="400" src="http://1.bp.blogspot.com/-a-J2KqHtLmM/TV1sAakE7sI/AAAAAAAANsY/DqI1rzaBSec/s400/Info-iPhone-plist-before.png" /></a></div><br />
<h3>4. Right-click on one of the entries and select Add Row.</h3><br />
<h3>5. As key enter UIApplicationExitsOnSuspend.</h3><br />
<h3>6. Right-click on the new row and select Value Type Boolean.</h3><br />
<h3>7. Check the value field.</h3><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-y0Y0Kf_7H_c/TV1sEGmIgEI/AAAAAAAANsg/8zpawHq3lLk/s1600/Info-iPhone-plist-after.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="35" width="400" src="http://4.bp.blogspot.com/-y0Y0Kf_7H_c/TV1sEGmIgEI/AAAAAAAANsg/8zpawHq3lLk/s400/Info-iPhone-plist-after.png" /></a></div><br />
Let me know if you have any trouble.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-87424243182111357282011-02-16T10:37:00.000-08:002011-02-16T10:37:09.943-08:00Objective C: alternating background color in UITableViewCell for iPhone AppsIn one of my iPhone Apps that has a UITableView I wanted to make the background color of the UITableViewCells alternating. Having two different colors in the background of the cells help to improve the readability. <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-Yrq5g8ff-70/TVwRm_4hmaI/AAAAAAAANrw/2EYrvYNqkuU/s1600/UITableView%2Balternating%2Bbackground%2Bcolor%2Bcells.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="200" width="134" src="http://3.bp.blogspot.com/-Yrq5g8ff-70/TVwRm_4hmaI/AAAAAAAANrw/2EYrvYNqkuU/s200/UITableView%2Balternating%2Bbackground%2Bcolor%2Bcells.png" /></a></div><br />
As you can see in the screenshot the odd cells are grey and the even cells are white.<br />
The changes need to be done in the DataSource method cellForRowAtIndexPath.<br />
<br />
<pre class="objc" name="code">- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"cell"];
if( nil == cell ) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"cell"] autorelease];
}
Fruits *fruit = [fruits objectAtIndex:indexPath.row];
cell.textLabel.text = fruit.fruitName;
//start of important code for background color changes
cell.textLabel.backgroundColor = [UIColor clearColor];
UIView *bgColor = [cell viewWithTag:100];
if (!bgColor) {
CGRect frame = CGRectMake(0, 0, 320, 44);
bgColor = [[UIView alloc] initWithFrame:frame];
bgColor.tag = 100; //tag id to access the view later
[cell addSubview:bgColor];
[cell sendSubviewToBack:bgColor];
[bgColor release];
}
if (indexPath.row % 2 == 0){
bgColor.backgroundColor = [UIColor colorWithRed:233.0/255.0
green:233.0/255.0
blue:233.0/255.0
alpha:1.0];
} else {
bgColor.backgroundColor = [UIColor clearColor];
}
//end of important code
return cell;
}
</pre><br />
Above is the whole method with all the additional code you need to get a white/grey background color alternation. <br />
<br />
Lets go through the main changes in detail:<br />
<h3>Make sure the cell text has a transparent background</h3><pre class="objc" name="code">cell.textLabel.backgroundColor = [UIColor clearColor];
</pre>This line makes sure your cell text has an transparent background, otherwise you end up with a result like in the screenshot below.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-_hy1N_Vif1A/TVwWzHmZveI/AAAAAAAANr4/RRD-929GQ7E/s1600/Cell%2Bwithout%2Btransparent%2Bbackground.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="139" width="200" src="http://4.bp.blogspot.com/-_hy1N_Vif1A/TVwWzHmZveI/AAAAAAAANr4/RRD-929GQ7E/s200/Cell%2Bwithout%2Btransparent%2Bbackground.png" /></a></div><br />
<h3>Create a view that holds the new background color</h3><pre class="objc" name="code">UIView *bgColor = [cell viewWithTag:100];
if (!bgColor) {
CGRect frame = CGRectMake(0, 0, 320, 44);
bgColor = [[UIView alloc] initWithFrame:frame];
bgColor.tag = 100; //tag id to access the view later
[cell addSubview:bgColor];
[cell sendSubviewToBack:bgColor];
[bgColor release];
}
</pre>First we check if the cell has already a view with tag id 100. If not, create a new view with the size of the cell(standard 320x44). Then the view gets add to the cell and send to the background.<br />
If the view exists we don't need to create it again.<br />
<br />
<h3>Set the color for odd and even cells</h3><pre class="objc" name="code">if (indexPath.row % 2 == 0){
bgColor.backgroundColor = [UIColor colorWithRed:233.0/255.0
green:233.0/255.0
blue:233.0/255.0
alpha:1.0];
} else {
bgColor.backgroundColor = [UIColor clearColor];
}
</pre>If the cell index is even (0, 2, 4, etc.) the background color of the background color view is set to grey. Else it is set to clear (white). <br />
If you want it to be the other way around use:<br />
<pre class="objc" name="code">if (indexPath.row % 2 == 0){
...
</pre><br />
Hope that helps. Please let me know if you have any problems or questions.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-74871019051475843402011-02-07T13:33:00.000-08:002011-02-07T15:23:27.746-08:00Objective C: Use Network Activity Indicator in iPhone Apps with GTMHTTPFetcherThe Google <a href="http://code.google.com/p/gtm-http-fetcher/">Toolbox HTTP Fetcher</a> (GTMHTTPFetcher) allows you to send synchronous and asynchronous HTTP request in iPhone/iPad Apps using Objective C/Xcode.<br />
<br />
Pretty common in those Apps is to display the network activity indicator during the request process.<br />
<br />
The below instructions should also work for other HTTP libraries, you just need to replace the observer names accordingly.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_YXaOUFCKil8/TVBeBA2SWhI/AAAAAAAANro/lcJL7RE7JkA/s1600/networkActivity.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="24" width="200" src="http://1.bp.blogspot.com/_YXaOUFCKil8/TVBeBA2SWhI/AAAAAAAANro/lcJL7RE7JkA/s200/networkActivity.png" /></a></div><br />
This is how you can do it. The example tutorial below shows how to add this functionality to the RootViewController, but it could be added to any ViewController. <br />
<br />
<h3>In the RootViewController.h</h3><br />
<pre class="objc" name="code">// RootViewController.h
#import <UIKit/UIKit.h>
@class GTMHTTPFetcher;
@interface RootViewController : UIViewController <UINavigationControllerDelegate> {
int networkActivityCounter;
...
}
- (void)startFetchingData;
- (void)fetchData:(GTMHTTPFetcher *)fetcher finishedWithData:(NSData *)retrievedData error:(NSError *)error;
@end
</pre><br />
Important here is the networkActivityCounter that will later hold the number of requests that are currently running.<br />
<br />
<h3>In the RootViewController.m</h3><br />
<pre class="objc" name="code">// RootViewController.m
- (void)viewDidLoad{
//add observer for fetcher start and stop events
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(incrementNetworkActivity:) name:kGTMHTTPFetcherStartedNotification object:nil];
[nc addObserver:self selector:@selector(decrementNetworkActivity:) name:kGTMHTTPFetcherStoppedNotification object:nil];
...
}
</pre><br />
First add the observers for the fetch start and stop events in the viewDidLoad method.<br />
<br />
<pre class="objc" name="code">#pragma mark Network activity
- (void)incrementNetworkActivity:(NSNotification *)notify {
++networkActivityCounter;
if (1 == networkActivityCounter) {
UIApplication *app = [UIApplication sharedApplication];
[app setNetworkActivityIndicatorVisible:YES];
}
}
- (void)decrementNetworkActivity:(NSNotification *)notify {
--networkActivityCounter;
if (0 == networkActivityCounter) {
UIApplication *app = [UIApplication sharedApplication];
[app setNetworkActivityIndicatorVisible:NO];
}
}
</pre><br />
The increaseNetworkActivity is called when a fetch requested started, when the counter is at 1 the indicator gets displayed. After when the counter gets increased it doesn't need to be activated anymore, its still running.<br />
<br />
Each time a fetch request has stopped the activity gets decreased, at 0 activity the indicator gets invisible.<br />
<br />
<pre class="objc" name="code">- (void)dealloc {
//remove the observer
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self];
...
[super dealloc];
}
</pre><br />
Don't forget to remove the observer when not needed anymore.stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com0tag:blogger.com,1999:blog-3509978114633708798.post-67366453030736428452011-01-14T04:29:00.000-08:002011-05-13T09:46:06.754-07:00Objective C: Remove certain characters from NSStringSometimes when you work in Xcode in the Cocoa Framework you want to filter a NSString so that only certain characters are left. That can be numbers or letters or special characters. Following code snippet can do that for you.<br />
<br />
<pre class="cpp" name="code">//the String with the original text
NSString *unfilteredString = @"The sum of 1 + 2 = 3.";
//initialize a string that will hold the result
NSMutableString *resultString = [NSMutableString stringWithCapacity:unfilteredString.length];
NSScanner *scanner = [NSScanner scannerWithString:unfilteredString];
//define the allowed characters, here only numbers from one to three, equal and plus
NSCharacterSet *allowedChars = [NSCharacterSet characterSetWithCharactersInString:@"123+="];
while ([scanner isAtEnd] == NO) {
NSString *buffer;
if ([scanner scanCharactersFromSet:allowedChars intoString:&buffer]) {
[resultString appendString:buffer];
} else {
[scanner setScanLocation:([scanner scanLocation] + 1)];
}
}
//Print out the result String, will be 1+2=3
NSLog (@"Result: %@", resultString);
</pre>stphnhttp://www.blogger.com/profile/01031559330515056587noreply@blogger.com1