Install Raspbian RAW image into an SD Card in Mac OS X

First download a Raspbian RAW image from here: http://www.raspberrypi.org/downloads

Plug-in your SD card into your Mac. Then use diskutil to see the name of the disk device of it:

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            319.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *4.0 GB     disk1
   1:             Windows_FAT_32                         4.0 GB     disk1s1

In my case it is /dev/disk1.

Unmount it so we can write the image into it:

$ diskutil unmountdisk /dev/disk1
Unmount of all volumes on disk1 was successful

Now copy the image (it will take quite long and you won’t get any feedback until the end so be patient):

$ sudo dd if=2013-09-25-wheezy-raspbian.img of=/dev/disk1 bs=1m
4297+0 records in
4296+0 records out
2199552 bytes transferred in 1.877077 secs (1171796 bytes/sec)

Install MongoDB in Ubuntu 12.04 with PHP driver

Install MongoDB:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-10gen

Install MongoDB PHP driver:

sudo apt-get install php-pear php5-dev
pecl search mongo
sudo pecl install mongo

Configure MongoDB PHP driver in Apache: Create a file called /etc/apache/conf.d/mongo.ini with this content:

extension=mongo.so

Then restart Apache:

sudo service apache2 restart

Start, stop and restart MongoDB:

sudo service mongodb start
sudo service mongodb stop
sudo service mongodb restart

Configuration file:

/etc/mongodb.conf

Log file:

/var/log/mongodb/mongodb.log

Data files:

/var/lib/mongodb

Ref: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

Select different available java and javac versions in Ubuntu with update-alternatives

It’s possible to have more than one version of Java in the same machine.

If you have more than one Java JRE or JDK installed you can switch between them with the update-alternatives command:

$ sudo /usr/sbin/update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1051      manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java to provide /usr/bin/java (java) in manual mode.

You can do just the same for javac:

$ sudo /usr/sbin/update-alternatives --config javac

There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                        Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-i386/bin/javac   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-i386/bin/javac   1061      manual mode
  2            /usr/lib/jvm/java-7-openjdk-i386/bin/javac   1051      manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-7-openjdk-i386/bin/javac to provide /usr/bin/javac (javac) in manual mode.

You can check wich version is currently in use running:

$ java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)
$ javac -version
javac 1.7.0_25

Fix “Cannot redeclare class Symfony\…” in Symfony2 after upgrade

After upgrading from Symfony 2.2 to 2.3 I got this error in my application:

Fatal error: Cannot redeclare class Symfony\Component\HttpFoundation\FileBag in app/cache/prod/classes.php on line 1823

Another symptom was this error while trying to clear the cache for the prod environment:

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The parameter "kernel.http_method_override" must be defined.

The process to solve this problem was:

1.- Remove the cache folder:

rm -rf app/cache/prod

2.- Then clear the cache for the prod environment:

php app/console cache:clear --env=prod --no-debug

Ref:

Nowdoc and heredoc in PHP

From the manual:

Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping.

Look that the difference between those 2 is that nowdocs uses single quotes when defining the tag (that can be anything you want) and heredocs doesn’t.

$foo = 'bar';

$now = <<<'NOW'
    I'm now, $foo!
NOW;

$here = <<<HERE
    I'm here, $foo!
HERE;

In this case:

$now is "I'm now, $foo!"

$here is "I'm here, bar!"

Ref: http://php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc
http://stackoverflow.com/a/11153164

  • Page 2 of 14
  • <
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • ...
  • 14
  • >