Skip to content

Instantly share code, notes, and snippets.

@wvengen
wvengen / README.md
Last active March 25, 2024 07:53
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

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

@simondavies
simondavies / VueJS-Cookies-message.js
Last active June 14, 2016 09:02
Example Combination of Vue JS with ES2015 style, using babelify to ports to the current ES5.
/**
* Cookies Pop Up Component
* A pop up to inform the user that cookies are used on a/this site.
*
* usage:
* <cookie></cookie>
*
* User Overwite the generic message and expiry days,
* add 'cookie-message' and/or 'days-to-expire' properties to the component
* <cookie
@Guitlle
Guitlle / pieChartFromObject.js
Created April 22, 2014 21:33
Sparkline pie chart from object. the tooltips are the object keys and the values are the object value for each key.
function pieChartFromObject(data, options, className) {
var labels = [], total = 0,
values = $.map(data, function(value, label) { total += value; labels.push(label); return value; });
var chart = $('<span class="'+className+'">&nbsp;</span>');
options.type = 'pie';
options.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> {{offset:labels}} - {{value}} ({{percent.1}}%)';
options.tooltipValueLookups = { labels: labels} ;
if (total == 0) {
@suryart
suryart / application.html.erb
Last active October 26, 2023 00:16
Rails 4 flash messages using Twitter Bootstrap(bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass). An improved version of https://gist.github.com/roberto/3344628
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>
@rsim
rsim / 01_thread.rb
Created March 26, 2013 21:15
Code examples from my "Using threads in Ruby applications" presentation in our local Ruby meetup http://www.meetup.com/ruby-on-rails-latvia/events/105142132/
Thread.new do
sleep 5
puts "finished"
end
thread = Thread.new do
sleep 5
puts "finished"
end
thread.join
@mperham
mperham / retries.rb
Created October 19, 2012 22:15
Sidekiq retry management API
require 'sidekiq'
module Sidekiq
# Encapsulates a single job awaiting retry
class Retry
attr_reader :score, :item
def initialize(score, item)
@score = score
@item = Sidekiq.load_json(item)
@kevinSuttle
kevinSuttle / meta-tags.md
Last active May 12, 2024 15:28 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@vraravam
vraravam / translator.rb
Created August 5, 2011 05:32
Use Google translate to translate a yml file from one language to generate a new one for a different language
#!/usr/bin/env ruby
if ARGV.size != 2
puts "Usage: #{$0} <from_language> <to_language>"
exit -1
end
require 'rubygems'
require 'ya2yaml' # this gem is needed for this to work!
require 'yaml'
@tmm1
tmm1 / gist:329682
Created March 11, 2010 21:31
EM Chat Server Demo
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
class String
def bold
"\033[1m#{self}\033[0m"
end
end