Skip to content

Instantly share code, notes, and snippets.

Nathan Klatt nklatt

Block or report user

Report or block nklatt

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
nklatt / concrete5_adjust_file_permissions.php
Last active Apr 30, 2018
For Concrete5 v8, how to programmatically set file permissions so that they are only accessible by a single user plus a single group of users and are stored outside of the webroot.
View concrete5_adjust_file_permissions.php
use Concrete\Core\Entity\File\File;
use Concrete\Core\File\Set\Set as FileSet;
use Concrete\Core\File\StorageLocation\StorageLocationFactory as FileStorageLocationFactory;
use Concrete\Core\Permission\Access\Entity\GroupEntity as GroupPermissionAccessEntity;
use Concrete\Core\Permission\Access\Entity\UserEntity as UserPermissionAccessEntity;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\User\Group\Group as UserGroup;
use PermissionKey;
use UserInfo;
nklatt / create_attributes.php
Last active Dec 22, 2018
Programmatically add new product attribute with options to a Magento 2 store and add to Default attribute group
View create_attributes.php
defined('STDIN') or die(_("Access Denied. CLI Only"));
// execute from the command line: php <path to magento root>/cli/create_attributes.php
require __DIR__.'/../app/bootstrap.php'; // assuming this file is in /cli under the root magento dir
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$installer = $bootstrap->getObjectManager()->create('Magento\Catalog\Setup\CategorySetup');
$objectManager = $bootstrap->getObjectManager();
nklatt / add_column.php
Created May 12, 2016
Ensure a column exists in a MySQL table using concrete5, though that is secondary
View add_column.php
<?php defined('C5_EXECUTE') or die(_('Access Denied.'));
function addColumnToTable($table, $column, $type = 'tinyint(1) not null default 0') {
$db = Loader::db();
$qResult = $db->Execute('show columns from `'.$table.'` like "'.$column.'"');
$columnAlreadyExists = false;
foreach ($qResult as $row) {
if (is_array($row) && !empty($row['Field']) && $row['Field'] === $column) {
$columnAlreadyExists = true;
nklatt / dbTablesLoop.php
Created Nov 17, 2015
Loop over all tables in a database.
View dbTablesLoop.php
use Illuminate\Database\Capsule\Manager as DB;
'host' => 'localhost',
'database' => 'information_schema',
'username' => 'usr',
'password' => 'pwd',
'collation' => 'utf8_general_ci',
'charset' => 'utf8',
'driver' => 'mysql',
nklatt / myApp.js
Last active Aug 29, 2015
Extending Angular number inputs to validate for step attribute
View myApp.js
.module('myApp', [])
.directive("step", function() {
return {
restrict: "A",
require: "ngModel",
link: function(scope, element, attributes, ngModelCtrl) {
ngModelCtrl.$validators.step = function(modelValue, viewValue) {
var isValid = true; // assumed innocent until proven guilty
if ( ! ngModelCtrl.$isEmpty(modelValue) ) { // empty is okay
nklatt / mountsshfs
Last active Aug 29, 2015 — forked from pete-otaqui/mountsshfs
mountsshfs with addition of MOUNT_AS variable
View mountsshfs
## The script will attempt to mount any fstab entry with an option
## "...,comment=$SELECTED_STRING,..."
## Use this to select specific sshfs mounts rather than all of them.
## mount as user, default = "root"
You can’t perform that action at this time.