This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface HandleIterator { | |
public function getNextHandle(); | |
public function dataCallback($data); | |
} | |
class IndexHandleIterator implements HandleIterator{ | |
private $curl; | |
private $count; | |
public function __construct(){ | |
$this->curl = curl_init("http://localhost/index.php"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Facade{ | |
private static $service = null; | |
public static function getKey(){ | |
return 'world'; | |
} | |
public static function __callstatic($method,$args){ | |
if(!isset(self::$service)){ | |
self::$service = ServiceLocator::getInstance()->getService(self::getKey()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
db: | |
image: mysql | |
ports: | |
- "3306:3306" | |
volumes: | |
- ./mysql:/var/lib/mysql | |
environment: # ??? | |
MYSQL_ROOT_PASSWORD: root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"原生设置 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
filetype on | |
filetype indent on | |
filetype plugin on | |
filetype plugin indent on | |
"set foldmethod=syntax "set default foldmethod | |
set foldminlines=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//install dependancy: composer require guzzlehttp/guzzle | |
include 'vendor/autoload.php'; | |
use GuzzleHttp\Client; | |
use GuzzleHttp\Promise\each_limit; | |
$client = new Client(); | |
function getIps(){ | |
while(!feof(STDIN)){ | |
$ip = trim(fgets(STDIN)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @example | |
* | |
* $a = new ProcessExecutor(); | |
* $b = function ($arg){ sleep(1);echo "hello $arg\n"; }; | |
* $a->setRunnables($b,['aaa','bbb']); | |
* $a->setCheckStatus(function($arg){return $arg === 'aaa';}); | |
* $a->execute(); | |
* var_dump($a->getRunStatusArr()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageDraw, ImageFont | |
class FontPlotter: | |
def __init__(self,font_size=200,convas_size=256): | |
self._font_size = font_size | |
self._convas_size = convas_size | |
self._offset = int((convas_size - font_size) / 2) | |
self._font = None | |
def loadFont(self,filename): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 在所有机器上配置部署账号和权限 | |
set -x | |
ROOT_PASS=rootpassword | |
USR=dev | |
PASS=password | |
OTHER_NODES_IP="ip1 ip2" #以空格分割 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gbk_to_utf8(source, target): | |
with open(source, "r", encoding="gbk") as src: | |
with open(target, "w", encoding="utf-8") as dst: | |
for line in src.readlines(): | |
dst.write(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from pyspark import SparkContext | |
from pyspark import HiveContext | |
from pyspark.sql.types import * | |
from _collections import defaultdict | |
from datetime import date | |
from operator import add | |
from datetime import datetime | |
sc = SparkContext() |
OlderNewer