Skip to content

Instantly share code, notes, and snippets.

@wqlin
wqlin / MyRunner.java
Created October 27, 2018 02:40
Read Committed Test
class MyRunner implements Runnable {
public void run() {
System.out.println(Thread.currentThread().getName() + ":连接数据库...");
Connection connection = null;
try {
connection = DriverManager.getConnection(RepeatableRead.DB_URL, RepeatableRead.USER, RepeatableRead.PASS);
connection.setAutoCommit(false);
//connection.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
String querySql = "select * from account where id=?";
@wqlin
wqlin / Find.cpp
Created March 4, 2017 02:47
阿里巴巴2017实习生招聘在线编程测验--基础平台研发工程师
#include <iostream>
#include <unordered_map>
#include <queue>
#include <sstream>
/*
* 阿里巴巴2017实习生招聘在线编程测验--基础平台研发工程师
* 思路:使用邻接矩阵表示图, 因为地理位置不超过100,所以可以先建立起一个 100x100 的矩阵
* 然后读入数据,依次建立矩阵(使用两个哈希表建立起地理位置和下标的对应关系)
* 建立完成后,使用 Dijkstra 算法算出最短路径,注意使用一个数组保存
@wqlin
wqlin / flatten.py
Created January 18, 2017 03:35
flatten python's nested sequences
from collections import Iterable
def flatten(items, ignore_types=(str, bytes)):
"""flatten a nested sequence
implement it based on Python Cookbook(version 3) 4.14 Flattening a Nested Sequence"""
for x in items:
if isinstance(x, Iterable) and not isinstance(x, ignore_types):
yield from flatten(x, ignore_types)
else: