Every developer wants to build the next instagr.am and sell it to Facebook for 1Billion dollares ;)
Why not start today?
Please notice that myCustomMethod invokes the UIImagePickerController directly and this will lead to a memory leak. You should place the imagePicker in the header file and release it in the dealloc method! While where on it, please include UINavigationControllerDelegate and UIImagePickerControllerDelegate reference in the header file.
-(void)myCustomMethod
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
NSLog(@"user cancel");
[self dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *pickedImage = [[info objectForKey:UIImagePickerControllerOriginalImage] retain];
UIImageWriteToSavedPhotosAlbum(pickedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil );
[self dismissModalViewControllerAnimated:YES];
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
if (error) {
NSLog(@"Unable to save image to Camera Roll");
} else {
NSLog(@"Image saved to Camera Roll");
}
}
A very good way of displaying extra options or any action confirmation, its using UIActionSheet.
In the header (.h file) make a reference to UIActionSheetDelegate.
Demo.h
@interface Demo : UIViewController <UIActionSheetDelegate>
{
}
@end
Next, in the Demo.m
-(void)someMethod:(id)sender
{
UIActionSheet *actionsheet = [[UIActionSheet alloc]
initWithTitle:@"This is a title"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Item 1", @"Item 2", nil];
[actionsheet showInView:[self view]];
[actionsheet release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"button %i clicked", buttonIndex );
}
var obj = {x:100, y:0, z:-15, alpha:1};
for (var key in obj)
{
if (obj.hasOwnProperty(key))
{
console.log("the property " + key + " has the value of " + obj[key]);
}
}
I was pretty happy with my mediatemple (gs) server until I wanted to play with HTML5 websockets and I had to install node.js!
So, I decided to upgrade to a (ve) server. If your a mediatemple owner and you want to start building and hosting your own websocket applications, please keep reading!
If your not familiarized with command line language, don’t worry, neither was I until I had to learn it! (not that hard, thanks to google!)
So, the first thing to do is to login to your website via ssh (you can use putty if your on windows, or you can use the terminal if your on a mac).
1) Connect, update and install Lamp
Log in to your (ve) Server as root or another user with sudo privileges. Please use your server ip instead of 205.186.163.156
Make sure your server is up to date
apt-get upgrade
Next we are going to install LAMP on our server. After the process is complete you will be asked to set the root MySQL password.
2) Configure your website
Now that you completed your LAMP install, we need to add some websites using virtual entries. This will allow you to host multiple sites using the one IP address that comes with your (ve) Server. If your new to command line language I recommend you to use the pico editor, it makes your life easier!
Now, lets go editing our first file using the command line! First, go to the directory of apache, and then edit “ports.conf” file
sudo nano ports.conf
In this file, you should change the NameVirtualHost line to include your own IP address which you can easily find in your AccountCenter Server Guide. Make sure you are listening on port 80 as well.
# If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default # This is also true if you have upgraded from before 2.2.9-3 (i.e. from # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and # README.Debian.gz NameVirtualHost 205.186.163.156:80 Listen 80 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. Listen 443 <IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule>
Now you need to change the default file in the sites-available directory to allow us to configure multiple sites.
<VirtualHost 205.186.163.156:80>
ServerName andrevenancio.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Now lets restart the apache server using this command
You should now be able to see the default page on your website!
3)Install Node.js
There are a few options out there for using websockets, but I prefered to go along with node!
First install the dependencies
sudo apt-get install git-core
cd node
./configure
make
sudo make install
And thats it! You should now have node installed on your system! Lets test it out! Open your favorite editor and save this into hello_node.js
var http = require('http');
http.createServer(function (req, res)
{
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
save this into your /var/www/ folder and then in command line utility run:
node hello_node.js
You should see a message saying: “Server running at http://127.0.0.1:8124″ and if you use your browser to access that link you should see your “Hello Node.js” message
And thats it! Have a look at this website for some node resources!

