Moja lista:
- zadanie pierwsze
- zadanie drugie
Moja lista:
<? | |
// Bardzo prosty parser linków | |
$html = preg_replace( | |
'#(([^ \'\"\<]+)?[^ \'\"\.\<]+\.(pl|com|net|org)(\/[^ \'\"\<]+)?)#', | |
'<a href="http://$1" target="_blank" rel="nofollow">$1</a>', | |
$html | |
); |
var doSomething = function(extraStuff) { | |
return function(data, textStatus) { | |
//do something with extraStuff | |
}; | |
}; | |
var clicked = function() { | |
var extraStuff = { myParam1: 'foo', myParam2: 'bar' }; | |
$.post("someurl.php", someData, doSomething(extraStuff), "json"); | |
}; |
<? | |
// Prosty generator losowej godziny | |
function getRandomHour() { | |
$godzina = str_pad(rand(6,23), 2, "0", STR_PAD_LEFT); | |
$minuta = str_pad(rand(0,59), 2, "0", STR_PAD_LEFT); | |
$sekunda = str_pad(rand(0,59), 2, "0", STR_PAD_LEFT); | |
return $godzina .':'. $minuta .':'. $sekunda; | |
} |
<? | |
$emails = array(); | |
function getRandomEmail() { | |
global $emails; | |
if (empty($emails)) { | |
$f = file_get_contents('http://ktmatu.com/cgi-bin/rea.pl'); | |
preg_match_all('/\=\"mailto\:(.*)\"/', $f, $matches); | |
$emails = $matches[1]; |
# Short if in Python | |
usersOnline = p.count() - 1 if p.count() > 0 else 0 |
from botModels import Roster, PresenceStatus | |
import logging as console | |
# Zliczanie elementów w GAE | |
# SELECT count(1) FROM PresenceStatus WHERE online = True | |
p = PresenceStatus.all(keys_only=True) | |
p.filter("online =",True) | |
items = p.count() | |
console.info(items) |
# Szukanie po kluczu w GAE | |
p = PresenceStatus.get_by_key_name(jid) | |
console.info(p.online) |
class NamedModel(db.Model): | |
"""A Model subclass for entities which automatically generate their own key | |
names on creation. See documentation for _generate_key function for | |
requirements.""" | |
def __init__(self, *args, **kwargs): | |
kwargs['key_name'] = _generate_key(self, kwargs) | |
super(NamedModel, self).__init__(*args, **kwargs) | |
def _generate_key(entity, kwargs): | |
"""Generates a key name for the given entity, which was constructed with |
var http = require('http'); | |
exports.sendPost = function(options,data,callback) { | |
var post_data = querystring.stringify(data); | |
var opts = { | |
host: options.host, | |
port: options.port, | |
maxSockets : 100, | |
path: options.path, | |
method: 'POST', |