Skip to content

Instantly share code, notes, and snippets.

Avatar

DJ Adams qmacro

View GitHub Profile
View cols.awk
# Output fields in a nicely arranged columnar format.
# Takes two optional variables:
# COLS: comma-separated list of column nrs (fields) to output (default: all)
# GAP: gap required between each column (default: 1)
# Take care of the GAP default
BEGIN {
if (GAP == "") GAP=1
}
@qmacro
qmacro / episodes-A.js
Last active Apr 13, 2020
Code at Home Ep.8
View episodes-A.js
const episodes = [
{
number: 1,
title: 'Setting up for our first challenge'
},
{
number: 2,
title: 'Fizz-Buzz and Fibonacci'
},
{
View taskscript.js
// -----------------------------------------------------
// Globals, contants
// -----------------------------------------------------
TASKLIST = "DJ's list";
LABEL_PENDING = "newtask";
LABEL_DONE = "newtaskdone";
// -----------------------------------------------------
// getTasklistId_(tasklistName)
// Returns the id of the tasklist specified
View fixposts.js
/**
* From previous conversions from WordPress to Ghost, I have a lot of posts
* with links to other posts, where the link is actually incorrect. The
* incorrect links are missing the day (dd) part of the URL.
*
* This script is a quick and dirty way of fixing them, in-place:
* 1) read all the posts, and work out a slug-to-anchor mapping
* 2) go through all the posts, using regexes to find incorrect links
* and replace them with the correct ones, referencing the mapping
* from the first step.
@qmacro
qmacro / neo-app.json
Created Sep 17, 2016
sitMAN Workshop
View neo-app.json
{
"routes": [
{
"path": "/d/pos",
"target": {
"type": "destination",
"name": "public-odata-services"
},
"description": "Public OData Services"
},
View fixURLs.js
#!/usr/bin/env node
var stdin = process.stdin,
stdout = process.stdout,
aConfigLines = [],
https = require('https'),
sDocuRoot = "https://help.hana.ondemand.com/webide/",
sDocuPage = "233396e994584fe9b4c7ab6cb2798640.html";
// Read in current .eslintrc.ext config from STDIN
View UI5RelativeDates.html
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>Relative Dates</title>
<script id="sap-ui-bootstrap"
type="text/javascript"
@qmacro
qmacro / recordequality.js
Created Feb 3, 2015
Test equality of record structures as maps, in JavaScript, using reduce. Assuming maps have same structure.
View recordequality.js
var map1 = {name: "DJ", colour: "green"};
var map2 = {name: "DJ", colour: "green"};
Object.keys(map1).reduce(function(bool, prop) {
return bool && map1[prop] === map2[prop];
}, true); // => true
map2.name = "Joseph";
Object.keys(map1).reduce(function(bool, prop) {
@qmacro
qmacro / data.json
Last active Aug 29, 2015
Functional JavaScript scratchpad
View data.json
// Test data only, sourced from a JSON/YAML style data set; this
// is not realistic in production as the data would be normalised
// and the repetitive nature would be avoided, but it's a reality
// when you're setting up test data by hand, so valid. This data
// is referred to later as "d.employees"
[
{
"name":"Employee Zero",
"wbses":[