- GitHub Trending http://github.com/trending
- The Changelog http://thechangelog.com
- Hacker News http://news.ycombinator.com
- FripFrap http://fripfrap.io/
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 | |
// How can foreach be implemented with while? | |
while (list($key, $value) = each($array)) { | |
print "$key is $value".PHP_EOL; | |
} | |
// How to get rid of @ in foreach (@$arr .. ) ? | |
// (this is always a bad practice, but anyway) |
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 | |
function loop($count, $callback) { | |
if (is_int($count)) { | |
for ($i = 0; $i < $count; $i++) { | |
$callback($i); | |
} | |
} | |
elseif(is_array($count)) { | |
$_copy = $count; |
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 | |
// A short example of my current bot API usage | |
hear("/^close( issue)? #(?P<id>\d+)/iu", function($bot, $msg, $matches) { | |
// This bot likes to work with Redmine | |
$issue = new \Redmine\Issue(); | |
$issue = $issue->find($matches['id']); | |
// Is issue present? |
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 Colorize { | |
static $foreground_colors = array( | |
'bold' => '1', 'dim' => '2', | |
'black' => '0;30', 'dark_gray' => '1;30', | |
'blue' => '0;34', 'light_blue' => '1;34', | |
'green' => '0;32', 'light_green' => '1;32', | |
'cyan' => '0;36', 'light_cyan' => '1;36', |
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
<my-parent-tag> | |
<div> | |
this is parent tag | |
<script type="riot/tag" src="https://rawgit.com/madfriend/51a535e989b710429334/raw/18753e624291e350e3f230aaece6a93be3785299/test2.tag"></script> | |
<my-tag>this should be replaced by my-tag contents</my-tag> | |
</div> | |
</my-parent-tag> |
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
<my-tag> | |
hello | |
</my-tag> |
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 | |
namespace traits; | |
trait Singleton { | |
// Для тех, кто не предусмотрел конструктор в классе | |
private function __construct() { | |
} |
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
#! coding: utf-8 | |
# sklearn = библиотека scikit-learn (http://scikit-learn.org) | |
# Установить можно, например, так: | |
# сначала поставить дистрибутив Anaconda (https://www.continuum.io/downloads#_windows) | |
# а потом в терминале "conda install sklearn". | |
# Нам из sklearn нужно не так много | |
from sklearn.linear_model import LogisticRegression | |
# в sklearn есть удобная функция для создания | |
# отчетов по качеству классификации (Precision, Recall, F1) | |
from sklearn.metrics import classification_report |
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 | |
function preg_match_callback($expression, $subject, $callback) { | |
static $matches_count = 0; | |
preg_replace_callback($expression, function($matches) use($callback) { | |
call_user_func($callback, $matches); | |
}, $subject, -1, $matches_count); | |
return $matches_count; | |
} |