This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Communicator | |
class Command | |
def initialize(cmd) | |
@cmd = cmd | |
end | |
def execute(params = []) | |
`#{@cmd} #{params.join(' ')}` | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'communicator' | |
include Communicator | |
ls = Command.new('ls') | |
ls.execute().each do |l| | |
puts l | |
end | |
p ls.execute(['-l']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
=begin | |
to add vhost we do the following: | |
1- create directory | |
2- create configration file | |
3- enable vhost with a2ensite | |
4- reloading apache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
nodes = [ { :name => "station1", | |
:services => { :ssh => { :listenaddress => "192.168.0.254", | |
:sshd_port => "2222" | |
} | |
} | |
}, | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'logger' | |
require 'rubygems' | |
require 'wirble' | |
require 'pp' | |
Wirble.init | |
Wirble.colorize | |
# require 'utility_belt' | |
if ENV.include?('RAILS_ENV')&& !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def kata(digits = [], has_pair = false) | |
if digits.inject {|sum, digit| sum + digit } == 15 | |
has_pair ? [digits] : [] | |
else | |
start = (digits.last || 0) + 1 | |
(start..9).inject([]) do |result, digit| | |
result + kata(digits + [digit], has_pair) + kata(digits + [digit, digit], true) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def kata(digits = [], sum = 0, has_pair = false) | |
if sum < 15 | |
start = (digits.last || 0) + 1 | |
(start..9).inject([]) do |result, digit| | |
result + | |
kata(digits + [digit], sum + digit, has_pair) + | |
kata(digits + [digit, digit], sum + digit + digit, true) | |
end | |
elsif sum == 15 && has_pair | |
[digits] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
access_log /opt/nginx/logs/test_server.access.log main buffer=32k; | |
error_log /opt/nginx/logs/test_server.error.log info; | |
expires 6h; | |
listen 2300 default rcvbuf=64k backlog=128; | |
root /opt/apps/test_server/current/public; | |
server_name test_server.com www.test_server.com; | |
passenger_enabled on; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pid /opt/nginx/logs/nginx.pid; | |
# Run as the nginx user | |
user nginx nginx; | |
worker_processes 2; | |
error_log /opt/nginx/logs/error.log notice; | |
events { | |
worker_connections 1024; | |
use epoll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
OlderNewer