Skip to content

Instantly share code, notes, and snippets.

View JosephMaxwell's full-sized avatar
🇺🇸
Working.

Joseph Maxwell JosephMaxwell

🇺🇸
Working.
View GitHub Profile
<?php
/** @var Mage_Catalog_Model_Resource_Setup $installer **/
$installer = $this;
if (!$installer->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'attribute_name')) {
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'attribute_name', array( // TABLE.COLUMN: DESCRIPTION:
'label' => 'Label', // eav_attribute.frontend_label admin input label
'group' => 'General', // (not a column) tab in product edit screen
'sort_order' => 0, // eav_entity_attribute.sort_order sort order in group
@JosephMaxwell
JosephMaxwell / gist:743c035151ed787b67ab
Last active August 29, 2015 14:15
Adding JS file to head
<reference name="before_body_end">
<block type="core/text" name="sharpspring.form">
<action method="setText">
<text><![CDATA[<!-- SharpSpring Form for Contact Us -->
<script>// <![CDATA[
var ss_form = {'account': 'MzIxNgQA', 'formID': 'S022NLG0sDDSNTY2NtU1sUxK1bVISzHRNbQwS000MTFJS0y2AAA'};
ss_form.domain = 'app-1DN7CXM.sharpspring.com';
// ss_form.hidden = {'Company': 'Anon'}; // Modify this for sending hidden variables, or overriding values
// ]]></script>
<script type="text/javascript" src="https://koi-1DN7CXM.sharpspring.com/client/form.js?ver=1.1.1"></script>]]></text>

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@JosephMaxwell
JosephMaxwell / fizzbuzz.php
Created May 7, 2015 13:04
FizzBuzz kata without control statements
<?php
function getMap($input, $function) {
$numbers = getNumbers();
$array = array_filter($numbers, $function);
return array_combine($array, array_fill(0, count($array), $input));
}
function getNumbers()
{
@JosephMaxwell
JosephMaxwell / setup.sh
Last active August 29, 2015 14:25 — forked from boo1ean/setup.sh
Setup apache-2.4.4 + php-5.5.0 on CentOS 6.3
#!/usr/bin/env bash
# Install dependencies
yum update -y
yum install -y gcc apr-devel apr-util-devel openssl-devel pcre-devel libxml2-devel libcurl-devel
mkdir setup && cd setup
wget http://mirrors.besplatnyeprogrammy.ru/apache//httpd/httpd-2.4.4.tar.gz
tar -xvf httpd-2.4.4.tar.gz
<?php
/**
* SwiftOtter_Base is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SwiftOtter_Base is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@JosephMaxwell
JosephMaxwell / cleanup.sh
Last active April 26, 2016 21:34
Make production Magento database into development-ready database
# USAGE: cleanup.sh input-file.sql output-file.sql "www.production-site.com" "dev.production-site.com"
awk '!/INSERT INTO `customer_(entity|address)/' $1 \
| awk '!/INSERT INTO `log_/' \
| awk '!/INSERT INTO `m2epro_/' \
| awk '!/INSERT INTO `sales_/' \
| awk '!/INSERT INTO `report_viewed_/' \
| awk '!/INSERT INTO `load_/' \
| sed "s/$3/$4/; s/http:\/\/$3/http:\/\/$4/; s/https:\/\/$3/http:\/\/$4/" \
> $2
param (
[Parameter(Mandatory=$true)string]$directoryPath,
[Parameter(Mandatory=$true)string]$iisAppName,
[string]$iisAppPoolName = "Default",
[string]$iisAppPoolDotNetVersion = "v4.5"
)
Import-Module WebAdministration
#navigate to the app pools root
@JosephMaxwell
JosephMaxwell / jenkins.json
Created August 12, 2016 12:34
CloudFormation Template for Jenkins on EC2
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Launches a Jenkins server.",
"Parameters" : {
"InstanceType" : {
"Description" : "EC2 instance type",
"Type" : "String",
"Default" : "t2.small",
@JosephMaxwell
JosephMaxwell / jenkins.template
Last active January 27, 2022 00:38
Jenkins CloudFormation Template (more information and tutorial videos at https://swiftotter.com/technical/running-jenkins-on-amazon-ec2-with-cloudformation)
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Launches a Jenkins server.",
"Parameters": {
"InstanceType": {
"Description": "EC2 instance type",
"Type": "String",
"Default": "t2.small",
"AllowedValues": [
"t1.micro",