Skip to content

Instantly share code, notes, and snippets.

@johnlane
johnlane / tom.rb
Last active August 29, 2015 13:56
The One Module (TOM) is an example Ruby module that demonstrates setting of module, class, class instance and instance variables for classes that include or extend the module.
# TOM : The One Module
#
# An example Ruby module that demonstrates setting of module, class, class instance
# and instance variables for classes that include or extend the module
#
# (c) John Lane 20140218
#
module Tom
extend self # makes module methods available as class and instance methods.
@johnlane
johnlane / eicar.eml
Created September 10, 2014 12:13
EICAR test message
From: John Doe <john.doe@example.com>
Subject: EICAR Test Message
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="XXXXboundary text"
This is a multipart message in MIME format.
--XXXXboundary text
Content-Type: text/plain
@johnlane
johnlane / cryptsetup-keyfile.patch
Created December 9, 2014 12:55
initrd support for crypt key file with offset and size
--- encrypt_hook 2014-12-09 12:47:02.379911026 +0000
+++ encrypt_hook 2014-12-09 12:47:41.416087076 +0000
@@ -7,7 +7,7 @@
# Get keyfile if specified
ckeyfile="/crypto_keyfile.bin"
if [ -n "$cryptkey" ]; then
- IFS=: read ckdev ckarg1 ckarg2 <<EOF
+ IFS=: read ckdev ckarg1 ckarg2 ckarg3 ckarg4 <<EOF
$cryptkey
EOF
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
PGP Transition Statement
========================
I have transitioned my GPG key from an old 1024-bit DSA key to a new 4096-bit RSA key.
The old key is now invalid; please use my new key from now on.
@johnlane
johnlane / gist:7fece74c501fd77cc0c3
Created April 17, 2015 09:46
Grub loopback iso example
set imgdevpath='/dev/disk/by-uuid/e7bc3210-ee80-4111-a6da-3db1d2e2cbef'
set isofile="/iso/tails-i386-1.2.2.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz fromiso=$imgdevpath/$isofile boot=live config noswap nopersistent nomodeset noautologin splash
initrd (loop)/live/initrd.img
@johnlane
johnlane / PKGBUILD
Created May 5, 2015 10:32
PKGBUILD for AUR package netkit-bsd-finger with systemd support
# Maintainer:
# Contributor: dorphell <dorphell@archlinux.org>
# Updated for systemd by John Lane <archlinux at jelmail dot com>
pkgname=netkit-bsd-finger
pkgver=0.17
pkgrel=9
pkgdesc="BSD-finger ported to Linux"
arch=('i686' 'x86_64')
url='http://ftp.linux.org.uk/pub/linux/Networking/netkit'
@johnlane
johnlane / PKGBUILD
Created June 11, 2015 13:03
revised PKGBUILD for Ghost 0.6.4 with npm dependency
# Maintainer: Chun Yang <x@cyang.info>
pkgname=ghost
pkgver=0.6.4
pkgrel=1
pkgdesc="Free, open, simple blogging platform"
arch=('i686' 'x86_64')
url="http://ghost.org"
license=('MIT')
makedepends=('unzip')
depends=('nodejs>=0.12' 'npm')
@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
@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 / 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