Skip to content

Instantly share code, notes, and snippets.

@agazso
agazso / index.html
Last active December 11, 2020 13:49
Swarm File Upload
<!-- https://gist.github.com/agazso/15b2245cfa1206ec34f60c782b96b2cf -->
<html>
<head>
<title>Swarm File Uploader</title>
<script src="/files/192a6e12ffc8bd9a246103bcac2a6c7afac55bc9dd1eaf2cb37c0b6cad9be278"></script>
<script>
const url = window.location.origin
const bee = new window['@ethersphere/bee-js'].default(url)
function getIndexDocument(files) {
@agazso
agazso / dates.ts
Created November 20, 2020 15:32
Performance logging in Typescript
const dates = []
const logDates = () => dates.forEach((datePair, index) => {
if (index === 0) {
console.debug(datePair[0], datePair[1])
} else {
console.debug(datePair[0], datePair[1], 'elapsed: ' + (datePair[1] - dates[index - 1][1]))
}
if (index === dates.length - 1) {
console.debug('total', 'elapsed: ' + (datePair[1] - dates[0][1]))
}
@agazso
agazso / error.ts
Last active November 20, 2020 16:20
Type safe error handling in Typescript with classes
// compile: tsc error.ts --lib ES2015,dom
type Result<T> = T | Error
const isError = <T>(r: Result<T>): r is Error => (r instanceof Error)
class CustomError extends Error {
value: any
constructor(value, ...params) {
super(...params)
const axios = require('axios')
const apiKey = 'YOUR-ETHERSCAN-API-KEY'
const address = '0xb27e3af4eb6e40007b5f74a635b9d5fb6c4887ec'
const urlBase = 'https://api-goerli.etherscan.io/api'
async function txlist(address) {
const url = `${urlBase}?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&sort=asc&apikey=${apiKey}`
const response = await axios.get(url)
return response.data.result
@agazso
agazso / FelfeleSocialProtocol.md
Created December 17, 2019 19:12
Felfele Social Protocol Draft

Felfele Social Protocol

In this article we will describe a social protocol on the Ethereum Swarm decentralized cloud service. Our goal is to make the protocol comprehensive and practical so that it covers all the basic functionality, although due to the richness of social applications it does not thrive to be complete. This is not (yet) a specification of a standard, but rather a result of research that hopefully inspires others to share similar ideas, enable cooperation and compatibility.

Our goals include:

  • good usability
  • pretty good privacy
  • anonymity
  • self-sovereignity
  • sustainability
@agazso
agazso / gist:2db41e42f8dbe24108000f7eb200f4b5
Created November 27, 2019 18:45
erebos yarn start error output
% yarn start
yarn run v1.19.2
$ yarn build && yarn test:all
$ lerna run build
lerna notice cli v3.19.0
lerna info Executing command in 33 packages: "yarn run build"
lerna info run Ran npm script 'build' in '@erebos/secp256k1' in 45.2s:
$ yarn test:types && yarn clean && yarn build:js && yarn build:types
$ tsc --noEmit -p tsconfig.build.json
$ del cjs esm types
09-27 18:20:49.546 6730 6790 I GoLog : DEBUG[09-27|16:20:49.545] handleRequestSubscription: streamer 3c45a70dc5d73bff72133821d8060d47dcdf83f483b7d177a96301bcc10ee948 to subscribe to 815813dc8520dd3739f703df2817464f8e4897b28884d1d34edcfd160f31ead0 with stream SYNC|4|l
09-27 18:20:49.567 6730 6780 I GoLog : DEBUG[09-27|16:20:49.546] handleRequestSubscription: streamer 3c45a70dc5d73bff72133821d8060d47dcdf83f483b7d177a96301bcc10ee948 to subscribe to 815813dc8520dd3739f703df2817464f8e4897b28884d1d34edcfd160f31ead0 with stream SYNC|4|l
09-27 18:20:49.567 6730 6780 I GoLog : DEBUG[09-27|16:20:49.550] handleRequestSubscription: streamer 3c45a70dc5d73bff72133821d8060d47dcdf83f483b7d177a96301bcc10ee948 to subscribe to 0ac419439f72566d1be65c336e7ecfdfd5fbbb0ffd2aaaaf3bc9a58b6823e5cf with stream SYNC|6|l
09-27 18:20:49.570 6730 6780 I GoLog : DEBUG[09-27|16:20:49.568] handleRequestSubscription: streamer 3c45a70dc5d73bff72133821d8060d47dcdf83f483b7d177a96301bcc10ee948 to subscribe to 815813dc8520dd3739f
@agazso
agazso / copy.html
Last active August 16, 2019 14:02
Proof-of-concept copy to clipboard that works on Safari 12 on iOS
<html>
<head>
<style>
#textarea {
visibility: hidden;
}
</style>
<script>
function iosCopyToClipboard(el) {
var oldContentEditable = el.contentEditable,
@agazso
agazso / photoshare-crash.txt
Created July 30, 2019 10:11
Photo share extension crash log
2019-07-30 12:07:57.482992+0200 Share[88219:34956174] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d70e1bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010b73c735 objc_exception_throw + 48
2 CoreFoundation 0x000000010d65a4ec _CFThrowFormattedException + 194
3 CoreFoundation 0x000000010d77d541 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
4 CoreFoundation 0x000000010d709c9b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
5 Share 0x0000000109caafea __47-[ReactNativeShareExtension resolver:rejecter:]_block_invoke + 378
6 Share 0x0000000109cabdf7 __65-[ReactNativeShareExtension extractDat
Error: redux-persist: persist timed out for persist key "root"
at blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:143328:45
at blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:27430:21
at _callTimer (blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:27347:9)
at Object.callTimers (blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:27554:9)
at MessageQueue.__callFunction (blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:2589:44)
at blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:2346:17
at MessageQueue.__guard (blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:2543:13)
at MessageQueue.callFunctionReturnFlushedQueue (blob:file:///6a03775b-b572-4c40-aab2-117927db1e3b:2345:14)
at e (file:///Applications/React%20Native%20Debugger.app/Contents/Resources/app.asar/js/RNDebuggerWorker.js:1:136705)