Skip to content

Instantly share code, notes, and snippets.

@TemporaryJam
TemporaryJam / Magento - Attributes
Created September 3, 2014 13:39
Various magento attribute notes
//Get attribute value, where 'technical_pdf' is attribute code
$_technical_pdf = $_product->getResource()->getAttribute('technical_pdf')->getFrontend()->getValue($_product);
//Get attribute frontend store label
$label = $_product->getResource()->getAttribute('attribute_code')->getStoreLabel();
//Get attribute value
$attribute_value = $_product->getAttributeText($attributeCode);
@TemporaryJam
TemporaryJam / Magento - Get attributes by attribute group
Created September 3, 2014 13:14
Retrieves attribute codes by the attribute group name
$setId = $_product->getAttributeSetId(); // Attribute set Id
$groups = Mage::getModel('eav/entity_attribute_group')
->getResourceCollection()
->setAttributeSetFilter($setId)
->setSortOrder()
->load();
$attributeCodes = array();
foreach ($groups as $group) {
if($group->getAttributeGroupName() == 'Somename'){ // set name
@TemporaryJam
TemporaryJam / PHP config class
Last active August 29, 2015 13:56
PHP config class supporting dot notation
class Config
{
/**
*@var array
*/
private static $config = null;
/**
* Returns a config setting.
* @param string $name
@TemporaryJam
TemporaryJam / Gluster (Glusterfs) setup and install
Last active March 10, 2016 20:54
Gluster (Glusterfs) setup and install
#http://www.gluster.org
#nathan's notes https://gist.github.com/f58f3aa963f2165a0caa
#install gluster repo
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
#create brick directory
[root@re-sw-cen-web1 ~]# mkdir -p /gluster/var-www-html
#install client & server software
@TemporaryJam
TemporaryJam / RandomLogo.class.js
Last active January 3, 2016 08:08
Random logo rotator
/*
---
script: RandomLogo.class.js
description: Cycles through a collection of available logos in a given container. Obviously there should be more
available logos than there are logos displayed at only one time
requires:
- Core
- More/Fx.Tween
@TemporaryJam
TemporaryJam / Howto convert a PFX to a seperate .key & .crt file
Last active April 4, 2024 10:52
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
@TemporaryJam
TemporaryJam / getWorkingDays
Last active January 2, 2016 09:39
Calculate working days between dates
$nr_work_days = getWorkingDays('2014-05-01','2014-05-06', null);
echo $nr_work_days;
/**
* Calculate the number of working days between two dates.
* Note: The result is inclusive of the start and end date. Given two adjacent weekday dates the result is 2
* Return 0 if the start date is greater than the end date
* @param string $startDate Starting date
* @param string $endDate End date
* @param array $additional_holidays Additional holidays to remove from the calculation
@TemporaryJam
TemporaryJam / Command line IP
Last active December 29, 2015 01:59
Find IP on the terminal (CLI)
wget http://ipecho.net/plain -O - -q ; echo
@TemporaryJam
TemporaryJam / Remove BOM linux
Created September 29, 2013 12:55
How to remove the byte order mark (BOM) from a file on Linux CLI
tail --bytes=+4 text.txt > text_no_bom.txt
@TemporaryJam
TemporaryJam / RabbitMQ Clustering
Created September 20, 2013 07:51
RabbitMQ clustering guide
#To tell RabbitMQ to instruct Erlang to communicate on a certain range of ports, create a file at /etc/rabbitmq/rabbitmq.config with the following contents:
[
{kernel, [{inet_dist_listen_min, 9100},{inet_dist_listen_max, 9105}]}
].
#Now for the iptables configuration. Update /etc/sysconfig/iptables with the following rules:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5672 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4369 -j ACCEPT