Skip to content

Instantly share code, notes, and snippets.

@ivoba
ivoba / post-merge
Created November 13, 2014 17:13
post-merge hook for composer php apps
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# forked by Gianluca Guarini
# phponly by Ivo Bathke ;)
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
@ivoba
ivoba / app.js
Last active December 26, 2015 04:59
bower & masonry & imagesloaded & requirejs
define(['masonry/masonry', 'imagesloaded/imagesloaded'], function(Masonry, imagesLoaded) {
$(document).ready(function() {
var container = document.querySelector('#masonry');
imagesLoaded(container, function() {
var msnry = new Masonry(container, {
columnWidth: 200,
gutter: 20,
itemSelector: '.item',
isFitWidth: true
});
<?php
class MemberProfileFieldExtension extends DataExtension {
public static $db = array(
'SortOrder' => 'Int'
);
function updateCMSFields(FieldList $fields) {
$fields->push(new NumericField('SortOrder', 'SortOrder'));
@ivoba
ivoba / IndexController.php
Created July 30, 2012 09:21
Symfony2 caching with LiipDoctrineCacheBundle
$cache = $container->get('liip_doctrine_cache.ns.[mynamespace]');
if (false === ($cached_data = $cache->fetch($cache_key))) {
$cached_data = $SOMEAPI->getData($params);
$cache->save($cache_key, $cached_data, 3600);//TTL 1h
}
@ivoba
ivoba / IndexController.php
Created July 10, 2012 10:15
symfony2 caching data via doctrine/commons
$cache = $this->get('cache');
$cache->setNamespace('mynamespace.cache');
if (false === ($cached_data = $cache->fetch($cache_key))) {
$cached_data = $SOMEAPI->getData($params);
$cache->save($cache_key, $cached_data, 3600);//TTL 1h
}
@ivoba
ivoba / install_silverstripe3.sh
Created June 18, 2012 13:38
SilverStripe3 installer
#!/bin/sh
#install SilverStripe3 CMS
#usage sh install_silverstripe3.sh
DEFAULT_BROWSER="/usr/bin/firefox"
RELEASE="SilverStripe-cms-v3.0.1.tar.gz"
RELEASE_FOLDER="SilverStripe-cms-v3.0.1"
echo "-------------- Install $RELEASE from web :) ---------------"
echo "Type your Project Folder:"
@ivoba
ivoba / gist:2775277
Created May 23, 2012 13:40
AppKernel.php registerContainerConfiguration for config_local.yml
public function registerContainerConfiguration(LoaderInterface $loader) {
if ($this->getEnvironment() == 'dev') {
$extrafiles = array(
__DIR__ . '/config/config_local.yml',
);
foreach ($extrafiles as $filename) {
if (file_exists($filename) && is_readable($filename)) {
$loader->load($filename);
}
@ivoba
ivoba / index.php
Created May 23, 2012 13:16
Tweaked Symfony2 bootstrap file
<?php
/**
* Tweaked Symfony2 bootstrap file
*/
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
umask(0000);
if ( file_exists( dirname(__FILE__).'/../.env.php' ) ){
@ivoba
ivoba / install_silverstripe.sh
Created February 8, 2012 12:24
silverstripe installer using submodules
# install silverstripe + common modules from github
# usage sh install_silverstripe.sh <folder_name> <tag/branch>
# examples:
# sh install_silverstripe.sh some_folder tags/2.4.5
# sh install_silverstripe.sh some_folder master
#set up project base folder
git clone git@github.com:silverstripe/silverstripe-installer.git $1
cd $1
git checkout $2
@ivoba
ivoba / src.php
Created January 30, 2012 13:55
MongoDB integration in superleansilexplate
<?php
require_once __DIR__ . '/../vendor/silex/silex.phar';
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
$app = new Silex\Application();