Skip to content

Instantly share code, notes, and snippets.

@pvdb
pvdb / process_rss.rb
Last active December 14, 2022 10:50
Get real memory (resident set) used by current Ruby process
#
# This first version should work on Mac OS X and Linux, but it spawns a process
#
# http://stackoverflow.com/questions/7220896/
# https://github.com/rdp/os/blob/master/lib/os.rb#L127
# http://www.ruby-doc.org/core-2.0/Process.html
#
# A better - but more complicated - way to achieve the same is documented here:
#
# https://build.betterup.com/tracking-a-processs-memory-usage-in-ruby/
@JoshCheek
JoshCheek / gc_test.rb
Created September 19, 2012 05:20
Ruby gc not collecting array
THE_STRING = 'a random 369-characterish string'
def self.find_array
ObjectSpace.each_object Array do |array|
return array if array.any? && array.all? { |s| s == THE_STRING }
end
nil
end
def self.print_whether_array_exists
@rolo
rolo / gist:1481128
Created December 15, 2011 13:44
Install Postgres 9.1, PostGIS and create PostGIS template on Ubuntu 11.10 Oneiric Ocelot
#!/bin/bash
#
# Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 11.10 Oneiric Ocelot box
# http://wildfish.com
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update