Skip to content

Instantly share code, notes, and snippets.

View simonbaird's full-sized avatar
💭
🤔

Simon Baird simonbaird

💭
🤔
View GitHub Profile

HACBS Enterprise Contract Policies

About

The HACBS Enterprise Contract is a Tekton task that can be used to verify the provenence of a container image built in HACBS and validate it against a set of policies.

@simonbaird
simonbaird / README.md
Last active April 2, 2021 18:08
Bookmarklet for unchecking tasks in a Confluence document

If you want to uncheck all the checkboxes in a Confluence page with many tasks in it then try this bookmarklet.

Go to Bookmarklet Crunchinator (or similar) to generate a bookmarklet using the contents of src.js below.

See also this feature request.

Update: actually it's not working for me in a bookmarklet, but works fine from Scratchpad in Firefox.

@simonbaird
simonbaird / with_stubbed_const.rb
Created March 13, 2015 01:26
Stubbing a constant in ruby
module WithStubbedConst
def with_stubbed_const(consts, scope=self.class)
stash = {}
consts.each_pair do |key, val|
stash[key] = scope.send(:remove_const, key)
scope.send(:const_set, key, val)
end
begin
yield
@simonbaird
simonbaird / foo.rb
Last active December 16, 2015 00:59 — forked from anonymous/foo.rb
# For @echorand :)
require 'test/unit'
class Float
class NoYouCantBecauseMaths < RuntimeError; end
def even?
raise NoYouCantBecauseMaths unless whole_number?
to_i.even?
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']"
@simonbaird
simonbaird / .gitconfig
Created October 31, 2012 02:22
Nice brief git logs
[core]
# -E means don't page if less one screen
# -F means quit when EOF reached
# -r fixes the %C(yellow)%+d colouring somehow
pager = less -E -F -r
[alias]
ll = log --pretty=nice -n 30 # about one screen worth
lll = log --pretty=nice # goes back forever
@simonbaird
simonbaird / block_render_helper.rb
Created August 8, 2012 08:02
block_render rails helper
#
# A trick so you can have partials that take blocks.
# Uses render :layout.
#
# Example:
# <%= block_render 'some_partial_with_a_yield', :foo => 123 do %>
# Any erb here...
# <% end %>
#
def block_render(partial_name, locals={})
@simonbaird
simonbaird / styles.css
Created August 8, 2012 07:00
Make pinned tabs in Firefox a bit wider
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
.tabbrowser-tab[pinned] {
width: 72px;
}
@simonbaird
simonbaird / create_with_subtype.rb
Created February 8, 2012 02:27
Specify type when creating a record in AR STI
#
# This was causing problems when submitting the nested object form
# in a/v/product/channels_edit because all the nested channels would
# be created at plan Channel objects instead of the PrimaryChannel, EusChannel etc.
#
# In active record normally :type is ignored, eg:
# Channel.create(:type='PrimaryChannel', :etc=>1, ...)
# ignores the type attr and uses 'Channel'.
#
# This hack will make it actually use the :type value.
@simonbaird
simonbaird / example.erb
Created December 10, 2011 13:50
Embedded python?
<%#
#
# Embedded python?
#
# See:
# http://mail.python.org/pipermail/python-ideas/2011-December/013003.html
# http://readthedocs.org/docs/ncoghlan_devs-python-notes/en/latest/pep_ideas/suite_expr.html
# and related discussion:
# http://mail.python.org/pipermail/python-ideas/2011-December/thread.html#13003
#