Skip to content

Instantly share code, notes, and snippets.

@qiuwei
qiuwei / poetry_slow.toml
Created February 27, 2020 06:10
poetry_slow
[tool.poetry]
name = "test_poe"
version = "0.1.0"
description = ""
[tool.poetry.dependencies]
python = "^3.7"
allennlp = "^0.9.0"
[tool.poetry.dev-dependencies]
@qiuwei
qiuwei / hw4
Last active February 22, 2023 19:25
Hex implementation CPP-for C
//Homework 4, implement game of hex
#include <iostream>
#include <vector>
#include <set>
using namespace std;
enum Color{
RED,
@qiuwei
qiuwei / benchmark_tiledb.py
Created December 11, 2020 03:10
Benchmark read and write speed of TileDb
#%%
import glob
import os
import datetime
import tiledb
import pandas as pd
from tiledb.dataframe_ import _tiledb_result_as_dataframe
from tqdm import tqdm
import time
import numpy as np
[tool.poetry]
name = "poetry_debug"
version = "0.1.0"
description = ""
authors = ["Wei Qiu <wei@qiu.es>"]
[tool.poetry.dependencies]
python = "^3.7"
pandas = "^1.1.3"
@qiuwei
qiuwei / clone graph
Last active July 2, 2017 21:32
Clone Graph
/**
* Definition for undirected graph.
* class UndirectedGraphNode {
* int label;
* ArrayList<UndirectedGraphNode> neighbors;
* UndirectedGraphNode(int x) { label = x; neighbors = new ArrayList<UndirectedGraphNode>(); }
* };
*/
public class Solution {
/**
@qiuwei
qiuwei / factorial
Created June 22, 2017 15:39
Factorial with stack
class Frame {
int number;
int answer;
boolean done;
public Frame(int number, int answer, boolean done){
this.number = number;
this.answer = answer;
this.done = done;
}
@qiuwei
qiuwei / TreeIterator
Created June 22, 2017 13:08
BST TreeIterator
/**
* Definition of TreeNode:
* public class TreeNode {
* public int val;
* public TreeNode left, right;
* public TreeNode(int val) {
* this.val = val;
* this.left = this.right = null;
* }
* }

Keybase proof

I hereby claim:

  • I am qiuwei on github.
  • I am wqiu (https://keybase.io/wqiu) on keybase.
  • I have a public key ASBTOKMRrTDXZVGtPuNEVDa5htxnzDrklV5daaL6MGJPOgo

To claim this, I am signing this object:

@qiuwei
qiuwei / fifo.c
Last active December 24, 2015 09:49
fifo
#include <stdio.h>
#define MAX_SIZE 128
struct fifo{
int size;
int head;
int count;
char element[MAX_SIZE];
};
@qiuwei
qiuwei / sqrt.clj
Created August 9, 2013 16:32
sqrt in clojure which follows scheme style
(defn sqrt [x]
(defn fixed-point [f first-guess]
(defn close-enough? [v1 v2]
(let [tolerance 0.000000001]
(< (Math/abs (- v1 v2))
tolerance)))
(defn tryo [guess]
(loop [oldo guess
newo (f oldo)]
(if (close-enough? oldo newo)