Skip to content

Instantly share code, notes, and snippets.

View shonenada's full-sized avatar
🤷‍♂️
Focusing

Yaoda Liu shonenada

🤷‍♂️
Focusing
View GitHub Profile
@shonenada
shonenada / tinywebserver.py
Created April 18, 2013 16:20
A simple web server in python
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import re
import os
import socket
web_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
web_socket.bind(("127.0.0.1", 8080))
web_socket.listen(5)
@shonenada
shonenada / compare.jsp
Last active December 16, 2015 02:19
上传图片并且比较图片相似度
<%@ page language="java" contentType="text/html; charset=utf-8" import="java.awt.image.BufferedImage, javax.imageio.ImageIO, java.io.*, java.util.*" %>
<%!
static int[] deColor(BufferedImage orgImgBI)
{
int oWidth = orgImgBI.getWidth();
int oHeight = orgImgBI.getHeight();
int oMinx = orgImgBI.getMinX();
int oMiny = orgImgBI.getMinY();
int i,j;
int pixel, R, G, B, Gray;
@shonenada
shonenada / Gauss.py
Last active December 15, 2015 21:28
高斯列主元消去法
#-*-coding: utf-8 -*-
EPS = 1.0e-4
def guass(A, b):
""" 高斯消元法
输入要求:
A = [[x11, x12, x13], [x21, x22, x23], [x31, x32, x33]]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;
typedef struct
{
char type1;
char type2;
}BmpFileHead;
#include<iostream>
using namespace std;
int i=0;
bool chk();
bool c();
void main(){
chk();
}
bool chk(){
i >=1000 || i++,cout << i << " ";
@shonenada
shonenada / BmpIO.cpp
Created March 12, 2013 09:09
BMP 图像处理,包括去色,反色,左右翻转,上下翻转。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;
typedef struct
{
char type1;
char type2;
}BmpFileHead;
@shonenada
shonenada / compare two files.py
Created March 12, 2013 08:55
Compare two files, show which line is not equal..
file1 = open("file1", "r")
file2 = open("file2", "r")
line1 = file1.readlines()
line2 = file2.readlines()
for i in range(0, len(line1)):
if(line1[i] != line2[i]):
print i+1
@shonenada
shonenada / BinSortTree.cpp
Created December 12, 2012 11:32
Binary Sort Tree
struct BinNode {
int data;
BinNode *lChild, *rChild;
};
class BinSortTree{
public:
BinSortTree();
~BinSortTree();
void SearchBST(int);
void CreateBST(int *, int);
@shonenada
shonenada / RecuirsiveBinSearch.cpp
Created December 12, 2012 11:25
Binary Search Recursive
#include<iostream>
using namespace std;
int bs(int* a, int key, int low, int high){
int mid;
mid = (low+high) / 2 ;
if(low>high){
return -1;
}
@shonenada
shonenada / binarysearch.cpp
Created December 12, 2012 11:14
Binary Search in c++
#include<iostream>
using namespace std;
int BS(int* arr, int n, int key){
int low, high, mid;
low = 0;
high = n-1;
while(low<=high){
mid = (low+high) >> 1;