# Fetch latest version
TAG=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases | jq -r '.[] | .tag_name' | head -n 1)
echo $TAG
# Remove the `v` prefix
VERSION=$(echo $TAG | sed 's/v//')
echo $VERSION
This file contains hidden or 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/sh | |
| # @author: Jarle Friestad | |
| # Based on script by Claus Witt (http://clauswitt.com/319.html) | |
| # Adding or Removing Items to hosts file | |
| # Use -h flag for help | |
| DEFAULT_IP=127.0.0.1 | |
| IP=${3:-$DEFAULT_IP} | |
This file contains hidden or 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
| namespace :deploy do | |
| namespace :assets do | |
| Rake::Task['deploy:assets:precompile'].clear_actions | |
| desc "Precompile assets on local machine and upload them to the server." | |
| task :precompile do | |
| run_locally do | |
| execute 'RAILS_ENV=production bundle exec rake assets:precompile' | |
| end |
This file contains hidden or 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
| # this monit config goes in /etc/monit/conf.d | |
| check process puma_master | |
| with pidfile /data/myapp/current/tmp/puma.pid | |
| start program = "/etc/monit/scripts/puma start" | |
| stop program = "/etc/monit/scripts/puma stop" | |
| group myapp | |
| check process puma_worker_0 | |
| with pidfile /data/myapp/current/tmp/puma_worker_0.pid |
When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.
There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the
This file contains hidden or 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 "bigdecimal" | |
| # List of our individual pricing rules | |
| TAX = ->(val) { val + val*0.05 } | |
| FEE = ->(val) { val + 1 } | |
| PREMIUM = ->(val) { val + 10 } | |
| DISCOUNT = ->(val) { val * 0.90 } | |
| ROUND_TO_CENT = ->(val) { val.round(2) } | |
| # One presenter | |
| PRESENT = ->(val) { val.to_f } |
In your command-line run the following commands:
brew doctorbrew update
This file contains hidden or 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
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains hidden or 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
| # p4merge for 64 bit | |
| wget https://cdist2.perforce.com/perforce/r18.2/bin.linux26x86_64/p4v.tgz | |
| tar zxvf p4v.tgz | |
| sudo cp -r p4v-* /usr/local/p4v/ | |
| sudo ln -s /usr/local/p4v/bin/p4merge /usr/local/bin/p4merge |
This file contains hidden or 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 'minitest/mock' | |
| require 'minitest/unit' | |
| require 'date' | |
| MiniTest::Unit.autorun | |
| class TestMailPurge < MiniTest::Unit::TestCase | |
| class MailPurge | |
| def initialize(imap) | |
| @imap = imap |
NewerOlder