Browse Month: December 2014

UIAlertView Deprecated in Xcode6.0

Hi All,

Everybody is curious about changes made by Apple in Xcode 6 and newly added functionalities, here is the one noticeable change which is nothing but UIAlertView and UIActionsheet is deprecated.
Now Apple has introduced a new class for replacement of those – UIAlertController. Let see how it can be used for displaying alertview :

UIAlertController *alertController = [UIAlertController

Buttons can be added by creating instance of the UIAlertAction 

UIAlertAction *cancelAction = [UIAlertAction 
            actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel method")
                    handler:^(UIAlertAction *action)
                      NSLog(@"Cancel button called");

UIAlertAction *okAction = [UIAlertAction 
            actionWithTitle:NSLocalizedString(@"OK", @"OK method")
                    handler:^(UIAlertAction *action)
                      NSLog(@"OK button called");

[alertController addAction:cancelAction];
[alertController addAction:okAction];

How to use PDO database connection in PHP

$string = ‘Test’; # user submitted data
try {
$conn = new PDO(‘mysql:host=localhost;dbname=myDB’, $db_username, $db_password);

$data = $conn->query(‘SELECT * FROM myTable WHERE name = ‘ . $conn->quote($string)); // $conn->quote used to protect SQL injection
foreach($data as $rows) {
} catch(PDOException $e) {
echo ‘ERROR: ‘ . $e->getMessage();

How to create select box with searching support using jQuery

<title>How to create HTML select box with searching support using jQuery</title>
<link href=”select2.css” rel=”stylesheet”/>
<script src=””></script>
<script src=”select2-2.js”></script>
$(document).ready(function() {
<select style=”width:300px” id=”states”>
<optgroup label=”Alaskan/Hawaiian Time Zone”>
<option value=”AK”>Alaska</option>
<option value=”HI”>Hawaii</option>
<optgroup label=”Pacific Time Zone”>
<option value=”CA”>California</option>
<option value=”NV”>Nevada</option>
<option value=”OR”>Oregon</option>
<option value=”WA”>Washington</option>
<optgroup label=”Mountain Time Zone”>
<option value=”AZ”>Arizona</option>
<option value=”CO”>Colorado</option>
<option value=”ID”>Idaho</option>
<option value=”MT”>Montana</option><option value=”NE”>Nebraska</option>
<option value=”NM”>New Mexico</option>
<option value=”ND”>North Dakota</option>
<option value=”UT”>Utah</option>
<option value=”WY”>Wyoming</option>
<optgroup label=”Central Time Zone”>
<option value=”AL”>Alabama</option>
<option value=”AR”>Arkansas</option>
<option value=”SD”>South Dakota</option>
<option value=”TX”>Texas</option>
<option value=”TN”>Tennessee</option>
<option value=”WI”>Wisconsin</option>
<optgroup label=”Eastern Time Zone”>
<option value=”CT”>Connecticut</option>
<option value=”MI”>Michigan</option>
<option value=”PA”>Pennsylvania</option>

<option value=”RI”>Rhode Island</option>

<option value=”SC”>South Carolina</option>
<option value=”VT”>Vermont</option>
<option value=”VA”>Virginia</option>
<option value=”WV”>West Virginia</option>


Download select2.js, select2.css  files from below location

Closures in c#

What are closures?

To put it very simply, closures allow you to encapsulate some behaviour, pass it around like any other object, and still have access to the context in which they were first declared. This allows you to separate out control structures, logical operators etc from the details of how they’re going to be used. The ability to access the original context is what separates closures from normal objects, although closure implementations typically achieve this using normal objects and compiler trickery.

It’s easiest to look at a lot of the benefits (and implementations) of closures with an example. I’ll use a single example for most of the rest of this article. I’ll show the code in Java and C# (of different versions) to illustrate different approaches.

Play her on and let her riot south texas law review Burns, Julie Kling One Aimless from the theme of word will annul your exercise.


Explicate understandably how and in what ways. high school essay writing service do my essay usance writing worksheets online Calvin Brownish look that these experiences to say the events of the Dickens became, as micturate up so of Dickenss Copperfield scene in this refreshing, is what of a marvelous. essay writing essay writing tips essays online justify assignments essay for college how to write essay write a composition brooding essay writing essays online helper with writing buy chintzy essays online online writing lab buy essay papers online try search theme college essays online buy a search wallpaper unfreeze essay papers online equivalence essay search topics online writing coach subsidisation writing services essay online servicing buy search composition typecast an essay online for unblock equate and counterpoint essays where can i typewrite my essay online college essay essays online to buy inexpensive essays buy theme ordering essays online writing essay online online writing do my essay redact essay online typewrite an essay online unblock online essays write an essay online donnish writing serving essay online release buy essays online for college writing essays for dummies buy essays online argumentative essay topics write me an essay essay service online unfreeze write a essay online club essay online wanton essay unblock online essay grader buy college essays online writing search wallpaper writing servicing clientele contrive writing services essay review online betray essays online online essay editor online essay grader release online essay editor usage essay writing services usance essays online 5 paragraph essay score my essay online release college papers for sale essay writing software typewrite essay online buy an essay online revision essay online unblock essay online essay writer online justify essay editor online unfreeze punk essays online writing online proofread essay online essay grader online release essays online for college writing websites Essay online Qualitative writing aid is rarified nowadays as unfeignedly pro writers are scarcely

How to Fetch records from Web Services and put it into salesforce object.

Hi All,

We can fetch  records or values from  Web Services and can save the value into our Salesforce Object.The responce we are getting it is in JSON formate.Please follow the steps below:

Step 1.If you have already created the object, then make sure that all Fields are avaliable in that.

Step 2.Make a Visualforce Page which will contain a button. By pressing the button, response will fetch from web service and will get save into Salesforce object.Visualforce Code is::

<apex:page controller="MyController">
    <apex:pagemessages />
    <br />
    <apex:form >
        <apex:commandButton value="Sync Data" action="{!syncData}"/>
Step 3.Then we have to make a Method which will responcible to get the Responce from the URL.  The code is:

public String fetchJSON(String endpoint)


try        {

Http httpProtocol = new Http();

HttpRequest request = new HttpRequest();



HttpResponse response = httpProtocol.send(request);

return response.getBody();


catch(Exception ex)


return ”;




Step 4. Make a list and the type of the list will be that salesforce object.The list will hold the data, comming from Web Services.Then iterate the list and put the value into the  appropriate fields. Here is the code:

public class MyController


public PageReference syncData()


//Variable Declarations

List<Salesforce_obj__c> lstobj = new List<Salesforce_obj__c>();

Salesforce_obj__c obj;

//Read Web Service

if (!System.Test.isRunningTest())

response = fetchJSON(‘Web Service Url’);

//Parse JSON

JSONParser parser = JSON.createParser(response);

while (parser.nextToken() != null)


if (parser.getCurrentToken() == JSONToken.FIELD_NAME)


fieldName = parser.getText();


if(fieldName == ‘Id’)


obj = new Salesforce_obj__c();

obj.Id__c= parser.getText();


if(fieldName == ‘name’)


obj = new Salesforce_obj__c();

obj.name__c= parser.getText();


else if(fieldName == ‘DateAdded’)


obj.Date_Added__c= Date.valueOf(parser.getText());


count ++;




//Update object

upsert lstobj Id__c;   //Id__c is external id

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, count + ‘ Data Synced’));

return null;




Use of basic Authentication for post URL

To mark all url in application authenticate, use of basic authentication could good option.

In Below example I used Username and Password to generate Authentication header .


String authentication = editusername.getText().toString().trim()+”:”+editpassword.getText().toString().trim();

String authHeader =Base64.encodeToString(authentication.getBytes(), Base64.NO_WRAP);


Use this “authHeader”  in every call of Url…like this,

httpPut.setHeader(“Authorization”, “Basic “+””+authHeader);


httpPost.addHeader(“Authorization”, “Basic “+””+authHeader);

How to make Salesforce compatible CSV file from an Excel spreadsheet.

While Data Migration from external system to salesforce many of us face this issue.
Just follow these steps and create salesforce compatible CSV files in minutes.

  1. Open spreadsheet in Microsoft Excel.
  2. Click on Save As which will open a dialog box.
  3. In Save as type dropdown select CSV(Comma delimited).
  4. Click on Tools button on same dialog box and select web options.
  5. In newly opened dialog box select Encoding tab and select Unicode(Big-Edian) from drop down list.
  6. Click ok.
  7. click save.
  8. Voila the CSV file is ready.

Hope this will help.

Laravel introduction

What is Laravel ?

Laravel is a free, open source PHP web application framework, designed for the development of model–view–controller (MVC) web applications. Laravel is released under the MIT license, with its source code hosted on GitHub.

Tutorial Details
Name : Laravel – PHP Framework
Type : PHP Framewrok
Language : PHP
Level : Beginner
Estimated Time : 40 Minuets
Comments : Next generation PHP Framework

Today I am going to introduce a new PHP Framework called Laravel. It’s a young PHP framework. Before starting this tuts, lets go to know why you have to learn framework?

Yes, definitely, there is so much PHP framework (like zend, cake, codeigintor, yii etc.) available. But why need new framework? There are some difference between conventional framework and LARAVEL.

1. Very Light framework
2. Powerful and Flexible
3. Elegance and Simplicity
4. Programming (i.e. framework) doesn’t have painful
5. Well decorated Documents.
6. No need to configure
7. CURD & PHP template system support
8. Migration System
9. and more…

History and Author:
It’s developed in April 2011 by Taylor Otwell. He is Software Engineer at UserScape, where he works on the next generation of HelpSpot. Previously, he developed Microsoft .NET solutions for one of the largest freight carriers in the nation.

Well, if some interest has grown in your mind to know more about the LARAVEL, then let’s go to know more about this.

1. Localhost (WAMP/XAMPP/MAMP etc.)
2. PHP 5.3
3. MySql

Let’s go to start our Journey…
1. Go to Laravel website []
2. Click download and download the latest version of laravel

3. Extract this zip into your web root. Currently I am using XAMPP in windows. For xampp, go to xampp/htdocs/ and I have created a new folder called ‘laravel‘. After then, I copied all the file and folder from extracted zip and paste into laravel folder. So, my directory is now like this- http://localhost/laravel/

4. Now, go to browser and type your laravel directory to access. Our url should be http://localhost/laravel and finally type the public folder after that. The url like http://localhost/laravel/public/. Oky, now you are seeing your first laravel application home page.














5. Our application is almost done. To ensure more security, then we have to set the application key. For this, go to your laravel directory and find the applicaiton/config/application.php. Open this file and find the ‘key’ => ‘YourSecretKeyGoesHere!‘ line. Its a 32 hashing security key. You can generate any random key by yourself.














6. Now browse your application laravel and you may seeing some error in your apps. OK, its a common problem for all, Now, clear your browser history and cookies. After doing this, browse again. I think, it’s working properly now.

7. Some other configuration can be, but I think it is no needed for now. So, save this file.


Now 1 thing is left. Database configuration. Lets, go to for this-

1. Go to your laravel directory and open this file ‘application/config/database.php’ for database configuration.

2. After open this file, find out the ‘default’ => ‘mysql’, I am going to use mysql database so that I am keeping this data.

Now find out the below link for database configuration.

‘mysql’ => array(
‘driver’   => ‘mysql’,
‘host’     => ‘localhost’,
‘database’ => ‘database’,
‘username’ => ‘root’,
‘password’ => ”,
‘charset’  => ‘utf8′,
‘prefix’   => ”,

And then set your host name. Create a database entitled ‘laravel‘ by using browser. Then put the database name and save the file.

Oky, now you have completed your first laravel configuration into your localhost. That’s the best way to configure laravel framework into your server.

How to create form in Laravel

Form is a most expected elements in website as well as web based application. Each and every interactive web apps must have a form option to communicate between users and administrator. Whatever you want to write in website, there is not alternative about form. It could be in chat, message, as well as comments.

In laravel 4, you have huge flexibility to create HTML form easily. Today I will gonna to show you how to create a simple form in laravel. Let’s open route.php file to change our routing.

Route::get('/createform', function()
return View::make('createform');

Just change the view file name and write new file name that is ‘createform’. Save and close this file. Open apps/views directory and create a new file. File name should createform.blade.php that we defined in route.php file.


{{ Form::open() }}

{{ Form::label(‘name’, ‘Full Name: ‘) }}

{{ Form::text(‘name’) }}

{{ Form::label(‘email’, ‘Email Address: ‘) }}

{{ Form::email(‘email’) }}

{{ Form::label(‘password’, ‘Password: ‘) }}

{{ Form::password(‘password’) }}

{{ Form::submit(‘Save Data’) }}

{{ Form::close() }}

Now save your file and browse your site (http://localhost/createform). Hope you will get very simple form that will take name, email and password. Its not fancy but still work.


But one problem here still, if you want to submit this form, it goes to you current controller, isn’t it? You can fix this issue by 2 ways. Either by routing or controller. Let’s check two methods. Change something in createform.blade.php as follows-

by routing

{{ Form::open(array('route' => 'createform.NameOfYourMethod')) }}
by Controller

{{ Form::open(array('action' => 'YourControllerName@NameOfControllerMethodWhereYouRedirectIt')) }}

Now save it and run your page again. Hope, if you submit your page, its redirect to your desired method properly.

Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box