Skip to content

Instantly share code, notes, and snippets.

View wsakaren's full-sized avatar

Karen Baker wsakaren

  • WebShopApps
  • Austin, TX
View GitHub Profile
@markshust
markshust / data-install-0.0.0.1.php
Created July 9, 2015 12:39
update magento static block programmatically through upgrade scripts
<?php
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$connection = $installer->getConnection();
$identifier = 'id-goes-here';
$title = 'Title Goes Here';
@ajbrown
ajbrown / CloudFormation.template
Created June 18, 2015 17:24
CloudWatch mappings of AWS EC2 Instance types to Java Heap sizes
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Use these mappings for cloudwatch templates which launch a java process. They define a heap size close to (but never over) 70% of the available RAM, at multiples of 64 megabytes. No heap is declared over 32GB for performance reasons.",
"Mappings" : {
"AWSInstanceType2JavaMaxHeap" : {
"t1.micro" : { "Heap" : "384m" },
"t2.micro" : { "Heap" : "640m" },
"t2.small" : { "Heap" : "1280m" },
"t2.medium" : { "Heap" : "2816m" },
"t2.large" : { "Heap" : "5g" },
@makmanalp
makmanalp / comparison.md
Last active June 10, 2024 14:24
Angular vs Backbone vs React vs Ember notes

Note: these are pretty rough notes I made for my team on the fly as I was reading through some pages. Some could be mildly inaccurate but hopefully not terribly so. I might resort to convenient fiction & simplification sometimes.

My top contenders, mostly based on popularity / community etc:

  • Angular
  • Backbone
  • React
  • Ember

Mostly about MVC (or derivatives, MVP / MVVM).

@mrluanma
mrluanma / api.example.net.conf
Created September 9, 2014 08:27
cache POST request with Nginx
upstream api_example_net {
server api.example.net:4000;
keepalive 600;
}
proxy_cache_path /var/cache/nginx/tag levels=1:2 keys_zone=tag:10m inactive=1d max_size=10g;
server {
listen 80;
server_name api.example.net;
@kalenjordan
kalenjordan / repurchase-rate.sql
Last active January 1, 2016 20:59
Magento Repurchase Rate Note: This assumes you don't use guest checkout - if you do, you could probably group by customer_email and get relatively accurate results.
# The number of customers who haveve only purchased once from December 2012 to December 2013
SELECT customers_in_segment
FROM
(
SELECT count(*) AS customers_in_segment, order_count
FROM
(
SELECT customer_id, min(created_at) AS first_order_at, count(*) AS order_count
FROM sales_flat_order
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;
@lukes
lukes / find_invalid_records_in_rails.rake
Last active July 18, 2022 23:43
Find invalid records in Rails.
namespace :db do
desc "Outputs any invalid data records"
task :invalid_records => :environment do
puts "\n** Testing record validating in #{Rails.env.capitalize} environment**\n"
ActiveRecord::Base.send(:subclasses).each do |model|
puts "#{model} records (#{model.count})"
next if model.count == 0
invalid = model.all.reject(&:valid?)
if invalid.size.zero?
@hbrandl
hbrandl / RailsFlashToHeaders.md
Last active November 2, 2023 11:57 — forked from linjunpop/README.md
Rails flash messages with AJAX requests & twitter-bootstrap
@arm1n
arm1n / phpswap
Created February 2, 2013 13:31
This is a convenience script to switch between different php5 versions installed via macports. The script simply changes the httpd.conf file located in /opt/local/apache2/conf/httpd.conf with sed. It's believed that you have installed your php versions with 'sudo port install php5x-apache2handler'.
#!/bin/bash
#-------------------------------------------------------------------------------
# PHPSWAP for changing php5 versions installed via macports in apache2 config.
#
# @author armin.pfurtscheller@locandy.com
# @license MIT License
#
# Kindly referring to the following useful help pages:
# http://mark-story.com/posts/view/maintaining-two-versions-of-php-with-macports
@sandeepshetty
sandeepshetty / gist:1838803
Created February 15, 2012 20:32
Verify Shopify webhook in PHP
<?php
define('SHOPIFY_APP_SECRET', 'my_shared_secret');
function verify_webhook($data, $hmac_header)
{
$calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_APP_SECRET, true));
return ($hmac_header == $calculated_hmac);
}