Skip to content

Instantly share code, notes, and snippets.

View sebastian-marinescu's full-sized avatar
🤓

Sebastian G. Marinescu sebastian-marinescu

🤓
View GitHub Profile
@sebastian-marinescu
sebastian-marinescu / modx-json-to-placeholders
Created September 17, 2022 02:49 — forked from jmaddington/modx-json-to-placeholders
Quick snippet to set placeholders from a JSON array. Made basically so I could create MIGXs inside MIGXS. There is little error checking are anything else at this point. Use at your own risk.
<?php
/**
* jsonToPlaceholders snippet for JM Customer Database extra
*
* Copyright 2013 by JM Addington [email protected]
* Created on 04-28-2013
*
* @package jmc
*/
@sebastian-marinescu
sebastian-marinescu / ModRestAuthController.php
Created December 28, 2020 18:35 — forked from nick2687/ModRestAuthController.php
This controller can be used with the modrestcontroller class to preform basic remote authentication through the modrestservice class (modx rest api). Should only be used over https as it requires the username & pass to be sent along as a url param.
<?php
/**
* Found at: Controllers/Box.php
*
* Handle requests to [URL]/Controllers/Box. Automagically handles CRUD (GET/POST/PUT/DELETE) for the xPDOObject class myBox.
*/
class MyControllerAuth extends modRestController {
public $classKey = 'modUser';
public $defaultSortField = 'id';
@sebastian-marinescu
sebastian-marinescu / plink-plonk.js
Created February 24, 2020 07:41 — forked from tomhicks/plink-plonk.js
Listen to your web pages
@sebastian-marinescu
sebastian-marinescu / Copy.gs
Created November 6, 2019 14:56 — forked from takvol/Copy.gs
Copy google spreadsheet with all protected ranges permissions
function Main() {
var template = DriveApp.getFileById('YOUR_SPREADSHEET_ID'); //template spreadsheet
var destination = DriveApp.getFolderById('COPY_DESTINATION_FOLDER_ID'); //the directory to copy the file into
var curDate = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyy-MM-dd");
var copyName = template.getName() + ' copy ' + curDate; //the filename that should be applied to the new copy (e.g. "My spreadsheet copy 2019-08-24")
copyTemplate(template, copyName, destination);
}
/**
@sebastian-marinescu
sebastian-marinescu / .htaccess
Created December 3, 2018 15:31 — forked from benhuson/.htaccess
Disable HTTP Strict Transport Security (HSTS) in .htaccess
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=0; includeSubDomains; preload" env=HTTPS
</IfModule>
@sebastian-marinescu
sebastian-marinescu / JSMin.class.php
Created November 15, 2018 01:31 — forked from justindmartin/JSMin.class.php
JSMin -- Ryan Grove <[email protected]> (PHP port) -- Steve Clay <[email protected]> (modifications + cleanup) -- Andrea Giammarchi <http://www.3site.eu> (spaceBeforeRegExp) -- 2002 Douglas Crockford <[email protected]> (jsmin.c) -- 2008 Ryan Grove <[email protected]> (PHP port) -- http://opensource.org/licenses/mit-license.php MIT License -- http:…
<?php
/**
* JSMin.php - modified PHP implementation of Douglas Crockford's JSMin.
*
* <code>
* $minifiedJs = JSMin::minify($js);
* </code>
*
* This is a modified port of jsmin.c. Improvements:
*
@sebastian-marinescu
sebastian-marinescu / cbContentEditor.php
Created October 28, 2018 14:13 — forked from jonleverrier/cbContentEditor.php
This MODX plugin hides certain Content Blocks buttons from a specific MODX user group. It also disables the drag and drop functionality, so that you can provide some users with a more locked down version of Content Blocks.
<?php
/**
* Content Blocks cbContentEditor Plugin
*
* This plugin hides certain CB buttons from certain MODX user groups
* and disables the drag and drop functionality, so that you can provide
* some clients with a more locked down version of CB.
*
* I would suggest setting up CB templates and defaults in the CB component manager,
* so that predefined layouts are loaded automatically when a new resource is created.
@sebastian-marinescu
sebastian-marinescu / SortTabs.php
Created September 19, 2018 10:22
PHP snippet for MODX, that is used as a plugin to sort the resource-tabs
<?php
switch ($modx->event->name) {
case 'OnBeforeManagerPageInit':
$modx->controller->addHtml('
<script>
// This should be a component that registers late
Ext.ComponentMgr.onAvailable("emptifier", function(){
@sebastian-marinescu
sebastian-marinescu / LanguageMatch.php
Last active April 23, 2021 12:09
A PHP snippet for MODX to redirect to accepted client-languages (adapted so it trims prefix/suffix before matching)
<?php
/**
* LanguageMatch
*
* Based on https://gist.github.com/christianseel/504302ce8ddfcde009c0
* Original code by http://stackoverflow.com/a/3771447
*
* Updated by Indigo74 & x-vance for prefix/suffix and default context
*/
@sebastian-marinescu
sebastian-marinescu / install-CB-import-Fields-Layouts-Templates.php
Created January 11, 2018 18:53 — forked from carnevlu/install-CB-import-Fields-Layouts-Templates.php
MODX install package __ContentBlock__ and import Fields,Layouts,Templates from multiple export files
<?php
define('MODX_API_MODE', true);
// Full path to the index
require_once('index.php');
$modx = new modX();
$modx->initialize('mgr');
######################## Variables