Skip to content

Instantly share code, notes, and snippets.

View lcx's full-sized avatar

Cristian Livadaru lcx

View GitHub Profile
#! /usr/bin/env ruby
# encoding: UTF-8
#
# check-smart
#
# DESCRIPTION:
#
# OUTPUT:
# plain text
#
def initialize(device_id)
@device_path = "-d megaraid,#{device_id} /dev/sda"
@smart_available = false
@smart_enabled = false
@smart_healty = nil
check_smart_capability!
check_health! if smart_capable?
end
def scan_disks!
output = `sudo /usr/sbin/storcli /c0 /eall /sall show J`
parsed_output = JSON.parse(output)
critical "Can't get device ID from storcli" unless parsed_output["Controllers"][0]["Command Status"]["Status"]=="Success"
parsed_output["Controllers"][0]["Response Data"]["Drive Information"].each do |drive|
@devices << Disk.new(drive["DID"])
end
end
# encoding: UTF-8
class Shop
SHOP_CONFIG = YAML.load_file("#{Rails.root}/config/holvi_config.yml")[Rails.env]
def self.get_shop_url
holvi_request = {}
holvi_request["pool"] = SHOP_CONFIG["pool"]
holvi_request["purchases"] = [{"product"=>holvi_product_id}]
holvi_request["firstname"] = firstname
holvi_request["lastname"] = lastname
@lcx
lcx / adhearsion.rb
Created March 20, 2014 13:27
Adhearsion with syslog
config.development do |dev|
dev.platform.logging.level = :debug
dev.platform.logging.outputters<<Logging::Appenders::Syslog.new('my_ahn_app')
end
@lcx
lcx / bluepill
Created October 24, 2013 16:41
Debian bluepill init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start: $local_fs $remote_fs $network $syslog $time
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: bluepill daemon, providing process monitoring
# Description: bluepill is a monitoring tool. More info at http://github.com/arya/bluepill.
@lcx
lcx / Gemfile
Created April 19, 2013 10:42
Gemfile for zeus issue #134 of project without issues
source 'https://rubygems.org'
gem 'rails', '3.2.11'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'execjs'
gem 'therubyracer'
end
@lcx
lcx / Gemfile
Created April 19, 2013 10:36
Gemfile for zeus issue #134
source 'https://rubygems.org'
gem 'rails', '3.2.12'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'execjs'
gem 'therubyracer'
end
@lcx
lcx / gist:4655740
Last active December 11, 2015 20:29
Kazoo Restart Server
stop rabbitmq-server
start rabbitmq-server
status rabbitmq-server
bluepill whapps restart
bluepill ecallmgr restart
@lcx
lcx / checkout_controller_decorator.rb
Created September 21, 2012 06:27
Fix for spree_address_book issues 16
Spree::CheckoutController.class_eval do
helper Spree::AddressesHelper
after_filter :normalize_addresses, :only => :update
before_filter :set_addresses, :only => :update
protected
def set_addresses
return unless params[:order] && params[:state] == "address"