Skip to content

Instantly share code, notes, and snippets.

View dotmh's full-sized avatar

Martin Haynes dotmh

View GitHub Profile
# Setting up a local solr instance on a mac
# install solr with homebrew
brew install solr
# create the base solr index directory
mkdir -p /data/solr
# make sure you can write to the solr logs
sudo chown -R `whoami` /usr/local/Cellar/solr/
@dotmh
dotmh / Gemfile
Created October 28, 2013 17:51
This is the standard Rails Gemfile , that I use for most rails projects as a starting base.
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use mysql as the database for Active Record
gem "mysql2"
# Adds foreign key support to rails Active Record
# https://github.com/matthuhiggins/foreigner
@dotmh
dotmh / Error in log
Last active December 22, 2015 23:49
Image cropper error using carrier wave
CarrierWave::ProcessingError (Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: Command ("mogrify -crop '217x217+0+136' /var/folders/1_/fj3rk_750w32l91pxp59xz180000gn/T/mini_magick20130913-12950-ul75bn.jpg") failed: {:status_code=>1, :output=>"mogrify: invalid argument for option `'217x217+0+136'': -crop @ error/mogrify.c/MogrifyImageCommand/4227.\n"}):

How to use a PS3 controller on Mac OS X 10.7 (Lion)

  1. Open Apple menu -> System Preferences -> Bluetooth and disable Bluetooth on Mac as well as any other nearby Macs or devices which will try to pair with and confuse the controller.

  2. Reset PS3 controller by inserting paperclip into pinhole near L2 button.

  3. Connect PS3 controller to Mac with USB cable.

  4. Enable Bluetooth.

Implement Routing for Subdomains

Rails 3.0 introduced support for routing constrained by subdomains.

A subdomain can be specified explicitly, like this:

match '/' => 'home#index', :constraints => { :subdomain => 'www' } 
@dotmh
dotmh / gist:2988172
Created June 25, 2012 11:54 — forked from sasimpson/gist:1112739
Ruby Net:HTTP chunked transfer
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
@dotmh
dotmh / inspect.rb
Created June 10, 2012 06:05
A ruby hash inspector
def inspect data , depth = 0
data.each do | key , value |
if value.class == Hash
spacing = ''
depth.times { spacing << '-' }
puts spacing+' '+key.to_s
inspect value , depth+1
else
spacing = ''
@dotmh
dotmh / alpha.jquery.js
Created June 8, 2012 08:56
A Jquery Alpha range plugin
(function($){
$.alphaRange = function(from , to , onlyLetters) {
var startLetter = from || 'A',
endLetter = to || 'Z',
start = startLetter.charCodeAt(0),
end = endLetter.charCodeAt(0),
length = end - start,
letter = 0,
@dotmh
dotmh / popdown.jquery.js
Created June 7, 2012 16:09
jQuery pop down menu
(function($){
$.fn.popdown = function( trigger_at ) {
var element = this;
var trigger = trigger_at;
$(document).scroll(function(e){
var spos = $(document).scrollTop();
if (spos >= trigger) {
@dotmh
dotmh / server.rb
Created June 6, 2012 09:12
really stupid and simple web server for static content
#!/usr/bin/env ruby
require 'sinatra'
PUBLIC_FOLDER = File.join(File.dirname(__FILE__) , 'site')
set :public_folder , PUBLIC_FOLDER
set :static , true
get '/' do
File.open(File.join(PUBLIC_FOLDER , 'index.html') , 'r').read.to_s