Skip to content

Instantly share code, notes, and snippets.

@jimpick
Last active November 12, 2018 14:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimpick/0a6cfbeb21f327b4cc8ed79a08723561 to your computer and use it in GitHub Desktop.
Save jimpick/0a6cfbeb21f327b4cc8ed79a08723561 to your computer and use it in GitHub Desktop.
Example of async iterators + scuttlebutt
// To run: node -r esm read-log
import ssbClient from 'ssb-client'
import pull from 'pull-stream'
import toIterator from 'pull-stream-to-async-iterator'
import { promisify } from 'util'
const openSsbClient = promisify(ssbClient)
async function run () {
try {
const sbot = await openSsbClient()
const whoamiAsync = promisify(sbot.whoami)
const whoami = await whoamiAsync()
const source = pull(sbot.createUserStream({id: whoami.id}))
const iterator = toIterator(source)
for await (const value of iterator) {
const {
value: {
timestamp,
content: {
type,
channel,
text,
reply
}
}
} = value
if (type === 'post' && !reply) {
console.log('Date: ' + new Date(timestamp))
if (channel) {
console.log(`Channel: #${channel}`)
}
console.log('\n' + text + '\n\n')
// console.log(JSON.stringify(value, null, 2)) + '\n\n'
}
}
sbot.close()
} catch (err) {
console.error('Exception', err)
}
}
run()
Date: Fri Oct 06 2017 10:27:49 GMT-0700 (Pacific Daylight Time)
Channel: #dogs
![DSCF0027.JPG](&7+tpGSNgoXHchrz9n9ypXJ/bhQqu0LFTeJReqQrlphk=.sha256)
Date: Fri Oct 06 2017 11:37:44 GMT-0700 (Pacific Daylight Time)
Channel: #new-people
Hi!
This is nifty.
Date: Fri Oct 06 2017 13:20:45 GMT-0700 (Pacific Daylight Time)
Channel: #new-people
Likewise! I think we last hung out 18 years ago. :-)
Date: Thu Oct 12 2017 11:28:40 GMT-0700 (Pacific Daylight Time)
Channel: #new-people
And dwww! The first software package I ever adopted. :-)
Date: Fri Oct 13 2017 00:03:51 GMT-0700 (Pacific Daylight Time)
Tried out 'Rotonde' in Beaker Browser today. Pretty neat.
https://louis.center/p2p-social-networking/
Also written by somebody who lives on a boat.
My feed is at: dat://72671c5004d3b956791b6ffca7f05025d62309feaf99cde04c6f434189694291/
Date: Fri Oct 13 2017 00:06:04 GMT-0700 (Pacific Daylight Time)
Channel: #new-people
I didn't really do a great job with it... I was still learning back then. But it was fun!
Date: Fri Oct 13 2017 11:12:57 GMT-0700 (Pacific Daylight Time)
Sort of funny, I posted a link on Hacker News to a good article that somebody wrote:
https://news.ycombinator.com/item?id=15463721
It was late at night, and it got to the #1 position. :-)
Date: Sat Oct 14 2017 23:20:31 GMT-0700 (Pacific Daylight Time)
I think Rotonde grew by about 10x today
Date: Thu Nov 02 2017 10:12:06 GMT-0700 (Pacific Daylight Time)
Over in the Dat ecosystem, I announced my new project named "Pipette" ... it's blogging system.
I created a "dev blog":
https://pipette-dev-blog-jimpick.hashbase.io/
Date: Fri Nov 03 2017 22:32:32 GMT-0700 (Pacific Daylight Time)
Channel: #dat
Pipette dev blog: Messing around with HyperOS https://pipette-dev-blog-jimpick.hashbase.io/post/messing-around-with-hyperos/
Date: Wed Dec 06 2017 12:14:22 GMT-0800 (Pacific Standard Time)
Channel: #rotonde
@dominic I'm following you now!
Rotonde needs some work ... new people are basically invisible until somebody follows. I'll try to follow everybody on this thread...
Date: Wed Dec 06 2017 22:03:11 GMT-0800 (Pacific Standard Time)
Channel: #rotonde
@tim I get timeouts trying to load your Rotonde portal. You might want to use hashbase.io so that there are some online peers for it even when you aren't online.
Date: Sat Dec 09 2017 22:52:15 GMT-0800 (Pacific Standard Time)
Channel: #Ticktack
Nice work!
Date: Sun Jan 14 2018 23:15:48 GMT-0800 (Pacific Standard Time)
Date: Mon Jun 18 2018 14:12:16 GMT-0700 (Pacific Daylight Time)
I want to link my Fritter and my Rotonde and my Patchwork and my Cabal and my gitverse together somehow... and somehow get notifications to my phone.
Date: Fri Jun 22 2018 23:30:28 GMT-0700 (Pacific Daylight Time)
Channel: #dat
Got cabal-mobile partly working on iOS!
![ios-cabal.png](&QreXuu/c5c3bhRLHLkIBl/Me8M9nGfCq5IqoeN3Uxac=.sha256)
Lots of toolchain messing around silliness ... seems like a lot of peer-to-peer software could be made to work on Android + iOS this way.
Date: Mon Jul 02 2018 14:24:42 GMT-0700 (Pacific Daylight Time)
I've been trying to avoid posting too much to Twitter (apart from retweets) ... I've mostly been using Fritter.
But... not enough other Fritter people are posting, so I feel like I'm drowning out the public feed. There's only about 100 or so people, and only about 10 active posters, and they're probably all enjoying the summer weather.
So, I think I'll post a bit more here...
I'm going to be having coffee tomorrow with somebody who wants to talk to me about Dat and IPFS. I've done some basic IPFS demos, but I haven't built anything elaborate with it, so I'm going to tinker with it a bit today.
Date: Mon Jul 02 2018 14:33:18 GMT-0700 (Pacific Daylight Time)
Channel: #ipfs
Going to try out this tutorial here:
https://medium.freecodecamp.org/from-zero-to-interplanetary-hero-7e62f7d4427
Looks interesting... IPFS seems to be the land of "gateways" compared to Dat. But it's not like Dat can completely get away from the idea of gateways either - especially if you look at my glitch.com demos, which all have a gateway baked in.
Date: Mon Jul 30 2018 13:20:43 GMT-0700 (Pacific Daylight Time)
Channel: #dat
Prepping some visualizations using vizceral and mininet for the presentation I'm going to do in SF with mafintosh.
Now I can dynamically add new nodes to my swarm:
![vizceral-mininet-add-2.gif](&swyK4UTuSq2HtXHMLAxB+vULpS8CT7pzvxlR8UJ67cI=.sha256)
Date: Tue Aug 07 2018 23:00:07 GMT-0700 (Pacific Daylight Time)
Channel: #dwebsummit
I found [@dinosaur](@6ilZq3kN0F+dXFHAPjAwMm87JEb/VdB+LC9eIMW3sa0=.ed25519) 's awesome lightning talk about #ssb at #dwebsummit on archive.org!
![Screenshot 2018-08-07 22.44.57.png](&r59DdSacFBkZgpTYPWiRE6ySuXp1FjRhIO5S55DeQBI=.sha256)
https://archive.org/details/decentralizedwebsummitmedia-2018-hyperroom/DWeb+Hyper+Room+080118+01.mov?start=394
The YouTube video is completely messed up, so I'm glad to see that the archive.org version of the video has the talk!
Date: Thu Aug 09 2018 23:42:07 GMT-0700 (Pacific Daylight Time)
Channel: #dat
I dumped the MaxMind GeoLite2 geo IP lookup csv files into a hypertrie (single-writer hyperdb). And I made a little command line tool to do quick IP lookups by sparsely querying the database:
https://github.com/jimpick/dat-geoip
```
$ npm install -g @jimpick/dat-geoip
```
```
$ dat-geoip 64.46.22.7
{
"ip": "64.46.22.7",
"network": "64.46.20.0/22",
"geonameId": 6173331,
"registeredCountryGeonameId": 6251999,
"representedCountryGeonameId": 0,
"isAnonymousProxy": false,
"isSatelliteProvider": false,
"postalCode": "V6B",
"latitude": 49.2788,
"longitude": -123.1139,
"accuracyRadius": 5,
"localeCode": "en",
"continentCode": "NA",
"continentName": "North America",
"countryIsoCode": "CA",
"countryName": "Canada",
"subdivision1IsoCode": "BC",
"subdivision1Name": "British Columbia",
"subdivision2IsoCode": "",
"subdivision2Name": "",
"cityName": "Vancouver",
"metroCode": "",
"timeZone": "America/Vancouver",
"isInEuropeanUnion": false
}
```
I'd love to here if it works for anybody else!
Date: Thu Aug 16 2018 11:01:51 GMT-0700 (Pacific Daylight Time)
Channel: #dat
Inspired Ed Silverton's talk at #DWebSummit - I made a test site for Beaker that can do zoomable tiled images without a server!
![biiif-beaker.gif](&el3gCp/YoG/EMoYZYTUL7aVJFZ9P/6t76es7FTHcEsM=.sha256)
Try it out here:
dat://7e81d3e1fb359ee5e8c05eef3811fd81fb62b91d5c5fcbf768de73988712dac6/
Date: Fri Aug 17 2018 15:46:23 GMT-0700 (Pacific Daylight Time)
Channel: #cabal
I was inspired by Brian Warner's talk about Secure Ecmascript at #DWebSummit, and I made a chat bot server for cabal so I could try it out.
Any user can upload javascript for a bot and it will run. It's running live on the public cabal chat right now!
https://github.com/jimpick/cabal-ses-bot
![cabal-ses-bot.gif](&PEv9ajfpMUP0mF4dwZndChRtUrEiFH2uSwAVR+WgiaQ=.sha256)
Date: Mon Aug 27 2018 13:10:43 GMT-0700 (Pacific Daylight Time)
Channel: #dat
Big milestone!
Sam Macbeth got the Dat protocol working in Firefox as an extension using libdweb!
https://github.com/cliqz-oss/dat-webext
![Screenshot 2018-08-27 11.34.45.png](&YrTqIZi15zvIxswD/PcqBkUxmtVWueox4i3DR9NA7ps=.sha256)
Date: Wed Sep 12 2018 14:39:51 GMT-0700 (Pacific Daylight Time)
Channel: #dat
Going to record another DatCast podcast with @noffle in a few minutes!
Date: Mon Sep 17 2018 19:44:08 GMT-0700 (Pacific Daylight Time)
Heads up! I'm doing a 3 month contract with Protocol Labs with @pgte ... hopefully I'll have some demos to show to the #ipfs channel soonish. :-)
Date: Tue Sep 25 2018 17:13:55 GMT-0700 (Pacific Daylight Time)
I created another account for #manyverse ... welcome [@Jim Pick (on Android)](@/JWlofjvOvKhKz1VT9mvg2XiHySxsH2619QoAdfWPmc=.ed25519)
It would be nice if I could eventually merge my accounts together... wasn't that being worked on?
Date: Sat Sep 29 2018 22:14:10 GMT-0700 (Pacific Daylight Time)
Submitted a talk for Tokyo Nodefest!
Date: Fri Oct 05 2018 17:03:18 GMT-0700 (Pacific Daylight Time)
Channel: #ipfs
Flying to Glasgow tomorrow to hang out at the Protocol Labs all-hands (I'm doing a contract with them for a few months) and learn a bunch more about #ipfs.
Date: Sun Nov 11 2018 20:19:30 GMT-0800 (Pacific Standard Time)
Channel: #ssb-show-and-tell
Playing around with [@alanshaw](@95pGuafWywXH4M86R+D4Y7HFw6jZbTsTUI46Brx5emg=.ed25519)'s pull-stream-to-async-iterator and the scuttlebutt API...
https://gist.github.com/jimpick/0a6cfbeb21f327b4cc8ed79a08723561
Date: Sun Nov 11 2018 20:20:29 GMT-0800 (Pacific Standard Time)
Hey, I've been on scuttlebutt for more than a year now!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment