Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am johnlane on github.
  • I am johnlane (https://keybase.io/johnlane) on keybase.
  • I have a public key ASDE5-a54ZM6flDHH8atfeVPVgu1sXGE16_2aNJ4OPnG-go

To claim this, I am signing this object:

@johnlane
johnlane / gpgtest.out
Created January 18, 2017 14:44
GNUPG trust-signatures test output
-----------------------------------------------------------------
VERSION INFORMATION
gpg (GnuPG) 2.1.17
libgcrypt 1.7.5
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: /home/john/.gnupg
@johnlane
johnlane / gpgtest.sh
Created January 18, 2017 14:38
Testing GNUPG trust-signatures
#!/bin/sh
#
export GNUPGHOME
echo -----------------------------------------------------------------
echo VERSION INFORMATION
gpg --version
uname -vimposr
@johnlane
johnlane / wysiwyg.js
Last active September 14, 2020 14:56
An integrated Markdown WYSIWYG editor
$(document).on('ready page:load ajaxComplete', function() {
$('textarea.wysiwyg').each(function() {
var textarea = $(this)
textarea.hide().uniqueId();
var textarea_id = textarea[0].id;
var textarea_class = textarea[0].className;
var wysiwyg_id = "wysiwyg_" + textarea_id;
var wysiwyg_class = textarea_class + " wysiwyg";
@johnlane
johnlane / test.rb
Created April 24, 2016 13:19
StackOverflow#36799396
# in-ruby-is-it-possible-to-move-a-module-up-the-ancestor-chain
# http://stackoverflow.com/questions/36799396
module A
def hiya(str)
puts "ho #{str}"
end
def if_what?
end
end
@johnlane
johnlane / answer.md
Created April 16, 2016 19:48
Can a Trailblazer concept inherit from another and be able to extend its operati ons (multiple inheritance) ?

The effect of multiple inheritance can be achieved by using modules.

First define the ActiveRecord objects like this:

class Topic < ActiveRecord::Base; end
class Location < ActiveRecord::Base; end

There is no longer a base Tag abstract class, allowing Tag to be defined as a module like this (app/concepts/tag/crud.rb):

module Tag

@johnlane
johnlane / in_out_trailblazer.md
Created October 19, 2015 18:10
The Ins and Outs of a Trailblazer Operation Contract

The Ins and Outs of a Trailblazer Operation Contract

These notes record my attempts to understand how and when to populate a Trailblazer contract. They may be incomplete, inaccurate or just plain wrong. They may also be right; I hope they are! Comments are welcome.

It all began with the requirement to seed a presenting contract from the inbound request. Having looked for answers in the Trailblazer book and on Gitter (there was a similar conversation on the 25th September), taking

@johnlane
johnlane / session.md
Created October 7, 2015 09:40
Trailblazer Session

The Session

The application can behave differently based on the request URL by presenting a diferent 'site' experience to the end-user, who may also choose from the locales (language presentations) that the site supports.The Session manages this: it's a PORO plus some Trailblazer operations. It keeps state for the current request including current user, the Rails session and site and locale selections. It's established with a Session::Create operation before processing a request.

The Session does not persist across requests, except for data placed in its persistent store, for which the Rails session is used (but another Hash-like object could be used instead).

The Session is established in the ApplicationController:

  before_action do
    Session::Create.reject(params.merge(store: session, host: request.host,           
 preferred_locales: get_preferred_locales_from_http_request)) do |op|
@johnlane
johnlane / cell.rb
Created October 1, 2015 10:40
Widget wrapper around cell
# app/concepts/widget/cell.rb
# A very basic "Widget" that is a container of Cell objects
# When rendered, it recursively renders all cells that it
# contains.
class Widget < Cell::Concept
attr_reader :parent
attr_reader :children
# Create a new widget

Injecting Terminal Input

Some examples demonstrating how to inject keystrokes into a terminal's input stream.