Skip to content

Instantly share code, notes, and snippets.

View jules0x's full-sized avatar
🔥

Jules jules0x

🔥
View GitHub Profile
@jules0x
jules0x / raygun-test.php
Last active June 4, 2024 22:36
raygun-error-manual
<?php
namespace App\Tasks;
use Psr\Log\LoggerInterface;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask;
/**
* BuildTask to cause Raygun to fire. This can be used to test Slack/Raygun integration.
@jules0x
jules0x / imagefrommapfunction.php
Created September 29, 2022 22:34
Image from Map
<?php
$url = 'https://maps.googleapis.com/maps/api/staticmap?center=Berkeley,CA&zoom=14&size=400x400&key=' . Config::inst()->get(GeocodeService::class, 'google_api_key');
$folder = Folder::find_or_make('maps');
$map = new Image();
$map->setFromString(file_get_contents($url), 'map.png');
$map->ParentID = $folder->ID;
$map->write();
@jules0x
jules0x / dateRange.php
Created April 10, 2022 20:02
Date range display value
<?php
/**
* Determine the best way to render the date based on conditions
*
* @return string | null
*/
public function getEventDate()
{
$start = DBDate::create()->setValue($this->owner->StartDate);
@jules0x
jules0x / query.sql
Last active June 21, 2023 21:36
SQL: Query row count for all tables in DB
SELECT table_name, table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'db_name'
ORDER BY table_rows desc;
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
@jules0x
jules0x / tinymce_hotkeys.md
Last active March 1, 2020 23:00
# TinyMCE hotkeys to trigger editor actions

#TinyMCE hotkeys

Add 'format' to initalization:

formats: {text_center: {selector: 'p,h1,h2,h3,h4,h5,table', classes: 'text-center'}}

Then add the shortcut in 'setup':

setup: function (ed) {
@jules0x
jules0x / tinymce_toggle.md
Last active October 24, 2022 16:56
# Add buttons to the tinyMCE toolebar to toggle custom items (styles, classes etc.)

#TinyMCE style toggle button

First of all, you need to define a custom format:

formats: {
   custom_format: {inline: 'span', attributes: {class: 'some_css_class'}}
}

Then you'll have to add a button to your toolbar:

@jules0x
jules0x / _config.php
Last active March 1, 2020 22:58
# TinyMCE custom classes ### Apply custom classes to html elements via a dropdown
<?
$htmlEditorConfig = HtmlEditorConfig::get('cms');
// Add half' and 'third' wrappers to tinyMCE (will appear in styles drop-down).
$htmlEditorConfig->setOption('style_formats', [
[
'title' => 'Half (md)',
'block' => 'div',
'wrapper' => true,
@jules0x
jules0x / _config.php
Last active March 1, 2020 22:54
# Sitemode CSS Add some custom styling to visually the environment you're currently editing. Helps prevent accidently testing things in prodution.
<?php
//Set CMS style based on environment type
if (Director::isDev()) {$sitemodeCSS = 'app/css/sitemode-dev.css';}
if (Director::isTest()) {$sitemodeCSS = 'app/css/sitemode-test.css';}
if (Director::isLive()) {$sitemodeCSS = 'app/css/sitemode-live.css';}
Config::inst()->update('LeftAndMain', 'extra_requirements_css', [
$sitemodeCSS
]);
@jules0x
jules0x / _config.php
Created August 31, 2015 22:41
Exclude reports from CMS using 'add_excluded_reports'
<?php
SS_Report::add_excluded_reports(
array(
'SideReport_BrokenRedirectorPages',
'SideReport_BrokenVirtualPages',
'SideReport_BrokenFiles',
'CwpStatsReport',
'SideReport_BrokenLinks',
'BrokenLinksReport',