Skip to content

Instantly share code, notes, and snippets.

View johndel's full-sized avatar
🖖

John Deliyiannis johndel

🖖
View GitHub Profile
@johndel
johndel / viva_payment.rb
Created October 27, 2014 16:16
Viva Payment
if Rails.env.production?
@viva_url = "https://www.vivapayments.com"
@rest = RestClient::Resource.new "#{@viva_url}/api/orders", :user => "user_id4", :password => "password"
else
@viva_url = "http://demo.vivapayments.com"
@rest = RestClient::Resource.new "#{@viva_url}/api/orders", :user => "user_id", :password => "password"
end
email = @order.email
phone = @order.phone
@johndel
johndel / your_project_sidekiq.conf
Created October 3, 2014 15:01
sidekiq conf for monit
check process your_project_sidekiq
with pidfile /your_project/current/tmp/pids/sidekiq.pid
start program = "/bin/bash -l -c 'cd /your_project/current && bundle exec sidekiq -e staging -C config/sidekiq.yml -d -P tmp/pids/sidekiq.pid -L log/sidekiq.log'"
stop program = "/bin/bash -l -c kill -s TERM `cat /your_project/current/tmp/pids/sidekiq.pid`"
@johndel
johndel / your_project_unicorn.conf
Created October 3, 2014 14:59
unicorn conf for monit
check process your_project_unicorn
with pidfile /your_project_unicorn/current/tmp/pids/unicorn.pid
start program = "/bin/bash -l -c 'cd /your_project_unicorn/current && bundle exec unicorn -E staging -c /your_project_unicorn/current/config/unicorn.rb -D'"
stop program = "/bin/bash -l -c kill -QUIT `cat /your_project_unicorn/current/tmp/pids/unicorn.pid`
@johndel
johndel / ssh.conf
Created October 3, 2014 14:56
ssh conf for monit
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
@johndel
johndel / nginx1.conf
Last active August 29, 2015 14:07
Nginx conf for monit
check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
@johndel
johndel / redis.conf
Created October 3, 2014 14:53
Redis conf for monit
check process redis-server
with pidfile "/var/run/redis/redis-server.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
@johndel
johndel / monitrc
Created October 3, 2014 14:40
monitrc basic file
set daemon 30
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue
basedir /var/lib/monit/events # set the base directory where events will be stored
slots 100 # optionally limit the queue siz
set httpd port 2812
allow 0.0.0.0/0.0.0.0
allow username:password
.groups{ng_repeat: "row in [] | skip_range:0:keyword_groups.length-1:3"}
.group{ng_repeat: "keyword_group in [] | range:row*3:((row+1)*3)-1:keyword_groups"}
#!/usr/bin/ruby
require 'aws-sdk'
require 'mail'
# The filename for using it during the script and the location
filename = "#{Time.now.to_s.split(" ").first}_data_only_dump.sql"
store_location = "/home/your_user/your_backups/#{filename}"
# Local backup of a postgres database
`pg_dump -U your_user your_db_name -f #{store_location} --data-only`
@johndel
johndel / cagniotte.rb
Created July 12, 2014 08:10
Calculation of cagniotte
bet1 = 2.25
bet2 = 3.15
bet3 = 3.15
puts "#{(1 - 1/(1/bet1 + 1/bet2 + 1/bet3)) * 100}%"