Skip to content

Instantly share code, notes, and snippets.

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

Kyle Welsby kylewelsby

🏠
Working from home
View GitHub Profile
daemon off;
error_log /dev/stdout error;
worker_processes 4;
events {
worker_connections 1024;
}
@kylewelsby
kylewelsby / prepare
Created September 25, 2013 12:02
prepare rails application with ProstgreSQL and Redis
#!/bin/bash -e
cp config/database.yml.example config/database.yml
# bundle install
postgres -D /usr/local/var/postgres > /dev/null 2>&1 &
POSTGRES_PID=$!
redis-server > /dev/null 2>&1 &
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page</title>
</head>
<body>
<div>
<div>
<strong>Hello World</strong>
@kylewelsby
kylewelsby / Dockerfile
Created August 7, 2013 16:56
Proposed docker module syntax
# vi: expandtab filtype=dockerfile
FROM base
MAINTAINER Lee Hambley "[email protected]"
# Debian isn't too smart, there's no tty dude!
ENV DEBIAN_FRONTEND noninteractive
# Update Apt, never a bad move
RUN apt-get update
@kylewelsby
kylewelsby / ability.rb
Created July 19, 2013 14:01
RSpec to test a cancan ability of 'create'
class Ability
include CanCan::Ability
def initialize(user)
can :create, Something
end
end
/* global module:false */
module.exports = function(grunt) {
grunt.initConfig({
karma:{
unit: {
configFile: 'karma.conf.js'
}
},
watch: {
files: [
@kylewelsby
kylewelsby / capybara_selecting_test.rb
Created June 14, 2013 14:52
Selecting content from a page and rendering it into an array of hashes `ruby server.rb` to start the server before running test.
require_relative 'test_helper'
require 'capybara'
require 'capybara/poltergeist'
class ArraySotringTest < MiniTest::Test
def test_drill_down
session = Capybara::Session.new(:poltergeist)
session.visit "http://0.0.0.0:9494/"
@kylewelsby
kylewelsby / array.rb
Created June 14, 2013 14:22
is there any cleaner way of writing this.
# example 1
array = [1] # input value is a single item in aray
array = array.size == 1 ? array.first : array
# => 1
# example 2
array = [1,2,3] # input value is a collection of items in a array
array = array.size == 1 ? array.first : array
# => [1,2,3]
@kylewelsby
kylewelsby / common.rb
Created June 14, 2013 13:49
Find common items within two arrays.
a1 = ["html", "body", "ul", "li", "a"]
a2 = ["html", "body", "ul", "li", "p"]
a1.zip(a2).map{|n| n.first if n.first == n.last}.compact