Skip to content

Instantly share code, notes, and snippets.

View muskie9's full-sized avatar

Nic muskie9

View GitHub Profile
@jonom
jonom / MaxWidthHeightImageExtension.php
Last active August 29, 2015 14:21
SilverStripe crop image to maximum width or height
<?php
class MaxWidthHeightImageExtension extends DataExtension {
/**
* Crop an image if it exceeds a certain height.
* Use in templates e.g. $Image.SetWidth(200).MaxHeight(200)
*
* @param integer $maxHeight Max height of image
* @return Image
<?php
class Page extends SiteTree {
/**
* Return any event pages that are in this section.
* @param ArrayList|null $children
* @param ArrayList|null &$events
* @return ArrayList
*/
@camfindlay
camfindlay / SilverStripe on Heroku
Last active March 11, 2021 04:26
SilverStripe database setup on Heroku.
mysite/_config.php
<?php
// . . . config above
//Heroku ClearDB support
if(isset($_ENV['CLEARDB_DATABASE_URL'])) {
global $databaseConfig;
$parts = parse_url($_ENV['CLEARDB_DATABASE_URL']);
$databaseConfig['type'] = 'MySQLDatabase';
$databaseConfig['server'] = $parts['host'];
$databaseConfig['username'] = $parts['user'];
@Zauberfisch
Zauberfisch / BaseValidator.php
Last active August 29, 2015 14:13
Better SilverStripe Form Validator
<?php
/**
* @author zauberfisch
*/
class BaseValidator extends Validator {
protected $validateFields, $requireFields;
/**
* @param bool|string[]|\FormField[]|\FieldList $validateFields
@dljoseph
dljoseph / SS-modelAdmin.php
Created November 22, 2014 09:05
SilverStripe 3.1.x add date range filters to modeladmin
<?php
class MyDataObjectAdmin extends ModelAdmin {
private static $managed_models = array('MyDataObject'); // Can manage multiple models
private static $url_segment = 'my-data-object'; // Linked as /admin/my-data-object/
private static $menu_title = 'My DataObjects';
public function getSearchContext() {
@roachhd
roachhd / README.md
Last active August 7, 2025 00:56
EMOJI cheatsheet ๐Ÿ˜›๐Ÿ˜ณ๐Ÿ˜—๐Ÿ˜“๐Ÿ™‰๐Ÿ˜ธ๐Ÿ™ˆ๐Ÿ™Š๐Ÿ˜ฝ๐Ÿ’€๐Ÿ’ข๐Ÿ’ฅโœจ๐Ÿ’๐Ÿ‘ซ๐Ÿ‘„๐Ÿ‘ƒ๐Ÿ‘€๐Ÿ‘›๐Ÿ‘›๐Ÿ—ผ๐Ÿ”ฎ๐Ÿ”ฎ๐ŸŽ„๐ŸŽ…๐Ÿ‘ป

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. โœˆ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: ๐Ÿ˜„

@mpalourdio
mpalourdio / php-cs-fixer
Created November 12, 2014 21:24
@fabpot php-cs-fixer config for PhpStorm
parameters
--level=psr2 --verbose fix $FileDir$/$FileName$
working directory
$ProjectFileDir$
@wernerkrauss
wernerkrauss / post-merge
Last active April 18, 2016 10:08
git post-merge hook for silverstripe installs.
#!/bin/bash
echo "running git post receive hook..."
DIR=$(git rev-parse --show-toplevel)
composer.phar install --no-dev -o
echo "running dev/build"
sudo -u www-data php $DIR/framework/cli-script.php dev/build flush=1
@halkyon
halkyon / gist:ec08493c2906c1539a49
Last active June 18, 2019 23:08
BuildTask for SilverStripe to remove obsolete tables, columns and indexes from the database
<?php
/**
* Remove old tables, columns, and indexes from a SilverStripe database.
*
* Define your obsolete tables, columns and indexes in {@link $deleted_tables},
* {@link deleted_columns} and {@link deleted_indexes} and these will be deleted
* from the database.
*
* In addition to that, it will automatically remove any tables and columns prefixed with "_obsolete".
*/
@jedateach
jedateach / _ss_environment.php
Created May 16, 2014 21:45
Localhost ss environment file
<?php
//set up reporting level, depending on ss version
if(strrpos($_SERVER['SCRIPT_NAME'], 'sapphire') !== false){
error_reporting(E_ERROR | E_WARNING | E_PARSE);
}else{
error_reporting(E_ALL);
}
define('SS_GEM_PATH', '/usr/bin/');