Skip to content

Instantly share code, notes, and snippets.

View SylvanasSun's full-sized avatar

SylvanasSun SylvanasSun

  • Tianjin,China
View GitHub Profile
@SylvanasSun
SylvanasSun / http_utils.py
Created February 6, 2018 09:48
Some utils in common use of python
import requests
import logging
METHOD_GET = 'GET'
METHOD_POST = 'POST'
RETURN_TEXT = 'TEXT'
RETURN_BINARY = 'BINARY'
RETURN_JSON = 'JSON'
RETURN_RAW = 'RAW'
@SylvanasSun
SylvanasSun / simhash.py
Created January 30, 2018 10:57
In computer science, SimHash is a technique for quickly estimating how similar two sets are. The algorithm is used by the Google Crawler to find near duplicate pages. It was created by Moses Charikar.
# Created by SylvanasSun in 2017.10.17
# !/usr/bin/python
# -*- coding: utf-8 -*-
import collections
import jieba
from jieba import analyse
# TODO: Change default hash algorithms to the other algorithms of high-performance.
@SylvanasSun
SylvanasSun / SkipList.java
Last active July 6, 2024 18:09
A simple implementation of the Skip List.
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Random;
/**
* A skip list is a data structure that allows fast search within
* an ordered sequence of elements. Fast search is made possible
* by maintaining a linked hierarchy of subsequences, with each
* successive subsequence skipping over fewer elements than the
* previous one. Searching starts in the sparsest subsequence until
@SylvanasSun
SylvanasSun / PackageScanner.java
Created October 14, 2017 12:15
Package Scanner
/**
* Interface PackageScanner is the basic interface for package scanning.
*
* Created by SylvanasSun on 10/13/2017.
*/
public interface PackageScanner {
/**
* Scanning specified package then return a class list of the after the scan.
*/
@SylvanasSun
SylvanasSun / girl_face_match.c
Created July 16, 2017 16:30
The algorithms from the movie <<The Social Network>>.
#include <stdio.h>
#include <math.h>
typedef struct {
const char *name;
int rank;
double expect_rate;
} girl;
const int K = 10;
@SylvanasSun
SylvanasSun / log4j.xml
Created July 16, 2017 06:11
The log4j xml config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- 输出日志到控制台 ConsoleAppender -->
<appender name="console"
class="org.apache.log4j.ConsoleAppender">
<param name="encoding" value="UTF-8"/>
<layout class="org.apache.log4j.TTCCLayout">
<param name="ConversionPattern" value="TTCCLayout"/>
@SylvanasSun
SylvanasSun / RedBlackTree.java
Last active October 14, 2018 11:07
This class represent red black tree.
import java.util.*;
/**
* The {@code RedBlackTree} class represents an ordered symbol table of generic
* key-value pairs.
* This implements uses a left-leaning red-black Binary Search Tree.
*
* Created by SylvanasSun on 2017/6/1.
*
* @author SylvanasSun
@SylvanasSun
SylvanasSun / ConcurrentStack.java
Last active May 29, 2017 10:29
This class represents a thread-safe stack and use CAS instruction to ensure thread safe.
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/**
* This class represents a thread-safe stack and use CAS instruction to ensure thread safe.
*
* Created by SylvanasSun on 2017/5/29.
*
@SylvanasSun
SylvanasSun / LinearProbingHashST.java
Created April 14, 2017 09:12
This hash table implements uses a separate chaining and linear probing.
import java.util.*;
/**
* The {@code LinearProbingHashST} class represents a symbol table of generic
* key-value paris.
* This implementation uses a linear probing hash table.
* It requires that the key type overrides the {@code equals()} and {@code hashCode()} methods.
* <p>
* Created by SylvanasSun on 2017/4/11.
*/
@SylvanasSun
SylvanasSun / AvlTree.java
Created April 8, 2017 10:53
This implements uses a AVL balanced tree. Allow any node in the tree of the height of the two subtree biggest difference for one.
package chapter3_searching.C3_3_BalancedSearchTrees;
import edu.princeton.cs.algs4.Queue;
import java.util.NoSuchElementException;
import java.util.Scanner;
/**
* The {@code AvlTree} class represents an ordered symbol table of generic
* key-value pairs.