Yay, undocumneted. Mostly used to test Issue 39 - http://code.google.com/p/django-simple-captcha/issues/detail?id=39
327016
def huge_words_and_punctuation_challenge():
    ""
    fd = open(settings.CAPTCHA_WORDS_DICTIONARY, 'rb')
    l = fd.readlines()
    fd.close()
    word = ''
    while True:
        word1 = random.choice(l).strip()
        word2 = random.choice(l).strip()
        punct = random.choice(settings.CAPTCHA_PUNCTUATION)
        word = '%s%s%s' % (word1, punct, word2)
        if len(word) >= settings.CAPTCHA_DICTIONARY_MIN_LENGTH and len(word) <= settings.CAPTCHA_DICTIONARY_MAX_LENGTH:
            break
    return word.upper(), word.lower()
828009
function captcha($font,$size=24,$len=5,
		$key=NULL,$path='',$fg=0xFFFFFF,$bg=0x000000) {
		if ((!$ssl=extension_loaded('openssl')) && ($len<4 || $len>13)) {
			user_error(sprintf(self::E_Length,$len),E_USER_ERROR);
			return FALSE;
		}
		if (!function_exists('imagettftext')) {
			user_error(self::E_TTF,E_USER_ERROR);
			return FALSE;
		}
		$fw=Base::instance();
		foreach ($fw->split($path?:$fw->UI.';./') as $dir)
			if (is_file($path=$dir.$font)) {
				$seed=strtoupper(substr(
					$ssl?bin2hex(openssl_random_pseudo_bytes($len)):uniqid(),
					-$len));
				$block=$size*3;
				$tmp=[];
				for ($i=0,$width=0,$height=0;$i<$len;$i++) {
					// Process at 2x magnification
					$box=imagettfbbox($size*2,0,$path,$seed[$i]);
					$w=$box[2]-$box[0];
					$h=$box[1]-$box[5];
					$char=imagecreatetruecolor($block,$block);
					imagefill($char,0,0,$bg);
					imagettftext($char,$size*2,0,
						($block-$w)/2,$block-($block-$h)/2,
						$fg,$path,$seed[$i]);
					$char=imagerotate($char,mt_rand(-30,30),
						imagecolorallocatealpha($char,0,0,0,127));
					// Reduce to normal size
					$tmp[$i]=imagecreatetruecolor(
						($w=imagesx($char))/2,($h=imagesy($char))/2);
					imagefill($tmp[$i],0,0,IMG_COLOR_TRANSPARENT);
					imagecopyresampled($tmp[$i],
						$char,0,0,0,0,$w/2,$h/2,$w,$h);
					imagedestroy($char);
					$width+=$i+1<$len?$block/2:$w/2;
					$height=max($height,$h/2);
				}
				$this->data=imagecreatetruecolor($width,$height);
				imagefill($this->data,0,0,IMG_COLOR_TRANSPARENT);
				for ($i=0;$i<$len;$i++) {
					imagecopy($this->data,$tmp[$i],
						$i*$block/2,($height-imagesy($tmp[$i]))/2,0,0,
						imagesx($tmp[$i]),imagesy($tmp[$i]));
					imagedestroy($tmp[$i]);
				}
				imagesavealpha($this->data,TRUE);
				if ($key)
					$fw->$key=$seed;
				return $this->save();
			}
		user_error(self::E_Font,E_USER_ERROR);
		return FALSE;
	}
1159706
def unescape(self):
        
        from ._constants import HTML_ENTITIES

        def handle_match(m):
            name = m.group(1)
            if name in HTML_ENTITIES:
                return unichr(HTML_ENTITIES[name])
            try:
                if name[:2] in ("#x", "#X"):
                    return unichr(int(name[2:], 16))
                elif name.startswith("#"):
                    return unichr(int(name[1:]))
            except ValueError:
                pass
            # Don't modify unexpected input.
            return m.group()

        return _entity_re.sub(handle_match, text_type(self))
829100
async def remove(request: web.Request) -> web.Response:
    
    requested_hash = request.match_info['key_md5']
    new_keys: List[str] = []
    found = False
    for keyhash, key in get_keys():
        if keyhash == requested_hash:
            found = True
        else:
            new_keys.append(key)

    if not found:
        return web.json_response(
            data={'error': 'invalid-key-hash',
                  'message': f'No such key md5 {requested_hash}'},
            status=404)

    with authorized_keys('w') as ak:
        ak.write('\n'.join(new_keys) + '\n')

    return web.json_response(
        data={
            'message': f'Key {requested_hash} deleted. '
            'Restart robot to take effect',
            'restart_url': '/server/restart'},
        status=200)
593320
def _unescape_token(escaped_token):
    

    def match(m):
        if m.group(1) is None:
            return u"_" if m.group(0) == u"\\u" else u"\\"

        try:
            return six.unichr(int(m.group(1)))
        except (ValueError, OverflowError):
            return ""

    trimmed = escaped_token[:-1] if escaped_token.endswith("_") else escaped_token
    return _UNESCAPE_REGEX.sub(match, trimmed)
324814
def simple_password(request):
    
    if request.method == "POST":
        form = PasswordForm(data=request.POST)
        if form.is_valid():
            # TODO: set session with better param
            request.session["simple_auth"] = True
            return redirect(form.cleaned_data["url"] or "/")
    else:
        form = PasswordForm()
    return render(request, "simple_auth/password_form.html",
                  {"form": form})
728282
def get_captcha(self, id=None):
        
        payload = {'id': id}
        r = self.request('get', 'http://cleanweb-api.yandex.ru/1.0/get-captcha', params=payload)
        return dict((item.tag, item.text) for item in ET.fromstring(r.content))
229383
function (event) {

            if (!event.ctrlKey && !event.metaKey) {

                var keyCode = event.keyCode;

                if ((keyCode >= 33 && keyCode <= 40) || (keyCode >= 63232 && keyCode <= 63235)) {
                    // 33 - 40: page up/dn and arrow keys
                    // 63232 - 63235: page up/dn and arrow keys on safari
                    setMode("moving");
                }
                else if (keyCode == 8 || keyCode == 46 || keyCode == 127) {
                    // 8: backspace
                    // 46: delete
                    // 127: delete
                    setMode("deleting");
                }
                else if (keyCode == 13) {
                    // 13: Enter
                    setMode("newlines");
                }
                else if (keyCode == 27) {
                    // 27: escape
                    setMode("escape");
                }
                else if ((keyCode < 16 || keyCode > 20) && keyCode != 91) {
                    // 16-20 are shift, etc. 
                    // 91: left window key
                    // I think this might be a little messed up since there are
                    // a lot of nonprinting keys above 20.
                    setMode("typing");
                }
            }
        }
118210
def get_captcha(self):
        
        self._session.get(Zhihu_URL)
        r = self._session.get(self._get_captcha_url())
        return r.content
194120
function requireRecaptchaAfterTries(number) {
    /*
     * Recaptcha keypair
     * http://www.google.com/recaptcha/whyrecaptcha
     */
    var recaptchaKeys = {
        PUBLIC: '6Ler-9cSAAAAALgxcaiMpgfDb6tL36IvM2dCb7g7',
        PRIVATE: '6Ler-9cSAAAAAMO0RJB39zFvYwLHvykldkml2uWK'
    };
    return function (req, res, next) {
        var badAttempts = req.delayed && req.delayed.counter || -1;
        // Note: We show recaptcha form PRIOr to require it
        if (badAttempts >= number) {
            req.session.recaptchaForm = (new Recaptcha(recaptchaKeys.PUBLIC, recaptchaKeys.PRIVATE)).toHTML();
        }
        if ((req.requireRecaptcha = badAttempts > number)) {
            var data = {
                remoteip: req.connection.remoteAddress,
                challenge: req.body.recaptcha_challenge_field,
                response: req.body.recaptcha_response_field
            },
                recaptcha = new Recaptcha(recaptchaKeys.PUBLIC, recaptchaKeys.PRIVATE, data);
            recaptcha.verify(function (success, error) {
                req.isValidRecaptcha = {
                    success: success,
                    error: error
                };
                next();
            });
        } else {
            next();
        }
    };
}
989722
function handleDocumentKeyup(e) {
  if (overlay && e.keyCode === 46 &&
      e.target.nodeName.toLowerCase() !== 'textarea' &&
      e.target.nodeName.toLowerCase() !== 'input') {
    deleteAnnotation();
  }
}
482014
def unescape_form(str)
      str = str.dup
      binary_encode(str)
      str.gsub!(/\+/, ' ')
      str.gsub(ESCAPED) { $1.hex.chr }
    end
1207620
def unhandled(exception, opt):
    
    exmod = type(exception).__module__
    name = "%s.%s" % (exmod, type(exception).__name__)
    # this is a Vault error
    if exmod == 'aomi.exceptions' or exmod == 'cryptorito':
        # This may be set for Validation or similar errors
        if hasattr(exception, 'source'):
            output(exception.message, opt, extra=exception.source)
        else:
            output(exception.message, opt)

    else:
        output("Unexpected error: %s" % name, opt)

    sys.exit(1)
953860
def _get_captcha(reddit_session, captcha_id):
    """"""
    url = urljoin(reddit_session.config['captcha'],
                  captcha_id + '.png')
    sys.stdout.write('Captcha URL: {0}\nCaptcha: '.format(url))
    sys.stdout.flush()
    raw = sys.stdin.readline()
    if not raw:  # stdin has reached the end of file
        # Trigger exception raising next time through. The request is
        # cached so this will not require and extra request and delay.
        sys.stdin.close()
        return None
    return {'iden': captcha_id, 'captcha': raw.strip()}
921882
def generate_captcha
      if EasyCaptcha.cache
        # create cache dir
        FileUtils.mkdir_p(EasyCaptcha.cache_temp_dir)

        # select all generated captchas from cache
        files = Dir.glob(EasyCaptcha.cache_temp_dir + "*.png")

        unless files.size < EasyCaptcha.cache_size
          file              = File.open(files.at(Kernel.rand(files.size)))
          session[:captcha] = File.basename(file.path, '.*')

          if file.mtime < EasyCaptcha.cache_expire.ago
            File.unlink(file.path)
            # remove speech version
            File.unlink(file.path.gsub(/png\z/, "wav")) if File.exists?(file.path.gsub(/png\z/, "wav"))
          else
            return file.readlines.join
          end
        end
        generated_code = generate_captcha_code
        image = Captcha.new(generated_code).image

        # write captcha for caching
        File.open(captcha_cache_path(generated_code), 'w') { |f| f.write image }

        # write speech file if u create a new captcha image
        EasyCaptcha.espeak.generate(generated_code, speech_captcha_cache_path(generated_code)) if EasyCaptcha.espeak?

        # return image
        image
      else
        Captcha.new(generate_captcha_code).image
      end
    end
613600
def urlencode_params(params):
    
    # urlencode does not handle unicode strings in Python 2.
    # Firstly, normalize the values so they get encoded correctly.
    params = [(key, normalize_for_urlencode(val)) for key, val in params]
    # Secondly, unquote unreserved chars which are incorrectly quoted
    # by urllib.urlencode, causing invalid auth signatures. See GH #72
    # for more info.
    return requests.utils.unquote_unreserved(urlencode(params))
435645
def ruokuai_captcha_handler(self, params, image_url):
        

        headers = {
            'Connection': 'Keep-Alive',
            'Expect': '100-continue',
            'User-Agent': 'ben',
        }
        image_data = requests.get(image_url).content
        files = {'image': ('check_code.png', image_data)}
        r = requests.post(
            'http://api.ruokuai.com/create.json',
            data=params,
            files=files,
            headers=headers
        )
        verify_code_dict = r.json()
        if verify_code_dict:
            if 'Error' in verify_code_dict.keys():
                print (verify_code_dict['Error'])
                return ''
            verify_code = verify_code_dict.get('Result', '')
        else:
            print ('rk failed ', verify_code_dict)
            return ''

        return verify_code