Controlling the flow of asynchronous code in PHP works much like it does in Java, and looks pretty similar too. Colloquially referred to as "synchronization", pthreads supports both synchronized blocks and synchronized methods:
<?php
#!/usr/bin/env python | |
# pylint: disable=W0622 | |
# Copyright (c) 2006 Allan Saddi <[email protected]> | |
# Copyright (c) 2011 Vladimir Rusinov <[email protected]> | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions | |
# are met: |
// Copyright 2012 Junqing Tan <[email protected]> and The Go Authors | |
// Use of this source code is governed by a BSD-style | |
// Part of source code is from Go fcgi package | |
// Fix bug: Can't recive more than 1 record untill FCGI_END_REQUEST 2012-09-15 | |
// By: wofeiwo | |
package fcgiclient | |
import ( |
<!DOCTYPE HTML> | |
<html lang="zh-cn"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>围脖是个好图床</title> | |
<style type="text/css" media="screen"> | |
*{ | |
margin:0;padding:0; | |
font-family:arial, sans-serif; | |
color:#222; |
""" base58 encoding / decoding functions """ | |
import unittest | |
alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' | |
base_count = len(alphabet) | |
def encode(num): | |
""" Returns num in a base58-encoded string """ | |
encode = '' | |
#! /usr/bin/env python | |
# -*- coding: iso-8859-1 -*- | |
# vi:ts=4:et | |
# $Id$ | |
# | |
# Usage: python retriever.py <file with URLs to fetch> [<# of | |
# concurrent connections>] | |
# |
// requires | |
var utils = require('utils'); | |
var casper = require('casper').create() | |
var casper = require('casper').create({ | |
verbose: true, | |
logLevel: "debug" | |
}); | |
// setup globals | |
var email = casper.cli.options['email'] || 'REPLACE THIS EMAIL'; |
from selenium import webdriver | |
from selenium.common.exceptions import TimeoutException | |
import selenium.webdriver.support.wait | |
selenium.webdriver.support.wait.POLL_FREQUENCY = 0.05 | |
import re | |
import random | |
import collections | |
class AdwordsAutomater(object): |
import re | |
from unicodedata import normalize | |
_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+') | |
def slugify(text, delim=u'-'): | |
"""Generates an slightly worse ASCII-only slug.""" | |
result = [] | |
for word in _punct_re.split(text.lower()): | |
word = normalize('NFKD', word).encode('ascii', 'ignore') |
test: | |
clear | |
nosetests --with-coverage --cover-package name_utils test_name_utils.py | |
clean: | |
find -regex '.*\.pyc' -exec rm {} \; | |
find -regex '.*~' -exec rm {} \; | |
.PHONY: test clean |