Skip to content

Instantly share code, notes, and snippets.

View pvdb's full-sized avatar
🖥️
Busy making computers do things!

Peter Vandenberk pvdb

🖥️
Busy making computers do things!
View GitHub Profile
#!/usr/bin/ruby
require 'rubygems'
installed_gems = Gem::Dependency.new '', Gem::Requirement.default
missing = []
# mind the short-hand, looping over installed gem specs
specs = Gem.source_index.search installed_gems
specs.each do |spec|
gem = Gem::Dependency.new spec.name, spec.version
# looping over gem dependencies
specs = Gem.source_index.search gem
@pvdb
pvdb / benchmark.rb
Last active December 10, 2015 07:08
a multi-dimensional Ruby benchmark script :-)
#!/usr/bin/env ruby
#
# NAME
#
# benchmark.rb -- a multi-dimensional Ruby benchmark script :-)
#
# DESCRIPTION
#
# a customized Ruby "interpreter" that benchmarks
# other Ruby scripts... by default, both resident
@pvdb
pvdb / fields_inheritance_fix.rb
Created May 17, 2012 07:12
mongoid - git bisect FTW!
#!/usr/bin/env ruby
$:.unshift File.join File.dirname(__FILE__), "lib"
require 'mongoid.rb'
class Shape
include Mongoid::Document
field :x, type: Integer, default: 0
field :y, type: Integer, default: 0
@pvdb
pvdb / markdown.xml
Created May 14, 2012 20:57 — forked from lg0/markdown.xml
Markdown Syntax Highlighting for Sublime text 2
<!-- copy this to YOUR_THEME.tmTheme-->
<dict>
<key>name</key>
<string>diff: deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#EAE3CA</string>
$ export GITHUB_USER="your-github-username"
$ export GITHUB_PASSWORD="your-github-password"
@pvdb
pvdb / methodfinder.rb
Created March 30, 2011 20:11
MethodFinder and irb via .irbrc
#
# https://github.com/citizen428/methodfinder
#
# stick the below snippet in your .irbrc file
# in order to be able to do something like...
#
# irb :001 > ' blegga '.method_finder 'blegga'
# => [:strip, :strip!]
# irb :002 > 'blegga'.method_finder 6
# => [:bytesize, :length, :size]
@pvdb
pvdb / deploy.md
Created March 13, 2011 10:09
Capistrano start/stop/restart tasks for Phusion Passsenger Standalone

With the introduction of Phusion Passenger Standalone, some of the established wisdom with regards to Capistrano tasks for managing Passenger are a tad outdated.

In particular, the start and stop tasks for Passenger are typically NOOPs, and only the restart task is deemed relevant. This is arguably no longer the case for standalone Passenger, where start and stop tasks do make sense, as they did back in the mongrel days.

The following Capistrano tasks illustrate how to start, stop and restart a standalone Passenger setup.

These tasks are for a Passenger setup that uses Unix domain sockets, but they can easily be modified for Passenger instances configured for TCP sockets.

    namespace :deploy do

task :start, :roles => :app, :except => { :no_release => t

@pvdb
pvdb / list_targets.sh
Last active August 16, 2024 15:26
List all targets (sometimes incorrectly referred to as "goals") in a GNU Makefile
#
# this gist can be used to list all targets, or - more correctly - rules,
# that are defined in a Makefile (and possibly other included Makefiles)
# and is inspired by Jack Kelly's reply to a StackOverflow question:
#
# http://stackoverflow.com/questions/3063507/list-goals-targets-in-gnu-make/3632592#3632592
#
# I also found this script - http://www.shelldorado.com/scripts/cmds/targets - which does
# something similar using awk, but it extracts targets from the "static" rules from a single
# Makefile, meaning it ignores any included Makefiles, as well as targets from "dynamic" rules
#
# http://github.com/thoughtbot/paperclip/issues/issue/247
#
#
# put this in the relevant section of your config/application.rb
#
config.after_initialize do
#
# ActiveRecord SQL Logging on the Rails Console - revisited/updated
# -----------------------------------------------------------------
#
# If you're living on the edge ("edge Rails", that is) and would like to
# log all SQL statements executed by ActiveRecord to STDOUT when you're
# in a Rails console, then the ConsoleLogSubscriber class is for you!
#
# Notes:
#