Skip to content

Instantly share code, notes, and snippets.

View mitchkramez's full-sized avatar

Mitch Kramer mitchkramez

View GitHub Profile
// loop through the 'paper' variable from Raphael JS and build up the JSON object describing all images and paths within it.
loadJSON = function(paper, json) {
var set = paper.set();
$.each(json, function(index, node) {
try {
var el = paper[node.type]().attr(node);
set.push(el);
} catch(e) {}
});
return set;
@redoPop
redoPop / extension_specific_route.php
Created May 27, 2011 22:59
CakePHP custom Route class that restricts a route to a single extension.
<?php
/**
* Custom Route class that restricts a route to a single extension.
* Enables you to build controller actions that are only applied to specific
* extensions, e.g., '/posts.json' goes to PostsController::index_json while
* '/posts' goes to PostsController::index.
*
* To use, drop this into app/libs/routes/extension_specific_route.php and add
* the following to the top of app/config/routes.php:
*
@claylo
claylo / cf-invalidate.php
Created June 5, 2011 17:09
How to invalidate items in AWS CloudFront
<?php
/**
* Super-simple AWS CloudFront Invalidation Script
*
* Steps:
* 1. Set your AWS access_key
* 2. Set your AWS secret_key
* 3. Set your CloudFront Distribution ID
* 4. Define the batch of paths to invalidate
* 5. Run it on the command-line with: php cf-invalidate.php
@mitchkramez
mitchkramez / array_columns.php
Created January 17, 2012 15:32
sort an array for output in columns
/**
* function: array_columns
* author: Brecht Cloetens
* params: $a = array() // original array
* $c = int() // number of columns
*/
function array_columns(&$a, $c=2)
{
$m = ceil(count($a)/$c);
$j = 0;
@molotovbliss
molotovbliss / gist:2562551
Last active September 7, 2022 20:18 — forked from davidalexander/gist:1086455
Magento Snippets

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@mitchkramez
mitchkramez / vhost.conf
Last active December 15, 2015 06:19
Ignore HTTP Auth for a Specific IP (vhost.conf)
# Put this in the vhost.conf... otherwise remove the directory wrappers when using as an htaccess... but use it in the vhost.conf, not the htaccess.
# Allow traffic from IP without login
SetEnvIf Remote_Addr ^11\.11\.11\.11$ MOVE_ALONG=true
# Allow traffic from any iPhone user agent without login
SetEnvIfNoCase User-Agent iPhone MOVE_ALONG=true
<Directory "/var/www/vhosts/vhost.com/httpdocs">
Satisfy Any
Order deny,allow
@petemcw
petemcw / 01-README.md
Last active February 2, 2024 11:50
Mac OS X LEMP Configuration

Mac OS X LEMP Configuration

This Gist is a collection of configuration files that can be used to easily setup a Homebrew-based LEMP stack on Mac OS X.

Files in this repository are numbered and named for ordering purposes only. At the top of each file is a section of metadata that denote what component the file belongs to and the default name & location of the file. Feel free to implement it however you want.

Note: some configuration files have hard-coded paths to my user directory -- fix it for your setup

Setup

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@Michael-Brooks
Michael-Brooks / passwordValidation.php
Last active July 7, 2024 03:44
Laravel Password validation Regex (Contain at least one uppercase/lowercase letters and one number)
<?php
/*
* Place this with the rest of your rules.
* Doesn't need to be in an array as there are no pipes.
* Password is required with a minimum of 6 characters
* Should have at least 1 lowercase AND 1 uppercase AND 1 number
*/
$rules = [
'password' => 'required|min:6|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/'
];
@a-vasyliev
a-vasyliev / example.com.conf
Created March 25, 2015 11:42
Nginx: proxy cache without utm_* parameters (remove query parameter, remove utm tags nginx)
server {
listen 443;
server_name example.com;
error_log /var/log/nginx/example_com_error.log warn;
ssl on;
ssl_certificate /etc/nginx/ssl/your.crt; #certificate chains
ssl_certificate_key /etc/nginx/ssl/your.key; #private key