Skip to content

Instantly share code, notes, and snippets.

View carsonfarmer's full-sized avatar
✏️
Reading, writing, arithmetic

carsonfarmer carsonfarmer

✏️
Reading, writing, arithmetic
View GitHub Profile
@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 / 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 / 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 / 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 / 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: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 / 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 / index.html
Created June 14, 2018 06:37
index.html step 1
<!doctype html>
<html>
<head>
<meta charset="utf8">
<title>Encryptoid ĐApp</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="main">
<h1>Welcome to Encryptoid!</h1>
@carsonfarmer
carsonfarmer / main.js
Last active June 21, 2018 20:05
Update to main.js IPFS Dapp example
const setup = async () => {
// The root IPFS CID for our xkcd archive
const xkcdRoot = '/ipfs/QmS74HhZt3ZekqUDqdttSgMsHwYQ6miDLwGUHy6pp4qLyD'
// Pick and random comic between 1 and 2003 (which is the latest in the archive)
const comicNumber = Math.floor(Math.random() * 2003) + 1
try {
// Create IPFS peer
const ipfs = await getIpfs()
// Connect to public peer pinning xkcd comics (might not be needed)
await ipfs.swarm.connect(

Keybase proof

I hereby claim:

  • I am carsonfarmer on github.
  • I am carsonfarmer (https://keybase.io/carsonfarmer) on keybase.
  • I have a public key ASCn5qH7gBKTze_0Tu48Y-hfPRwRARddzi6M6HjMi2mTVQo

To claim this, I am signing this object: