Skip to content

Instantly share code, notes, and snippets.

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

Ashley Connor ashleyconnor

🏠
Working from home
View GitHub Profile
@ashleyconnor
ashleyconnor / go_getter.go
Created May 21, 2014 21:25
Go Getter - Go program that fetches a webpage and outputs to STDOUT
package main
import (
"fmt"
"net/http"
"io/ioutil"
"os"
)
func main() {
@ashleyconnor
ashleyconnor / unicorn
Last active August 29, 2015 14:06 — forked from shapeshed/unicorn
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@ashleyconnor
ashleyconnor / gist:8cfecc5eeea300f69bcc
Created September 18, 2014 15:36
Context Validations
class Article
with_options on: :view do |on_view|
on_view.validate :has_been_published
on_view.validate :is_not_spam
end
def viewable?
valid? :view
end
# unicorn
description "unicorn ruby app server"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [2345])
stop on runlevel [!2345]
env WORKDIR=/data
env PIDFILE=/data/tmp/pids/unicorn.pid
env CFGFILE=/data/config/unicorn.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver
#!/bin/sh
# init.d script for basexserver http://basex.org/
# (c) 2012 Andy Bunce <bunce.andy@gmail.com>, BSD
# (c) 2015 Ashley Connor <ashconnor@me.com>, LICENSE AS ABOVE
### BEGIN INIT INFO
# Provides: basex-server
# Required-Start: $syslog
# Required-Stop: $syslog
@ashleyconnor
ashleyconnor / logstash.conf
Last active August 29, 2015 14:19
Example logstash config
input {
tcp { port => 3333 type => "json event" codec => json_lines {} }
stdin {
type => "stdin-type"
}
file {
type => "syslog"
path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
input {
tcp { port => 3333 type => "json" }
stdin {
type => "stdin-type"
}
file {
type => "syslog"
path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
@ashleyconnor
ashleyconnor / Berksfile
Created August 8, 2015 05:27
Vagrantfile for Berkshelf and Chef Zero
source "https://supermarket.chef.io"
cookbook 'apt', '~> 2.7.0'
cookbook 'build-essential', '~> 2.2.3'
cookbook 'git', '~> 4.3.3'
cookbook 'heroku-toolbelt', '~> 0.1.0'
cookbook 'imagemagick', '~> 0.2.3'
cookbook 'nginx', '~> 2.7.6'
cookbook 'nodejs', '~> 2.4.0'
cookbook 'postgresql', '~> 3.4.20'