Skip to content

Instantly share code, notes, and snippets.

require 'octokit'
client = Octokit::Client.new(access_token: ENV['ACCESS_TOKEN'])
client.login
client.add_deploy_key(ENV['REPO'], 'shipment@github', File.read('/root/.ssh/id_rsa.pub'))
@loganhasson
loganhasson / deploy.rb
Created July 22, 2014 18:43
Sample mina deploy
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
set :domain, "ip_address"
set :deploy_to, "/path/to/app"
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, "ssh_clone_url"
set :branch, "branch"
set :user, "username"
class FileFinder
def self.location_to_dir(dir_name)
new.location_to_dir(dir_name)
end
def location_to_dir(dir_name)
File.join(File.dirname(File.expand_path(__FILE__)), "#{dir_name}")
end
def self.location_to_file(file_name)
function gho () {
if [ -n "$3" ]; then
private=$("false")
else
private=$("true")
fi
curl -s -u 'username:apikey' https://api.github.com/orgs/"$2"/repos -d "{\"name\":\"$1\",\"private\":\"$private\"}"
}
after "deploy:symlink", "deploy:restart_workers"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}"
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end
/*global PushStream WebSocketWrapper EventSourceWrapper EventSource*/
/*jshint evil: true, plusplus: false, regexp: false */
/**
* Copyright (C) 2010-2013 Wandenberg Peixoto <[email protected]>, Rogério Carvalho Schneider <[email protected]>
*
* This file is part of Nginx Push Stream Module.
*
* Nginx Push Stream Module is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
FROM ubuntu
MAINTAINER Eric Mill "[email protected]"
# turn on universe packages
RUN echo "deb http://archive.ubuntu.com/ubuntu raring main universe" > /etc/apt/sources.list
RUN apt-get update
# basics
RUN apt-get install -y nginx openssh-server git-core openssh-client curl
RUN apt-get install -y nano
@loganhasson
loganhasson / actioncontroller-live.js
Created July 1, 2014 22:15
boilerplate js for actioncontroller::live
$(function(){
function initialize() {
var source = new EventSource('/stream?name=Logan');
source.addEventListener('message', function(e){
console.log("Received "+e.data);
updateMessagesList(e.data);
}, false);
source.addEventListener('open', function(e){
console.log('Connection was opened.');
@loganhasson
loganhasson / .irbrc
Created June 26, 2014 14:56
flatiron irbrc
class Object
def lm
(self.methods - Object.methods).sort
end
def lim
(self.instance_methods - Object.instance_methods).sort
end