Tuesday, September 22, 2015

Bash - Get output after matching line

$ cat file.txt
line 1
line 2
this is the line
line 4
line 5

If you want lines starting from "this is the line"

$ cat file.txt | awk '/this is the line/{ f=1; } f'
this is the line
line 4
line 5

When the line is found, set f to 1.
The last 'f' is shortcut to 'f == 1 { print }'

If you want output after the matching line

$ cat file.txt | awk '/this is the line/{ f=1; next; } f'
line 4
line 5

Saturday, August 01, 2015

Get celery init.d scripts

Downloads init.d scripts (celeryd and celerybeat) for your installed version.
Also accepts APP_NAME as an argument. Saves the files as celeryd-<app_name> and celerybeat-<app_name>


Install Redis inside virtualenv

Just run this script.
Puts the redis.conf in ${VIRTUAL_ENV}/etc/redis.conf.
Adds a wrapper redis-server-ve to use this conf by default.

Defaults to stable release. Else pass the version as an argument.


Monday, October 27, 2014

Packer vmware-iso on Ubuntu 14.04 with VMware Player 6

VMware build can be done with packer on Ubuntu using VMware Player 6.

Download VMware Player 6 from:
https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0|PLAYER-603|product_downloads

Also, click on Driver & Tools and download the correct version of VIX.

e.g.
$ wget https://download3.vmware.com/software/player/file/VMware-Player-6.0.3-1895310.x86_64.bundle
$ chmod +x VMware-Player-6.0.3-1895310.x86_64.bundle
$ sudo ./VMware-Player-6.0.3-1895310.x86_64.bundle

$ wget https://download3.vmware.com/software/player/file/VMware-VIX-1.13.3-1895310.x86_64.bundle
$ chmod +x VMware-VIX-1.13.3-1895310.x86_64.bundle
$ sudo ./VMware-VIX-1.13.3-1895310.x86_64.bundle

$ sudo apt-get install qemu-utils

$ packer build vmware.json

If you see errors like vmware or vmrun not in $PATH, VIX was not installed properly.

If you see errors like "specified version not found", incorrect version of VIX was installed.

If you see qemu related errors, qemu-utils was not installed.

vmware-iso only outputs the vmware instance as .vmx along with other files.


To export to ovf/ova format
$ ovftool appliance.vmx appliance.ovf
$ ovftool appliance.vmx appliance.ova

Thursday, July 18, 2013

VMware Fusion - Permissions on Shared Folders on Ubuntu

VMware Fusion provides a nice functionality of sharing folder from host (Mac OSX) to guest (Ubuntu). But then, it seems they are more focused on windows guests, because they screwup on file permissions of shared folders.

"ls -al /mnt/hgfs" will show 501 dialout as user and group, which is sure to cause permission issues on linux guest.

Update: Found a more persistent alternative
1. sudo vim /etc/vmware-tools/services.sh
2. Search for 'vmhgfs_mnt="/mnt/hgfs"'. After this line add: 'vmuser=${VMWARE_MNT_USER:-root}'
3. Then search for 'vmware_exec_selinux "mount -t vmhgfs .host:/ $vmhgfs_mnt"' and replace it with following section:
   uid=`id --user $vmuser`
   gid=`id --group $vmuser`
   vmware_exec_selinux "mount -t vmhgfs .host:/ $vmhgfs_mnt -o uid=$uid,gid=$gid"
4. sudo vim /etc/init/vmware-tools.conf
Before the "pre-start" and "post-stop" lines add:
env VMWARE_MNT_USER=[The guest user you want]
5. sudo reboot

NOTE: This will have to be redone when you update/ reinstall vmware-tools

To fix this:
ssh to your ubuntu.
run command "id". Make note of uid and gid.
"sudo vim /etc/mtab"
look for line ".host:/ /mnt/hgfs vmhgfs rw,ttl=1 0 0"
Duplicate the line and change it to ".host:/ /mnt/hgfs vmhgfs rw,ttl=1,uid=1000,gid=1000 0 0"
"sudo umount /mnt/hgfs"
"sudo mount /mnt/hgfs"

Now do a "ls -al /mnt/hgfs" to verify if correct username and group are shown.

Ideally, vmware fusion should be making this as transparent as possible. But then again, they don't care because they still don't have a real competition. Once, we do some real competitors, maybe then might start worrying about such minor but key items.

Currently, I spend more time trying to get it working than actually working on a VM. I am desperately looking for a better alternative.

This seems like a pretty neat fix. On the sharing screen, VMWare could add a simple textbox for user name and next time vmware tools are installed, use this value while generating the vmware-tools.conf file.

Not sure when VMWare will take note of such minor issues.

Tuesday, May 07, 2013

error in setup.cfg: command 'nosetests' has no such option 'with_pylons'

When running nosetests, if you see error in setup.cfg: command 'nosetests' has no such option 'with_pylons' or Error reading config file 'setup.cfg': no such option 'with-pylons', it could be because you have Pylons==1.0* installed. Pylons==1.0* does not register itself as a nose plugin (https://github.com/Pylons/pylons/issues/13). Use following work arounds:
  1. For "python setup.py nosetests":
    Add the following to your projects "setup.py -> entry_points" and ".egg-info/entry_points.txt"
        [nose.plugins]
        pylons = pylons.test:PylonsPlugin
    
  2. For "nosetests --version":
    sudo vim `which nosetests`
    
    Make it look something like:
    #!/usr/bin/python
    # EASY-INSTALL-ENTRY-SCRIPT: 'nose==1.3.0','console_scripts','nosetests'
    __requires__ = 'nose==1.3.0'
    import sys
    from pkg_resources import load_entry_point
    
    addplugins = []
    
    try:
        import pylons
        if pylons.__version__[0] == '1':
            from pylons.test import PylonsPlugin
            addplugins.append(PylonsPlugin())
    except ImportError:
        pass
    
    if __name__ == '__main__':
        sys.exit(
            load_entry_point('nose==1.3.0', 'console_scripts', 'nosetests')(addplugins=addplugins)
        )
    
    now you should be able to run it as nosetests --version

Friday, April 19, 2013

Working with multiple Python projects

While working with multiple Python projects, you might soon realize you need different versions of the same Py package or packages are conflicting between multiple projects.
VirtualEnv to your rescue.
But once you go through the docs, install and start using virtualenv, you might soon realize it is a little cumbersome.
  1. You need to provide the complete path where you want to save your virtualenv environment folder. virtualenv proj1 will just create the env in your current directory. If you are using a long path to store your envs, it might be a pain to put it in every-time.
  2. To activate an env, source <path-to-envs>/proj1/bin/activate
  3. To find all envs, you have to ls <path-to-envs>. But this works only if you have all yours envs in a single place.
Don't worry, VirtualEnvWrapper is here to help you.
Now you have a wrapper which provides you some shortcuts to the virtualenv commands. But it doesn't end there. VirtualEnvWrapper provides you with the an extension system.
ls $WORKON_HOME and you will find files starting with "post" and "pre". These are simple shell scripts. You can add your commands to these scripts and they will be everytime you run one of the commands.
It doesn't end there. You can also have separate extensions for each of your env. ls $WORKON_HOME/proj1/bin/ should show some similar files starting with "post" and "pre". For eg. To go to your source folder when you activate your env, just add "cd to "postactivate"
All said and done, one thing that might trouble you is figure out what packages are available in your current env?
Yolk will prove useful here. Remember, you can write extensions in wrapper. Just add pip install yolk to "$WORKON_HOME/postmkvirtualenv" and yolk will be installed on all new virtual envs created automatically. You can then activate your env and just use yolk -l to list packages available in that env.
Not much time for formatting. Will do it later.

Wednesday, April 03, 2013

Install CyanogenMod 10.1 (JellyBean Android 4.2.2) on Samsung S2 Skyrocket

Before you begin:

  • You NEED a windows machine (atleast as of now) for odin.
  • Download using Chrome/ Firefox to avoid issues with tar/ md5 downloads.
  • Read all steps before you start anything.

5 simple steps:

  1. Download CyanogenMod 10.1 and gapps, copy it on the internal external SD card
  2. Download and run odin on Windows machine
  3. Download and install TWRP using Odin
  4. Boot in recovery and install the ROM using TWRP
  5. Install gapps using TWRP

Lets get going:

  1. CyanogenMod 10.1:
    1. Go to http://get.cm/?device=skyrocket
    2. Select the type of build
      • Stable - Stable. Well tested. But will not have latest features.
      • Nightly - Nightly builds. Latest features added but unstable.
      • M snapshot (Experimental) - Similar to nightly. You could call them monthly builds. Somewhere between stable and nightly.
    3. Copy the file onto the phone using USB transfer.
  2. GApps
    1. Go to http://goo.im/gapps
    2. Download the gapps which match your CyanogenMod version.
    3. Copy the file onto the phone using USB transfer.
  3. TWRP (Similar to clockworkmod [CWM])
    1. Download TWRP from http://d-h.st/Xo2
  4. Odin
    1. Download odin from http://forum.xda-developers.com/attachment.php?attachmentid=925569&d=1330549534.
    2. Extract the zip.
    3. Run the exe.
    4. Check "auto-boot". Uncheck all other options
    5. Click on "PDA" button. Select TWRP tar file.
    6. HOLD YOUR HORSES HERE
  5. Process - Install TWRP
    1. Put the phone into download mode. (Download mode is different from recovery mode.)
    2. Connect USB cable to computer but not the phone.
    3. Shutdown and remove the battery of the phone
    4. Wait for sometime and reinsert the battery.
      • AT&T - Hold both volume buttons.
      • Rogers - Hold only volume down button.
      (Do not release the buttons until instructed to do so. Do not touch the power button.)
    5. Insert the usb cable into the phone. The phone will boot up. When you see a download mode page with a little yellow triangle at bottom, release the volume button(s).
    6. Now press the volume up button as per the instructions on the screen to continue to download mode.
    7. Odin should have recognized your phone now. You should see a green box with com port listed.
    8. Click start in Odin.
    9. When odin is finished flashing, you should see a green box with Pass written right above the com port green box.
  6. Process - Install CyanogenMod 10.1
    1. Put the phone in recovery mode:
    2. Turn off phone and unplug USB.
    3. Hold down both volume keys.
    4. Hold power button till you feel the phone vibrate. (Release only power button, not the volume keys when the phone vibrates.)
    5. When the screen goes black, release volume keys.
    6. You should now be in recovery mode.
    7. It is a good idea to backup here.
    8. Click on install button.
    9. Select the cyanogenmod zip file from internal/ external sd card and follow on screen instructions to complete the install.
    10. Click Home.
    11. Click Wipe.
    12. Click on Cache, Dalvik Cache and Factory Reset.
    13. Click on back button.
    14. Click on Reboot -> System.

Since we reset cache, the first boot could take 5-10 mins. But if it is taking longer, go to recovery mode and try other options in Wipe menu of TWRP. Then reboot.

On first boot, you might panic to see none of the Google related apps available. Not even Google Play. Thats where the gapps we downloaded come into picture.

  1. Install GApps
    1. Go to recovery mode.
    2. Click Install and select the gapps file. Complete the install.
    3. Reboot.

You should be good to go.

References

Need some more time to work on the post formatting. But instructions are pretty much covered.

Tuesday, December 25, 2012

MimeTypes for Google Docs and Drive

Google Docs: application/vnd.google-apps.document
Google Presentations: application/vnd.google-apps.presentation
Google Spreadsheets: application/vnd.google-apps.spreadsheet
Google Drawing: application/vnd.google-apps.drawing

Few more of Google Docs and Google Drive MIME types:
application/vnd.google-apps.audio
application/vnd.google-apps.document
application/vnd.google-apps.drawing
application/vnd.google-apps.file
application/vnd.google-apps.folder
application/vnd.google-apps.form
application/vnd.google-apps.fusiontable
application/vnd.google-apps.kix
application/vnd.google-apps.photo
application/vnd.google-apps.presentation
application/vnd.google-apps.script
application/vnd.google-apps.sites
application/vnd.google-apps.spreadsheet
application/vnd.google-apps.unknown
application/vnd.google-apps.video

Wednesday, October 03, 2012

Extract compressed files easily on Linux

Tired of remembering the unzip, tar command line options? Just add this to your ~/.bashrc.

extract () {
   if [ -f $1 ] ; then
       case $1 in
 *.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
 *.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
 *.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
 *.bz2)  bunzip2 $1 && cd $(basename "$1" /bz2) ;;
 *.rar)  unrar x $1 && cd $(basename "$1" .rar) ;;
 *.gz)  gunzip $1 && cd $(basename "$1" .gz) ;;
 *.tar)  tar xvf $1 && cd $(basename "$1" .tar) ;;
 *.tbz2)  tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
 *.tgz)  tar xvzf $1 && cd $(basename "$1" .tgz) ;;
 *.zip)  unzip $1 && cd $(basename "$1" .zip) ;;
 *.Z)  uncompress $1 && cd $(basename "$1" .Z) ;;
 *.7z)  7z x $1 && cd $(basename "$1" .7z) ;;
 *)  echo "don't know how to extract '$1'..." ;;
       esac
   else
       echo "'$1' is not a valid file!"
   fi
}
And then all you do is $ extract filename.tar.bz2

Monday, November 28, 2011

No module named PIL - after buildout

If you are using buildout to install PIL and if you get this error, check once in the eggs directory. If there is a PIL egg directory, check its contents. If there are files directly, that is the reason for the error. You can manually move all those contents to PIL subdirectory or add the following buildout part to your buildout script

# ============================================================================================== #
# PIL Hack #
# When buildout install PIL egg, it keeps all files under the PIL-1.1.7-py2.6-X-X-universal.egg. #
# We need to put all the files under a subdirectory PIL inside this folder to make it work. #
# ============================================================================================== #
[PIL-hack]
recipe=iw.recipe.cmd:py
on_install=true
on_update=true
cmds=
>>> import os
>>> while True:
>>> lst = []
>>> for p in os.listdir('${buildout:eggs-directory}'):
>>> if p.startswith('PIL-${versions:PIL}') and p.endswith('.egg'):
>>> lst.append(p)
>>> if len(lst) > 1:
>>> print '\033[91m' + 'I am confused. Multiple PIL eggs found. %s.' % lst + '\033[0m'
>>> raw_input('Delete the one which is not required and then press Enter to continue...')
>>> elif len(lst) == 0:
>>> print '\033[91m' + 'No PIL egg found in eggs directory' + '\033[0m'
>>> raw_input('Press Enter to continue...')
>>> break
>>> elif len(lst) == 1:
>>> path = os.path.join('${buildout:eggs-directory}', lst[0])
>>> path2 = os.path.join(path, 'PIL')
>>> if not os.path.exists(path2):
>>> print '\033[92m' + ('Using PIL egg: %s' % lst[0]) + '\033[0m'
>>> lstdir = os.listdir(path)
>>> os.mkdir(path2)
>>> for p in lstdir:
>>> os.rename(os.path.join(path, p), os.path.join(path2, p))
>>> break

Python colors on command line print

While writing a command line script, adding colors might ease understanding the output. To print a line in color just follow this simple technique
print '\033[91m' + 'my error string' + '\033[0m'
You might have guessed it by now. '\033[' is a control char and '0m'/ '91m' define the color to be displayed.
Few examples: 0m is white 91m red 92m green 93m orange 94m blue Hope this helps

Monday, July 11, 2011

Python httplib2 certificate verify failed

If you are trying to make a https connection using httplib2.Http to a server which uses self-signed certificate, you might face "httplib2.SSLHandshakeError: [Errno 1] _ssl.c:480: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed".

There are 2 solutions:
1. httplib2.Http(disable_ssl_certificate_validation=True).request('https://www.godaddy.com/')

2. httplib2 uses its own certificate store. Usually, the location would be /usr/local/lib/python2.7/dist-packages/httplib2/httplib2/cacerts.txt.
Edit this file to add the certificate of your server and you should be good to go.

Steps to download site certificates (eg. certificates from DigiCert):

  1. Open the site
  2. Click on the lock icon in the address bar.

    1. Chrome:
      1. Go to "Connection" tab
      2. Click on "Certificate Information"
    2. Firefox:
      1. Click "More Information"
      2. Go to "Security" tab
      3. Click "View certificate"
      4. Go to "Details" tab
  3. Make a note of the first node of certificate (eg "DigiCert High Assurance EV Root CA")
  4. Go to DigiCert certificates page (https://www.digicert.com/digicert-root-certificates.htm).
  5. Search for the certificate with the name you found above and download it.
  6. Convert the .crt file to .pem "openssl x509 -in DigiCertHighAssuranceEVRootCA.crt -out DigiCertHighAssuranceEVRootCA.pem -outform PEM"
  7. If above steps returns error, refer to http://info.ssl.com/article.aspx?id=12149. For this certificate you need to pass "-inform der"
  8. Open the DigiCertHighAssuranceEVRootCA.pem, copy the contents and paste in cacerts.txt


Thursday, June 30, 2011

Install sun java jdk on Ubuntu 10.10 Maverick Meerkat

*** NO TIME FOR FORMATTING ***

Sun Java has finally been uploaded to the Ubuntu 10.10 Maverick Meerkat official Partner repository.

From UI:
To install (Sun) Java in Ubuntu 10.10 Maverick Meerkat you'll have to enable the Partner repository: open Ubuntu Software Center and go to Edit > Software Sources, then on the "Other Software" enable the Partner repository (it should be the first on the list; it looks like this: "http://archive.canonical.com/ubuntu maverick partner".).

Then, click "Close" and when asked, click "Reload" and finally install Sun Java6 in Ubuntu 10.10 by searching for it in Ubuntu Software Center.

From command line:
sudo vim /etc/apt/sources.list
Uncomment
deb http://archive.canonical.com/ubuntu maverick partner
deb-src http://archive.canonical.com/ubuntu maverick partner
sudo apt-get update
sudo apt-get install sun-java6-jdk

sudo apt-get install sun-java6-plugin
sudo update-java-alternatives -s java-6-sun
You also need to setup JAVA_HOME and PATH variable. Open your $HOME/.bash_profile or /etc/profile (system wide) configuration. Open your .bash_profile file:
$ vi $HOME/.bash_profile

Append following line:
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

Wednesday, December 29, 2010

Generating runtime image in iPhone/ iPad

input color in int.

+ (UIImage *)shapeCircle:(int)color {

// create the bitmap context
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(nil,30,30,8,0, colorSpace,kCGImageAlphaPremultipliedLast);
CFRelease(colorSpace);

// set the fill color
//CGColorRef fillColor = [[UIColor blackColor] CGColor];
NSString *hexColor = [NSString stringWithFormat:@"%x", color];
hexColor = [[@"" stringByPaddingToLength:6 - [hexColor length] withString:@"0" startingAtIndex:0] stringByAppendingString:hexColor];
float r = [self hexToColorValue:[hexColor substringToIndex:2]];
float g = [self hexToColorValue:[hexColor substringWithRange:NSMakeRange(2, 2)]];
float b = [self hexToColorValue:[hexColor substringFromIndex:4]];

//fillColor = [[[UIColor alloc] initWithRed:1 green:0 blue:0 alpha:1] CGColor];
//CGContextSetFillColor(context, CGColorGetComponents(fillColor));
CGContextSetRGBFillColor(context, r, g, b, 1);
CGContextAddArc(context, 15.0f, 15.0f, 12.0f, 0, 360 * M_PI/180, 1);
CGContextFillPath(context);

//CGContextSetFillColor(context, CGColorGetComponents([[UIColor whiteColor] CGColor]));
CGContextSetRGBFillColor(context, 1, 1, 1, 1);
CGContextAddArc(context, 15.0f, 15.0f, 6.0f, 0, 360 * M_PI/180, 1);
CGContextFillPath(context);

// convert the context into a CGImageRef
CGImageRef imageRef = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
CGImageRelease(imageRef);

return [image autorelease];
}

+ (float)hexToColorValue:(NSString *)color {
NSScanner* scanner = nil;
unsigned int cInt;
scanner = [NSScanner scannerWithString:color];
[scanner scanHexInt:&cInt];
return (float)cInt / 255;
}

Adding a toolbar to keyboard for textField and textView

textField and textView have a property inputAccessoryView which allows you to easily add a toolbar to the top of the keyboard to show your custom buttons.

- (IBAction)beginEditing: (id)sender {
CGFloat _width = self.view.frame.size.width;
CGFloat _height = 40.0;

// Create a new toolbar
UIToolbar *toolbar = [[[UIToolbar alloc] initWithFrame:CGRectMake(0, -_height, _width, _height)] autorelease];
// Create the necessary buttons
UIBarButtonItem *barButtonItemSubmit = [[[UIBarButtonItem alloc] initWithTitle:@"Submit" style:UIBarButtonItemStyleBordered target:self action:@selector(btnSubmitClicked:)] autorelease];
UIBarButtonItem *barButtonItemCancel = [[[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(btnCancelClicked:)] autorelease];
/*
By default the buttons that are added to the toolbar are left aligned.
To align them as you like, create a flexible space bar button and add it where you want.
*/
UIBarButtonItem *flexibleSpace = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
/*
Adding the flexible space in between will make both buttons float towards the opposite ends.
You can repeat the flexible space as many times and at positions to get the desired layout of buttons.
*/
[toolbar setItems:[[[NSArray alloc] initWithObjects:barButtonItemSubmit, flexibleSpace, barButtonItemCancel, nil] autorelease]];

if ([sender isEqual:myTextField]) {
myTextField.inputAccessoryView = toolbar;
}
else if ([sender isEqual:myTextView]) {
myTextView.inputAccessoryView = toolbar;
}
}


Assign the begin editing event of the text field to the above function.

For textview, you might need to do something like this:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
if ([textView isEqual:myTextView]) {
[self beginEditing:myTextView];
}
return YES;
}

resignFirstResponder does not hide keyboard in presentModalViewController

For some great "Apple" reason, when the input elements are in a modal view controller, resignFirstResponder just loses the focus from the element. The keyboard stays visible.

After searching for a long time, I found 2 explanations for the same.
1. Its a bug!
2. Its a feature! Apple kept it that way to avoid the keyboard coming up and going down when switching between input elements in the modal form. B******T!

So the workaround I came up with is:
- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
NSArray *arrWindows = [[UIApplication sharedApplication] windows];

if ([arrWindows count] > 1) {
UIWindow *keyboardWindow = [arrWindows objectAtIndex:1];
[keyboardWindow setHidden:YES];
}
return YES;
}

Monday, November 22, 2010

Adding new view to RootViewController in UISplitViewController

  1. Right click the blue icon in Xcode.
  2. Add new file > Cocoa Touch Classes > UIViewController subclass.
  3. Select all 3 checkbox options (Targetted for iPad, UITableViewController subclass, with XIB for user interface) (You could rearrange the file in correct locations under classes and resources).
  4. Open NewView.h. Add NSArray variable for populating the UITableView.
  5. Open NewView.m. Edit numberOfSectionsInTableView, numberOfRowsInSectioncellForRowAtIndexPath to populate the table form the NSArray variable.
  6. Open RootViewController.h. Add #import "NewView.h".
  7. Open RootViewController.m. Edit

    - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NewView * NewView = [[NewView alloc] initWithNibName:@"NewView" bundle:nil];
    NewView.arrData = [[dataHolder objectAtIndex:indexPath.row] objectForKey:@"subdata"];
    [[NewView navigationItem] setTitle: @"Subdata"];
    [self.navigationController pushViewController:NewView animated:YES];
    [NewView release];
    /* When a row is selected, set the detail view controller's detail item to the item associated with the selected row.*/
    detailViewController.detailItem = [dataHolder objectAtIndex:indexPath.row];
    }
    Save and Run.

When an item is selected from the main root view, the table will slide to left to give way to your new view, with a back button. If the RootViewController is given a title, the title will be used for the back button.

To provide a title:
Open RootViewController.m In viewDidLoad, add
[self.navigationItem setTitle: @"Main View"];

Wednesday, June 09, 2010

Showing tabs of open sessions in screen

Screen is a very good terminal-multiplexer to allow multiple terminal sessions.

It is very useful when you are working on a remote machine through ssh.

More info about screen at: https://help.ubuntu.com/community/Screen

But it could be quite irritating when you have multiple sessions open and you have to cycle through them frequently since there are no tabs or status bar.

But, there is a solution for the same :)

Edit /etc/screenrc or ~/.screenrc and add the following line. Then start screen.

caption always '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %D %Y-%m-%d %c:%s %{g}]'

Tuesday, February 23, 2010

PHP mail returns false on Fedora linux

While helping out a friend on a PHP installation, came across this issue.

Everything worked fine on his development server. But on his deployment server, the mail function returned false and hence no mails were sent out.

After some debugging found that the issue was with permission for httpd on sendmail.

vim /var/log/maillog had error NOQUEUE: SYSERR(apache): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied

After spending some time on Google, came across this command.
# getsebool -a | grep sendmail
httpd_can_sendmail --> off

So the issue was that the apache user did not have permissions to send mails using sendmail.

Ran the following command
# togglebool httpd_can_sendmail

and everything worked fine.

Why Your New External Drive is Breaking Your macOS Builds

Picture this: you're running dangerously low on disk space, so you invest in a brand new external drive. Time to migrate your developmen...