Wednesday, August 6, 2014

How to save to a text file in Python

Saving to a text file can be very useful when database access is restricted and data needs to be saved.

In Python, this can be accomplished with just a few lines of code.

file = open('MyText.txt','w')
file.write("Name\nAddress\n")
file.close()


Now, if you check the file directory, your file will be there.

Check out my car app for iPhone in the iTunes App Store

Thursday, July 31, 2014

Orientation tutorial with JQuery

Detecting a device's orientation change is very useful when an image has to change or other event is necessary when designing a mobile site or building an app.

All that is necessary is just a few lines of code.

$(window).bind('orientationchange',function(e) {

    switch(window.orientation) {

         case 0:
              alert("device rotated");
         break;
         case 90:
              alert("device rotated again");
         break;
         case -90:
              alert("device rotated yet again");
         break;


}


});


Check out my new car app for iPhone in the iTunes App Store

Tuesday, July 29, 2014

How to open email program within iPhone app

Sometimes within an iPhone application, it might be necessary to open the phone's default email client.

In order to do this, all you need are just a few lines of code.

First, create your method in the header file.

-(IBACTION)openEmail;

Next, build it out in the implementation file.

-(IBACTION)openEmail {

[[UIApplication sharedApplication]openURL;[NSURL URLWithString:@"mailto:test@test.com"]];


}

That's it.

Check out my car app for iPhone in the iTunes App Store

Saturday, July 26, 2014

How to change UIButton text for iPhone app

Although it's very simple, most developers new to the iPhone SDK wonders how to change the UIButton text with Xcode and not just in interface builder.

Well, I will show you how below.

In your header file create an instance of UIButton.

@property(nonatomic,retain)IBOutlet UIButton *button1;

Next, go to your implementation file.

@synthesize button1;

With the viewDidLoad method the text can be changed with the following code:

[button setTitle:@"About Us" forState:UIControlStateNormal];

I hope this helps. Have a great weekend!

If you get a chance, please check out my car app for iPhone in the iTunes App Store.

Friday, July 25, 2014

How to set a cookie in PHP

Setting a cookie in PHP is very easy and takes just a few lines of code.

If you are authenticating a username, you could use this code below to set a cookie.

<?php

$username = $_POST["username"];

if ($username == "test") {

setCookie("cookietest");
echo "You are logged in";

} else {

echo "Please try again";

}

?>

I hope this helps your general knowledge of how to set a cookie in PHP

Check out my car information app if you get a chance


Tuesday, July 22, 2014

Duck hunting game for iPhone

Duck season is now year round! At least, it is for those who download Bayou Duck Hunter. This exciting game tests your preparation, timing and shooting skills along beautiful landscapes. Bayou Duck Hunter contains multiple levels for those skilled enough to move past the beginner stage. Bayou Duck Hunter also uses terrific sound effects to enhance the user hunting experience. After completing the bonus round, see how your score ranks against other players. Download today and make every day a part of hunting season!

Duck hunting game for iPhone in the iTunes App Store

Monday, July 21, 2014

PHP functions tutorial

Below is a brief tutorial on how to use PHP functions. The purpose of functions is to run a series of statements without having to duplicate the code several times. This makes your program neater and easier to interpret.

Here is an example:

<?php

class test {

public function hello() {

echo "hello world";

}

}

$test1 = new test;

$test1->hello();

?>

Your browser should read 'hello world'.

Check out my car info app in the iTunes App Store


Wednesday, July 16, 2014

How to create SoundPool in Android

Below is a brief tutorial on how to add a SoundPool to an Android activity.

Declare SoundPool at the top of activity and create an instance.

SoundPool sound1;
int mysound = 0;

Within onCreate Method, add the following code.

sound1 = new SoudPool(5,AudioManager.STREAM_MUSIC,1);
mysound  = sound1.load(this,path to file,1);

Next, within your onClickListener event, add the play action.

sound1.play(mysound,1,1,0,0,1);

That's it. Thanks for visiting.

Click here for Car information app

Tuesday, July 15, 2014

How to create a counter in JQuery

Below is a tutorial on how to create a counter with JQuery.

A counter can be useful when you want an event to take place within a certain time frame. For instance, you want your visitors to see a message after 10 seconds. That's what this tutorial is going to focus on.

First, add your JQuery library.
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">

function counter(time) {

var interval = setInterval(function() {

time = time - 1;
$("#container").html("Seconds Remaining: " + time);

},1000);

}

$(document).ready(function() {

counter(10);


});

</script>

<div id="container"></div>

I hope this tutorial on creating a timer in JQuery has been helpful. Check out my latest car info app.

Monday, July 14, 2014

iPhone Camera app tutorial

Below is a brief tutorial on how to launch the camera application from with your iPhone app. Once the image is stored, you can do anything you want with it inside your application.

The first step is adding the following code within your button:

UIImagePickerController *myPicker = [[UIImagePickerController alloc]init];
picker.allowsEditing = YES;
picker.sourceType =  UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
[self presentViewControllerAnimated:picker Completion:NULL];

Once adding this within your button method, the Camera app will launch.

Check out my car app if you get a chance in the iTunes App Store.

Saturday, July 12, 2014

How to pull data from MySql Database

This brief tutorial will explain how to pull data from a MySql Database. This is useful in the event you have had visitors complete data from a feedback form or imported information through another method.

The first step is connecting.

mysql_connect("localhost","username","password");
mysql_select_db("databasename");

Then, build your query.

$query = "select * from tablename";

$results = mysql_query($query);

while($row=mysql_fetch_array($results)) {

$field1 = $row["name"];

echo $field1 . "<br/>";

}

I hope this tutorial was useful. Please check out my new car app for iPhone if you get a chance

Thursday, July 10, 2014

How to create a popup window after clicking link

One of the most basic, but useful javascript functions is creating a resizeable popup window without a toolbar.

Just use the following code:

<a href="javascript:void() onclick="open('url','title of window','width=640,height=400,resizeable=true,toolbars=0'>Test link </a>

I hope you find that useful. See you next time!

In the meanwhile, check out my new car app for iPhone

Car Info app for iPhone

Car and Truck Facts with Trivia is the ideal app for automobile enthusiasts, who enjoy learning about and looking up car information. This app allows users to retrieve recall information and lookup car specs based on year, make, model and trim. Car and Truck Facts with Trivia has a section dedicated to the safety ratings of almost every automobile. This app contains an extensive and fun trivia game. If that isn't enough, this app uses your geolocation to find nearby gas stations sorted by lowest gas price average. Not only can users make informative decisions about future car purchases, but one will learn about features of his or her current car or truck. Download today and share your knowledge with friends and colleagues tomorrow!

Download from iTunes App Store

Wednesday, July 9, 2014

How to change background color of view in iPhone app

Being able to change the background color of a view in an iphone app can be useful for many reasons. Whether you want to indicate an action or just match other images after an action is taken.

First, in your header file, create a method for your button click. Use the following code:
-(IBACTION)buttonClick:(sender);

Now, in the implementation file, add the following code:

-(IBACTION)buttonClick:(sender) {

[self.view.backgroundcolor colorBlue];


}

Where color blue is, you can add any color from the UIColor class.

Thanks for visiting and check out my car app for iPhone

Tuesday, July 8, 2014

How to create a Session variable with PHP

Creating session variables in PHP can be a useful to transfer data from page to page without having to ask visitors for the same information.

A session can be created with the following code:

<?php

session_start();

$name = $_SESSION["name"];

<input type="hidden" name="name-var" value="<?php echo $name; ?>"/>

<button>Continue</button>

Check out my new app about car and truck information

Monday, July 7, 2014

How to make a Toast in Android

The tutorial below is how to create a Toast in an Android application. It's very simple, but very useful. In order to display text for a short period of time and have it disappear, you can use Toast. Please see code below as an example.

Toast.makeText(this,"Hello world",Toast.length_short).show();

That's it!

Check out my latest car app if you get a chance

Saturday, July 5, 2014

How to set a cookie in PHP

A common way to capture useful information about your visitors is to track with cookies. In PHP, it's extremely easy.

Let's say, you want to capture information from a login and want to authenticate. You could use similar code to this.

$name = $_POST["form_name"];
$password = $_POST["form_pass"];

Next, compare it to other variable values to see if they match. Ideally, you would connect to mysql server and compare, but for brevity sake, we'll just use variable values.

$db_name = "db-name";
$db_pass = "db-pass";

if (($name == $db_name) && ($password == $db_pass)) {

setcookie("your_auth","Successful");

}

That's it! Next time, we'll go over $_COOKIE variable and how that let's you capture the values.

Check out my car info app if you get a chance

Friday, July 4, 2014

Interested in cars

If you are in to cars, check out my latest blog at http://carandtruckinformation.com . I will be posting everyday information regarding reviews, technology and recall information. Also, I can be found at Facebook at http://www.facebook.com/carandtruckinformation .

Happy 4th of July!

How to make an AlertDialog on Android

The post below will display how to create an AlertDialog in an Android app.

Within the onCreate method, under setContentView, add the following code:

AlertDialog alert = new AlertDialog.Builder(YourActivity.this).create();
alert.setTitle("Hello world");
alert.setMessage("My message");
alert.setButton("Button name",new DialogInterface.setOnClickListener() {

add what you want your button to do in this block

};

alert.show();

Although, AlertDialog is now deprecated, it will still work in Ice Cream Sandwich and above.

Happy coding!

Check my latest car app by clicking here

Car app for iPhone

Car and Truck Facts with Trivia is the ideal app for automobile enthusiasts, who enjoy learning about and looking up car information. This app allows users to retrieve recall information and lookup car specs based on year, make, model and trim. Car and Truck Facts with Trivia has a section dedicated to the safety ratings of almost every automobile. This app contains an extensive and fun trivia game. If that isn't enough, this app uses your geolocation to find nearby gas stations sorted by lowest gas price average. Not only can users make informative decisions about future car purchases, but one will learn about features of his or her current car or truck. Download today and share your knowledge with friends and colleagues tomorrow!

Car app for iPhone

Tuesday, June 24, 2014

Car and Truck Fact app Coming Soon

An exciting new app has been submitted and will be under review soon.

Car and Truck Facts with Trivia is the ideal app for automobile enthusiasts, who enjoy learning about and looking up car information. This app allows users to retrieve recall information and lookup car specs based on year, make, model and trim. Car and Truck Facts with Trivia has a section dedicated to the safety ratings of almost every automobile. This app contains an extensive and fun trivia game. If that isn’t enough, this app uses your geolocation to find nearby gas stations sorted by lowest gas price average. Not only can users make informative decisions about future car purchases, but one will learn about features of his or her current car or truck.

Full Story