Skip to content

Instantly share code, notes, and snippets.

View joshwnj's full-sized avatar

Josh Johnston joshwnj

View GitHub Profile
@joshwnj
joshwnj / init.lua
Created October 4, 2016 02:41
hammerspoon config for window resizing / moving in a grid
local hotkey = require "hs.hotkey"
local grid = require "hs.grid"
grid.MARGINX = 10
grid.MARGINY = 10
grid.GRIDHEIGHT = 3
grid.GRIDWIDTH = 7
local mash = {"cmd", "alt", "ctrl"}
local mashshift = {"cmd", "alt", "ctrl", "shift"}
;; turn line numbers off by default
(global-linum-mode -1)
(defun goto-line-with-feedback (&optional line)
"Show line numbers temporarily, while prompting for the line number input"
(interactive "P")
(if line
(goto-line line)
(progn
(linum-mode 1)
@joshwnj
joshwnj / text_overflow.js
Created October 18, 2010 23:18
detect text overflow and crop, inserting an ellipsis
var TextOverflow = {
crop: function(elm) {
var w = elm.width(),
t = elm.text(),
child;
elm.html('<span style="overflow: hidden; white-space: nowrap">'+t+'</span>');
child = elm.children(":first-child");
while (t.length > 0 && child.width() > w) {
t = t.substr(0, t.length - 1);
const ct = require('countries-and-timezones')
const countries = ct.getAllCountries()
const flatten = (a) => a.reduce((acc, val) => acc.concat(val), [])
const unique = (a) => [...new Set(a)]
const combinations = Object.values(countries).map(country => {
const { id, name } = country

Let me start out by saying that I have zero intention of trying to convince you that my views are right and yours are wrong. Even if that were possible, I don't see how it could possibly be helpful or worthwhile for either of us. I've got no interest in that at all.

What I am interested in doing is answering your question, which relates to my comment that I have good reason for believing what I do. My belief can be summarised in one sentence: that Jesus is who he said he is. Following on from that, I find him the most worthy of admiration of any person I've ever heard about, and so naturally want to know him better, and learn to see the world the way he sees it.

As I said: I don't expect you to accept this as airtight proof that something in history definitely happened (what would

@joshwnj
joshwnj / duration.php
Created January 30, 2012 22:27
Creating ISO 8601 durations
<?php
$parts = secondsToDuration(61);
assert($parts['hours'] === 0);
assert($parts['minutes'] === 1);
assert($parts['seconds'] === 1);
assert('PT0H1M1S' === formatDuration($parts));
$parts = secondsToDuration(7202);
assert($parts['hours'] === 2);
// @flow
import React, { PureComponent } from 'react'
import cmz from 'cmz'
import elem from '../utils/elem'
import type { Element } from 'react'
type Props = {
title?: string,
@joshwnj
joshwnj / twitterify.js
Created June 16, 2017 04:29
design refresh
document.querySelectorAll('*').forEach(function (a) { a.style['border-radius'] = '50%' })
@joshwnj
joshwnj / write.sh
Created April 21, 2017 06:41
very simple bash script to write a new blog post
#!/bin/bash
YYYY=$(date +%Y)
MM=$(date +%m)
DD=$(date +%d)
DIR=posts/$YYYY/$MM/$DD
FILE="$DIR/$1.md"
mkdir -p $DIR
echo "# $1" > $FILE
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.zkeleton = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
const upsertCss = require('./lib/upsert-css')
const createName = require('./lib/create-name')
function isName (val) {
if (!val) { return false }
return /^[a-zA-Z][a-zA-Z0