Skip to content

Instantly share code, notes, and snippets.

@Zauberfisch
Zauberfisch / install-wkhtml2pdf.sh
Last active March 14, 2017 10:53
Install wkhtml2pdf on ubuntu precise 64bit (12.04 LTS) with patched QT
# I managed to get the compiled version with patched QT working on ubuntu precise 64bit (12.04 LTS) and thought I'd share my bash history in the hopes it might spare others some trouble shooting.
# Also note that this install process takes rather long, you might want to consider running it in a screen or something
# you will be needing git if you haven't got it yet
sudo apt-get install git-core
# as per installation instructions, install dependencies for wkhtmltopdf
sudo apt-get install openssl build-essential xorg libssl-dev libxrender-dev
# clone the repo
git clone git://github.com/antialize/wkhtmltopdf.git wkhtmltopdf
@Zauberfisch
Zauberfisch / SilverStripe-Clean-ModelAdmin.md
Last active October 11, 2017 13:47
Clean up SilverStripe ModelAdmin (no sidebar, no filter, no import, no print)

Clean up SilverStripe ModelAdmin (no sidebar, no filter, no import, no print)

@Zauberfisch
Zauberfisch / MyModelAdmin.php
Created October 24, 2013 08:55
Hide ModelAdmin sidebar in SilverStripe 3.x
<?php
class MyModelAdmin extends ModelAdmin {
private static $managed_models = array('MyDataObject');
private static $url_segment = 'foobar';
}
@Zauberfisch
Zauberfisch / gist:6992149
Created October 15, 2013 14:08
Hack for IntelliJ SCSS/Compass FileWatcher. FileWather uses scss by default (/usr/bin/scss on mac), so to get it to compile to compass one can replace scss with the following code:
require 'rubygems'
version = ">= 0"
ARGV.clear
ARGV << "compile"
path = ".."
i = 0
while !File.exists?(File.join(path, "config.rb"))
if i > 3 then
/**
* Return children from the stage site
*
* @param showAll Inlcude all of the elements, even those not shown in the menus.
* (only applicable when extension is applied to {@link SiteTree}).
* @return SS_List
*/
public function stageChildren($showAll = false) {
$baseClass = ClassInfo::baseDataClass($this->owner->class);
@Zauberfisch
Zauberfisch / GridFieldPersonSalutationDropDown.php
Created March 3, 2013 20:51
GridField example inline/inrow Dropdown example (Changing a Persons Salutation)
<?php
class GridFieldPersonSalutationDropDown implements GridField_ColumnProvider, GridField_URLHandler {
public function augmentColumns($gridField, &$columns) {
$columns[] = 'Salutation';
}
public function getColumnsHandled($gridField) {
return array('Salutation');
}
@Zauberfisch
Zauberfisch / _rgba-background.scss
Created February 7, 2012 16:49
[SCSS] Cross Browser alpha background colour mixin
@mixin rgba-background($color, $opacity) {
$rgba: rgba($color, $opacity);
$IEcolor: ie_hex_str($rgba);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#{$IEcolor}', endColorstr='#{$IEcolor}', GradientType=0 );
background: $rgba;
}
@Zauberfisch
Zauberfisch / Page.php
Created December 30, 2011 12:30
[Silverstripe] add <a href="big.png"> to all <img class"popup" src="small.png"> to allow opening full image
class Page extends SiteTree {
...
function Content() {
$content = $this->Content;
// move class to the beginning right after <img
$pattern[0] = '/(<img)([^>]*?)(class=(\'|")([^>]*?)(\'|"))([^>]*?>)/i';
$replacement[0] = '$1 $3$2$7';
// add <a> to all images with class popup and a src having _resampled
@Zauberfisch
Zauberfisch / _config.php
Created November 22, 2011 19:26
[Silverstripe] Display ID and Filesize in AssetsAdmin (Works with and without DataObjectManager!)
<?php
if (class_exists('AssetManager')) DataObjectManager::allow_assets_override(false); // if DOM is installed
Object::add_extension('Folder', 'myAssetsFolderDecorator');
if (class_exists('AssetManager')) DataObjectManager::allow_assets_override(true); // if DOM is installed
@Zauberfisch
Zauberfisch / Page.php
Created November 22, 2011 09:26
[SilverStripe] Page with Folder (always same name)
<?php
class myPage extends Page {
public static $has_one = array(
'Folder' => 'Folder'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
//$PhotoManager = new ImageDataObjectManager (/* some params here */);