A Brief Introduction to Multi-Threading in PHP
- Foreword
- Execution
- Sharing
- Synchronization
- Pitfalls
| <?php | |
| /** | |
| * Copyright © 2011 Erin Millard | |
| */ | |
| /** | |
| * Returns the number of available CPU cores | |
| * | |
| * Should work for Linux, Windows, Mac & BSD |
| #!/bin/bash | |
| OPTIONS="--retries=3 --userpass=username.1:x" | |
| while : | |
| do | |
| ./minerd $OPTIONS --url=http://ejpool.info:9332/ | |
| ./minerd $OPTIONS --url=http://lc.ozco.in:9332/ | |
| ./minerd $OPTIONS --url=http://litecoinpool.org:9332/ | |
| ./minerd $OPTIONS --url=http://mine.pool-x.eu:8337/ | |
| done |
| <?php | |
| // Clean argument values | |
| $phpStormRunner = null; | |
| $cleanedArgv = array(); | |
| foreach ($_SERVER['argv'] as $key => $value) { | |
| if (strpos($value, 'ide-phpunit.php') === false) { | |
| $cleanedArgv[] = $value; | |
| } else { | |
| $phpStormRunner = $value; | |
| } |
| # delete local tag '12345' | |
| git tag -d 12345 | |
| # delete remote tag '12345' (eg, GitHub version too) | |
| git push origin :refs/tags/12345 | |
| # alternative approach | |
| git push --delete origin tagName | |
| git tag -d tagName |
| <?php | |
| /** | |
| * This file is an example gist to show the interaction between an ArticleContext and a LikeContext | |
| * | |
| * @example: | |
| * | |
| * We have to bounded contexts: ArticleContext and LikeContext and show the simplified process of following use case: | |
| * | |
| * In order to create a valid article Like, I should validate the article ID given to the LikeContext. | |
| * |
| I've take an simple test for get sure what is the best basic case for this | |
| Firstly my timing result: | |
| ```shell | |
| % (php /tmp/testmd5.php); (php /tmp/testsha1.php); (php /tmp/teststr_replace.php); (php /tmp/teststrtr.php); | |
| 11.715120792389( php /tmp/testmd5.php; ) 11,73s user 0,01s system 99% cpu 11,750 total | |
| 13.626849889755( php /tmp/testsha1.php; ) 13,65s user 0,00s system 99% cpu 13,653 total | |
| 16.591732978821( php /tmp/teststr_replace.php; ) 16,60s user 0,02s system 99% cpu 16,627 total | |
| 87.248502969742( php /tmp/teststrtr.php; ) 87,24s user 0,01s system 99% cpu 1:27,28 total |
| #!/bin/bash | |
| # Shows branches with descriptions | |
| branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||') | |
| for branch in $branches; do | |
| last_used=$(git show --pretty=format:"%Cgreen%cr%Creset" $branch | head -1) | |
| desc=$(git config branch.$branch.description) | |
| if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then | |
| branch="*\t$last_used\t\033[0;32m$branch\033[0m" | |
| else |
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x| # Make sure you grab the latest version | |
| curl -OL https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip | |
| # Unzip | |
| unzip protoc-3.3.0-linux-x86_64.zip -d protoc3 | |
| # Move protoc to /usr/local/bin/ | |
| sudo mv protoc3/bin/* /usr/local/bin/ | |
| # Move protoc3/include to /usr/local/include/ |