Skip to content

Instantly share code, notes, and snippets.

@colinf
colinf / readRows.js
Last active January 14, 2018 17:23
Reading the top level rows of an outline ( see https://medium.com/@softwarecf/a-faint-outline-2a2c641d6492 )
function readRows () {
let oo = Application('OmniOutliner')
let doc = oo.documents[0]
let rows = doc.children
let idList = rows.id()
let nameList = rows.name()
let hasChildrenList = rows.hasSubtopics()
return idList.map((id, i) => {
return {id, name: nameList[i], hasChildren: hasChildrenList[i]}
})
@colinf
colinf / getChildren.js
Last active January 14, 2018 17:26
Recursive function using ES8 async/await ( see https://medium.com/@softwarecf/a-faint-outline-2a2c641d6492 )
async function getChildren (id = 0) {
let childRows = await runJxa(readChildren, [id])
let result = await Promise.all(childRows.map(async child => {
let {hasChildren, ...resultChild} = child
if (!child.hasChildren) return resultChild
return {...resultChild, children: await getChildren(child.id)}
}))
return result
@colinf
colinf / step1.js
Created January 9, 2018 16:24
Read the top level rows of the outline
const runJxa = require('run-jxa')
let resultPromise = getRows()
resultPromise.then(rows => {
console.log(rows)
})
async function getRows () {
let rows = await runJxa(readChildren)
return rows
GetHttpHeader ( headers; searchHdr ) =
Let (
[
$hdrCount = ValueCount ( headers );
$nextValue = GetValue ( headers ; 1 );
$nextHdr = Left ( $nextValue ; Length ( searchHdr ) )
];
If ( $nextHdr = searchHdr ;
@colinf
colinf / Component2.vue
Last active March 24, 2017 19:23
HTML template of Component2 ( see http://j.mp/2n2nK6R )
<template>
<div class='Component1'>
<form>
<div class="form-group">
<label for="inputName">Your name (2)</label>
<input v-model="localPerson.name" type="text" class="form-control" id="inputName" placeholder="Name">
</div>
<div class="form-group">
<label for="inputProfession">Your profession (2)</label>
<input v-model="localPerson.profession" type="text" class="form-control" id="inputProfession" placeholder="Profession">
@colinf
colinf / Component1.vue
Last active March 24, 2017 19:24
Vuex component1 ( see http://j.mp/2n2nK6R )
<template>
<div class='Component1'>
<form>
<div class="form-group">
<label for="inputName">Your name (1)</label>
<input v-model="person.name" type="text" class="form-control" id="inputName" placeholder="Name">
</div>
<div class="form-group">
<label for="inputProfession">Your profession (1)</label>
<input v-model="person.profession" type="text" class="form-control" id="inputProfession" placeholder="Profession">
@colinf
colinf / vue-routing_template.html
Last active March 9, 2017 22:00
Links and route content with vue-router ( see http://j.mp/2m7IauQ )
<template>
<div id="app">
<div class="container-fluid">
<div class="row">
<div class="col-xs-2 menu-pane"> <!-- Section 1 -->
<ul class="nav nav-stacked">
<li><router-link :to="teamLink">Teams</router-link></li>
<li><router-link to="/about">About</router-link></li>
</ul>
</div>
@colinf
colinf / vue-routing.index.js
Last active March 9, 2017 21:58
Defining the routes with vue-router ( see http://j.mp/2m7IauQ )
import Vue from 'vue'
import Router from 'vue-router'
import TeamList from '../components/TeamList.vue'
import TeamDetailWrapper from '../components/TeamDetailWrapper.vue'
import About from '../components/About.vue'
import Home from '../components/Home.vue'
import NotFoundComponent from '../components/NotFoundComponent.vue'
Vue.use(Router)
@colinf
colinf / Example.vue
Last active February 23, 2017 14:32
Example of using modal-vue component ( see http://j.mp/2m3mQGt )
<template>
<div id="app">
<div>
<button @click="showModal = true">Show it</button>
</div>
<modal :showModal="showModal" :closeAction="closeDialog">
<h1 slot="header">Simple Dialog</h1>
<span slot="body">
Hello <strong>simple!</strong>
</span>
@colinf
colinf / Modal.vue
Last active February 17, 2017 16:17
modal-vue template html ( see http://j.mp/2m3mQGt )
<template>
<div :class="containerClass">
<div :class="{modal: true, in: showModal}" :style="{ display: showModal ? 'block' : 'none' }">
<div class="modal-dialog">
<div class="modal-content">
<div v-if="this.$slots.header || closeAction" class="modal-header">
<button class="close" @click="closeAction">x</button>
<slot name="header"></slot>
</div>
<div v-if="this.$slots.body" class="modal-body">