Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
ryaan-anthony / elasticsearch-healthcheck.php
Created May 21, 2015 14:21
Simple PHP healthcheck for elasticsearch (add to crontab)
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "127.0.0.1");
curl_setopt($ch, CURLOPT_PORT, "9200");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
<?php
class Jemoon_Htmlminify_Model_Observer {
public function Htmlminify($observer) {
// Fetches the current event
$event = $observer->getEvent();
$controller = $event->getControllerAction();
$allHtml = $controller->getResponse()->getBody();
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.reddit.com/r/philadelphia/.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
<?php
define( 'REDDIT_API_USER_HASH', 'reddit_api' );
class Reddit_Api_Bot{
//@mixed Set after successful login, otherwise false
public $user_hash;
@ryaan-anthony
ryaan-anthony / complete.php
Created June 1, 2015 17:44
Set magento orders to complete.
<?php
require_once 'app/Mage.php';
$app = Mage::app();
Mage::register('isSecureArea', true);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$order = Mage::getModel('sales/order')->loadByIncrementId('100000266');
$order->setData('state', 'complete');
$order->setStatus('complete');

Application initialization My video "Under the hood of Magento": http://www.youtube.com/watch?v=M10RR9acNE8 (watch in 1080p)

Front Controller These articles both cover in greater depth how the Front controller is initiated and how routers are selected. http://www.andreiboar.com/magento/magento-front-controller/ http://blog.belvg.com/magento-front-controller-pattern.html

URL rewrites These articles describe how url paths are formatted, where theyre located, and how theyre used by routers. As well as ... dun dun dunnn .. how the catalog url rewrite indexer works.

<?php
// Set product positions within a selected category
$cat_id = CATEGORY_ID;
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_api = new Mage_Catalog_Model_Category_Api;
@ryaan-anthony
ryaan-anthony / clean.icls
Created July 8, 2015 13:33
Clean PHPStorm Theme
<scheme name="Clean" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="13" />
<option name="EDITOR_FONT_NAME" value="Courier New" />
<colors>
<option name="CARET_ROW_COLOR" value="" />
<option name="LINE_NUMBERS_COLOR" value="808080" />
</colors>
<attributes>
<option name="BAD_CHARACTER">
<?php
class X
{
const X = 'x';
static function foo()
{