Peter Rehm's Blog

apple,development,life & more

Remote notes to git commits

without Comments

Wit git notes you have an easy option of adding notes to commits. This is e.g. useful to
attach the github discussion to a commit.

Unfortunately the workflow to achieve this is slightly more complicated than just adding
commits. You can get your stuff done with the following commands.

CODE:
git remote update 
git checkout <sha>
git notes --ref=github-comments add -m <content> <sha>
git push <remote> refs/notes/github-comments


I recommend to have a different refs for different notes types to not have any conflicts.

You can read more about git notes here.

Posted by Peter Rehm

01/30/2014 at 09:23:25 AM

Defined tags for this entry: ,

wkhtmltopdf and fonts on a linux/debian server

without Comments

I just wondered why the created pdf is different between the one I had in my dev environment
and the one in production. The actual reason has been missing fonts in this case.

You can easily install the most common windows and mac fonts on your debian server:

CODE:
apt-get install msttcorefonts
wget https://invisible-files.googlecode.com/files/ttf-mac-fonts.tar.gz
tar xzvf ttf-mac-fonts.tar.gz
sudo mv ttf-mac-fonts /usr/share/fonts/
sudo fc-cache -f -v

Posted by Peter Rehm

09/14/2013 at 04:20:33 PM

Defined tags for this entry: , ,

Setting secure file permissions for PHP projects

without Comments

I am setting the permission for folders to 755 and for files to 644.
This can be adjusted automatically with find:

CODE:
$ find /path/to/project -type d -exec chmod 755 {} \;
$ find /path/to/project -type f -exec chmod 644 {} \;

Posted by Peter Rehm

07/23/2013 at 08:21:45 AM

PHP 5.5 Opcache in Development

without Comments

PHP 5.5 comes with the Zend Opcache built in. There are also recommended
settings for production which needs to be adjusted for development.

In development you usually dont want to wait until you see your latest changes.
Therefore you need to set the revalidate_freq to 0 in order to revalidate the
files on each request. My development configuration looks like following:

CODE:
opcache.enable=On
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=0
opcache.fast_shutdown=1
opcache.enable_cli=1


To manually clear the opcache just execute the following in your command
line:

CODE:
php -r 'opcache_reset();'


NOTE: In case you are going to use Zend OPcache together with Xdebug,
be sure that Xdebug is loaded after OPcache. "php -v" must show Xdebug
after OPcache.

Posted by Peter Rehm

07/14/2013 at 12:36:34 PM

Defined tags for this entry: ,

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: , ,