Skip to content

Instantly share code, notes, and snippets.

@maxlinc
maxlinc / search.rb
Created March 12, 2014 21:04
Check for trailing blank lines
Dir['**/*.rb'].each do |f|
begin
puts f unless File.read(f) =~ /^$\Z/
rescue => e
$stderr.puts "Couldn't read #{f}: #{e.message}"
end
end
@maxlinc
maxlinc / Gemfile
Created April 1, 2014 21:16
Using vagrant-rackspace and vagrant-aws together
# If you just do:
# $ vagrant plugin install vagrant-aws
# $ vagrant plugin install vagrant-rackspace
# $ vagrant plugin list
# Then it will downgrade vagrant-aws to 0.0.1 (rather than downgrading fog)
# A sample Gemfile
source "https://rubygems.org"
group :plugins do
@maxlinc
maxlinc / Gemfile
Last active August 29, 2015 13:58
DOAPLite - Extract a simplified YAML version of DOAP (Description of a Project) from RDF or GitHub. Useful for static site generators like Jekyll or other places where full RDF queries aren't practical
source "http://rubygems.org"
group :development do
gem 'jekyll', '~> 1.5.0'
gem 'stringex', '~> 1.4.0'
gem 'rake'
end
group :semantic_web do
# rdf-raptor requires libraptor
@maxlinc
maxlinc / Vagrantfile
Last active August 29, 2015 14:00
Proposed Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
@maxlinc
maxlinc / dash_property_handler.rb
Last active August 29, 2015 14:01
Start of a Hashie::Dash yard extension?
# Usage: `yardoc -e dash_property_handler.rb lib/**/*.rb`
class DashPropertyHandler < YARD::Handlers::Ruby::AttributeHandler
handles method_call(:property)
namespace_only
def process
name = statement.parameters.first.jump(:tstring_literal, :ident).source
scope = :instance
namespace.attributes[scope][name] ||= SymbolHash[:read => nil, :write => nil]
o = YARD::CodeObjects::MethodObject.new(namespace, name)
@maxlinc
maxlinc / broken_spec.rb
Created May 30, 2014 20:49
unexpected token tNL
# You'll receive "E: unexpected token tNL" if you run rubocop broken_spec.rb
module A
module B
class C
end
end
end
module A
module B do
@maxlinc
maxlinc / build_environment.md
Created June 2, 2014 22:20
Mapping the travis build environment to windows

I'm trying to take the current Build Environment documentation and see what is applicable on Windows. This is obviously a moving target, and my goal isn't necessarily to keep this up to date as much as it's to get an initial ideal of what does and doesn't make sense on Windows.

This might be better as a wiki or some other collaborative document, but I didn't see a wiki and don't know if you use something else, so I created an issue.

Common Environment

Networking

I'm not sure anything special is needed for IPv6 support, but I think it's not part of an MVP. There are plenty of projects that could test on windows with ipv4 only.

Version Control

@maxlinc
maxlinc / setup_winrm.ps1
Last active August 29, 2015 14:02
Setup WinRM
Function GetRDPCert
{
$srcStoreScope = "LocalMachine"
$srcStoreName = "Remote Desktop"
$srcStore = New-Object System.Security.Cryptography.X509Certificates.X509Store $srcStoreName, $srcStoreScope
$srcStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly)
Write-Host "Existing certificates:"
Write-Host $srcStore.Certificates | select -expand Subject
return $srcStore.Certificates -match "${env:computername}"
}
Vagrant.configure("2") do |config|
config.vm.define :suite_brettswift_com do |nodeserver|
config.vm.provider :rackspace do |rs, override|
override.vm.box = "rackspace"
override.vm.box_url = "https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box"
rs.username = "#{ENV['RACKSPACE_USERNAME']}"
@maxlinc
maxlinc / template_with_arrays.rb
Last active August 29, 2015 14:04
URI template sample
template = Addressable::Template.new 'http://open.mapquestapi.com/staticmap/v4/getmap{?key,size,zoom,center}'
template.expand key: 'foo', size: [200, 400], zoom: 5, center: [200, 9]
# => <Addressable::URI:0x3ffb7b824dd8 URI:http://open.mapquestapi.com/staticmap/v4/getmap?key=foo&size=200,400&zoom=5&center=200,9>
template.expand size: [200, 400], center: [200, 9]
# => <Addressable::URI:0x3ffb7b801ce8 URI:http://open.mapquestapi.com/staticmap/v4/getmap?size=200,400&center=200,9>
template.expand size: [200, 400]
# => <Addressable::URI:0x3ffb7a1d3714 URI:http://open.mapquestapi.com/staticmap/v4/getmap?size=200,400>