Skip to content

Instantly share code, notes, and snippets.

Chris Maas cmaas

Block or report user

Report or block cmaas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cmaas /
Last active Jun 25, 2019
PHPBB3: Login by email and authenticate at ACP

PhpBB3: Login by email and re-authenticate at ACP

I made a custom auth provider that accepts the email as username. However, if you try to login to the ACP, you get this error:

You are not able to re-authenticate as a different user.

The problem causing this is in the file includes/functions.php. When you re-authenticate for the ACP, the provided username is compared with the user data (around line 2358):

// Check if the supplied username is equal to the one stored within the database if re-authenticating
cmaas / basic.html
Last active Oct 24, 2016
HTML5 Page Templates: Basic & Social
View basic.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<link rel="icon" type="image/png" href="favicon.png">
cmaas / CastsValueObject.php
Last active Nov 7, 2019
A Trait to automatically cast value objects in Laravel without needing a Mutator and an Accessor.
View CastsValueObject.php
trait CastsValueObjects
protected function castAttribute($key, $value)
$castToClass = $this->getValueObjectCastType($key);
// no Value Object? simply pass this up to the parent
if (!$castToClass) {
return parent::castAttribute($key, $value);
cmaas / headlines-to-permalinks.js
Last active Feb 2, 2016
Adds permalink anchor to all headlines in an article
View headlines-to-permalinks.js
cmaas / pixel_tracker.php
Created Jan 5, 2016
Function to track visitor information (e. g. pixel tracker)
View pixel_tracker.php
// callback
function get_server_info($k) {
return '"' . (isset($_SERVER[$k]) ? $_SERVER[$k] : '-') . '"';
// format: 2016/01/06-15:38:40 "/p.gif?page=home" "Mozilla/5.0" ""
function track_visitor() {
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$client_ip = $_SERVER['REMOTE_ADDR'];
} else {
cmaas / backup-sd-card.txt
Created Feb 28, 2015
Backup of an SD Card on OS X with dd
View backup-sd-card.txt
diskutil list
diskutil unmountdisk /dev/disk2s1
dd if=/dev/disk2s1 of=card.img bs=1m
Check status of dd by pressing Ctrl + T in Terminal.
cmaas /
Last active Aug 29, 2015
Laravel: Basic Value Object with Predefined Range of Accepted Values (Type Object)

Laravel: Basic Value Object with Predefined Range of Accepted Values

Your model has a list of accepted values. Say, your student score can be low, medium, or high. You want to store these values as Integers in the database and as a programmer, you want to work with constants like so:


Also, your HTML <select> field should have options for all available Constant values and label them with a translated label from your language file.

cmaas /
Last active Oct 24, 2017
Laravel: Basic Value Object

Laravel: Basic Value Object

If you want to enforce certain values in your models, you can use simple value objects for this job. This class helps to reuse some of the logic:

 * Representation of a simple value object with a single attribute that should be validated
 * @package Demo
cmaas / knockout-dirtyflag.js
Created Feb 10, 2015
Knockout: Dirty Flag / Dirty Tracking
View knockout-dirtyflag.js
// dirty tracking
// original:
// do things like:
// localStorage.setItem("tekpubCart",ko.toJSON(self.items));
}).extend({throttle : 1});
cmaas / knockout-extensions.js
Created Feb 10, 2015
Knockout: Force a positive integer
View knockout-extensions.js
// extension to replace an observable with a writeable computed that forces write to be numeric
// original:
ko.observable.fn.asPositiveInteger = function(defaultForBadValue) {
var original = this,
interceptor = ko.computed({
read: original,
write: function(newValue) {
var parsed = parseInt(newValue, 10);
//if value is bad or negative, then use default
if (isNaN(parsed) || parsed < 0) {
You can’t perform that action at this time.