This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## http://ubuntuforums.org/showthread.php?t=430312 | |
## 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. | |
SELECTED_STRING="sshfs" | |
## mount as user, default = "root" | |
MOUNT_AS="root" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Database\Capsule\Manager as DB; | |
$capsule->addConnection(array( | |
'host' => 'localhost', | |
'database' => 'information_schema', | |
'username' => 'usr', | |
'password' => 'pwd', | |
'collation' => 'utf8_general_ci', | |
'charset' => 'utf8', | |
'driver' => 'mysql', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Company\Module\Console\Command; | |
// How to iterate through pages of products in Magento 2 (specifically tested with version 2.3.5-p2) using a | |
// Product CollectionFactory. This specific example is for a console command that maintains that products that | |
// meet a certain set of criteria are in the Clearance category. It also happens to show how to include stock | |
// quantity information with the products. | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Helper\ProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I needed a way to check the value of a product attribute so whipped up this | |
little command line interface tool to do it. It accepts a SKU and a product | |
attribute code and outputs the value of that attribute for that product. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$status = 500; // if we don't change this then the problem is this code | |
$result = array(); | |
if (empty($_FILES['file']['tmp_name'])) { | |
$status = 400; | |
$result['message'] = 'No file found.'; | |
} else if (empty($_FILES['file']['name'])) { | |
$status = 400; | |
$result['message'] = 'No file name found.'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$table = 'some_table'; | |
$columns = implode(',', array( | |
'title', | |
'description', | |
'etc...', | |
)); | |
$sql = ' | |
INSERT INTO '.$some_table.' (product_id, '.$columns.') | |
SELECT "'.$destId.'", '.$columns.' | |
FROM '.$some_table.' WHERE product_id = "'.$origId->id.'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
OlderNewer