Skip to content

Instantly share code, notes, and snippets.

@Vinai
Vinai / 2016-48.md
Last active January 13, 2020 09:25
List of past code katas. The file names are the [year]-[week-of-year].md. I'll try to update the list each week.

The first kata is the classic BowlingGame Kata from Uncle Bob.

Write a class named Game that has two methods

  • roll(pins : int) is called each time the player rolls a ball. The argument is the number of pins knocked down.
  • score() : int is called only at the very end of the game. It returns the total score for that game.

Here is the original PowerPoint from Uncle Bob with the instructions including the solution steps. The PPT file also includes the rules for the scoring of a bowling game.

@gwillem
gwillem / magento-nginx.conf
Last active July 29, 2023 10:13
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
@alistairstead
alistairstead / local.xml
Created November 1, 2014 12:09
Disable the automatic application of update scripts on each page request following cache clear. Use MageRun to apply the upgrades manually within a controlled step.
<?xml version="1.0"?>
<config>
<global>
<skip_process_modules_updates>1</skip_process_modules_updates>
</global>
</config>
@colinmollenhour
colinmollenhour / log_deadlocks.sh
Last active December 4, 2018 20:51
Record all new deadlocks in separate files
#!/bin/bash
#
# Copyright Colin Mollenhour 2014
dir=/root/deadlocks
[ -d $dir ] || mkdir -p $dir
cd $dir || { echo "Could not cd to $dir"; exit 1; }
mysql -be 'show engine innodb status;' \
| sed 's/\\n/\n/g' \
@SchumacherFM
SchumacherFM / README.md
Last active September 21, 2018 10:05
Avoiding database deadlocks in Magento 1.7

After having many deadlocks due to a high order volumne I've applied the these fixes to the core. Some can be found in a Magento forum. Before the fixes we could only process 1 order every 5-10 secs. Updating to Magento 1.8 is currently not an option but in 1-2 months.

1st Deadlock

Mage_Sales_Model_Abstract::_afterSave must be removed and replaced with afterCommitCallback. This is important to move the grid update (of sales_flat_order_grid) out of the transaction.

2nd Deadlock

Rewrite the method of the Mage_CatalogInventory_Model_Observer::reindexQuoteInventory() to remove the price reindexing from the transaction. That index process will also be fired in event sales_model_service_quote_submit_success.

@rothgar
rothgar / main.yml
Last active March 8, 2024 07:16
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@drewdhunter
drewdhunter / Magento - core code pre commit hook
Last active December 31, 2015 20:08
Pre commit hook useful for Magento projects
#!/usr/bin/env bash
set -eu
declare -a file_patterns=('app/code/core' 'app/Mage.php$' '^index.php$')
exit_status=0
while read x file; do
for file_pattern in ${file_patterns[@]}; do
if [[ $file =~ $file_pattern ]]; then
@Andrewpk
Andrewpk / OSX-junos_pulse_listenToMe.sh
Last active April 16, 2022 03:01
wtf juniper. Anyone else find it irritating that junos pulse services and pulse tray must always running in OS X regardless of whether or not you're currently connected? Yeah, me too. I added the following as aliases to my shell to fix this problem. Be sure to change your /Library/LaunchAgents/net.juniper.pulsetray.plist file to reflect the `Kee…
#################################################################################
# start and stop the vpn from the command line from now on with these two commands
# or rename the aliases as you see fit.
#################################################################################
alias startvpn="sudo launchctl load -w /Library/LaunchDaemons/net.juniper.AccessService.plist; open -a '/Applications/Junos Pulse.app/Contents/Plugins/JamUI/PulseTray.app/Contents/MacOS/PulseTray'"
alias quitvpn="osascript -e 'tell application \"PulseTray.app\" to quit';sudo launchctl unload -w /Library/LaunchDaemons/net.juniper.AccessService.plist"
@SchumacherFM
SchumacherFM / Magento-HHVM.md
Last active May 17, 2018 18:26
Running Magento Enterprise Edition with Facebook HipHop HHVM

Running Magento Enterprise Edition with Facebook HipHop HHVM

Prerequisites

Hardware

MacBook Air (MBA) Mid 2012

@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active March 27, 2024 06:36
A badass list of frontend development resources I collected over time.