Skip to content

Instantly share code, notes, and snippets.

import { Parser } from 'expr-eval'
import toposort from 'toposort'
const parser = new Parser()
const get_deps = expr => expr.symbols({ withMembers: true })
.filter(dep => dep.startsWith('collections.'))
.map(dep => dep.slice('collections.'.length))
const check = (manual, dynamic) => {
@tcoats
tcoats / notion-api.js
Created November 15, 2020 20:59
Notion API Example
const uuid = require('uuid')
const guid_space = s =>
`${s.substr(0,8)}-${s.substr(8,4)}-${s.substr(12,4)}-${s.substr(16,4)}-${s.substr(20)}`
module.exports = {
all: async (notion, url) => {
const [id, collectionViewId] = url.split('/').slice(-1)[0].split('?v=')
.map(guid_space)
const collectionId = (await notion.getRecordValues({
// Use an ssh public key to encrypt content that can only be unencrypted with the ssh private key
// Internally shares an AES key for the main content.
const sshpk = require('sshpk')
const fs = require('fs').promises
const {
publicEncrypt,
privateDecrypt,
generateKeySync,
randomFillSync,
createCipheriv,
@tcoats
tcoats / msal.js
Last active November 14, 2020 08:50
// Open Office365 Admin https://admin.microsoft.com/
// On the left hand menu click show all and click Azure Active Directory
// On the left hand menu click Azure Active Directory then click App registrations.
// Click New registration and type MSAL Demo for the name. Make sure Accounts in this organizational directory only is selected.
// Click Register and record the following:
// Application (client) ID
// Directory (tenant) ID
// In the left hand sub menu click Expose an API then click Add a scope
// Click Save and continue with the default Application ID URI
// In Scope name type "access_as_user"
#import <React/RCTBridgeModule.h>
#import <React/RCTLog.h>
@interface RCT_EXTERN_MODULE(CallSwift, NSObject)
RCT_EXTERN_METHOD(setUserId:(NSString *)userId token:(NSString *)token)
@end
@tcoats
tcoats / discovery.js
Last active September 13, 2018 19:16
const dc = require('discovery-channel')
const tls = require('tls')
const EventEmitter = require('events')
// const server1 = discovery({
// id: 'server1',
// port: 19898,
// channel: 'test channel',
// key: fs.readFileSync('../tls/key.pem'),
// cert: fs.readFileSync('../tls/cert.pem'),
const serialport = require('serialport')
const bytelength = require('@serialport/parser-byte-length')
const delimiter = require('@serialport/parser-delimiter')
// serialport.list((err, ports) => {
// ports.forEach((port) => {
// console.log(port.comName)
// })
// })
@tcoats
tcoats / README.md
Last active December 17, 2017 18:30
Odo.js Parcel Example
diskutil list
diskutil unmountDisk /dev/disk2
sudo dd if=/file/path.iso of=/dev/disk2 bs=1m
diskutil eject /dev/disk2
<!DOCTYPE HTML>
<html>
<head>
<script src="https://www.webglearth.com/v2/api.js"></script>
<script>
function init() {
WE
.tileLayer('https://gist.githubusercontent.com/tcoats/87aab39d4f0e3bab2dac0f5a3eaeecef/raw/da04047425662ac94a134da1ff9914bc64fe17c5/tile{z}{x}{y}.png', { maxZoom: 0, tms: true })
.addTo(new WE.map('earth', { center: [-34.26828811505704,178.0706979131573], zoom: 2 }));
}