Skip to content

Instantly share code, notes, and snippets.

View dougbeal's full-sized avatar

Douglas Beal dougbeal

View GitHub Profile
@dougbeal
dougbeal / Contract Killer 3.md
Created August 31, 2018 00:01 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@dougbeal
dougbeal / shelldown-demo
Created July 29, 2018 20:54 — forked from pjeby/shelldown-demo
"You got your markdown in my shell script!" "No, you got your shell script in my markdown!"

Mixed Markdown and Shell Scripting

: By the power of this magic string: ex: set ft=markdown ;:<<'```shell' #, this file is now both a markdown document and an executable shell script. chmod +x it and try running it!

The above line does just what it says. More specifically, when placed within in the first 5 lines and preceded only by blank lines or #-prefixed markdown headers:

  1. The first part of the magic string makes github and various editors (e.g. atom with the vim-modeline packge) treat the file as having markdown syntax (even if the file doesn't have an extension)
  2. The second part (if run in a shell), makes the shell skip execution until it encounters the next ```shell block.

(The line also has to start with a : so that it's valid shell code.)

@dougbeal
dougbeal / Frankenstein.php
Created May 19, 2017 06:01 — forked from miklb/Frankenstein.php
facepiles for WP comments
/**
* Override core Walker_Comment for mf2 & Bulma.
*
* @method __construct
*/
class Independence_Walker_Comment extends Walker_Comment {
/**
* Start the element output.
*
* This opens the comment. Will check if the comment has children or is a stand-alone comment.
<?php
/*
Default Template
* The Goal of this Template is to be a general all-purpose model that will be replaced by customization in other templates
*/
$kind = get_post_kind_slug( get_the_ID() );
$meta = new Kind_Meta( get_the_ID() );
$author = Kind_View::get_hcard( $meta->get_author() );
$cite = $meta->get_cite();
@dougbeal
dougbeal / Optional+Empty.swift
Created June 4, 2016 04:24 — forked from irace/Optional+Empty.swift
`UITextView` should really just have this by default.
protocol TextContaining {
var isEmpty: Bool { get }
}
extension String: TextContaining {
}
extension Optional where Wrapped: TextContaining {
var isEmpty: Bool {
switch self {
@dougbeal
dougbeal / find-duplicate-files.rb
Created January 2, 2016 22:17 — forked from ma11hew28/find-duplicate-files.rb
Ruby script that finds identical (md5) files in all subdirectories (recursive)
require 'digest/md5'
hash = {}
Dir.glob("**/*", File::FNM_DOTMATCH).each do |filename|
next if File.directory?(filename)
# puts 'Checking ' + filename
key = Digest::MD5.hexdigest(IO.read(filename)).to_sym
if hash.has_key? key