Skip to content

Instantly share code, notes, and snippets.

View mystix's full-sized avatar

Marc mystix

  • Singapore
View GitHub Profile
@mystix
mystix / 0_reuse_code.js
Created January 21, 2014 05:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?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', 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
'backend' => 'module/class_name', // eav_attribute.backend_model backend class
@mystix
mystix / dedupe.js
Last active May 19, 2018 08:02
[JavaScript] Remove duplicate occurences of string within string
// adapted from http://stackoverflow.com/a/13486540
function dedupe(str, delimiter) {
return str.split(delimiter || ',').reverse().filter(function(e, i, arr) {
return arr.indexOf(e, i+1) === -1;
}).reverse();
}
# Magento 1.12 cluster
* 815,000 lines of code (100,000 lines more than core + Zend)
* 96% PHP
* 1.7% Perl
* 1.5% Ruby
* 0.5% Shell
* Admin users: 46
* Categories: 2,450 (largest one has 2,400 products)
* Product entities: 101,000
@mystix
mystix / stop-it.sh
Created July 5, 2013 04:24
OSX: Stop Adobe Fireworks CSx from re-opening last opened files
#!/bin/bash
rm -rf ~/Library/Saved\ Application\ State/com.macromedia.fireworks.*
@mystix
mystix / get-secure-urls.php
Last active December 18, 2015 16:28
Magento: get list of all secure frontend URLs
<?php
Mage::getConfig()->getNode('frontend/secure_url')->children()
<?php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Create the root catalog
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@mystix
mystix / border-glow.css
Last active March 17, 2019 18:03
CSS Glow Effect
a:hover {
/* border glow effect on hover */
box-shadow: 0px 0px 20px #000;
filter:progid:DXImageTransform.Microsoft.Glow(Color=black,Strength=20);
}
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#