Skip to content

Instantly share code, notes, and snippets.

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

Peter Vandenberk pvdb

🖥️
Making computers do things!
View GitHub Profile
@pvdb
pvdb / SSLPoke.java
Created May 18, 2016 19:21 — forked from 4ndrej/SSLPoke.java
Test of java SSL / keystore / cert setup. Check the commet #1 for howto.
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
@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 / gem-reset.rb
Last active December 23, 2015 00:29 — forked from nixpulvis/gem-reset
#!/usr/bin/env ruby
# Remove all gems EXCEPT defaults :)
`gem list -d`.split(/\n\n^(?=\w)/).each do |data|
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/)
name = match[:name]
versions = match[:versions].split(', ')
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/)
next if match[1].empty? # it's the only version if this match is empty
#!/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]
#
# http://github.com/thoughtbot/paperclip/issues/issue/247
#
#
# put this in the relevant section of your config/application.rb
#
config.after_initialize do