Skip to content

Instantly share code, notes, and snippets.

View RichardLitt's full-sized avatar

Richard Littauer RichardLitt

View GitHub Profile
@RichardLitt
RichardLitt / gist:90243a2dfa0ed5785e75
Last active August 29, 2015 14:25
Why are new props not being rerendered?
var React = require('react/addons')
var PouchDBUrl = require('../env.js').PouchDBUrl
var PouchDB = require('pouchdb')
PouchDB.plugin(require('pouchdb-authentication'))
var db = new PouchDB(PouchDBUrl)
var _ = require('lodash')
// TODO: On Load:
// Get the conversations needed -- Pass these through to the component
// Get the date of the first (or last?) note in each conversation
module.exports.getConversationPosts = exports.getConversationPosts = function getConversationPosts (conversation, cb) {
return db.query(function (doc) {
if (doc.conversation && doc.type && doc.type === 'note') {
emit(doc.conversation)
}
}, {include_docs: true, key: conversation.id}).then(function (response) {
// TODO This shouldn't be needed, the query should be doing this for us.
// Actually, this isn't working at all. The conversation.id is undefined.
console.log('conversation', response, conversation.id)
return _.filter(justTheDocs(response), function (doc) {
@RichardLitt
RichardLitt / gist:87ff56363343bd4e745d
Last active August 29, 2015 14:28
Array iterators and async
var readPDFText = function (documentObject, options, cb) {
if (!documentObject) throw new Error('No pdf provided')
// For each page
async.map(
pdfjs.getDocument(documentObject).then(function (pdf) {
// Get all of the apges
async.times(pdf.numPages, function (pageNum, callback) {
pdf.getPage(pageNum + 1).then(function (page) {
// Get all of the strings on the page
@RichardLitt
RichardLitt / README.md
Created September 25, 2015 00:53
archive-format readme.

archive-format

This is a discussion repo for creating a spec and implemenation of an IPFS archive format. Please see the issues to join the conversation.

Keybase proof

I hereby claim:

  • I am RichardLitt on github.
  • I am richlitt (https://keybase.io/richlitt) on keybase.
  • I have a public key whose fingerprint is 1070 2CDC E1A8 61C8 4EC6 B5F1 4EA1 CEF2 3B01 6E42

To claim this, I am signing this object:

@RichardLitt
RichardLitt / gist:0b7072739d2ae46b9162
Created October 14, 2015 18:55
Returned undefined
function binSearch (dict, hunt) {
var len = dict.length
var half = Math.floor(len / 2)
if (len === 1) {
if (dict[0] === hunt) {
return hunt
} else {
return null
}
10:05 ~/src/ipfs-community 🐕 git co master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
10:05 ~/src/ipfs-community 🐕 git pull
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 11 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (11/11), done.
From github.com:ipfs/community
96a9229..34b44fe master -> origin/master
/* Print out open cards from a given list */
function listCards (listName) {
return Promise.try(function () {
return getOpenLists()
}).filter(function (list) {
return list.name === listName
}).then(function (list) {
return t.getAsync('/1/lists/' + list[0].id, {cards: 'open'})
}).spread(function (list.cards) {
// Here!
/* Print out open cards from a given list */
function listCards (listName) {
return Promise.try(function () {
return getOpenLists()
}).filter(function (list) {
return list.name === listName
}).then(function (list) {
return t.getAsync('/1/lists/' + list[0].id, {cards: 'open'})
}).then(function (list) {
return Promise.map(list.cards, function (card) {
Verifying that +richlitt is my blockchain ID. https://onename.com/richlitt