Skip to content

Instantly share code, notes, and snippets.

@kixorz
kixorz / gist:5281849
Created March 31, 2013 20:15
Installing nginx with passenger for Rails on CentOS
#assuming rvm installed with Ruby 2+
#install latest passenger gem
gem install passenger --pre
#install nginx from sources with passenger module
passenger-install-nginx-module
@kixorz
kixorz / gist:5281510
Last active May 30, 2016 20:33
Zabbix 2.0+ temperature monitoring configuration using IPMI
#zabbix user needs to be in /etc/sudoers to be able to execute ipmitool
zabbix ALL=NOPASSWD: /usr/bin/ipmitool
#zabbix config has to collect desired UserParameters
UserParameter=ipmi.ambient_temp,sudo ipmitool sdr | grep "Ambient" | awk '{print $3}' | head -1
UserParameter=ipmi.cpu_temp,sudo ipmitool sdr | grep "CPU" | awk '{print $3}' | head -1
UserParameter=ipmi.cpu_fan,sudo ipmitool sdr | grep -i "FAN1 SYS" | awk '{print $4}' | head -1
UserParameter=ipmi.cpu_fan_status,sudo ipmitool sdr | grep -i "FAN1 SYS" | awk '{print $7}' | head -1
#after restart of zabbix_agentd, collected values can be tested via
@kixorz
kixorz / gist:5242651
Last active December 15, 2015 09:59
Useful commands
#mysql
#export
mysqldump -u root -p <db> > <filename>.sql
#import
mysql -u root -p <db> < <filename>.sql
#mongo
#export
@kixorz
kixorz / aws_autoscaling_cron.rb
Created March 20, 2013 22:41
Running cron jobs in AWS Auto Scaling group is tricky. When you deploy the same code and configuration to all instances in the group, cron job would run on all of them. You may not want that. This script detects the first instance in the group and allows only this instance to run the job. IAM user used by this script needs to have permissions to…
#!/usr/bin/env ruby
require 'syslog'
require 'net/http'
require 'aws-sdk'
Syslog.open
AWS.config({
:access_key_id => '<iam user key>',
:secret_access_key => '<iam user secret>'
@kixorz
kixorz / aws_iam_policy.json
Last active April 11, 2022 10:32
Update Route53 DNS records from your EC2 instance using this simple Ruby script. You can call it from rc.local after setting your hostname locally. First parameter is the desired <hostname>.<domain> Domain and other parameters are hardcoded. This script is useful for handling internal DNS changes in your systems after instance changes. Attached …
{
"Statement": [
{
"Action": [
"route53:ChangeResourceRecordSets",
"route53:GetHostedZone",
"route53:ListResourceRecordSets"
],
"Effect": "Allow",
"Resource": [
@kixorz
kixorz / gist:5127099
Last active December 14, 2015 18:09
Globally Handling Not Found in Rails with Mongoid
class ApplicationController < ActionController::Base
rescue_from Mongoid::Errors::DocumentNotFound, :with => :rescue_not_found
protected
def rescue_not_found
render :template => 'application/not_found', :status => :not_found
end
end
@kixorz
kixorz / ares_document.json
Created December 6, 2012 05:01
Ares Spider
{
"Ares_odpovedi": {
"xmlns:are": "http:\/\/wwwinfo.mfcr.cz\/ares\/xml_doc\/schemas\/ares\/ares_answer_or\/v_1.0.3",
"xmlns:D": "http:\/\/wwwinfo.mfcr.cz\/ares\/xml_doc\/schemas\/ares\/ares_datatypes\/v_1.0.3",
"xmlns:U": "http:\/\/wwwinfo.mfcr.cz\/ares\/xml_doc\/schemas\/uvis_datatypes\/v_1.0.3",
"odpoved_datum_cas": "2012-12-06T06:04:46",
"odpoved_pocet": "1",
"odpoved_typ": "Vypis_OR",
"vystup_format": "XML",
"xslt": "klient",