Skip to content

Instantly share code, notes, and snippets.

@ruoguluo
ruoguluo / SimpleHTTPServerWithUpload.py
Created June 6, 2017 21:34 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@ruoguluo
ruoguluo / FindDuplicate.java
Created February 3, 2017 06:25
Find the duplicated number in an array of length N
public class FindDuplicate {
public static void main(String[] args) {
FindDuplicate fd = new FindDuplicate();
int[] nums = new int[]{1, 2, 3, 4, 5, 6, 1};
assert (fd.find(nums) == 1);
nums = new int[]{1, 2, 3, 4, 5, 6, 1};
assert (fd.find(nums) == 1);
nums = new int[]{2, 2, 3, 4, 5, 6, 1};
assert (fd.find(nums) == 2);
@ruoguluo
ruoguluo / PropertyLoader.java
Created July 13, 2015 23:08
getProperty from properties file
public class PropertyLoader {
private static Properties prop;
private PropertyLoader() {
}
public static synchronized String getProperty(String propertyName) throws IOException {
if (prop == null) {
prop = new Properties();
@ruoguluo
ruoguluo / file_cut.py
Created December 20, 2012 15:24
[Python] cut a big text file into small pieces of certain lines each
# -*- coding: utf-8 -*-
# Filename:file_cut.py
path = raw_input('please enter the file path:')
savepath = raw_input('please enter the save path:(not include the last \'\\\')')
newname = raw_input('please enter the new name:')
fr = file(path,'r')
flag = True
i = 0 #???
c = 1 #????
while flag: