Skip to content

Instantly share code, notes, and snippets.

View paulsturgess's full-sized avatar

Paul Sturgess paulsturgess

View GitHub Profile
class PaulAndRobin < RTanque::Bot::Brain
NAME = 'paul_and_robin'
include RTanque::Bot::BrainHelper
def tick!
command.speed = 1.5
new_heading = if sensors.position.on_wall?
sensors.heading + RTanque::Heading::HALF_ANGLE
else
RTanque::Heading.rand
@paulsturgess
paulsturgess / local_ignore.md
Created May 2, 2013 15:57
GIT: Ignore local changes made to a file that cannot be in the .gitignore

For example, ignore your .rvmrc file:

git update-index --assume-unchanged .rvmrc

Find out which files will always be considered as unchanged:

git ls-files -v | grep ^[a-z]

Remove the unchanged flag:

@paulsturgess
paulsturgess / attr_accessor_dates.md
Created May 2, 2013 08:11
How to set an attr_accessor date via Rails date_select and have Rails handle the multi-attributes automatically.

Your Class:

class YourClass < ActiveRecord::Base
  attr_accessor :some_date
  columns_hash["some_date"] = ActiveRecord::ConnectionAdapters::Column.new("some_date", nil, "date")
end

Your View:

<%= form_for :your_class do |f| %>

@paulsturgess
paulsturgess / pg.sh
Last active December 16, 2015 11:39 — forked from cjolly/pg.sh
pg_ctl -D /usr/local/var/postgres stop -s -m fast
launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
rm ~/Library/LaunchAgents/org.postgresql.postgres.plist
mv /usr/local/var/postgres/ /usr/local/var/postgres-9.0.4/
brew update
brew upgrade postgresql
cp /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@paulsturgess
paulsturgess / mpd.md
Last active December 16, 2015 06:59
MPD On OSX

Installation

brew install mpd

Config

~/.mpdconf

port "6600"

cd /etc/ssl
openssl req -nodes -newkey rsa:2048 -keyout domain.key -out domain.csr
Generating a 2048 bit RSA private key
.................................................................................+++
........................+++
writing new private key to 'domain.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
@paulsturgess
paulsturgess / .travis.yml
Last active December 15, 2015 23:59
Get wicked_pdf tests running on Travis
before_script:
- sudo apt-get install -y wkhtmltopdf
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
env: WKHTMLTOPDF_BIN=/usr/bin/wkhtmltopdf
@paulsturgess
paulsturgess / rubymotion bundler.md
Created April 6, 2013 12:36
Setup rvm and bundler for RubyMotion apps

Create rvmrc file:

$ rvm use 1.9.3@yourgemsetname --create --rvmrc

Add bundler to your Rakefile

$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'bundler'

Bundler.require

@paulsturgess
paulsturgess / app_controller.rb
Last active December 15, 2015 11:59
Idea for a standard approach to setting up the basics of a RubyMotion app
class AppController < UIViewController
def loadView
self.view = AppView.alloc.init
end
def viewDidLoad
super
view.viewDidLoad
end
@paulsturgess
paulsturgess / sublime_text.js
Last active December 15, 2015 04:59 — forked from twosixcode/gist:1988097
Make smart paste the default in Sublime Text 2. Put this in: Preferences > Key Bindings - User
// swap the keybindings for paste and paste_and_indent
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" }