1. C# / Говнокод #6632

    +116

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    IList<Hashtable> records = crit.List<Hashtable>();
    Guid[] personsId = records.Select(item => (Guid)item["PersonID"]).Distinct().ToArray();
    List<EmployeeData> empDatas = new List<EmployeeData>();
    
    foreach(Guid personId in personsId) {
    	IEnumerable<Hashtable> employeeRecords = records.Where(item => (Guid)item["PersonID"] == personId);
    	Hashtable employeeRecord = employeeRecords.FirstOrDefault(item => !(bool)item["IsLoad"] || (DateTime)item["EventDate"] == employeeRecords.Max(unit => (DateTime)unit["EventDate"]));
    
    	Hashtable employeeRecordAddition = new GenericNHibernateDao<BaseDocument>().CreateCriteria()
    		.CreateAlias("Department", "department")
    		.CreateAlias("Employee", "employee")
    		.CreateAlias("WorkDescription.Schedule", "schedule", JoinType.LeftOuterJoin)
    		.CreateAlias("WorkDescription.EmployeeApperance", "employeeApperance", JoinType.LeftOuterJoin)
    		.Add(Restrictions.Eq("EmployeeStamp.TabNo", employeeRecord["TabNo"]))
    		.Add(Restrictions.Eq("IsHalf", false))
    	...
    }

    No comments %)

    Guid, 12 Мая 2011

    Комментарии (5)
  2. bash / Говнокод #6631

    −133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #!/bin/bash
    
    cat -b $1 > file.txt
    sed -e 's/^/<br>/g' -i file.txt
    curl --data-urlencode [email protected] netelis.hmsite.net/upload.php | head -n1

    Аналог wgetpaste

    AliceGoth, 11 Мая 2011

    Комментарии (12)
  3. C# / Говнокод #6630

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    private string GetConnectionString() 
        { 
          string connString = String.Empty; 
          string location = Assembly.GetExecutingAssembly().Location; 
          int pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          location += @"\server\conf\config.conf"; 
          using (StreamReader sr = File.OpenText(location)) 
          { 
            string s = ""; 
            while ((s = sr.ReadLine()) != null) 
            { 
              connString += s; 
            } 
          } 
          connString += "database = ***; charset = utf8;"; 
          return connString; 
        }

    mahalex, 11 Мая 2011

    Комментарии (4)
  4. PHP / Говнокод #6629

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    function shab()
    {
      global $title;                            
      global $description;
      global $keywords;
      global $content;                                         
      global $patch;
      global $page_names;
      global $pn;
      global $id;
      include_once $patch.'/head.php'; // почему-то вспомнился логотип башоргру cat /dev/ass > /dev/head
      echo $title.'</title>'."\n";
      echo '<meta name="description" content="'.$description.'">'."\n";
      echo '<meta name="keywords" content="'.$keywords.'">'."\n";
      include_once $patch.'/shapka.php'; // wtf!?
      echo $content."<br>\n";
      if(in_array($pn,$page_names))
      {                                   
          include $patch.'/form.php';
      }
      $ua=mysql_real_escape_string(trim($_SERVER['HTTP_USER_AGENT']));
      $ip=mysql_real_escape_string(trim($_SERVER['REMOTE_ADDR'])); // вебкил не пройдет
      mysql_query("update content set views=views+1 where id='$id'");
      mysql_query("insert into views_content set id='$id', ip='$ip', t=NOW() + INTERVAL 1 HOUR, d=NOW() + INTERVAL 1 HOUR, ua='$ua'");
      $q=mysql_query("select views,t,d from content where id='$id'");
      while($r=mysql_fetch_array($q))
      {
         echo '<br><span style="font-color:#808080; font-size:8pt; float:right;">Просмотров: '.$r['views'].'<br>
         '.$r['d'].'<font color="#ca3200"> / </font>'.$r['t']."<br>\n"; //d и t это дата и время кто не понял :D	
      } 
      echo '<a style="font-color:#ca3200; font-size:10pt;" href="index.php">все статьи</a></span>';
      include_once $patch.'/footer.php';
    }

    это вам не смарти, тут всё просто и понятно, а главное быстро. shab() и дело в шляпе.

    GoodTalkBot, 11 Мая 2011

    Комментарии (16)
  5. C# / Говнокод #6628

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    ----Something.cs
    public partial class Something
    {
      // some implementation.
    }
    ----Something.Bla.cs
    partial class Something
    {
      private class Bla
      {
      }
    }
    ----Something.Foo.cs
    partial class Something
    {
      private class Foo
      {
      }
    }
    ----Something.Bar.cs
    partial class Something
    {
      private class Bar
      {
      }
    }

    Нормально ли использовать partial классы исключительно для хранения private nested классов? К примеру если количество таковых доходит до 5-15?

    walash, 11 Мая 2011

    Комментарии (14)
  6. JavaScript / Говнокод #6627

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /* DO NOT UNCOMMENT THIS CODE AGAIN.  THIS IS THE 3rd TIME I'VE HAD TO REMOVE THIS.
        if($("form#purchase_form").length) {
            var currentPaymentValue = $("input[name='paymentFormOverride']:checked", "#purchase_form").val();
            if (currentPaymentValue == 'cc')
                $("#pp_payment_method").click(function(){paymentRedirect('pp')});
            else
                $("#cc_payment_method").click(function(){paymentRedirect('cc')});
        }
    	*/

    Чоткая обратная связь :))

    kovel, 11 Мая 2011

    Комментарии (5)
  7. PHP / Говнокод #6626

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    $date = $_POST['date2'];
    if($_POST['1']!="") $r1=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[1]', '$lesson1', '$classID', '$date')");
    if($_POST['2']!="") $r2=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[2]', '$lesson2', '$classID', '$date')");
    if($_POST['3']!="") $r3=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[3]', '$lesson3', '$classID', '$date')");
    if($_POST['4']!="") $r4=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[4]', '$lesson4', '$classID', '$date')");
    if($_POST['5']!="") $r5=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[5]', '$lesson5', '$classID', '$date')");
    if($_POST['6']!="") $r6=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[6]', '$lesson6', '$classID', '$date')");
    if($_POST['7']!="") $r7=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[7]', '$lesson7', '$classID', '$date')");
    if($_POST['8']!="") $r8=mysql_query ("INSERT INTO `bazaname`.`dz` (`id` ,`value` ,`id_subject` ,`id_class` ,`date`) VALUES (NULL , '$_POST[8]', '$lesson8', '$classID', '$date')");
    }
    
    
    
    
    $Sunday = date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+0-$todayis,$year));
    $Monday = date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+1-$todayis,$year));
    $Tuesday = date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+2-$todayis,$year));
    $Wednesday = date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+3-$todayis,$year));
    $Thursday = date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+4-$todayis,$year));
    $Friday = date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+5-$todayis,$year));
    $Saturday = date("Y-m-d", mktime (0,0,0,date("m") ,date("d")+6-$todayis,$year));

    С песочницы хабра
    http://habrahabr.ru/sandbox/28776/

    rO_ot, 11 Мая 2011

    Комментарии (37)
  8. ActionScript / Говнокод #6625

    −110

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public function setCategory(categoryType:String):void
    {
    	giftIcon.visible 		= (categoryType == ActionsEnum.GIFTS);
    	effectIcon.visible 		= (categoryType == ActionsEnum.EFFECTS);
    	skinIcon.visible 		= (categoryType == ActionsEnum.SKINS);	
    	gamesIcon.visible 		= (categoryType == ActionsEnum.GAMES);
    	activtiesIcon.visible 	= (categoryType == ActionsEnum.APPLICATIONS);
    }

    Глядя на мир нельзя не удивлятся.

    wvxvw, 11 Мая 2011

    Комментарии (3)
  9. C++ / Говнокод #6624

    +152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    QString generateGuid( const std::string &tDeviceSerial,
            const std::string &nDatetime, const std::string &licnum,
            const char *violation )
    {
        std::ostringstream s;
        s << tDeviceSerial;
        s << nDatetime;
        s << licnum;
        s << violation;
        
        QCryptographicHash hash( QCryptographicHash::Md5 );
        hash.addData( QByteArray( s.str().c_str() ) );
        QByteArray result = hash.result();
        return convToHex( (unsigned char*)result.data(), result.size() );
    }

    Оно, конечно, работает. Но разобраться в таком коде....

    panter_dsd, 11 Мая 2011

    Комментарии (16)
  10. C++ / Говнокод #6623

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    QString convToHex( unsigned char *bytes, int size )
    {
    	if( size > 16 )
    		size = 16;
    	QString ret;
    	for( int i = 0; i < size; i++ )
    	{
    		char buf[3];
    		::sprintf( buf,"%02x", (unsigned int) bytes[i] );
    		ret += buf;
    	}	
    	return ret;
    }

    panter_dsd, 11 Мая 2011

    Комментарии (7)