Skip to content

Instantly share code, notes, and snippets.

@clockworkgeek
clockworkgeek / auto-dev-hosts
Last active March 28, 2016 16:46
A service script that waits on "docker events" and adds new containers and their host names to "dnsmasq"
#!/bin/bash
# put me in /usr/bin/auto-dev-hosts
HOSTSDIR=/tmp/auto-dev-hosts
# create dir
install -d "$HOSTSDIR"
RELOADFLAG=/tmp/auto-dev-hosts.flag
SCRIPTNAME=$(basename "$0")
@clockworkgeek
clockworkgeek / backup.sh
Created December 15, 2015 19:12
Read Magento connection settings from local.xml and backup database
#!/bin/sh
##
## save to "shell" dir and call every few hours from cron
##
## find root dir of Magento site, do not rely on current dir
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DIR=$(dirname $DIR)
LOCAL_XML=$DIR/app/etc/local.xml
@clockworkgeek
clockworkgeek / composer.json
Last active August 29, 2015 14:18
Generic, lightweight Magento project starter
{
"_readme": [
"Save this file in project root and change the capitalised placeholders.",
"Now run 'mkdir -p htdocs && composer install' on each server.",
"Optionally change 'htdocs' to something else like './'"
],
"name": "clockworkgeek/PROJECT-NAME-HERE",
"description": "BRIEF DESCRIPTION HERE",
"license": "MIT",
"require": {
@clockworkgeek
clockworkgeek / forgetSessions.php
Created March 12, 2015 11:47
Purge excess sessions caused by increased `gc_maxlifetime` and https://github.com/clockworkgeek/Magento-Remember-Me
#!/usr/bin/env php
<?php
/**
* Place this script in your Magento root and optionally set the executable flag.
*
* chmod +x forgetSessions.php
*
* For a dry run set "DEBUG = true" below and watch all the session names go by.
* For cron use consider setting "OUTPUT = false" to suppress success message,
* only errors will be reported.
@clockworkgeek
clockworkgeek / gist:e11c5964929f05dd01ab
Created July 17, 2014 13:12
Extending native Date using Prototype.js
/**
* Some built-in browser types cannot be subclassed normally.
* The following snippet demonstrates a perfect Date replacement.
*
* Example use:
* CustomDate = Class.create(BaseDate, {
* // custom methods here...
* });
*/