Skip to content

Instantly share code, notes, and snippets.

View boutell's full-sized avatar

Tom Boutell boutell

View GitHub Profile
<template>
<ApostropheFieldset :field="field" :error="error">
<template slot="body">
<input v-model="next" />
</template>
</ApostropheFieldset>
</template>
<template>
<fieldset :class="cssClass">
<label class="apos-field-label">{{ field.label }}</label>
<div v-if="field.help" class="apos-field-help">{{ field.help }}</div>
<slot name="body"></slot>
</fieldset>
</template>
<template>
<div class="apos-schema">
<component
v-for="field in fields"
:is="options.components.fields[field.type]"
v-model="fieldState[field.name]"
:field="field"
:context="next.data"
/>
</div>
@boutell
boutell / gist:db0ca16e4b6de7a592cb79a4ed4a700c
Created August 17, 2018 22:11
mongodb query for first array element being "null" does not obey the usual "undefined properties match null" rule
// This will find "bar" and "woo". But it does not find "foo".
(function() {
db.dropDatabase();
db.docs.insert([{
title: 'foo',
ids: []
}, {
title: 'bar'
}, {
@boutell
boutell / gist:8ea95b723b253cc697607a1cc51dd5fb
Created March 22, 2018 15:50
Apostrophe CMS addColumns example
[
{
name: 'title',
label: 'Title'
},
{
name: 'updatedAt',
label: 'Last Updated',
partial: function(value) {
if (!value) {
// Demonstration that promises do not involve the pyramid of doom.
// Native ES6 promises - you could do it with bluebird promises too,
// in which case Promise.delay is a built-in convenience method
function delays() {
return delay(100).then(function() {
return delay(100);
}).then(function() {
return delay(100);
}).then(function() {
let firstStep = null;
if (options.count !== false) {
// Create a dummy promise
firstStep = Promise.resolve(true);
} else {
// Do actual work
firstStep = q.clone().count(name + '.id')... // etc.
}
return firstStep.then(... more promises go down ...)
function getDb() {
knox = // ... init stuff, then ...
return knox.schema.createTableIfNotExists('users', function (table) {
table.bigIncrements();
table.string('username', 15);
table.timestamps();
})
.then(function() {
knox.schema.createTableIfNotExists('posts', function(table) {
table.bigIncrements();
// test1.js
var from = './test2.js';
try {
require(from);
} catch (e) {
console.log(e);
}
// test2.js
upstream upstream-mysite {
server localhost:3000;server localhost:3001;
}
server {
listen *:80;
server_name mysite.com;
client_max_body_size 32M;
access_log /var/log/nginx/mysite.access.log;