Peter Rehm's Blog

apple,development,life & more

Google Maps API in Twitter Bootstrap Tabs

without Comments

It is a common request to use the Google Maps API in some a tab.
I came across the issue again today using Twitter Bootstrap. If you
embed the MapCanvas not on the first tab you will notice that the
Map will not be fully loaded...

The issue can be solved with calling
CODE:
    google.maps.event.trigger(map, 'resize');

once the tab on which the map is included is activated.

If you have the following tabs (Example using an tabbed form)
CODE:
<ul class="nav nav-tabs">
    <li class="active"><a href="#tab-first" data-toggle="tab"><i class="icon-tasks"></i> Todo</a></li>
    <li><a href="#tab-second" data-toggle="tab"><i class="icofont-leaf"></i> My fancy Map</a></li>
</ul>

<form action="#" method="post" class="form-horizontal tab-content well">
    <fieldset id="tab-first" class="tab-pane active">
        <h2>Form elements to be added here...</h2>
    </fieldset>
    <fieldset id="tab-second" class="tab-pane">
        <div id="mapCanvas" class="span6 pull-right"></div>
        <h2>Fancy Map</h2>
    </fieldset>
</form>


you can handle the resize with the following JavaScript Snippet.

CODE:
    <script type="text/javascript">
        // handler to resize map once the tab content is shown to fix
        // loading and display of the google maps canvas
        $('a[data-toggle="tab"]').on('shown', function (e) {

            // only resize if the tab which contains the map has been shown
            if($(e.target).attr('href') == '#tab-second') {
                google.maps.event.trigger(map, 'resize');
            }
        })
    </script>


I hope this helps you!

Posted by Peter Rehm

01/22/2013 at 06:40:21 PM

Defined tags for this entry: , ,

git; insufficient permission

without Comments

If you get the following error

CODE:
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed


you have messed up something with the permissions. In this case you have to ensure,
that the permissions of the .git file get fixed.

CODE:
chown -R user.group .git

Posted by Peter Rehm

01/08/2013 at 10:32:56 AM

Defined tags for this entry:

Changing Locale on Debian to English

without Comments

If you want to change the locale on your Debian system you can make
this habben with the following two commands:

CODE:
dpkg-reconfigure locales
locale-gen


After that you have to restart your console (type the name of your console or
open up a new terminal)

Posted by Peter Rehm

01/06/2013 at 10:54:51 PM

Defined tags for this entry: , ,

Installing MongoDB Binaries on Mac

without Comments

Get latest binaries from here: http://www.mongodb.org/downloads
and unzip.

CODE:
sudo mv mongodb-osx-x86_64-2.2.1 /usr/local/mongodb
sudo mkdir /usr/local/mongodb_data /var/log/mongodb
sudo chown -R root /usr/local/mongodb
sudo vi /usr/local/mongodb/mongod.conf


Insert the following content

CODE:
# Store data alongside MongoDB instead of the default, /data/db/
dbpath = /usr/local/mongodb_data
 
# Only accept local connections
bind_ip = 127.0.0.1


Create a LaunchDaemon

CODE:
sudo vi /Library/LaunchDaemons/org.mongodb.mongod.plist


CODE:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>org.mongodb.mongod</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/mongodb/bin/mongod</string>
    <string>run</string>
    <string>--config</string>
    <string>/usr/local/mongodb/mongod.conf</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/usr/local/mongodb</string>
  <key>StandardErrorPath</key>
  <string>/var/log/mongodb/output.log</string>
  <key>StandardOutPath</key>
  <string>/var/log/mongodb/output.log</string>
</dict>
</plist>


CODE:
sudo launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist


Try it with http://localhost:28017

CODE:
sudo sh -c 'echo "/usr/local/mongodb/bin" > /etc/paths.d/mongodb'

Posted by Peter Rehm

11/05/2012 at 02:49:57 PM

Defined tags for this entry: , ,

Symfony2 Ordered Fixtures

without Comments

If you want to set the order in which the Fixtures are boing loaded there are
two steps:

- Use the AbstractFixture Interface

CODE:
class LoadCompanyData extends AbstractFixture implements OrderedFixtureInterface


- Add getOrder Methode

CODE:
public function getOrder()
{
    return 1;
}


Than it will work.

Posted by Peter Rehm

10/17/2012 at 07:33:40 PM

Defined tags for this entry: ,

Symfony2 Permissions on Mac

without Comments

To configure the permissions on mac use the following commands:


sudo rm -rf app/cache/
sudo rm -rf app/logs/

sudo chmod +a "_www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "yourusername allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs

Posted by Peter Rehm

10/17/2012 at 07:31:39 PM

Defined tags for this entry: ,

Compare Content of 2 Folders

without Comments

If you need to compare 2 folders on a windows machine to figure out
whether the content matches to check e.g. if you have really copied
all files you can do this on the command line.

CODE:
- open cmd
- cd folder1
- dir /S /b > content_folder1.txt
- cd folder 2
- dir /S /b > content_folder1.txt
- fc content_folder1.txt content_folder1.txt


Hint: You can also pipe the output of fc by adding "> diff.txt".

Posted by Peter Rehm

08/25/2012 at 12:29:32 PM

Defined tags for this entry:

Compiling error regarding xcode select

without Comments

If you get this error

CODE:
xcode-select: Error: No Xcode is selected. Use xcode-select -switch <path-to-xcode>, or see the xcode-select manpage (man xcode-select) for further information.


Make sure that you have the Apple Command Line Tools from https://developer.apple.com/downloads/index.action?=command%20line%20tools installed. This should be necessary unless you want to develop OSX or iOS applications.

Then just execute this on the command line to set the default entry.

CODE:
sudo xcode-select -switch /usr/bin


There you go...

Posted by Peter Rehm

08/18/2012 at 05:03:38 PM

Defined tags for this entry: ,

PHP 5.4.x on Mac OSX 10.6,10.7 or 10.8

without Comments

Link to a nice installer of the latest PHP version.

http://php-osx.liip.ch/

Posted by Peter Rehm

08/07/2012 at 12:27:50 PM

.DS_Store aus GIT Repository entfernen

without Comments

CODE:
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch --cached


modify .git/info/exclude

CODE:
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store


Have fun...

For further information regarding exclude or .gitignore see git ignore files locally

Posted by Peter Rehm

08/04/2012 at 01:13:05 PM

Defined tags for this entry:

Installation PEAR/PECL/autoconf/intl/icu auf Mac OSX Mountain Lion

without Comments

Installation PEAR/PECL/autoconf/intl/icu auf Mac OSX Mountain Lion

- Install PECL & PEAR

CODE:
cd /usr/lib/php
sudo php install-pear-nozlib.phar


- Add to php.ini

CODE:
include_path = ".:/usr/lib/php/pear"
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626"


- Update pear channels

CODE:
sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net
sudo pear upgrade-all


- Install ICU from http://site.icu-project.org/download/48#ICU4C-Download

CODE:
tar -xzvf icu4c-4_8_1_1-src.tgz
cd icu/source/
./runConfigureICU MacOSX
make
sudo make install


If you get something linke this...


configure: error: in `/Users/peterrehm/Downloads/icu/source':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
./runConfigureICU: ./configure failed


you have to install the apple command line tools which you will find
under the following URL for the appropriate OS version like Mountain Lion.

CODE:
https://developer.apple.com/devcenter/mac/index.action


then you should be able to install it..

CODE:
sudo pecl install intl


If you have autoconfi missing go for that:

CODE:
curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar -xzvf autoconf-latest.tar.gz
cd autoconf-2.69/


Now you should add "extension=intl.so" to php.ini and restart apache. Here you go.

Posted by Peter Rehm

08/01/2012 at 09:11:24 PM

Defined tags for this entry: , ,

MAC OSX; Locate Database aktualisieren

without Comments

Mit dem folgenden Befehl wird die Erzeugung des locate Indexes angestoßen:


sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Posted by Peter Rehm

08/01/2012 at 07:56:24 AM

Defined tags for this entry:

Anzeige der git branch in der Console (OSX/bash)

without Comments

.bash_profile anlegen mit dem folgenden Inhalt


PATH=$PATH:/usr/local/git/bin:.
source /usr/local/git/contrib/completion/git-completion.bash
PS1='[\u@\h \w$(__git_ps1 " (%s)")]\$ '


Danach sieht der shell prompt wie folgt aus:


[peterrehm@tokyo-3 /www/scalc (master)]$


Dadurch wird nebenbei auch die completion hinzugefügt, zum Beispiel bei
der Auswahl der Branches mittels git branch ...

Posted by Peter Rehm

07/29/2012 at 07:26:01 PM

Defined tags for this entry: , , ,

Script für externes Subversion Backup

without Comments

Mit diesem Script werden verschiedene Daten gepackt und in mit einem Dateinamen der
das Datum enthält "Datum_Serverbackup.tgz" versehen.

CODE:
#!/bin/bash
filename=`date '+%m%d%y'`
rm -rf /opt/tmpdir/backup/*

mkdir /opt/tmpdir/backup/svn/
mkdir /opt/tmpdir/backup/config/

svnadmin dump /home/svn/cms/ > /opt/tmpdir/backup/svn/cms_svn.dump
svnadmin dump /home/svn/templates/ > /opt/tmpdir/backup/svn/templates_svn.dump

tar -cvf /opt/tmpdir/backup/config/apache.tar /etc/apache2/
tar -cvf /opt/tmpdir/backup/config/opt_scripts.tar /opt/scripts/

tar -czvf /opt/tmpdir/backup/${filename}_serverbackup.tgz /opt/tmpdir/backup/*

Posted by Peter Rehm

10/30/2010 at 11:18:34 PM

Defined tags for this entry:

PEAR unter OSX Leopard installieren

with 1 Comment

Im folgenden wird in aller kürze beschrieben, wie man PEAR unter
OSX 10.5 Leopard installiert. Dies sollte unter den vorherigen OSX
Versionen sicher ähnlich funktionieren.

Auf meinem lokalen System habe ich PHP5 von entropy.ch am laufen, da
ich unbedingt die GD-Lib benötige. Dies hat nur Einfluss auf die Ablage
der php.ini. Dies muss eben von den auf dem jeweilig auf dem System vorhandenen
Gegebenheit abhängig gemacht werden.

Wir werden in /usr/local/ installieren, und dem System gestatten die TEMP-Files
in /usr/local/temp abzulegen.

CODE:
sudo mkdir /usr/local/temp
sudo chmod -R 777 /usr/local/temp
sudo mkdir /usr/local/share/pear
sudo chmod -R 777 /usr/local/share/pear


Im nächsten Schritt wird go-pear ausgeführt.

CODE:
curl http://pear.php.net/go-pear | php


Hier muss bei den Pfaden der 1. auf /usr/local geändert werden.
Alle anderen Einstellungen können in der Regel beibehalten werden.

Während der Installation kommt dann die Warnung, dass der PEAR Pfad
noch nicht in der php.ini vorhanden ist, und es deswegen zu Problemen
mit der Verwendung von den PEAR Scripts kommen kann.

Hier kommen wir an den Punkt wo es wichtig ist, zu wissen, wo die
Konfigurationsdatei des Webservers liegen muss. Dies kann man einfach
über ein kurzes Script herausfinden:

CODE:
<? phpinfo(); ?>


Im Browser die Datei ansehen und nach folgender Zeile suchen.

CODE:
Configuration File (php.ini) Path /usr/local/php5/lib


Hier muss die php.ini für den Webserver liegen, die php.ini für
das Command-Line-Interface (CLI) unabhängig davon in /etc/

Standardgemäß ist eine php.ini.default in /etc/. Diese kopieren
und modifizieren wir zunächst.

CODE:
sudo cp /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini


Nun nach dem Eintrag include_path suchen und diesen um "/usr/local/share/pear"
ergänzen. Bei mir sah dies nach der Anpassung so aus.

CODE:
include_path=".:/usr/local/share/pear"


Ist eine php.ini in dem Config-Path des Webservers vorhanden bearbeiten
wir diese, ansonsten kopieren wir die Datei /etc/php.ini an die gewünschte
Stelle

CODE:
sudo cp /etc/php.ini /usr/local/php5/lib/php.ini


Abschließend muss noch der Webserver neu gestartet werden, dann ist PEAR
einsatzfähig.

CODE:
sudo apachectl restart


Anmerkung: Kann PEAR von der Konsole nicht mit dem Befehl pear aufgerufen werden,
ist /usr/local/bin nicht korrekt in den SHELL-Pfaden eingetragen, und sollte nachgetragen
werden. Tipp: echo $PATH zum überprüfen in der SHELL eingeben.

Posted by Peter Rehm

01/02/2008 at 11:16:31 AM

Posted in PHP

Defined tags for this entry: , ,