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

Keybase proof

I hereby claim:

  • I am timmillwood on github.
  • I am timmillwood (https://keybase.io/timmillwood) on keybase.
  • I have a public key ASAI3wNnBXmeCRzcC3YoQ62_8xmYTqO9wciT2mbTwNvxRwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am timmillwood on github.
  • I am timmillwood (https://keybase.io/timmillwood) on keybase.
  • I have a public key ASAqa8R3rEYmHvzj4byrtJpU5Cd9AgY0C-K_AhutZ7WMNQo

To claim this, I am signing this object:

#!/bin/bash
echo "Starting Deploy..."
echo "Check for the files directory, if not created - create it"
if [ ! -d ${OPENSHIFT_DATA_DIR}sites/default/files ]; then
mkdir -p ${OPENSHIFT_DATA_DIR}sites/default/files
echo "Done creating files directory"
else
@timmillwood
timmillwood / mymodule.install
Created March 24, 2015 09:21
Importing a po file in hook update
<?php
/**
* Add pt translations
*/
function hook_update_7001() {
$path = drupal_get_path('module', 'mymodule');
$poFile = $path . '/translations/pt-pt-mymodule-7.x-1.0.po';
$file = new stdClass;
$file->uri = $poFile;
@timmillwood
timmillwood / application_controller.rb
Created June 19, 2014 14:41
app wide error handling
class ApplicationController < ActionController::Base
rescue_from Exception do |exception|
respond_to do |format|
format.html { redirect_to '/', :alert => exception.message }
format.js { render :js => "window.location.replace('/'); alert('#{html_escape(exception.message)}');" }
end
end
end
@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 {
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"
#!/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 / 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'
@timmillwood
timmillwood / gist:3951620
Created October 25, 2012 09:28
Simple Sinatra app
require 'sinatra'
get '/hi' do
"Hello World!"
end