Instantly share code, notes, and snippets.

View sample.js
let myCid = await ipfs.dag.put({name: "Mikeal Rogers"})
let projectsCid = await ipfs.dag.put(
{ title: "A new post!",
content: "Opinions about things!"
author: {'/': myCid.toBaseEncodedString()}
}
)
View vue.config.js
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.output.publicPath = `${process.cwd()}/dist/`
}
}
}
View package.json
{ "scripts":
{ "dev": "NODE_ENV=DEV vue-cli-service serve & sleep 5 && NODE_ENV=DEV electron app.js" }
}
View app.js
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
let url
if (process.env.NODE_ENV === 'DEV') {
url = 'http://localhost:8080/'
} else {
url = `file://${process.cwd()}/dist/index.html`
}
View install.sh
npm install -g @vue/cli
vue create my-project
cd my-project
npm install electron
View app.js
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
let url
if (process.env.NODE_ENV === 'DEV') {
url = 'http://localhost:8080/'
} else {
url = `file://${process.cwd()}/dist/index.html`
}
View r2.js
const r2 = require('r2')
let doJsonThing = async (path, propname) => {
let res = await r2(`http://api.com${path}`).json
return res[propname]
}
View byteStorage.js
// Byte Storage as Content Addressable Storage
class ByteStorage {
async set (key, value) async {
// Send to temporary storage w/ random UUID
let tmpfile = randomFile()
let p1 = send(value, tmpfile)
// Also stream the value to a hasher
let p2 = send(value, /* streaming hashing function */ )
let values = await Promise.all(p1, p2)
View bread.md

| Ingredient | Measure | Baker's Percentage | | Sifted White Flour (Red Fife) | 500g | 100% | | Water | | 70% | | Active Levain | 100g | 20% | | Salt | 11g | | |

View reverse-indentation.js
for (var key in {one:'two'}) {
if (key === 'one') {
console.log(key)
}
}