- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
#include <cstdio>
class A
{
public:
void sayHello()
{
printf("Hello!");
}
};
int main(int argc, char **argv)
{
A *a = 0;
a->sayHello();
return 0;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+145
#include <cstdio>
class A
{
public:
void sayHello()
{
printf("Hello!");
}
};
int main(int argc, char **argv)
{
A *a = 0;
a->sayHello();
return 0;
}
Что выведет этот код?
+143
/**
* Returns the first line of docblock.
*
* @param \Reflector $reflection
* @return string
*/
protected function parseDocCommentSummary($reflection)
{
$docLines = preg_split('~\R~u', $reflection->getDocComment());
if (isset($docLines[1])) {
return trim($docLines[1], "\t *");
}
return '';
}
/**
* Returns full description from the docblock.
*
* @param \Reflector $reflection
* @return string
*/
protected function parseDocCommentDetail($reflection)
{
$comment = strtr(trim(preg_replace('/^\s*\**( |\t)?/m', '', trim($reflection->getDocComment(), '/'))), "\r", '');
if (preg_match('/^\s*@\w+/m', $comment, $matches, PREG_OFFSET_CAPTURE)) {
$comment = trim(substr($comment, 0, $matches[0][1]));
}
if ($comment !== '') {
return rtrim(Console::renderColoredString(Console::markdownToAnsi($comment)));
}
return '';
}
Yii2, SOLID, очередной класс консольного приложения, который делает все подряд и хуево
https://github.com/yiisoft/yii2/blob/47bcd020fff582395db8fe9e00598acad0257922/framework/console/Controller.php#L481-L512
+142
return optionsBackButtonCommand ?? ((Func<RelayCommand>)(() =>
optionsBackButtonCommand = new RelayCommand(param =>
RandomMethod() )))();
Сам придумал. "Изящно" обошел использование if.
+142
#header .innerdiv > *:nth-child(odd):not(.logo) {
float: right;
width: 220px;
margin-right: 15px;
}
+143
class Security{
private $workFactor, $salt;
public function __construct(){
$this->setWorkFactor();
$salt = $this->getSaltBytes();
$this->setSalt($salt);
}
public function hash($password, $workFactor = 6){
$options = [
'cost' => (int)$workFactor,
'salt' => $this->getSalt()
];
$hash = password_hash($password, PASSWORD_BCRYPT, $options);
return $hash;
}
public function checkHash($password, $passwordHash, $options = []){
if( isset($options['salt'])){
$this->setSalt($options['salt']);
}
$workFactor = isset($options['workFactor']) ?
$options['workFactor'] : $this->getWorkFactor();
return $passwordHash === $this->hash($password, $workFactor);
}
public function isLegacyHash($passwordHash){
return strlen($passwordHash) === 60;
}
public function getSalt(){
return $this->salt;
}
public function setSalt($salt){
$this->salt = $salt;
}
public function getSaltBytes($lenght = 24){
return $this->getRandomBytes($lenght);
}
public function getRandomBytes($lenght = 24){
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $lenght; $i++){
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
public function setWorkFactor($workFactor = 6){
$this->workFactor = (int)$workFactor;
}
public function getWorkFactor(){
return $this->workFactor;
}
}
−161
CREATE TABLE [dbo].[Images](
[id] [int] IDENTITY(1,1) NOT NULL,
[category] [int] NOT NULL,
[tag] [nvarchar](16) NOT NULL,
[description] [nvarchar](128) NOT NULL,
[comment] [nvarchar](1024) NULL,
[code01] [nvarchar](max) NULL,
[code02] [nvarchar](max) NULL,
[code03] [nvarchar](max) NULL,
[code04] [nvarchar](max) NULL,
[code05] [nvarchar](max) NULL,
[code06] [nvarchar](max) NULL,
[code07] [nvarchar](max) NULL,
[code08] [nvarchar](max) NULL,
[code09] [nvarchar](max) NULL,
[code10] [nvarchar](max) NULL,
[code] AS (rtrim(((((((((((((((((((((((((((((rtrim(replace(replace(coalesce([code01],''),char((13)),' '),char((10)),' '))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code02],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code03],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code04],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code05],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code06],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code07],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code08],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code09],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10)))+rtrim(replace(replace(coalesce([code10],''),char((13)),' '),char((10)),' ')))+char((13)))+char((10))))
)
10 нормальная форма (_*_)
+146
<span class="enrty-comments-count">(0)</span>
Enligsh lagnauge rluze.
+142
public class DaoFactory {
private Map<Class<?>, Class<?>> daos = null;
public DaoFactory() {
init();
}
private void init() {
this.daos = new HashMap<>();
this.daos.put(AllSettings.class, AllSettingsDao.class);
this.daos.put(ClientProfile.class, ClientProfileDao.class);
}
public EntityDao<?> getDao(Class<?> entityClass) {
EntityDao<?> dao = null;
try {
if(daos.containsKey(entityClass)) {
dao = (EntityDao<?>)daos.get(entityClass).newInstance();
}
} catch (Exception e) {
e.printStackTrace();
}
return dao;
}
}
Фабрика Dao для сущностей
+144
if ((int)$qty && ((int)$qty > 0)) {
OpenCart
+149
$flag = "yes";
/* ... */
if($flag) {
$flag = $flag;
}