Skip to content

Instantly share code, notes, and snippets.

void Permutation(char* pStr, char* pBegin);
/////////////////////////////////////////////////////////////////////////
// Get the permutation of a string,
// for example, input string abc, its permutation is
// abc acb bac bca cba cab
/////////////////////////////////////////////////////////////////////////
void Permutation(char* pStr)
{
Permutation(pStr, pStr);
def perm(s = [], beg = 0, end = 0):
if (len (s) == 0):
return;
if ( beg == end ):
print s
else:
for i in xrange(beg, end):
temp = s[i]
s[i] = s[beg]
@docete
docete / word_detector.py
Created November 13, 2012 10:49
运用词频,词的内聚度和词的自由运用程度
#!/usr/bin/env python
# -*- coding: utf8 -*-
import collections
import math
import sys
import getopt
import re
def suffix(s, i):
@docete
docete / semaphore.py
Created December 10, 2012 15:23
synchronization primitive: semaphore example (resource limitation)
#!/usr/bin/env python
# -*- coding: utf8 -*-
import threading
import time
import random
sema = threading.Semaphore(2)
class Grab(threading.Thread):
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@docete
docete / WindowPojoJoin.java
Created September 17, 2019 09:31
WindowPojoJoin
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
import static org.opencv.core.CvType.CV_8U;
import static org.opencv.imgcodecs.Imgcodecs.IMREAD_COLOR;
import static org.opencv.imgproc.Imgproc.CHAIN_APPROX_SIMPLE;
import static org.opencv.imgproc.Imgproc.LINE_AA;
import static org.opencv.imgproc.Imgproc.RETR_TREE;
import static org.opencv.imgproc.Imgproc.THRESH_BINARY;
import static org.opencv.imgproc.Imgproc.fillConvexPoly;
import static org.opencv.imgproc.Imgproc.findContours;
import java.net.URL;