- 1
- 2
- 3
- 4
- 5
- 6
if (Cache[articlesRssData] != null)
{
return Cache[articlesRssData] as ArticleRssData?;
}
return null;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+131
if (Cache[articlesRssData] != null)
{
return Cache[articlesRssData] as ArticleRssData?;
}
return null;
+59
//выдерает из текста все метки и вовзращает вввиде массива
private function returnLabels($html)
{
$labels = array();
$s = "" ;
$flag = false ;
for ($i=0;$i<strlen($html);$i++)
{
if (substr($html,$i,strlen("{module:")) == "{module:")
{
$flag = true ;
}
if (substr($html,$i,strlen("{language:")) == "{language:")
{
$flag = true ;
}
if (substr($html,$i,strlen("{image:")) == "{image:")
{
$flag = true ;
}
if (substr($html,$i,strlen("{file:")) == "{file:")
{
$flag = true ;
}
if (substr($html,$i,strlen("{js:")) == "{js:")
{
$flag = true ;
}
if (substr($html,$i,strlen("{css:")) == "{css:")
{
$flag = true ;
}
if (substr($html,$i,strlen("}")) == "}" && $flag == true)
{
$s .="}";
$labels [] = $s ;
$s = "" ;
$flag = false ;
}
if ($flag == true)
{
$s .= substr($html,$i,1);
}
}
return $labels;
}
О великий Никита Иванов!
+137
private static Tag GetTopic(Guid tagId)
{
var tag = DataService.PerThread.TagSet.SingleOrDefault(x => x.Id == tagId);
if (tag == null && tag.GroupId != null)
return null;
if (tag.TopicState != (byte)TopicState.GroupTopic)
return null;
return tag;
}
+139
<HEADER>
<TITLE>The World Wide Web project</TITLE>
<NEXTID N="55">
</HEADER>
<BODY>
<H1>World Wide Web</H1>The WorldWideWeb (W3) is a wide-area<A
NAME=0 HREF="WhatIs.html">
hypermedia</A> information retrieval
initiative aiming to give universal
access to a large universe of documents.<P>
Everything there is online about
W3 is linked directly or indirectly
to this document, including an <A
NAME=24 HREF="Summary.html">executive
summary</A> of the project, <A
NAME=29 HREF="Administration/Mailing/Overview.html">Mailing lists</A>
, <A
NAME=30 HREF="Policy.html">Policy</A> , November's <A
NAME=34 HREF="News/9211.html">W3 news</A> ,
<A
NAME=41 HREF="FAQ/List.html">Frequently Asked Questions</A> .
<DL>
<DT><A
NAME=44 HREF="../DataSources/Top.html">What's out there?</A>
<DD> Pointers to the
world's online information,<A
NAME=45 HREF="../DataSources/bySubject/Overview.html"> subjects</A>
, <A
NAME=z54 HREF="../DataSources/WWW/Servers.html">W3 servers</A>, etc.
<DT><A
NAME=46 HREF="Help.html">Help</A>
<DD> on the browser you are using
<DT><A
NAME=13 HREF="Status.html">Software Products</A>
<DD> A list of W3 project
components and their current state.
(e.g. <A
NAME=27 HREF="LineMode/Browser.html">Line Mode</A> ,X11 <A
NAME=35 HREF="Status.html#35">Viola</A> , <A
NAME=26 HREF="NeXT/WorldWideWeb.html">NeXTStep</A>
, <A
NAME=25 HREF="Daemon/Overview.html">Servers</A> , <A
NAME=51 HREF="Tools/Overview.html">Tools</A> ,<A
NAME=53 HREF="MailRobot/Overview.html"> Mail robot</A> ,<A
NAME=52 HREF="Status.html#57">
Library</A> )
<DT><A
NAME=47 HREF="Technical.html">Technical</A>
<DD> Details of protocols, formats,
program internals etc
<DT><A
NAME=40 HREF="Bibliography.html">Bibliography</A>
<DD> Paper documentation
on W3 and references.
<DT><A
NAME=14 HREF="People.html">People</A>
<DD> A list of some people involved
in the project.
<DT><A
NAME=15 HREF="History.html">History</A>
<DD> A summary of the history
of the project.
<DT><A
NAME=37 HREF="Helping.html">How can I help</A> ?
<DD> If you would like
to support the web..
<DT><A
NAME=48 HREF="../README.html">Getting code</A>
<DD> Getting the code by<A
NAME=49 HREF="LineMode/Defaults/Distribution.html">
anonymous FTP</A> , etc.</A>
</DL>
</BODY>
HTML первого в мире сайта, которому на днях исполнился 21 год.
+154
if(Math.round(Math.random()*10)==7){
alert('Your name/lastname alredy used! Try other.');
}
Валидация форм, чё
+75
if ( !empty($special['catalog']) ) {
if (count($special['catalog'])>0) {
if (count($special['catalog'])>1) {
...
}
}
}
Интересная конструкция...
+72
<?php if ($content): ?>
<?php if($is_page): ?>
<?php print $content; ?>
<?php else: ?>
<?php print $content; ?>
<?php endif?>
<?php endif?>
Где-то, в глубоких кодах проекта (писанном на Drupal 7)
+34
#include "xsmell.hpp"
#include <iostream>
TAG(html, NO_ATTRIBS);
TAG(head, NO_ATTRIBS);
TAG(title, NO_ATTRIBS);
TAG(body, NO_ATTRIBS);
TAG(p, NO_ATTRIBS);
TAG(a, ATTRIB(href));
TAG(img, ATTRIB(src), ATTRIB(alt));
int main()
{
using namespace xsmell;
document doc =
_
<html>_
<head>_
<title>"XSMELL demo"<!title>_
<!head>_
<body>_
<p>"Yesssssssssssssssss!"<!p>_
<img .src("chucknorris.png") .alt("sneezing eyes open")>_ <!img>_
<!body>_
<!html>
_;
std::cout << doc << '\n';
return 0;
}
C++ умеет HTML не хуже этих ваших похапешечек ;)
https://bitbucket.org/edd/xsmell/src
−139
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use LWP::Simple;
binmode(STDOUT, ":utf8");
my $url = 'http://govnokod.ru/comments';
my $document = get $url; die "Couldn't get $url" unless defined $document;
$document =~ s/\n/ /g;
$document =~ s/\h+/ /g;
my @arr = ( $document =~ m/(?<=\<strong class="entry-author">)(.*?)(?<=\<a class="answer")/gi );
my $str;
my @sink;
foreach my $val (@arr) {
$val =~ m/(?<=\>)(.*?)(?=\<\/a\>)/i;
$str = "Author: ".$1;
$val =~ m/(?<=published" title\=")(.*?)(?=")/i;
( my $dt, my $tm ) = split('T', $1);
$str = $str . "\nDate: " . $dt;
$str = $str . "\nTime: " . $tm;
$val =~ m/(?<=\<\/abbr\> \<a href\=")(.*?)(?=" name\=)/i;
$str = $str."\nLink: ". $1;
$val =~ m/(?<=\<div class\="entry-comment">)(.*?)(?=\<\/div\>)/i;
$str = $str . "\nComment: " . str_formater($1);
push(@sink, $str);
}
@sink = reverse (@sink);
foreach my $v (@sink) {
print ("\n".("+" x 81)."\n"."$v\n");
}
print ("\n".("+" x 81)."\n\n");
sub str_formater {
my $str = $_[0];
my $res="";
my $cmt_len = 69;
my $cmt_indent = 11;
while (1) {
if (length($str)<=$cmt_len) {
return $res . $str;
}
$res = $res . substr($str,0, $cmt_len) . "\n" . (" " x $cmt_indent);
$str = substr($str, $cmt_len);
}
return $res;
}
exit 0;
Давненько перловку не заваривал...
+70
public static class TrollException extends RuntimeException {
@Override
public String getMessage() {
throw new TrollException();
}
@Override
public String getLocalizedMessage() {
throw new TrollException();
}
@Override
public Throwable getCause() {
throw new TrollException();
}
@Override
public synchronized Throwable initCause(Throwable cause) {
throw new TrollException();
}
@Override
public String toString() {
throw new TrollException();
}
@Override
public void printStackTrace() {
throw new TrollException();
}
@Override
public void printStackTrace(PrintStream s) {
throw new TrollException();
}
@Override
public void printStackTrace(PrintWriter s) {
throw new TrollException();
}
@Override
public synchronized Throwable fillInStackTrace() {
throw new TrollException();
}
@Override
public StackTraceElement[] getStackTrace() {
throw new TrollException();
}
@Override
public void setStackTrace(StackTraceElement[] stackTrace) {
throw new TrollException();
}
}