Google Maps API in Twitter Bootstrap Tabs
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
once the tab on which the map is included is activated.
If you have the following tabs (Example using an tabbed form)
you can handle the resize with the following JavaScript Snippet.
I hope this helps you!
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>
<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>
// 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!
git; insufficient permission
If you get the following error
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:
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed
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
Changing Locale on Debian to English
If you want to change the locale on your Debian system you can make
this habben with the following two commands:
After that you have to restart your console (type the name of your console or
open up a new terminal)
this habben with the following two commands:
CODE:
dpkg-reconfigure locales
locale-gen
locale-gen
After that you have to restart your console (type the name of your console or
open up a new terminal)
Installing MongoDB Binaries on Mac
Get latest binaries from here: http://www.mongodb.org/downloads
and unzip.
Insert the following content
Create a LaunchDaemon
Try it with http://localhost:28017
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
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
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>
<!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'
Symfony2 Ordered Fixtures
If you want to set the order in which the Fixtures are boing loaded there are
two steps:
- Use the AbstractFixture Interface
- Add getOrder Methode
Than it will work.
two steps:
- Use the AbstractFixture Interface
CODE:
class LoadCompanyData extends AbstractFixture implements OrderedFixtureInterface
- Add getOrder Methode
CODE:
public function getOrder()
{
return 1;
}
{
return 1;
}
Than it will work.
Symfony2 Permissions on Mac
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
Compare Content of 2 Folders
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.
Hint: You can also pipe the output of fc by adding "> diff.txt".
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
- 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".
Compiling error regarding xcode select
If you get this error
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.
There you go...
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...
PHP 5.4.x on Mac OSX 10.6,10.7 or 10.8
.DS_Store aus GIT Repository entfernen
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
# 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
Installation PEAR/PECL/autoconf/intl/icu auf Mac OSX Mountain Lion
Installation PEAR/PECL/autoconf/intl/icu auf Mac OSX Mountain Lion
- Install PECL & PEAR
- Add to php.ini
- Update pear channels
- Install ICU from http://site.icu-project.org/download/48#ICU4C-Download
If you get something linke this...
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.
then you should be able to install it..
If you have autoconfi missing go for that:
Now you should add "extension=intl.so" to php.ini and restart apache. Here you go.
- Install PECL & PEAR
CODE:
cd /usr/lib/php
sudo php install-pear-nozlib.phar
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"
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
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
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/
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.
MAC OSX; Locate Database aktualisieren
Mit dem folgenden Befehl wird die Erzeugung des locate Indexes angestoßen:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Anzeige der git branch in der Console (OSX/bash)
.bash_profile anlegen mit dem folgenden Inhalt
Danach sieht der shell prompt wie folgt aus:
Dadurch wird nebenbei auch die completion hinzugefügt, zum Beispiel bei
der Auswahl der Branches mittels git branch...
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
Script für externes Subversion Backup
Mit diesem Script werden verschiedene Daten gepackt und in mit einem Dateinamen der
das Datum enthält "Datum_Serverbackup.tgz" versehen.
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/*
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/*
PEAR unter OSX Leopard installieren
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.
Im nächsten Schritt wird go-pear ausgeführt.
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:
Im Browser die Datei ansehen und nach folgender Zeile suchen.
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.
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.
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
Abschließend muss noch der Webserver neu gestartet werden, dann ist PEAR
einsatzfähig.
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.
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
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
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.

