Skip to content

Instantly share code, notes, and snippets.

@jasononeil
jasononeil / AbstractExample.hx
Last active December 27, 2015 15:48
Really simple example of abstracts - creating an "extension" of AnchorElement with a custom constructor. Uses all inline code, and shows how implicit casts can be used when interacting with API that expects the underlying type.
// Compile with `haxe -js AbstractExample.js -dce full -main AbstractExample.hx`
import js.html.AnchorElement;
class AbstractExample {
static function main() {
var myAnchor = new MyAnchor( "http://google.com", "Click here!" );
expectsAnchor( myAnchor ); // Notice how it automatically casts back down to AnchorElement
}
@kalenjordan
kalenjordan / Batched Iterator for Magento collections
Last active May 9, 2022 12:25
Batched iterator for Magento collections
// This is how you would use it. Pass in your collection
// along with an individual callback as well as a batch callback
Mage::getSingleton('stcore/resource_iterator_batched')->walk(
$collection,
array($this, 'batchIndividual'),
array($this, 'batchAfter'),
self::BATCH_SIZE
);
public function batchIndividual($model)
@hightemp
hightemp / gist:2387916
Created April 14, 2012 21:16 — forked from borriglione/gist:2237588
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@davidalexander
davidalexander / gist:1086455
Last active September 7, 2023 07:42
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@scottjehl
scottjehl / anchorinclude.js
Created May 20, 2011 17:04
Anchor-include Pattern
/*
* anchor-include pattern for already-functional links that work as a client-side include
* Copyright 2011, Scott Jehl, scottjehl.com
* Dual licensed under the MIT
* Idea from Scott Gonzalez
* to use, place attributes on an already-functional anchor pointing to content
* that should either replace, or insert before or after that anchor
* after the page has loaded
* Replace: <a href="..." data-replace="articles/latest/fragment">Latest Articles</a>
* Before: <a href="..." data-before="articles/latest/fragment">Latest Articles</a>
@faisalman
faisalman / XML2003Parser.php
Created March 9, 2011 19:00
PHP class for parsing Microsoft Excel 2003 XML Spreadsheet
<?php
/**
* Excel 2003 XML-Parser
*
* PHP library for parsing Microsoft Excel 2003 XML Spreadsheet
* http://gist.github.com/862741
*
* Copyright (c) 2011 Faisalman <movedpixel@gmail.com>
*