Skip to content

Instantly share code, notes, and snippets.

@sorbits
sorbits / Color Marks.tmCommand
Last active March 3, 2024 16:33 — forked from gdsmith/Color Marks.tmCommand
Textmate command to find, create and add color marks for hex and rgb colors
#!/usr/bin/env ruby -wU
require 'erb'
require 'fileutils'
require 'shellwords'
# extension to String to extract colours into rgb array
class String
# hex to array
def h2a
@sorbits
sorbits / align.rb
Created May 24, 2011 21:02 — forked from mads-hartmann/align.rb
align.rb
# Alignes the source
def align(text, regexp, width)
text.to_a.map do |line|
if offset = offsetOfRegexpInLine(line, regexp)
if shouldInsertBefore(line, regexp)
before = line[0..offset-1]
before + ' ' * (width - (before.length)) + line[offset..line.length-1]
else
before = line[0..offset]
before + ' ' * (width - (before.length-1)) + line[offset+1..line.length-1]