Skip to content

Instantly share code, notes, and snippets.

View carsonfarmer's full-sized avatar
🏖️
Remote working...

Carson Farmer carsonfarmer

🏖️
Remote working...
View GitHub Profile
@carsonfarmer
carsonfarmer / step-three.diff
Created May 11, 2019 06:26
Adding some Textile functionality
diff --git a/index.js b/index.js
index 4cf1473..598b1d1 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,7 @@
#!/usr/bin/env node
const cli = require('cac')('txtl')
+const textile = require('@textile/js-http-client').default
var readline = require('readline')
@carsonfarmer
carsonfarmer / step-two.diff
Created May 11, 2019 06:22
Adding some interactivity
diff --git a/index.js b/index.js
index 11b46ac..4cf1473 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,7 @@
#!/usr/bin/env node
const cli = require('cac')('txtl')
+var readline = require('readline')
@carsonfarmer
carsonfarmer / index.js
Created May 11, 2019 06:14
Initial stub cmd-line tool
#!/usr/bin/env node
const cli = require('cac')('txtl')
const { log } = console
// Create 'default' chat command
cli.command('', 'Starts an interactive chat session in a thread.')
.action((opts) => {
log('do something')
@carsonfarmer
carsonfarmer / App.diff
Last active April 4, 2019 00:02
Full 'app' diff
diff --git a/src/Main.js b/src/Main.js
index a545559..e34f915 100644
--- a/src/Main.js
+++ b/src/Main.js
@@ -1,21 +1,11 @@
import React, { Component } from 'react'
import { observer, inject } from 'mobx-react'
-import { Image } from 'semantic-ui-react'
-// import Moment from 'react-moment'
-import * as Logo from './LaunchLogo@3x.png'
@carsonfarmer
carsonfarmer / Store.js.diff
Last active April 3, 2019 23:58
Store Diff
diff --git a/src/Store.js b/src/Store.js
--- a/src/Store.js
+++ b/src/Store.js
@@ -1,7 +1,10 @@
-import { observe, action, observable } from 'mobx'
+import { observe, action, observable, runInAction } from 'mobx'
+import { utc } from 'moment'
import { Textile } from '@textile/js-http-client'
import { toast } from 'react-semantic-toasts'
@carsonfarmer
carsonfarmer / Profile.js
Last active April 3, 2019 23:59
Profile Component
import React, { Component } from 'react'
import { observer, inject } from 'mobx-react'
import { Card, Icon, Image, Input, Form } from 'semantic-ui-react'
import Moment from 'react-moment'
@inject('store') @observer
class Profile extends Component {
handleUsername = e => {
e.preventDefault()
this.props.store.setProfile(this.inputRef.value, null)
@carsonfarmer
carsonfarmer / addFile.js
Created February 21, 2019 17:22
Working with Textile REST API from Javascript
/* eslint no-undef: "error" */
/* eslint-env browser */
import 'babel-polyfill'
import toposort from 'toposort'
import waterfall from 'async/waterfall'
const getThreadInfo = async (thread) => {
const threadId = thread || 'default'
return executeJsonCmd('GET', `${API}/threads/${threadId}`, { ctype: 'application/json' })
}
@carsonfarmer
carsonfarmer / facebook.py
Last active February 9, 2019 19:43
Textile's Python-base Command-Line tool for importing Facebook/Instagram data
import os
import click
from subprocess import check_output
import zipfile
try:
from tempfile import TemporaryDirectory
except:
from backports.tempfile import TemporaryDirectory
from glob import glob
import json
@carsonfarmer
carsonfarmer / docs.py
Created December 22, 2018 00:36
make commandline docs
import re
import subprocess
cmds = subprocess.check_output(["textile", "commands"]).decode("utf-8").split("\n")[:-1]
seen = set()
for cmd in cmds:
line = cmd.split(" ") + ["--help",]
if line:
if line[1] not in seen:
seen.add(line[1])
header = "# `{}`\n\n".format(line[1])
@carsonfarmer
carsonfarmer / ipfs-promise.js
Created November 26, 2018 04:57
Simple module to promisify ipfs initialization
#!/usr/bin/env node
'use strict'
import IPFS from 'ipfs'
const getIpfs = (opts) => {
opts = opts || {}
return new Promise(function (resolve, reject) {
var ipfs = new IPFS(opts)