Skip to content

Instantly share code, notes, and snippets.

View victorfei's full-sized avatar

Victor Fei victorfei

View GitHub Profile
@victorfei
victorfei / neo4j_notes.md
Last active December 7, 2022 01:33
neo4j notes

Notes for setting up and running Neo4j

Community edition only supports 1 db.

Community edition only supports 1 db, to create and switch db, needs to got to neo4j config file and manually set new db info and restart. https://community.neo4j.com/t5/neo4j-graph-platform/create-multiple-databases-in-community-version/m-p/33900

load csv

In neo4j.conf which located at root installation dir.

# This setting constrains all `LOAD CSV` import files to be under the `import` directory. Remove or comment it out to
@victorfei
victorfei / ipfs_rw_crypt.js
Created September 2, 2021 22:15
ipfs encrypt write, decrypt read
// Encryptes and writes string to ipfs. Retrieve and decrypts it.
var msg = 'begin r/w operation onto ipfs';
console.log(msg);
const crypto = require('crypto');
const ipfs = require('ipfs-core');
const { exit } = require('process');
const algo = 'aes-256-ctr';
let key = 'OrmiPrivateKey';
key = crypto.createHash('sha256').update(key).digest('base64').substr(0, 32);
@victorfei
victorfei / draw_chessboard.py
Last active April 30, 2022 19:54
Draw a chessboard image using python PIL
#!/usr/bin/python
# adapted from:
# http://wordaligned.org/articles/drawing-chessboards
from PIL import Image, ImageDraw
from itertools import cycle
def draw_chessboard(n=8, pixel_width=500):
"""
Draw an n x n chessboard using PIL.
"""
import os
from PIL import Image
import numpy as np
files = [f for f in os.listdir("handwriting/numbers/")]
files = ["handwriting/numbers/" + f for f in files]
STANDARD_SIZE = (50, 50)
def get_image_data(filename):
img = Image.open(filename)
@victorfei
victorfei / digit_recognition_sklearn.py
Created November 4, 2016 21:33
Using SciKit machine learning libraries for recognizing pictures of digits
# Standard scientific Python imports
import matplotlib.pyplot as plt
# Import datasets, classifiers and performance metrics
from sklearn import datasets, svm, metrics
# The digits dataset
digits = datasets.load_digits()
@victorfei
victorfei / FileWriter.cpp
Created September 30, 2016 08:20
A simple C++ snippet for writing to file on disk.
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ofstream msgFile;
msgFile.open("msg", ios::out);
@victorfei
victorfei / tmux-cheatsheet.markdown
Created August 26, 2016 21:06 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@victorfei
victorfei / 0_reuse_code.js
Created November 10, 2015 01:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console