Skip to content

Instantly share code, notes, and snippets.

View witt3rd's full-sized avatar
⌨️
coding

Donald Thompson witt3rd

⌨️
coding
View GitHub Profile
@witt3rd
witt3rd / youtube-dl.md
Last active October 25, 2020 14:09
YouTube Download Recipes

youtube-dl Recipes

brew install youtube-dl ffmpeg

Download video or playlist

youtube-dl -f best 'http://www.youtube.com/watch?v=P9pzm5b6FFY'
@witt3rd
witt3rd / useful-q-lambdas.md
Last active September 13, 2020 16:05
Useful Q Lambdas

GraphQL requests to CKG services

// wrap in async function
return (async () => {
  // request graphql
  const data = await input.__requestCkg({
    svcRef: "/service/donald-hello-world",
    query: "query { allFoos { id } }"
  })
  

Maana Q + Semantic Web/Linked Data

At the center of the Maana Q Knowledge Platform is the Computational Knowledge Graph, which consists of a cloud distributed set of GraphQL and RESTful microservices. Each service exposes a set of types and functions. The functions can be evaluated lazily (i.e., streaming) or strict/eager (i.e., batch) and can be marked as having pure (i.e., referential integrity) vs effectful (i.e., causes change or relies on changing externals) semantics.

The purpose of this system is to represent domain knowledge (i.e., concepts, properties, relations, individuals) and perform reasoning (i.e., operations performed on the domain to achieve various goals). This is similar in nature to the goals of the Semantic Web, which aims to unify:

  • Linking data
  • Organizing data into "ontologies"
  • Querying data
  • Logical inference (e.g., deduction, induction)

While the goals are similar, the underlying

@witt3rd
witt3rd / utils.js
Last active June 13, 2019 15:23
Useful code snippets in JavaScript
const fs = require("fs-extra");
const Path = require("path");
//
// String utilities
//
// Ensure initial letter is capitalized
const capitalize = word => word[0].toUpperCase() + word.substr(1);

Meta

Meta is a NodeJS-based shell command that provides a solution to working with many repos across machines/teams without the tradeoffs involved with submodules or monorepos.

Install

npm i -g meta

Create a new meta repo

mkdir my-meta-repo
cd my-meta-repo
const fs = require('fs');
const mkdirp = require('mkdirp');
const path = require('path');
const request = require('request');
const url = require('url');
const downloadFile = async (file, targetFolder) => {
// Parse remote file spec
const sourceUrl = url.parse(file.url ? file.url.id : file.id);
const sourceHref = sourceUrl.href;
// --- Object path operations
export const objGetPathList = ({ path }) => {
let pathList;
if (Array.isArray(path)) {
pathList = path;
} else if (typeof path === "string") {
pathList = path.split("/");
}
return pathList;

Ingesting Hierarchical Data

This will work for any model that you hook it up to, you just need to define the types in your service schema.

As it’s inspecting the metadata that graphql carries with each query to figure out which fields correspond to what type to construct the mutations (and the types have to be the same as those in the model in Q) because it assumes the boilerplate will look like:

def create_mutation_singular(type):
@witt3rd
witt3rd / linux.md
Last active October 13, 2020 20:43

Linux

Apt

Repair

sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
@witt3rd
witt3rd / Hask(Cat).md
Last active December 4, 2018 11:46
Categories in Haskell

Hask(Cat)

{-# LANGUAGE TypeOperators #-}
 
infix 9 
class Category k where
  ident :: a `k` a
  (∘) :: (b `k` c) -> (a `k` b) -> (a `k` c)