Skip to content

Instantly share code, notes, and snippets.

@qfrank
qfrank / how-to-setup-local-waku-node.md
Last active November 30, 2023 08:45
How to setup local waku node with status-mobile

Why we need local waku node?

Sometimes to reproduce the bug rather than message delivery issue, we need three simulators: one for userA and the remaining two for userB, with the latter two simulators being paired. When userA sends a contact request to userB, due to message delivery issues, reproducing the bug can be challenging or inconsistent. However, with a local Waku node, these message delivery issues are resolved, leading to faster and more reliable bug replication.

Another purpose could be: just want to know more about waku :)

How to setup local waku node with status-mobile?

Preparation

  • any preparations needed for building status-go should be done before setup local waku node
  • domain
@qfrank
qfrank / gist:f5064d9aa8b940d519dd850c2f15399d
Created October 20, 2023 08:07
Test DB(sqlite) for Notification ID
package protocol
import (
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/sqlite"
"github.com/stretchr/testify/require"
"testing"
)
func TestNotificationID(t *testing.T) {
@qfrank
qfrank / gist:501e3bb8e92c7d27054ed7d4f804a275
Created October 16, 2023 09:48
test if encrypting works
func TestOpen(t *testing.T) {
filePath := "/Users/xxx/Documents/tmp/0x49447b3c313e9bca0aeec82fb97a6b69f158d45797641919960e03ac60c83577-v4.db"
encrypted, err := IsEncrypted(filePath)
require.NoError(t, err)
require.True(t, encrypted)
db, err := InitializeDB(filePath, "0x20756cad9b728c8225fd8cedb6badaf8731e174506950219ea657cd54f35f46c",dbsetup.ReducedKDFIterationsNumber)
require.NoError(t, err)
rows, err := db.Query("SELECT COUNT(1) FROM keypairs_accounts")
require.NoError(t, err)

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@qfrank
qfrank / go_port_forwarding.go
Created May 10, 2020 14:14 — forked from qhwa/go_port_forwarding.go
network port forwarding in go lang
package main
import (
"fmt"
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8080")
@qfrank
qfrank / TableMd5.java
Created June 2, 2017 10:26
mysql table definition md5
private String md5(String table) {
String columnDefinitionSql = "SELECT column_name,ordinal_position,column_default,is_nullable,column_type\n" +
"FROM information_schema.columns\n" +
"WHERE table_schema = '%s' AND table_name = '%s' order by column_name";
MessageDigest md5 = DigestUtils.getMd5Digest();
jdbcTemplate.query(String.format(columnDefinitionSql, dbSchema, table), row -> {
ResultSetMetaData meta = row.getMetaData();
int cols = meta.getColumnCount();
for (int i = 1; i <= cols; i++) {
@qfrank
qfrank / MyImprovedNamingStrategy.java
Last active January 1, 2016 01:43
模仿grails NamingStrategy
package com.ys.scs.persistence;
import org.hibernate.AssertionFailure;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.internal.util.StringHelper;
/**
* User: Frank Tang <br/>
* Date: 15/11/26<br/>
@qfrank
qfrank / TestHttpPost.java
Last active November 17, 2015 03:44
http post without ssl validation
package test;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
.svn
.idea
target
logs
out
stacktrace.log
*.class
# default HSQL database files for production mode
@qfrank
qfrank / gist:9c09c3728cd8aac017b2
Last active August 29, 2015 14:23
tomcat virtual mapping xml
private static createVirtualMappingXml(){
if(Environment.current != Environment.DEVELOPMENT){
def catalinaHome = System.getenv('CATALINA_HOME')
if(!catalinaHome){
catalinaHome = System.getProperty("catalina.base")
}
if(!catalinaHome){
throw new RuntimeException("找不到环境变量CATALINA_HOME")
}