Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
ryaan-anthony / gist:34470a8628acef831203
Created April 11, 2015 16:14
mysql aliases for osx 10
alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'
alias mysqlrestart='sudo /usr/local/mysql/support-files/mysql.server restart'
@ryaan-anthony
ryaan-anthony / DefaultKeyBinding.dict
Last active June 28, 2017 22:58
~/Library/KeyBindings/DefaultKeyBinding.dict
{
/* Home */
"\UF729" = "moveToBeginningOfLine:";
/* End */
"\UF72B" = "moveToEndOfLine:";
/* Shift + Home */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
@ryaan-anthony
ryaan-anthony / shell-lib-Import.php
Created March 28, 2015 18:00
Volusion -> Magento import. (easy to reformat)
<?php
class Import
{
protected $store;
function __construct(Mage_Core_Model_Store $store)
{
<?php
// source arrays
$source_1 = [
'abc' => [0 => 'a'],
'b' => 'c'
];
$source_2 = [
@ryaan-anthony
ryaan-anthony / ajaxbackend.js
Last active August 29, 2015 14:13
Simple Ajax wrapper for Magento/Prototype.js
var AjaxBackend = Class.create();
AjaxBackend.prototype = {
initialize: function(url) {
this.url = url;
},
<frontend>
<events>
<!-- logs -->
<controller_action_predispatch>
<observers><log><type>disabled</type></log></observers>
</controller_action_predispatch>
<controller_action_postdispatch>
<observers><log><type>disabled</type></log></observers>
</controller_action_postdispatch>
<customer_login>
<?php
include 'app/Mage.php';
Mage::app();
$file = fopen("skus.csv", "r");
while ($data = fgetcsv($file, 1000, ",")) {
$old = $data[0];
$new = $data[1];
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $old);
if($product && $product->getId()){
$product->setSku($new);
<?php
class Dude implements Woah, Whoa{}
interface Woah
{
const WOAH = true;
}
interface Whoa
{
const WHOA = true;
<?php
function array_walk_depth(array &$arr, $depth, $callback)
{
$depth--;
foreach($arr as $key => &$val){
if($depth) array_walk_depth($val, $depth, $callback);
<?php
Product::create([
'sku' => 'foo',
'name' => 'Standard Foo',
'price' => 8.99,
'special_price' => 6.99,
'categories' => ['category' => [1,3,5]]
]);