Skip to content

Instantly share code, notes, and snippets.

View birchestx's full-sized avatar

Jo Baker birchestx

  • ShipperHQ
  • Austin, TX
View GitHub Profile
@birchestx
birchestx / install_magento2_with_db
Last active December 15, 2017 17:22
Install script for magento2 with database, assumes you are running from www.localhost.com/20
#!/bin/bash
# Sets up a database with a magento2 installation. This assumes you are running from under your httpdocs/<release> location and have www.localhost.com in your /etc/hosts file
# To run type : install_magento2 <dirname> <password> <release>
# password is used for the datbase user and the magento admin password
if [ $# -eq 0 ]; then
echo "No arguments supplied"
echo "Usage: `basename $0` <dirname> <password> <release>"
echo "e.g install_magento2.sh mage2 password 21"
exit 1
@birchestx
birchestx / singleton_enum.java
Last active February 1, 2016 08:33
Java singleton using enum and hashmap
public enum DomesticShipment {
INSTANCE;
private Map<String,String> domesticCountry;
DomesticShipment() {
domesticCountry = new HashMap<>();
domesticCountry.put("ausPost","AU");
}
@birchestx
birchestx / install_ga_magento2
Created December 1, 2015 16:30
Install GA Magento 2 - assumes have authentication keys
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <dirname>
@birchestx
birchestx / docker-cheat-sheet
Last active October 15, 2019 00:32
Docker cheat commands
#Build new Image (uses dockerfile in cwd)
docker build -t <your-desired-image-name> .
#Run Docker Container
docker run <image-name>
#Stop Docker Container (if you have used --name you can then stop with actual alias name)
docker stop <image-id>
#Show running Docker Images
@birchestx
birchestx / gist:3a26a61347cbe485677f
Created September 2, 2015 05:41
Mage::getStoreConfig in Magento 2 compared to Magento 1
Magento 1.x:
Mage::getStoreConfig('carriers/shipper/active')
Magento 2.x:
protected $scopeConfig;
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@birchestx
birchestx / simple_boot_tooltip_locale
Last active March 28, 2023 16:25
simple_form bootstrap with tooltips and locales
In simple_form_bootstrap.rb:
b.use :tooltip # enable the tooltip example from below.
I added these everywhere I saw word placeholder.
Add simple_form_components.rb:
module SimpleForm
module Components
@birchestx
birchestx / mage2_module_commands
Created August 9, 2015 06:38
Enable/Disable Extensions
When you type bin/magento from base directory get these module options:
module
module:disable Disables specified modules
module:enable Enables specified modules
module:status Displays status of modules
module:uninstall Uninstalls modules installed by composer
bin/magento module:status lists all the modules installed. You can see these in app/etc/config.php
Tables have moved around in Magento 2.
core_resource -> setup_module
@birchestx
birchestx / install_mag2_db_cli
Created July 30, 2015 08:36
Install Magento 2 Merchant Beta with database - quick route via command line
cd htdocs
composer create-project magento/community-edition magento2 1.0.0-beta --prefer-dist
create db (see details below)
Edit setup/index.php && index.php and add this - ini_set('xdebug.max_nesting_level', 200);
bin/magento setup:install --base-url=http://127.0.0.1/magento2/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=User [email protected] \
@birchestx
birchestx / toString.java
Created July 22, 2015 02:47
Better template for Java toString() - Puts newlines.
public java.lang.String toString() {
final String newLine = System.getProperty("line.separator");
final java.lang.StringBuffer sb = new java.lang.StringBuffer("$classname{");
#set ($i = 0)
#foreach ($member in $members)
sb.append(newLine);
#if ($i == 0)
sb.append(" ##
#else
sb.append(" ##