Skip to content

Instantly share code, notes, and snippets.

View timmillwood's full-sized avatar
🏠
Working from home

Tim Millwood timmillwood

🏠
Working from home
View GitHub Profile
@timmillwood
timmillwood / bashrc
Created July 29, 2012 21:16
function for opening files and folders in geany
function geany {
if [ -d $1 ]; then
cd $1;
for FILE in `dir -d *`; do
(/usr/bin/geany $FILE &);
done
else
for ARG in "$@"
do
(/usr/bin/geany $ARG &);
@timmillwood
timmillwood / gist:3775799
Created September 24, 2012 12:50
PHP for Developers - Exercise: Creating Classes
// index.php
<?php
function __autoload($classname) {
$filename = "./". $classname .".php";
include_once($filename);
}
$article = new Article('My Article', 'This is my article\'s body, it even escapes <strong>HTML</strong>');
@timmillwood
timmillwood / drupal-quick-dump.sh
Last active October 28, 2019 07:49 — forked from webbj74/drupal-quick-dump.sh
Script to dump Drupal database structure, but exclude data from massive/unneeded tables.
#!/bin/bash
# usage: drupal-quick-dump user host database
USER="$1"
HOST="$2"
DB="$3"
DATE=`date +%Y%m%d`
# Get User Password
echo "Please provide the password for ${USER} on db ${DB} hosted at ${HOST}:"
@timmillwood
timmillwood / dcmc-git.sh
Created October 11, 2012 09:58
script to migrate DC git repo to MC
#!/bin/bash
dc_git="$1"
mc_git="$2"
git clone --mirror ${dc_git} dc
cd dc
git remote add mc ${mc_git}
git push --mirror mc
cd ..
@timmillwood
timmillwood / gist:3932121
Created October 22, 2012 15:38
sinatra redirect
before do
if ['www.millwoodonline.com', 'millwoodonline.com', 'millwoodonline.co.uk'].include? request.host
redirect "http://www.millwoodonline.co.uk" + request.path
end
end
@timmillwood
timmillwood / gist:3951620
Created October 25, 2012 09:28
Simple Sinatra app
require 'sinatra'
get '/hi' do
"Hello World!"
end
@timmillwood
timmillwood / sinatra_redis_cache.rb
Created October 31, 2012 10:34 — forked from antirez/sinatra_redis_cache.rb
the simplest Redis caching for Sinatra -- not even tested... consider this code just an hint
# This is just an hint for a simple Redis caching "framework" using Sinatra
# A friend of mine asked for something like that, after checking the first two gems realized there was
# a lot of useless complexity (IMHO). That's the result.
#
# The use_cache parameter is useful if you want to cache only if the user is authenticated or
# something like that, so you can do cache_url(ttl,User.logged_in?, ...)
require 'rubygems'
require 'sinatra'
require 'redis'
#!/bin/bash
dc_git="$1"
mc_git="$2"
git clone --mirror ${dc_git} dc
cd dc
git remote add mc ${mc_git}
git push --mirror mc
cd ..
require 'sinatra/base'
require 'sinatra/assetpack'
require 'sass'
require 'bootstrap-sass'
class App < Sinatra::Base
path = File.expand_path(File.dirname(__FILE__))
set :root, '/'
set :views, "#{path}/views"
@timmillwood
timmillwood / style.scss
Created March 10, 2014 11:18
Millwood Online mixin
@mixin body-background($width) {
@media (max-width: #{$width}px) {
$height: $width / 3.26853707;
background-image: url('http://res.cloudinary.com/hghr6de3u/image/upload/c_scale,q_75,w_#{$width}/AbergavennyBackground_lldg0t.jpg');
#banner {
height: #{$height}px;
@if $width > 768 {
padding-top: 5em;
}
@else {