Skip to content

Instantly share code, notes, and snippets.

View oliver-montes's full-sized avatar

Oliver Montes oliver-montes

View GitHub Profile
@oliver-montes
oliver-montes / gist:1703546
Created January 30, 2012 09:28 — forked from davidalexander/gist:1086455
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

@oliver-montes
oliver-montes / hack.sh
Created April 2, 2012 16:32 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@oliver-montes
oliver-montes / .htaccess
Created August 9, 2012 11:51 — forked from justinkelly/.htaccess
Exclude file/directories/urls from Apache .htaccess password protected site
AuthType Basic
AuthName "Auth Required"
AuthUserFile /path/to/.htpasswd
Require valid-user
# allow public access to the following resources
SetEnvIf Request_URI "(path/to/directory/)$" allow
SetEnvIf Request_URI "(path/to/file\.phpt)$" allow
SetEnvIf Request_URI "(util)$" allow
Order allow,deny
Allow from env=allow
@oliver-montes
oliver-montes / files_modified_less.bash
Created August 10, 2012 12:37
find files modified less than 5 days ago
find . -type f -mtime -5 -print | xargs ls -l
@oliver-montes
oliver-montes / credis_requirements.txt
Created August 17, 2012 15:39 — forked from pizzapanther/credis_requirements.txt
Django Celery Redis Setup
Django==1.3.1
django-celery==2.3.3
redis==2.4.9
celerymon
@oliver-montes
oliver-montes / resque.py
Created August 19, 2012 10:43 — forked from defunkt/resque.py
Resque client in Python
from redis import Redis
import simplejson
class Resque(object):
"""Dirt simple Resque client in Python. Can be used to create jobs."""
redis_server = 'localhost:6379'
def __init__(self):
host, port = self.redis_server.split(':')
self.redis = Redis(host=host, port=int(port))
@oliver-montes
oliver-montes / django-fcgi-init.sh
Created October 30, 2012 18:25 — forked from anonymous/django-fcgi-init.sh
Init Script to Start Django+FastCGI Server
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
FCGIHOST="127.0.0.1"
FCGIPORT="5000"
RUNAS="projectuser:projectgroup"
UMASK="200"
DAEMON="/path/to/django/manage.py"
NAME="MyProject"
@oliver-montes
oliver-montes / mage-constraints.sql
Created November 14, 2012 16:20 — forked from cgdangelo/mage-constraints.sql
Recreate foreign keys for a Magento installation, after you fire the idiot who deleted all of them.
# one-liner for generating this: mysqldump --no-data -uroot magento1600 | nawk '{if(match($0, /CREATE TABLE `(.*)`/, matchesT)) { the_table = matchesT[1]; } if(match($0, /(CONSTRAINT .*),?/, matchesK) && the_table) { the_key = gensub(/,?$/, "", matchesK[1]); the_key = gensub(/^ */, "", the_key); print "ALTER TABLE `" the_table "` ADD", the_key ";"; }}'
ALTER TABLE `admin_rule` ADD CONSTRAINT `FK_ADMIN_RULE_ROLE_ID_ADMIN_ROLE_ROLE_ID` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `api_rule` ADD CONSTRAINT `FK_API_RULE_ROLE_ID_API_ROLE_ROLE_ID` FOREIGN KEY (`role_id`) REFERENCES `api_role` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `api_session` ADD CONSTRAINT `FK_API_SESSION_USER_ID_API_USER_USER_ID` FOREIGN KEY (`user_id`) REFERENCES `api_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `catalog_category_entity_datetime` ADD CONSTRAINT `FK_CAT_CTGR_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID` FOREIGN KEY (`attribute_id
require 'etc'
require 'fileutils'
# Copies the most recent MAX_IMAGES photos/videos from the device image dir.
# I use Dropbox to sync my device images to my workstation disk
MAX_IMAGES=500
USER_HOME_DIR = Etc::getpwuid.dir
DEVICE_IMAGES_DIR="#{USER_HOME_DIR}/Dropbox/Camera Uploads"
SIMULATOR_IMAGES_DIR="#{USER_HOME_DIR}/Library/Application Support/iPhone Simulator/5.1/Media/DCIM/100APPLE"
<?php
/**
* Copyright Magento 2012
* Example of products list retrieve using Customer account via Magento
REST API. OAuth authorization is used
*/
$callbackUrl = "http://yourhost/oauth_customer.php";
$temporaryCredentialsRequestUrl =
"http://magentohost/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);