Skip to content

Instantly share code, notes, and snippets.

View destroytoday's full-sized avatar

Jonnie Hallman destroytoday

View GitHub Profile
/*
Typescript erroring:
---
Type 'Promise<(T | undefined)[] | [any, undefined]>' is not assignable to type 'Promise<[void | Error, void | T]>'.
Type '(T | undefined)[] | [any, undefined]' is not assignable to type '[void | Error, void | T]'.
Type '(T | undefined)[]' is not assignable to type '[void | Error, void | T]'.
Target requires 2 element(s) but source may have fewer.ts(2322)
*/
export default function <T> (promise: Promise<T>): Promise<[Error | void, T | void]> {
function findAnnotations (field:Block | Inline):Array<Block | Inline> {
const annotations:Array<Block | Inline> = []
// `field.content` returns Block | Inline | Text
// I’d like to ignore Text
// `reduce` is showing a TypeScript error "This expression is not callable" because Text isn’t included
// but if I add it, `node.content` errors because Text doesn’t have `.content`
return field.content.reduce((acc:Array<Block | Inline>, node:Block | Inline) => {
if (node.nodeType === INLINES.EMBEDDED_ENTRY && node.data.target.sys.contentType.sys.id === 'annotation') {
acc.push(node.data.target)
{
computed: {
now () {
return new Date
}
}
}
{
data () {
return {
now: new Date
}
},
created () {
setInterval(() => this.now = new Date, 1000 * 60)
}
{
computed: {
...mapState('time', ['now'])
}
}
import startOfDay from 'date-fns/start_of_day'
const getters = {
today (state) {
return startOfDay(state.now)
}
}
const state = {
now: new Date
}
const actions = {
start ({ commit }) {
setInterval(() => {
commit('updateTime')
}, 1000 * 60)
}
var gulp = require('gulp');
var svgSprite = require('gulp-svg-sprite');
gulp.task('svgs', function() {
return gulp.src('./app/assets/images/**/*.svg')
.pipe(svgSprite({
transform: [{
svgo: {
plugins: [{ removeUnknownsAndDefaults: false }]
}
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var coffeeify = require('coffeeify');
var shim = require('browserify-shim');
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xml:base="{{ site.permalink }}">
<channel>
<title>{{ site.title | xml_escape }}</title>
<link>{{ site.permalink }}</link>
<description>{{ site.description | xml_escape }}</description>
<pubDate>{{ site.date | date_to_rfc822 }}</pubDate>
{% for post in site.pages.journal.posts limit: 10 %}
<item>
<title>{{ post.title | xml_escape }}</title>