Skip to content

Instantly share code, notes, and snippets.

View eerohele's full-sized avatar

Eero Helenius eerohele

View GitHub Profile
@eerohele
eerohele / Rakefile
Created February 16, 2012 21:19
A simple Rakefile for running RSpec, Cucumber, or both.
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
namespace :test do
desc 'Run RSpec tests'
RSpec::Core::RakeTask.new(:spec) do |task|
task.rspec_opts = %w[--color --format documentation]
task.pattern = 'spec/*_spec.rb'
end
@eerohele
eerohele / gemspec.rb
Created February 16, 2012 21:36
A template for a RubyGem specification.
require 'rake/gempackagetask'
# RubyGems versioning policy: http://docs.rubygems.org/read/chapter/7
gemspec = Gem::Specification.new do |gs|
gs.name = 'name'
gs.summary = 'summary'
gs.description = File.read(File.join(File.dirname(__FILE__), 'README.md'))
gs.requirements = [ 'requirements' ]
gs.version = '0.0.1'
@eerohele
eerohele / ringbuffer.rb
Last active October 29, 2018 12:00
A simple ring buffer for Ruby.
class RingBuffer < Array
attr_reader :max_size
def initialize(max_size, enum = nil)
@max_size = max_size
enum.each { |e| self << e } if enum
end
def <<(el)
if self.size < @max_size || @max_size.nil?
@eerohele
eerohele / mosh-cygwin.md
Last active March 3, 2024 04:20
Compiling Mosh (http://mosh.mit.edu/) under Cygwin

NOTE: You don't need to compile Mosh on Cygwin yourself anymore; just install the package with Cygwin's setup.exe.

  1. Download Cygwin.

  2. Run setup.exe and install the following packages in addition to the default ones:

    • make
    • boost
    • libncurses-devel
    • pkg-config
  • perl
@eerohele
eerohele / saxon.bat
Created July 24, 2012 10:14
Run an XSL transformation on an XML file with Saxon (XSLT 2.0 compliant)
@echo off
:: PREREQUISITES:
:: DITA Open Toolkit must be installed and the DITA_HOME environment variable
:: must be correctly set.
:: USAGE:
:: saxon.bat stylesheet.xsl source.xml output.xml
set STYLESHEET=%1
@eerohele
eerohele / rffm.bat
Created July 24, 2012 10:17
A batch file for reading FOP font metrics
@echo off
:: PREREQUISITES:
:: DITA Open Toolkit must be installed and the DITA_HOME environment variable
:: must be correctly set.
:: USAGE:
:: rffm.bat fontname.ttf metrics.xml
:: Set input and output files.
@eerohele
eerohele / fop.bat
Created July 24, 2012 10:19
A batch file for running FOP-to-PDF transformation on a .fo file
@echo off
:: PREREQUISITES:
:: DITA Open Toolkit must be installed and the DITA_HOME environment variable
:: must be correctly set.
:: USAGE:
:: fop.bat filename.fo filename.pdf
:: Set input and output files.
@eerohele
eerohele / gist:3169535
Created July 24, 2012 11:51
Remove all Ruby gems
# http://geekystuff.net/2009/01/14/remove-all-ruby-gems/
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@eerohele
eerohele / add-conditional-classes.xsl
Created July 24, 2012 12:42
An XSLT stylesheet for adding Paul Irish's conditional IE classes to an XHTML document
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" encoding="utf-8" indent="no" omit-xml-declaration="no"/>
<xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable>
@eerohele
eerohele / eclipsehelp.sh
Last active October 11, 2015 22:47
Eclipse Help Startup Script
#!/bin/bash
ECLIPSE_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LOGFILE="$ECLIPSE_HOME/configuration/run.log"
JAVA_CLASS=org.eclipse.help.standalone.Infocenter
COMMAND=$1
PRODUCT=$2
PORT=$3
send_command() {