自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(58)
  • 收藏
  • 关注

原创 bookmark

CUHKData Mining Big Data Distributed Systems 算法排序 堆与堆排序 八大排序算法javaspringMVC 动态代理 堆内存 spring ioc nio socket nio demo 注解python数据结构算法mysql索引 索引及慢查询 乐观锁 悲观锁 sql 事务隔离级别 范式

2015-03-06 22:13:31 401

原创 python2.7+pip+virtualenv

wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgztar xf Python-2.7.6.tgzcd Python-2.7.6./configure --prefix=/usr/localmakesudo make altinstall

2015-06-01 23:49:45 698

原创 事务

事务的ACID属性原子性:一个事务要么同时成功,要么同时失败ver1:Bob有100元 Smith有0元ver2:Bob有0元,Smith有0元(undo:Bob有100元 Smith有0元)ver3:Bob有0元,Smith有100元(undo:Bob有0元 Smith有0元)一致性:保证能看到系统内的所有修改,一个事务单元全部成功才可见,加锁实现并发上不来

2015-05-11 15:49:00 408

原创 volatile关键字

volatile关键字:1.能否保证volatile变量的可见性2.不能保证volatile变量复合操作的原子性volatile如何实现内存可见性:通过加入内存屏障和禁止指令重排序优化来实现的。对volatile变量执行写操作时,会在写操作后加入一条store屏障指令;对volatile变量执行读操作时,会在读操作前加入一条load屏障指令。通俗来讲:volatil

2015-05-08 14:21:56 811

原创 leetcode - Insertion Sort List

题目:Sort a linked list using insertion sort.1->3->2->5->41->2->3->4->5思路:当cur指针指向2时,pre指针从helper指针开始一直遍历到指向1时停止,pre指针指向1,此时要将2插入到1与3中间,cur.next = pre.next, pre.next = cur, cur = next解法:

2015-03-31 14:48:56 330

原创 leetcode - Balanced Binary Tree

题目:判断一棵数是不是平衡二叉树Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of ev

2015-03-29 21:20:41 303

原创 leetcode - Binary Tree Level Order Traversal

题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7},    3   / \  9  20

2015-03-28 00:07:00 294

原创 leetcode - Binary Tree Postorder Traversal

题目:二叉树的后序遍历Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},   1    \     2    /   3return [3,2,1].递归解法:publ

2015-03-27 23:38:33 263

原创 Spring - AOP

AOP也称面向切面编程,是Spring框架的特色之一,经常用来作为java web项目的事务控制、日志处理。在Spring中,AOP是利用java动态代理特性实现的。要说动态代理首先要说设计模式中的代理模式。1.代理模式类图 2.静态代理实现代理模式public interface Subject { public void doSomething();}public

2015-03-27 13:47:38 354

原创 leetcode - Binary Tree Preorder Traversal

题目:二叉树的先序遍历Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},   1    \     2    /   3return [1,2,3].递归解法:publi

2015-03-26 15:16:02 321

原创 原生ajax

if (window.XMLHttpRequest) { // 非IE内核 var XHR = new XMLHttpRequest();} else if (window.ActiveXObject) { // IE内核,这里早期IE的版本写法不同,具体可以查询下 var XHR = new ActiveXObject("Microsoft.XMLHTTP");

2015-03-25 22:04:23 280

原创 leetcode - Binary Tree Inorder Traversal

题目:二叉树的中序遍历递归解法:public ArrayList inorderTraversal(TreeNode root){ ArrayList res = new ArrayList(); helper(root, res); return res;}private void helper(TreeNode root, ArrayList res){ if(roo

2015-03-25 20:55:39 260

原创 netty环境配置

Netty框架用到了java里nio的特性,可以用来建立高性能服务器,为了了解netty的源代码,使用Intellij+maven搭建netty开发环境。1.maven中pom.xml配置 io.netty netty-all 4.0.26.Final2.java代码package com.gyq.netty;import io.netty.boots

2015-03-22 14:18:45 1975

原创 leetcode - Linked List Cycle II

题目:Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?思路:当快慢指针相遇时,让慢指针指向头节点,快指针变成每次移动一步,当

2015-03-20 16:09:47 260

原创 leetcode - Linked List Cycle

题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:维护两个指针,俗称快慢指针,慢指针一次移动一步,快指针一次移动两步,如果链表中存在环一定会相遇代码:public boolean has

2015-03-20 15:56:58 279

原创 leetcode - String to Integer (atoi)

题目:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible inp

2015-03-19 16:43:23 250

原创 leetcode - Merge Two Sorted Lists

题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路:有递归非递归两种解法。非递归解法的思路是维护两个指针对应两个链表,以一条链表为基准,比如说

2015-03-18 01:13:49 248

原创 nodejs+mongodb+linux开发环境配置

1.安装nodejssudo apt-get updatesudo apt-get install nodejs1.1安装npmsudo apt-get install npm1.2安装expresssudo apt-get install node-express1.3创建express工程express -e randomchat1.4安装依赖cd randomchat

2015-03-05 14:53:28 394

原创 hadoop wordcount demo

本文以wordcount为例子描述如何从写java mapreduce代码到提交hadoop任务然后查看结果。hadoop版本为1.2.11.编写mapreduce代码WordCount.javaimport java.io.IOException;import java.util.StringTokenizer;import org.apache.hadoop.conf.Con

2015-03-03 00:42:43 314

原创 GitHub协同开发

本文演示两个人如何通过GitHub进行协同开发,founder创建一个项目,然后contributor通过fork贡献代码。1.安装git并进行配置sudo apt-get gitgit config --global user.name "username"git config --global user.email "email"2.founder创建一个项目并上传基础代码g

2015-03-03 00:13:49 1194

原创 CountDownLatch - jdk1.5并发包

什么是CountDownLatch CountDownLatch是一种同步类,它运行一个线程在执行前等待一个或多个线程,这经常用于服务器端开发。通常当主线程调用await()方法后将会等待直到计数器到达0或者被其它线程中断。其它线程通过调用countDown()方法将会在完成任务后将计数器减1。计数器为0是主线程将开始运行。CountDownLatch 例子import j

2015-02-10 00:52:22 288

原创 生产者消费者问题的三种解法 - java

1.使用wait、notifypackage com.gyq.pc;import java.util.LinkedList;import java.util.Queue;/** * Created by andrewgyq on 2015/2/9. */public class WaitNotifyDemo { public static void main(Strin

2015-02-10 00:30:35 488

原创 Semaphore - jdk1.5并发包

Java中Semaphore是一个同步类,它维护了指定数量的权限。当前线程需要访问共享内存时需要获取权限,如果该权限被其它线程占有将会等待直到释放权限。这种同步策略可以用来实现生产者消费者问题以及应用在线程池、数据库连接池中。Semaphore类初始化时指定权限数,它提供了两个主要的方法acquire()和release()用于获取和释放权限。acquire()方法阻塞至有可用的权限,使用Se

2015-02-08 20:00:56 785

原创 CyclicBarrier - jdk1.5并发包

什么是CyclicBarrierCyclicBarrier是JDK 5中java.util.Concurrent包中提出的同步类。CyclicBarrier可以用来等待子任务都完成后执行最后的任务。所有的线程等待其它线程到达Barrier。CyclicBarrier初始化时指定需要等待的线程数,通过调用CyclicBarrier.await()方法,所有线程阻塞等待直到都调用了await()方

2015-02-08 19:27:40 1004

原创 设计模式:单例模式

单例模式是设计模式中最基础的,它保证了一个类只能有一个实例。Hibernate中的sessionfactory类是一个重量级的类,一般采用单例模式去创建。单例模式要注意以下三点:1. 构造方法要私有化2. 类中要创建一个实例3. 对外提供方法访问这个实例首先考虑单线程环境,单例模式分为饿汉式和懒汉式饿汉式:public class Singleton{ private s

2014-12-29 19:15:16 347

原创 三大基本排序冒泡、插入、选择

import java.util.Arrays;public class BasicSort{ public static void main(String[] args) { int [] array = {7,5,4,9,1,3,8}; System.out.println(Arrays.toString(bubbleSort(array))); System.out.prin

2014-12-29 19:00:24 310

原创 根据用户id获取其所有微博

import requestsimport timefrom bs4 import BeautifulSoupimport sysreload(sys)sys.setdefaultencoding('utf-8')headers = {'Cookie': '_T_WM=9136283cc44d10a7a33629a4d4303f60; WEIBOCN_WM=ig_1002; gsid

2014-12-05 22:44:11 7442

原创 mysql指令大全

1.创建数据库create database sakila2.显示数据库show databases3.使用数据库use sakila

2014-11-26 16:33:29 417

原创 java多线程状态图

下图展示了java中线程的状态图:

2014-11-20 14:30:27 939

原创 华为机试20141103

1.给定一个字符串,按照字符与‘U’的差的绝对值大小sheng'xu

2014-11-03 19:14:51 432

原创 hadoop常见问题

1.datanode启动不了原因:每次namenode format会重新创建一个namenodeId,而tmp/dfs/data下包含了上次format下的id,namenode format清空了namenode下的数据,但是没有晴空datanode下的数据,导致启动时失败,所要做的就是每次fotmat前,清空tmp一下 的所有目录.

2014-10-28 15:11:14 309

翻译 HashMap里的hash、indexFor方法

hash和indexFor方法属于HashMap类,为什么jdk开发者需要使用另一种hash方法而不用键对象自己的hashcode方法,下面看一下hash和indexFor的源代码:/** * Applies a supplemental hash function to a given hashCode, which * defends against poor quality

2014-10-22 23:59:25 753

原创 mongodb 使用技巧

1.根据某个字段建唯一索引,去掉重复的文档db.

2014-10-22 21:14:04 278

原创 mongodb windows 安装

1.下载mongodb安装包http://www.mongodb.org/downloads

2014-10-22 20:58:44 305

原创 获取weibo公共数据

最近在做的一个项目需要抓取新浪微博的公共微博数据,思路就是使用微博提供的API,但是不知道为什么public_timeline的接口出现了问题,每次返回的数据都为空。但是微博API测试gong'jv

2014-10-17 17:31:21 679

原创 Java JVM 内存区域

理解JVM内存区域有利于更好的java编程,java中最常见的OutOfMemoryError异常就是与JVM的内存区域有关。JVM内存模型分为以下六类:1.程序计数器2.

2014-10-17 15:51:32 530

原创 tomcat部署项目

可以在tomcat_home\conf\Catalina\localhost下新建一个xml文件,文件名就是

2014-10-14 00:36:06 259

翻译 Naive Bayes朴素贝叶斯

让我们回到女运动员的例子上。假设

2014-10-13 21:20:46 475

原创 hadoop streaming

hadoop streaming支持其它编程语言来写map、reduce程序

2014-10-13 16:58:26 338

转载 Strategy Pattern策略模式

策略模式是指定义一组算法,将mei'ge

2014-10-06 22:46:51 421

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除