Skip to content

Instantly share code, notes, and snippets.

View rootindex's full-sized avatar

rootindex rootindex

  • Silvertree
  • Cape Town
View GitHub Profile
@rootindex
rootindex / --Library--LaunchDaemons--co.echo.httpdfwd.plist
Created September 2, 2020 10:47
Making macos on boot redirect port 80 to 8080 and 443 to 8443 on all interfaces permanently, -- = /
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>co.echo.httpdfwd</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<?php
$postcode = $argv[1];
$regionMap = [
'EC' => [
['4731', '5199'],
['5200', '5299'],
['5300', '5499'],
['5500', '5999'],
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export PS1="\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]] \")[\e[38;5;240m\@\e[m] [$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\h'; else echo '\[\e[38;5;193m\u\[\033[0;37m\]@\e[38;5;26m\h'; fi)\[\033[0;37m\]][\[\033[0;32m\]\w\[\033[0;37m\]]\e[38;5;198m\$(__git_ps1 "[%s]")\e[m\n$ "
#!/usr/bin/env bash
function get_mage_path {
local result=${PWD##*/}
local ret='./'
if [ "$result" = "var" ]; then
local ret='../';
fi
if [ "$result" = "log" ]; then
local ret='../../';
UPDATE cataloginventory_stock_item AS s
INNER JOIN catalog_product_entity AS p ON s.product_id = p.entity_id
SET s.qty = '9999.0000', s.is_in_stock='1'
WHERE p.type_id = 'simple'
$newsFromDate = Mage::getResourceModel('catalog/product')
->getAttributeRawValue($product->getId(), 'news_from_date', $product->getStoreId());
@rootindex
rootindex / log.php
Created January 11, 2016 14:29
Including logger
<?php
class Blah {
protected $_logger;
public function __construct(
\Psr\Log\LoggerInterface $logger
){
$this->_logger = $logger;
@rootindex
rootindex / install.sh
Created January 11, 2016 09:42
Install Magento2 with composer
#!/bin/sh
# specify directory if not in it
composer create-project magento/community-edition .
# Fix file permissions
find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {} \;
# execute if you have not done so in the past
composer config repositories.magento composer http://packages.magento.com
@rootindex
rootindex / magento.sh
Last active January 11, 2016 09:43
Show mode and change mode
#!/bin/sh
magento deploy:mode:show
Current application mode: default.
magento deploy:mode:set developer
Enabled developer mode.
@rootindex
rootindex / MaintenanceMode.php
Last active January 11, 2016 09:27
Magento2 Maintenance Mode
<?php
// 1) Enabled maintenance mode by creating file .maintenance.flag in the var folder
// 2) By pass maintenance mode by creating file .maintenance.ip in the var folder
// 3) IP addresses does not work for ranges only individual ip addresses
if (!preg_match('/^[^\s,]+(,[^\s,]+)*$/', $addresses)) {
throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n");
}