Skip to content

Instantly share code, notes, and snippets.

View dougbeal's full-sized avatar

Douglas Beal dougbeal

View GitHub Profile
@Zegnat
Zegnat / authdiag.php
Last active August 7, 2018 15:50
Upload to a web server on an accessible path. Navigate to it in the browser. Copy the URL from the address bar and paste it in the form. Run the test to see if your server gets Authorization headers!
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$auth = filter_input(
INPUT_POST,
'auth',
FILTER_VALIDATE_REGEXP,
array('options' => array('regexp' => '@^authtest_\d+$@'))
@pjeby
pjeby / shelldown-demo
Last active January 2, 2024 19:02
"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.)

@nepsilon
nepsilon / how-to-use-mac-keychain-to-store-github-repos-credentials.md
Created July 18, 2017 06:50
How to use Mac KeyChain to store GitHub repos credentials? — First published in fullweb.io issue #108

How to use Mac KeyChain to store GitHub repos credentials?

You know the pain, you cloned a repo over HTTPS, and now Git asks you for your password each time you want to push or pull.

Chances are you already have the git credential-osxkeychain command installed. If not, just install Git with brew: brew install git.

Once installed, just tell Git to use the KeyChain to store your credentials:

git config --global credential.helper osxkeychain
<?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();
/* Tweaks to post kinds */
#kind-all .svg-icon {
fill: currentColor;
padding-left: 2px;
padding-right: 2px;
width: 48px;
height: 48px;
vertical-align: middle;
top: -0.0625em;
color: grey;
@miklb
miklb / Frankenstein.php
Last active May 19, 2017 06:01
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.
@miklb
miklb / UnspamWebmentions.php
Last active January 6, 2018 21:38
Unspam Webmentions in WordPress theme function
/**
* Unspam Webmentions
*
* @method unspam_webmentions
* @param [type] $approved [description].
* @param [type] $commentdata [description].
* @return [type] [description]
*/
function unspam_webmentions( $approved, $commentdata ) {
return $commentdata['comment_type'] == 'webmention' ? 1 : $approved;
@codemedic
codemedic / vpn-docker-fix
Last active June 15, 2023 18:17
Docker network through host IPSec / Strongswan VPN
#!/usr/bin/env bash
# Link up docker network via IPSec VPN on docker-host.
#
# NOTE: This script can either be "sourced" into your .bashrc or executed directly. Be
# it sourced or executed, the usage syntax below is the same.
#
# Usage: [dry_run=1] [debug=1] vpn-docker-fix [docker-network-1 [docker-network-2 ...]]
#
# Env Variables:

Using Swift Package Manager with iOS

Step 1:

File > New > Project...

Step 2:

Create a Package.swift file in your root project directory, add dependencies, then run swift package fetch on the command line in the same directory. We’re not going to run swift build because it will just complain.

@irace
irace / Optional+Empty.swift
Last active June 16, 2016 16:17
`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 {