Skip to content

Instantly share code, notes, and snippets.

@cyberdelia
cyberdelia / fabfile.py
Created April 3, 2010 14:05
Fabric deploy script with : south migrations, rollback and maintenance page.
from fabric.api import env, run, sudo, local, put
def production():
"""Defines production environment"""
env.user = "deploy"
env.hosts = ['example.com',]
env.base_dir = "/var/www"
env.app_name = "app"
env.domain_name = "app.example.com"
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name }
@domenic
domenic / di-in-requirejs.js
Created October 10, 2011 04:05
Dependency injection sample with RequireJS
// EntryPoint.js
define(function () {
return function EntryPoint(model1, model2) {
// stuff
};
});
// Model1.js
define(function () {
return function Model1() {
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@colinmollenhour
colinmollenhour / A-repo-moved.md
Created March 28, 2012 07:17
REPO MOVED! (Cm_Cache_Backend_File)
@davorbudimcic
davorbudimcic / string_grabber.php
Created April 2, 2012 07:08
Magento Translation strings Grabber
<?php
header('Content-type: text/plain');
/**
* Magento Translation strings Grabber
* davor.budimcic@inchoo.net
*
**/
@relay-zz
relay-zz / deferred-min.js
Created September 8, 2012 06:29
Deferred (Twisted API) implementation with no dependencies
/*Copyright(c)2012 relay.github.com http://opensource.org/licenses/MIT*/function Deferred(){this.callbacks=[]} Deferred.prototype={err:0,x:0,$:function(a){this.callbacks.push(a);2==this.x&&this._(this.o);return this},done:function(a){return this.$([a,0])},fail:function(a){return this.$([0,a])},always:function(a){return this.$([0,0,a])},then:function(a,c){return this.$([a,c])},reject:function(a){this.x||(this.err=1,this._(a));return this},resolve:function(a){this.x||this._(a);return this},_:function(a){this.x=1;for(var c=this.err,d=this.callbacks,b=d.shift(),e=a;b;)try{for(;b;){(b=b[2]||(c?b[1]:b[0]))&&(e= b(e||a));if(e instanceof Deferred){var f=this;e.always(function(b){f._(b||a);return b});return}b=d.shift()}}catch(g){c&&(b=d.shift()),this.err=c=1}this.o=e||a;this.x=2}};Deferred.when=function(a,c){if(!c)return a;for(var c=[].slice.call(arguments),a=new Deferred,d=c.length,b=d,e=[],f=function(c){return function(d){e[c]=d;--b||a.resolve(e)}},g=function(b){a.reject(b)};d--;)c[d].then(f(d),g);return a};
function Def( arg ) {
if( arg instanceof Def )
this.parent = arg;
else if( typeof arg !== "undefined" )
this.v = arg;
}
Def.prototype = {
chain: function(v){
delimiter ;;
drop procedure if exists build_catalog;;
create procedure build_catalog(IN categories INT, IN products INT)
begin
SET @category_count = 1;
SET @CATNAMEPREFIX = "Category ";
SET @CATURLKEYPREFIX = "cat-";
SET @CATURLPATHPREFIX = "catpath-";
SET @ROOTCATEGORY = 2;
SET @INCLUDEINMENU = 1;
@peterjaap
peterjaap / Mage_Catalog_Model_Resource_Url_getProduct.php
Last active May 4, 2017 06:09
Modified Mage_Catalog_Model_Resource_Url::_getProduct function. This function now contains a boolean that you can set to switch between rewriting the URL's for ALL products and rewriting only the URL's of products that are visible. Idea inspired by Alan Storm's blog on Scaling Magento - http://alanstorm.com/scaling_magento_at_copious
<?php
protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId)
{
$products = array();
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
$adapter = $this->_getReadAdapter();
if ($productIds !== null) {
if (!is_array($productIds)) {
$productIds = array($productIds);
@thomasfr
thomasfr / warmly.sh
Last active October 12, 2023 06:17
A wget based easy poor man`s cache warmer script
#!/bin/bash
# warmly.sh
# A wget based, easy, poor man`s cache warmer script
# https://gist.github.com/thomasfr/7926314
# The MIT License (MIT)
#
# Copyright (c) 2013,2014 Thomas Fritz <fritztho@gmail.com> (http://fritzthomas.com)
#