Skip to content

Instantly share code, notes, and snippets.

View sageworksstudio's full-sized avatar

Chris Brown sageworksstudio

View GitHub Profile
@sageworksstudio
sageworksstudio / SS-modelAdmin.php
Created April 19, 2019 17:29 — forked from dljoseph/SS-modelAdmin.php
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() {
@sageworksstudio
sageworksstudio / MultiplePHP.md
Created February 5, 2019 18:01
Multiple PHP

Using Multiple PHP Versions

Switching between multiple PHP

sudo a2dismod php?.?

sudo a2enmod php?.?

sudo update-alternatives --config php

@sageworksstudio
sageworksstudio / mariadb-cheat-sheet.md
Last active April 17, 2020 20:23
Cheat sheet for mariadb

MariaDB Cheat Sheet

From command line

Export database (with drop tables)

mysqldump -u username -p --add-drop-table database_name > data-dump.sql

Import database
@sageworksstudio
sageworksstudio / regex.md
Last active February 15, 2018 19:28
Regex cheat sheet

Regex cheat sheet

Search for an alpha-string between two delimiters.

Example: 'images/0-31604-01079-9_label_small.jpg'

In this case we're looking for the string 'label' between the underscore delimiters (not including the delimiters).

This would be our regex /(?<=_)+[A-Za-z]+(?=_)/

  1. Look for the preceeding delimiter, underscore (?<=_)
@sageworksstudio
sageworksstudio / ServerSetup.md
Last active December 29, 2021 15:18
Ubuntu 20.04 LAMP setup

Ubuntu 20.04 LAMP setup

Note: Because this is my personal cheat sheet, I'm installing a few PHP modules that you may not need if you're not running SilverStripe 4.x.x. Otherwise this is a pretty standard and secure LAMP installation.

SECURITY FIRST: Add a sudo user, require public key authentication and disable root login

Log into the remote machine as root: ssh root@123.45.67.890

First, add the admin user.

@sageworksstudio
sageworksstudio / restart-mysql.md
Last active May 15, 2021 18:24
Restart MySQL

Restart MySQL

Create a file that root/sudo can access:

restart-mysql.sh:

#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
if [[ "$(service mysql status)" != "running" ]]
@sageworksstudio
sageworksstudio / git-help.md
Last active April 11, 2018 16:59
Simple git commands

#Git Help#

##Git Remotes##

VIEW all remotes

git remote -v

ADD remote

@sageworksstudio
sageworksstudio / FolderPermissions.md
Last active June 1, 2020 05:19
Change permissions on folders only, not files

Set folder permissions

find . -mindepth 1 -type d | xargs chmod 700

@sageworksstudio
sageworksstudio / AutoChromium.md
Last active May 25, 2020 19:32
Open Chromium on system start in kiosk mode with notifications minimized (~/.config/autostart/autoChromium.desktop)

Autostart Chromium on boot

$ nano ~/.config/autostart/autoChromium.desktop

Add:

[Desktop Entry]
Type=Application
Exec=/usr/bin/chromium-browser --noerrdialogs --disable-session-crashed-bubble --disable-infobars --incognito --kiosk http://www.website.com