Skip to content

Instantly share code, notes, and snippets.

@davidChu201
davidChu201 / test.py
Created August 21, 2016 05:09 — forked from christianroman/test.py
Bypass Captcha using 10 lines of code with Python, OpenCV & Tesseract OCR engine
import cv2.cv as cv
import tesseract
gray = cv.LoadImage('captcha.jpeg', cv.CV_LOAD_IMAGE_GRAYSCALE)
cv.Threshold(gray, gray, 231, 255, cv.CV_THRESH_BINARY)
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)
tesseract.SetCvImage(gray,api)
print api.GetUTF8Text()
@davidChu201
davidChu201 / socks.py
Created August 20, 2016 01:48 — forked from e000/socks.py
socksipy + urllib2 handler
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
Use Scala function as the returned value from another function:
class Test3 {
def saySth(prefix: String) = (s: String) => {
prefix + " " + s
}
}
object Main {
def main(args: Array[String]) {
usort() Sorts an array using a user-defined comparison function
<?php
function u_sort($a,$b)
{
if ($a==$b) return 0;
return ($a < $b) ? -1 : 1;
}
$data=array("li"=> 3,"jim"=>5,"jack"=>10, "tom" =>"16");