- 1
if(($c>0 or $pusto) <...>) ...
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
if(($c>0 or $pusto) <...>) ...
Нашел тут в недрах компьютера своего какое-то говноподелие, открыл index.php, ужаснулся.
Но тут мой взгляд остановился на переменной-флаге (наверное) с отличным названием.
+71
public class AuthorizedUserObservervable implements Runnable {
private long sleepTime = 1000;
private HashMap<AuthorizedUserObserver, HashMap<AuthorizedUser, Integer>> observers = new HashMap<AuthorizedUserObserver, HashMap<AuthorizedUser, Integer>>();
private void setSleepTime(long sleepTime) {
this.sleepTime = sleepTime;
}
public void add(AuthorizedUserObserver auo) {
HashMap<AuthorizedUser, Integer> userCache = new HashMap<AuthorizedUser, Integer>();
for (AuthorizedUser user : auo.getUsers()) {
userCache.put(user, null);
}
observers.put(auo, userCache);
}
public void beginObservation() {
new Thread(this).start();
}
@Override
public void run() {
while (true) {
try {
for (Map.Entry<AuthorizedUserObserver, HashMap<AuthorizedUser, Integer>> observer : observers.entrySet()) {
for (Map.Entry<AuthorizedUser, Integer> user : observer.getValue().entrySet()) {
int newPostsCount = user.getKey().getNewPostsCount();
if (user.getValue() == null || newPostsCount != user.getValue()) {
HashMap<AuthorizedUser, Integer> userCache = new HashMap<AuthorizedUser, Integer>();
userCache.put(user.getKey(), newPostsCount);
observers.put(observer.getKey(), userCache);
observer.getKey().notify(user.getKey(), newPostsCount);
}
}
}
Thread.sleep(sleepTime);
} catch (InterruptedException ex) {
Logger.getLogger(UserObservervable.class.getName()).log(Level.SEVERE, null, ex);
} catch (AuthenticationException e) {
Thread.currentThread().stop(e);
}
}
}
}
Чего стоит гибкость.
−112
function READ_MAIL() {
if (mc_MESS._currentframe==1) {
if (mails_body.substr((mails_num - 1) * 9, 1) == "1") {// sys mail
GET_SYS_MAIL(mails_body.substr((mails_num - 1) * 9 + 1, 8))
}else if (mails_body.substr((mails_num - 1) * 9, 1) == "2") {// user mail
GET_USER_MAIL(mails_body.substr((mails_num - 1) * 9 + 1, 8))
}else if (mails_body.substr((mails_num - 1) * 9, 1) == "5") {//present
GET_PRESENT_MAIL(mails_body.substr((mails_num - 1) * 9 + 1, 8))
}
}
}
Читаем данные...
+123
public static string ConvertToBinary( ushort value )
{
StringBuilder builder = new StringBuilder( 19 );
int mask = (1 << 15);
for ( int j = 0; j < 4; j++ )
{
for ( int i = 0; i < 4; i++ )
{
builder.Append( ((value & mask) != 0) ? ("1") : ("0") );
mask = mask >> 1;
}
if ( j < 3 )
{
builder.Append( " " );
}
}
return builder.ToString();
}
+125
/// <summary>
/// Конвертирование String - Decimal
/// </summary>
/// <param name="text"></param>
/// <param name="value"></param>
/// <returns></returns>
public static decimal GetDecimal(this string text)
{
decimal number;
CultureInfo culture = null;
if (String.IsNullOrEmpty(text))
throw new ArgumentNullException("The input string is invalid.");
try
{
culture = CultureInfo.CurrentCulture;
number = decimal.Parse(text, culture);
return number;
}
catch
{
}
try
{
culture = culture.Parent;
number = decimal.Parse(text, culture);
return number;
}
catch
{
}
culture = CultureInfo.InvariantCulture;
try
{
number = decimal.Parse(text, culture);
return number;
}
catch (FormatException e)
{
throw new FormatException(String.Format("Unable to parse '{0}'.", text), e);
}
}
Это финиш.
+159
// this fucking motherfucker is because fucking popup (don't want to remake whole authorisatio system)
if (isset($_SERVER['HTTP_REFERER']) && !preg_match("/\/$/", $_SERVER['HTTP_REFERER']))
$_SERVER['HTTP_REFERER'] .= "/";
И блядь по 10 таких кусков кода на 1 файл.
−116
sub addOrUpdateContr {
my $doc = shift;
my( $id ) = $common->dbh->selectrow_array(
qq|SELECT contrid FROM... | );
$id = $id || 0;
if ( $id ) {
# вариант действий 1 ....
return $id;
}
if( !$id ) {
# вариант действий 2 (делает INSERT)....
return $id;
} else {
# вариант действий 3 ....
return $id;
}
return $id;
}
Просто красивая функция.
И то, что при названии addOrUpdateContr никакого апдэйта она не делает в ней далеко не самое замечательное.
+80
getBtnContent().setEnabled(enable);
if (getGridConfig().isContentEnabled()) {
getBtnContent().setEnabled(enable);
}
Программист со стажем, всегда хочет быть уверен что кнопка будет доступна на 150%
+161
...
public function getLocations($fresh = 0)
{
$tld =& $this->varGet('tld');
$domain =& $this->varGet('domain');
// if website is viewed via IP
$noWWWButIP =& $this->varGet('noWWWButIP');
$memCacheKey = 'getLocations';
if (!$fresh) {
// already fetched and stored in vars?
if (is_array($this->varGet('arrLocations')))
$arrLocations = $this->varGet('arrLocations');
// lets try fetching from memcache
else
$arrLocations = kd()->lib('kdCache')->get($memCacheKey);
}
// regenerate
unset($arrLocations);
if (!is_array($arrLocations)) {
...
Кэшируем))
+118
if (mainWareHouseId.HasValue && mainWareHouseId.Value.ToString() == this._locationList.SelectedValue)
{
return false;
}
else
{
return location == null ? true : !location.RegionalFulfillment;
}