Skip to content

Instantly share code, notes, and snippets.

View paulsturgess's full-sized avatar

Paul Sturgess paulsturgess

View GitHub Profile
@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
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 / mpd.md
Last active December 16, 2015 06:59
MPD On OSX

Installation

brew install mpd

Config

~/.mpdconf

port "6600"

@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 / 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 / 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:

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 / Todo.js
Last active June 17, 2017 11:46
Example stateless React Component
import React, { PropTypes } from 'react'
const Todo = ({ onClick, completed, text }) => (
<li
onClick={onClick}
style={{
textDecoration: completed ? 'line-through' : 'none'
}}
>
{text}
@paulsturgess
paulsturgess / Todo.test.js
Last active October 8, 2018 11:22
Testing a stateless component
import React from 'react';
import TestUtils from 'react/lib/ReactTestUtils';
import Todo from './Todo';
describe('Todo', () => {
let instance, li;
let Wrapper = React.createClass({
render: function() {
return this.props.children;
}
@paulsturgess
paulsturgess / redux-container-component.js
Created November 6, 2016 22:13
Redux Container Component
import { connect } from 'react-redux';
import AddTodoForm from '../components/AddTodoForm'
import actions from '../actions';
// mapDispatchToProps receives the dispatch() method and returns
// callback props that can be used to inject into the presentational component
// This means addTodo can be set as a prop when testing AddTodoForm which makes
// it easy to spy and check the correct actions are triggered
export const mapDispatchToProps = (dispatch) => ({
addTodo: (value) => dispatch(actions.addTodo(value))