Skip to content

Instantly share code, notes, and snippets.

View carsonfarmer's full-sized avatar

carsonfarmer carsonfarmer

View GitHub Profile
@carsonfarmer
carsonfarmer / style.css
Created June 14, 2018 06:38
style.css step 1
html, body {
font-family: "Lucida Sans Typewriter", "Lucida Console", "Bitstream Vera Sans Mono", monospace;
height: 100%;
}
#main {
width: 50%;
margin: 0 auto;
padding-top: 2%;
}
@carsonfarmer
carsonfarmer / main.js
Created June 14, 2018 06:42
main.js step 2
import 'babel-polyfill' // We need this for async/await polyfills
// Import our two IPFS-based modules
import getIpfs from 'window.ipfs-fallback'
import crypto from 'libp2p-crypto'
let ipfs
// Setup a very simple async setup function to run on page load
const setup = async () => {
try {
@carsonfarmer
carsonfarmer / index.html
Created June 14, 2018 06:44
index.html step 2
<h1>Welcome to Encryptoid!</h1>
<form id="secret">
<label for="message">Message</label>
<textarea id="message" required rows="5"></textarea>
<label for="password">Password</label>
<input id="password" type="text" required minlength="10" maxlength="100">
</form>
<button id="button" type="button">Encrypt</button>
<div id="output"></div>
@carsonfarmer
carsonfarmer / main.js
Created June 14, 2018 06:45
main.js step 3
import 'babel-polyfill' // We need this for async/await polyfills
// Import our two IPFS-based modules
import getIpfs from 'window.ipfs-fallback'
import crypto from 'libp2p-crypto'
let ipfs
// Setup a very simple async setup function to run on page load
const setup = async () => {
try {
@carsonfarmer
carsonfarmer / main.js
Created June 14, 2018 06:49
decryption
crypto.aes.create(Buffer.from(key), iv, (err, cipher) => {
if (!err) {
cipher.decrypt(Buffer.from(message.value, 'base64'), async (err, plain) => {
if (!err) {
output.innerText = `${plain.toString('utf-8')}`
}
})
}
})
@carsonfarmer
carsonfarmer / default
Created June 18, 2018 22:59
Nginx config
server {
server_name ipfs.my-domain-name.com;
listen [::]:4002 ssl ipv6only=on;
listen 4002 ssl;
ssl_certificate /etc/letsencrypt/live/ipfs.my-domain-name.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ipfs.my-domain-name.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://127.0.0.1:8081;
@carsonfarmer
carsonfarmer / index.html
Last active August 7, 2018 18:46
Code snippets for IPFS Dapp example
<!doctype html>
<html>
<head>
<meta charset="utf8">
<title>Demo Profile ĐApp</title>
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/solid.css" integrity="sha384-wnAC7ln+XN0UKdcPvJvtqIH3jOjs9pnKnq9qX68ImXvOGz2JuFoEiCjT8jyZQX2z" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/brands.css" integrity="sha384-nT8r1Kzllf71iZl81CdFzObMsaLOhqBU1JD2+XoAALbdtWaXDOlWOZTR4v1ktjPE" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/fontawesome.css" integrity="sha384-HbmWTHay9psM8qyzEKPc8odH4DsOuzdejtnr+OFtDmOcIVnhgReQ4GZBH7uwcjf6" crossorigin="anonymous">
</head>
@carsonfarmer
carsonfarmer / index.html
Last active September 5, 2018 23:27
Intermediate State of Chat Dapp
<!doctype html>
<html>
<head>
<meta charset="utf8">
<title>Chat ĐApp</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="main">
<div class="controls">
@carsonfarmer
carsonfarmer / main.js
Created September 5, 2018 22:16
Secondary State of Chat Dapp
import 'babel-polyfill'
import Room from 'ipfs-pubsub-room'
import IPFS from 'ipfs'
import ko from 'knockout'
import queryString from 'query-string'
// Global references for demo purposes
let ipfs
let viewModel
@carsonfarmer
carsonfarmer / package.json
Created September 24, 2018 18:51
scripts and deps section of package.json
...
"scripts": {
"setup": "yarn install",
"release": "npm version patch",
"postversion": "git push --follow-tags",
"build": "run-s build:*",
"build:copy": "run-p build:copy:*",
"build:copy:html": "shx mkdir -p dist && shx cp index.html dist/index.html",
"build:copy:images": "shx mkdir -p dist/img && shx cp img/* dist/img",
"build:copy:css": "shx mkdir -p dist/css && shx cp css/*.css dist/css",