Skip to content

Instantly share code, notes, and snippets.

View voxpelli's full-sized avatar

Pelle Wessman voxpelli

View GitHub Profile
@voxpelli
voxpelli / README.md
Last active July 19, 2016 18:36
How to get references to all PR:s on a "git fetch origin" – forgot where I found this, but rediscovered the setup in one of my local repos

In the .git/config file add the fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to the remote you want to fetch references to PR:s from.

@voxpelli
voxpelli / README.md
Last active August 29, 2015 14:27
Private Messaging With From: Sequence diagram
@voxpelli
voxpelli / .env
Last active October 4, 2015 14:35
Bedrock + Docker-Compose
DB_NAME=wordpress
DB_USER=root
DB_PASSWORD=""
DB_HOST=mysql:3306
WP_ENV=development
# And in /etc/hosts added wordpress.dev to point to 192.168.99.100
WP_HOME=http://wordpress.dev:8000
WP_SITEURL=http://wordpress.dev:8000/wp
@voxpelli
voxpelli / fetchkeys.js
Last active February 2, 2018 06:31
Check the ssh key length of specified users
// Replace this list with the result of to-run-on-org-page.js
// And remember to do an "npm install"
var users = ["voxpelli"];
var https = require('https');
var fs = require('fs');
var exec = require('child_process').exec;
var tmp = require('temporary-directory')
var cuid = require('cuid');
var chalk = require('chalk');
@voxpelli
voxpelli / news.js
Created March 20, 2015 14:53
Content Management _Components_ rather than Content Management _System_
// Create a "news" type content type
// Example module names – not real ones
module.exports = function () {
return require('contenttype')
.addField('title', require('textfield'))
.addField('image', require('imagefield'))
.addField('author', require('authorlink'));
};
@voxpelli
voxpelli / fail.js
Created September 16, 2014 14:22
Node.js fail with EventEmitter, Promise and Exception
var events = require('events');
var Promise = require('Promise');
var foo = new events.EventEmitter();
foo.on('bar', function () {
console.log('Four');
throw new Error('Fail!');
});
@voxpelli
voxpelli / indieconfig-loader.html
Last active August 29, 2015 14:06
Promise based loading of indie-config, wrapped in an example page using that promise. More info @ http://indiewebcamp.com/indie-config
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Indie Configuration</title>
<link rel="stylesheet" href="/css/style.css" />
</head>
<body>
<div class="page" id="page-wrapper">
<header>
(function () {
if (window.parent !== window) {
window.parent.postMessage(JSON.stringify({
// The config of your endpoint
reply: 'http://voxpelli.com/reply?u={url}'
}), '*');
}
// Pick a way to invoke the registerProtocolHandler, through a submit handler in admin or something
document.getElementById('confForm').addEventListener('submit', function (e) {
@voxpelli
voxpelli / autoselect.js
Created August 4, 2014 17:35
Less annyoing auto-select in readonly textarea content (with purpose of making it _easier_ to copy&paste stuff – not harder)
$('textarea[readonly]').on('mouseup', function () {
if (document.activeElement === this && this.selectionStart === this.selectionEnd) {
$(this).select();
}
});
@voxpelli
voxpelli / README.md
Created June 25, 2014 13:32
My initial take on a JSHint .jshintrc config

If it is mainly a Node.js project that should be linted, then I would switch the "browser" setting for a "node" setting, but no matter if the default is that the javascript files are meant for a Node.js environment or a browser environment one can always override it in a specific file by adding the JSLint-compatible settings:

/*jslint node: true */

Or:

/*jslint browser: true */