Skip to content

Instantly share code, notes, and snippets.

@yrong
yrong / monster-query.adoc
Created February 12, 2017 07:28
A monster-query in cypher

A complex query result projection in cypher

Table of Contents

Introduction

Sometimes it is better to request a complete object-tree from the (graph-)database at once instead sending more than one requests to the database and merging the results in program code.

@yrong
yrong / customized_pom.sh
Created February 14, 2017 15:57
customize pom with some linux commands
#!/usr/bin/zsh
source $HOME/.zshrc
alias mvnp="MAVEN_OPTS='-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=1081' mvn -Dlicense.skip=true -DskipTests=true -Dcheckstyle.skip=true -Denforcer.skip=true -Dscalastyle.skip=true"
mvnp clean
rm -rf build
rm -rf docs
rm -rf integrationtests
rm -rf manual
rm -rf stresstests
@yrong
yrong / neo4j_cypher_cheatsheet.md
Created February 26, 2017 07:58 — forked from DaniSancas/neo4j_cypher_cheatsheet.md
Neo4j's Cypher queries cheatsheet

Neo4j Tutorial

Fundamentals

Store any kind of data using the following graph concepts:

  • Node: Graph data records
  • Relationship: Connect nodes (has direction and a type)
  • Property: Stores data in key-value pair in nodes and relationships
  • Label: Groups nodes and relationships (optional)
package main
import (
"go/ast"
"go/parser"
"go/token"
"strconv"
)
// 实现一个只支持int,只支持加法,函数只有println,只支持一个参数的Go语言子集....
@yrong
yrong / RadixSort.java
Created February 2, 2018 04:23 — forked from yeison/RadixSort.java
Implementation of Radix Sort in Java.
/*
RadixSort.java : Sorts 32-bit integers with O(n*k) runtime performance.
Where k is the max number of digits of the numbers being
sorted.
(i.e. k=10 digits for 32-bit integers.)
Copyright (C) 2013 Yeison Rodriguez ( github.com/yeison )
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@yrong
yrong / proof_of_work
Created February 3, 2018 11:49
proof_of_work
#!/usr/bin/env python
# example of proof of work algorithm
import hashlib
import time
max_nonce = 2 ** 32 # 4 billion
block_map = {}
@yrong
yrong / markov.go
Created February 5, 2018 04:27
markov
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Generating random text: a Markov chain algorithm
Based on the program presented in the "Design and Implementation" chapter
of The Practice of Programming (Kernighan and Pike, Addison-Wesley 1999).
See also Computer Recreations, Scientific American 260, 122 - 125 (1989).
@yrong
yrong / btree.hpp
Created February 24, 2018 07:41 — forked from zhenghaoz/btree.hpp
B Tree
#include <memory>
#include <vector>
#include <iostream>
template <unsigned N, typename Key, typename Value>
class BTree
{
template <typename T> using vector = std::vector<T>;
template <typename T> using shared_ptr = std::shared_ptr<T>;
var msgSend;
var counter = 0
setInterval(function(){
msgSend = new Buffer(counter.toString());
ipfs.pubsub.publish(topic, msgSend, (err) => {
if (err) {
throw err
}
// msg was broadcasted
})
@yrong
yrong / epoll.go
Created March 8, 2018 10:04 — forked from tevino/epoll.go
Golang example for using epoll
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (