Skip to content

Instantly share code, notes, and snippets.

View Gabelbombe's full-sized avatar

Till Eulenspiegel Gabelbombe

  • The Deep Darkness, WA
View GitHub Profile
@Gabelbombe
Gabelbombe / install.0.1.0.php
Created October 24, 2014 21:34
Installer script template for attribute setup in Magento.
<?php
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
if (! $installer->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'attribute_name'))
{
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'attribute_name', [ // 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
'backend' => 'module/class_name', // eav_attribute.backend_model backend clas
@Gabelbombe
Gabelbombe / promotions.sql
Last active August 29, 2015 14:08
Displays promotion name, how many orders promo was applied to, percentage of those orders and the average total of those orders.
CREATE VIEW promotions AS
SELECT 'Full Price' AS 'Promotion Name'
, COUNT(entity_id) AS '# of Orders'
, CONCAT(ROUND(
(((SELECT COUNT(b.entity_id) FROM sales_flat_order b WHERE b.applied_rule_ids IS NULL)
/ (SELECT COUNT(entity_id) FROM sales_flat_order a)) * 100), 1), '%') AS '% of Orders'
, ROUND(AVG(subtotal), 2) AS 'Avg. Total'
FROM sales_flat_order
[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
#!/bin/bash
# Update servers, run via parallel
#
# CPR : Jd Daniel :: Ehime-ken
# MOD : 2014-12-12 @ 16:06:39
# VER : 1b
# REF : http://www.gnu.org/software/parallel/
#
# 5.5 or 6.6
@Gabelbombe
Gabelbombe / certwait.sh
Created December 19, 2014 00:20
Wait for puppet certificate
function certwait ()
{
i=0
while sleep 1; do
clear; echo "Ran ${i} loops"
echo -e "\nFOUND:"
matches=$(puppet cert list 2>/dev/null |awk '{print$1}' |sed -e 's/"//g' |grep "${1}")
if [ ! -z "${matches}" ]; then
echo $matches |sed -e 's/^//g'
@Gabelbombe
Gabelbombe / magent-links.php
Created December 19, 2014 20:09
Create Magnet links
#!/usr/bin/expect
# Expect login and SU for SSH
# Usage ssh_sudo_login.expect <host> <ssh user> <ssh password> <su user> <su password>
# CPR : Jd Daniel :: Ehime-ken
# MOD : 2015-01-14 @ 14:59:06
# VER : Version 1
set timeout 60
<VirtualHost *:80>
DocumentRoot /var/www/sn-query.io/public
ServerName www.sn-query.io
ServerAlias sn-query.io
<Directory "/var/www/sn-query.io/public">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
#!/bin/bash
#
#cptag - A script to resample mp3 files with LAME and
# copy id3v2 tags from the old file to the new one.
#
#####################
# Read id3 tags and write to file
mid3v2 -l "$1" > tag2.txt
@Gabelbombe
Gabelbombe / increment.sh
Created January 25, 2015 19:22
Iterate a loop in Puppet
#!/bin/bash
puppet apply --parser future -e '$ip="192.158.1" $vars={
0 => "${ip}.0",
1 => "${ip}.1",
2 => "${ip}.2",
} each($vars) |$id,$gate| { notice "${id} -> ${gate}" }'
## Outputs
#Notice: Scope(Class[main]): 0 -> 192.158.1.0