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 flask import Flask | |
app=Flask(__name__) | |
@app.route('/') | |
def index(): | |
return """ | |
<span id="now">loading<span> | |
<script type="text/javascript"> | |
window.WebSocket=window.WebSocket || window.MozWebSocket || false; |
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
############################################################################# | |
# current prompt | |
############################################################################# | |
# \d – Current date | |
# \t – Current time | |
# \h – Host name | |
# \# – Command number | |
# \u – User name | |
# \W – Current working directory (ie: Desktop/) | |
# \w – Current working directory, full path (ie: /Users/Admin/Desktop) |
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
location /resize { | |
alias /tmp/nginx/resize; | |
set $width 150; | |
set $height 100; | |
set $dimens ""; | |
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) { | |
set $width $1; | |
set $height $2; | |
set $image_path $3; |
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 MogileFS | |
* | |
* Специально для PHPStorm | |
* При использовании mogilefs.so - нет автокомплита и хинтинга для \MogileFS | |
* Собственно, по такому случаю - написан данный класс. | |
* Он несет исключительно информационную нагрузку. | |
*/ |
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
#! /bin/bash | |
# path% /usr/local/sbin/deploy | |
# directory for deployment | |
# here will cloned tags | |
BASEDIR="/project/versions"; | |
# path to project home | |
PROJECT="/project/www"; |
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 os | |
from autobahn.resource import WebSocketResource, WSGIRootResource | |
from autobahn.websocket import WebSocketServerFactory, WebSocketServerProtocol | |
from flask import Flask, render_template | |
from twisted.application import internet, service | |
from twisted.internet import reactor | |
from twisted.python.threadpool import ThreadPool | |
from twisted.web.server import Site |
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 | |
$socket = fsockopen('localhost', 8888); | |
$greeteng = trim(fread($socket, 2048)); | |
for ($i=0; $i<100; $i++) | |
{ | |
$message = array('return'=>"Line: $i"); | |
$bt = fwrite($socket, json_encode($message)."\r\n"); |
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 greenclock | |
class Scheduler(greenclock.Scheduler): | |
pool = None | |
greenlets = {} | |
def run_tasks(self): | |
''' | |
Runs all assigned task in separate green threads. If the task should not be run, schedule it |
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 | |
// Например, если у вас есть длинная выборка пользователей из базы, то можно сделать так: | |
// $t = pinba_timer_start(["group"=>"mysql", "server"=>"dbs2", "operation"=>"select"]); | |
// //работа с базой | |
// pinba_timer_stop($t); | |
// flush only stopped timers | |
define('PINBA_FLUSH_ONLY_STOPPED_TIMERS', 0); |
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 | |
final class MonkeyObject | |
{ | |
/** | |
* @var \Closure[] | |
*/ | |
private $l=[]; | |
public function __set($param, \Closure $value) |
OlderNewer