Skip to content

Instantly share code, notes, and snippets.

@reisepass
reisepass / minisend.js
Last active November 28, 2023 00:32
web5 mini send poc
import { Web5 } from "@web5/api";
import {readFileSync,appendFileSync,appendFile, unlinkSync} from "fs"
import { LevelStore } from '@web5/common';
import { EdDsaAlgorithm } from '@web5/crypto';
const { web5, did: myDid } = await Web5.connect({sync: '5s'});
let i_am="";
const roman_did= `did:ion:EiCfpN21p6o7dD9NImXtct5knTkOGhYy9OlSs0hdiCsrIQ:eyJkZWx0YSI6eyJwYXRjaGVzIjpbeyJhY3Rpb24iOiJyZXBsYWNlIiwiZG9jdW1lbnQiOnsicHVibGljS2V5cyI6W3siaWQiOiJkd24tc2lnIiwicHVibGljS2V5SndrIjp7ImNydiI6IkVkMjU1MTkiLCJrdHkiOiJPS1AiLCJ4IjoicFZJcGZzX3c5YXhsU3ZGVFVWU2hSRzRuZDdCQ2RobzZ3Y0wxRms4dHB4VSJ9LCJwdXJwb3NlcyI6WyJhdXRoZW50aWNhdGlvbiJdLCJ0eXBlIjoiSnNvbldlYktleTIwMjAifSx7ImlkIjoiZHduLWVuYyIsInB1YmxpY0tleUp3ayI6eyJjcnYiOiJzZWNwMjU2azEiLCJrdHkiOiJFQyIsIngiOiJlX0tvTDRRZnJuZWlNSGpDWFpGNjREaWU0Vjh6NjJZaE5vN1Bzc3lRXzhRIiwieSI6IjFYZ1JsTWJfR3FqNXBaTHRzMUxlcmRQaUowN1hSNzNRX0ZyT0FtbVBCdm8ifSwicHVycG9zZXMiOlsia2V5QWdyZWVtZW50Il0sInR5cGUiOiJKc29uV2ViS2V5MjAyMCJ9XSwic2VydmljZXMiOlt7ImlkIjoiZHduIiwic2VydmljZUVuZHBvaW50Ijp7ImVuY3J5cHRpb25LZXlzIjp
@reisepass
reisepass / minimalexternalkey.js
Created November 26, 2023 22:02
web5 load external private key
const passphrase = "passphrase typed in from user interface"
const private_key_restored_from_db = "uint8array_base64_encoded_on_db"
const public_key_restored_from_db = "uint8array_base64_encoded_on_db_pub"
let appData = new AppDataVault({
store: new LevelStore('DATA/AGENT/APPDATA')
});
const options={
algorithm : { name: 'EdDSA', namedCurve: 'Ed25519' },
package ch.ethz.dalab.dissolve.examples.neighbourhood
import cc.factorie.la._
import scala.collection.mutable.ArrayBuffer
import scala.collection.Set
import cc.factorie.util.{DoubleSeq, RangeIntSeq, SparseDoubleSeq}
import scala.collection.mutable
@reisepass
reisepass / MaximizeByBPLoopy_rw
Created August 19, 2015 14:32
Use this to change the number of iterations LoopyBP does
package ch.ethz.dalab.dissolve.examples.neighbourhood
import cc.factorie.la._
import scala.collection.mutable.ArrayBuffer
import scala.collection.Set
import cc.factorie.util.{DoubleSeq, RangeIntSeq, SparseDoubleSeq}
import scala.collection.mutable
@reisepass
reisepass / gist:38c2b29f0b1bb53e27a9
Created July 28, 2015 17:54
error happens on aws but not locally
/*
Exception in thread "main" java.lang.ClassCastException: breeze.linalg.Transpose cannot be cast to breeze.linalg.ImmutableNumericOps
at ch.ethz.dalab.dissolve.optimization.SolverUtils$.objectiveFunction(SolverUtils.scala:52)
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned.ch$ethz$dalab$dissolve$optimization$DBCFWSolverTuned$$evaluateModel$1(DBCFWSolverTuned.scala:237)
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned$$anonfun$optimize$1.apply$mcZI$sp(DBCFWSolverTuned.scala:375)
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned$$anonfun$optimize$1.apply(DBCFWSolverTuned.scala:359)
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned$$anonfun$optimize$1.apply(DBCFWSolverTuned.scala:359)
at scala.collection.immutable.Stream.takeWhile(Stream.scala:803)
at ch.ethz.dalab.dissolve.optimization.DBCFWSolverTuned.optimize(DBCFWSolverTuned.scala:358)
at ch.ethz.dalab.dissolve.classification.StructSVMWithDBCFW.trainModel(StructSVMWithDBCFW.scala:24)
@reisepass
reisepass / gist:e1b3b48bbbe8217fbfe6
Created June 30, 2015 13:32
Core portion of the Mean Field algorithm. Prettymuch one to one of the Matlab code
val Q = DenseMatrix.ones[Double](numRegions, numClasses)
var lastMaxE = 0.0
var lastMinE = 0.0
var numNoChange = 0
for (iter <- 0 until maxIterations) {
var numUnchangedQs = 0
val lastQ = Q;
val xiLab = (0 until numClasses).par
val Q = DenseMatrix.ones[Double](numRegions, numClasses) //TODO maybe initialize to 1/num neighbours or 1/numneighbours*numClass
//TODO This Q could be stored in a spark RDD if it gets too large for memory;; Prob not necesary because thetaUnayr is the same size
//TODO consider storing the probabilities in a byte
if (debug) {
//val header = (0 until numClasses).toSeq.toList.flatMap { curclass => (0 until numRegions).toSeq.toList.map { curregion => ",Qr" + curregion + " Qc" + curclass } }
// println("#MF_Q_LOG#,timeID,elapsedTime" + header)
// println("#MF_E_LOG#,timeID,logTag,iter,maxE,minE,maxE_change,minE_change")
}
var lastMaxE = 0.0
class RegionVar(val score: Int) extends IntegerVariable(score)
object PixelDomain extends DiscreteDomain(numClasses)
class Pixel(i: Int) extends DiscreteVariable(i) { //i is just the initial value
def domain = PixelDomain
}
val labelParams = Array.fill(graph.size) { new Pixel(0) }
val nodePairsUsed: HashSet[(Int, Int)] = new HashSet[(Int, Int)]()
{
"d":{
"__type":"Response:http:\/\/research.microsoft.com",
"Author":null,
"Conference":null,
"Domain":null,
"Journal":null,
"Keyword":null,
"Organization":null,
"Publication":{
@reisepass
reisepass / gist:5631031
Last active December 17, 2015 15:19
Here is an example use case for the wildcard.
protected ArrayList<String> wildWithInpAtBack(String inp,int ngramLength){
ArrayList<String> out = new ArrayList<String>(ngramLength);
for(int i=0;i<ngramLength-1;i++){
out.add(i, FirstSentSum.WILDCARD_STRING);
}
if(inp.indexOf(" ")!=-1){
for(String sepI : inp.split(" ")){
out.add(sepI);
}
}