- 1
- 2
- 3
>>> mylist = [3,5,8,5,3,12]
>>> print dict().fromkeys(mylist).keys()
[8, 3, 12, 5]
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−162
>>> mylist = [3,5,8,5,3,12]
>>> print dict().fromkeys(mylist).keys()
[8, 3, 12, 5]
"Getting rid of duplicate items in a list" типа способ убрать дубликаты в списке
+124
public void GeneratXMLForChatServerControl()
{
List<ClassUsersList> List = GetUsersList();
System.IO.StreamWriter TextW = new System.IO.StreamWriter("Update_Settings.xml", false,System.Text.Encoding.GetEncoding("UTF-8"));
TextW.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
TextW.WriteLine("<General>");
foreach (ClassUsersList User in List)
{
User.Information = User.Information.Replace("<", "");
User.Information = User.Information.Replace(">", "");
User.Information = User.Information.Replace("&", "");
TextW.WriteLine("<Name>" + User.Information + "</Name>");
TextW.WriteLine("<Login>" + User.UIN + "</Login>");
TextW.WriteLine("<Password>" + User.Pwd + "</Password>");
TextW.WriteLine("<LocalPath>D:\\chat2\\" + User.UID + "\\</LocalPath>");
TextW.WriteLine("<UID>" + User.UID + "</UID>");
TextW.WriteLine("<UIN>" + User.UIN + "</UIN>");
TextW.WriteLine("<Lock>0</Lock>");
TextW.WriteLine("");
}
TextW.WriteLine("</General>");
TextW.Flush();
TextW.Close();
}
Крутобл, создаём XML налету
+162
class recordset {
/*используется для оптимизации работы с MySQL*/
var $res;
function recordset($sql,$link="") {
if ($link!="")
{
$this->res=mysql_query($sql,$link);
if (!$this->res)
{
echo $sql;
echo mysql_error($link);
}
}
else
{
$this->res=mysql_query($sql);
if (!$this->res)
{
echo $sql;
echo mysql_error();
}
}
}
function gr() {
$row=mysql_fetch_row($this->res);
if ($row) {for ($i=0;$i<count($row);$i++) $row[$i]=convert_cyr_string($row[$i],"k","w");}
return $row; }
function ga() {
$row=mysql_fetch_array($this->res);
if ($row) {foreach($row as $key=>$val) $row[$key]=convert_cyr_string($val,"k","w");}
return $row; }
function nr() {
$num=mysql_num_rows($this->res);
return $num; }}
еще один перл того же автора, что и в 2х предыдущих опубликованных мной говнокодах.
На этот раз старорежимный ООП - великолепный класс.
+111
/// -----------------------------------------------------------------------------
/// <summary>
/// Page_Load runs when the control is loaded
/// </summary>
/// -----------------------------------------------------------------------------
protected void Page_Load(object sender, System.EventArgs e)
{
...
}
да ну!! серьезно что-ли???
+111
<?
class newPage
{
public $bigMainImage;
public $smallMainImage;
protected $id;
//Фамилия и имя
protected $surname;
protected $name;
//город
protected $city;
//конструктор
public __construct($id,
$surname,
$name,
$city)
{
$this->id = htmlspecialchars($id);
$this->surname = htmlspecialchars($surname);
$this->name = htmlspecialchars($name);
$this->city = htmlspecialchars($city);
//копируем большое и маленькое изображение
copy("photos/$id/1.jpg","photos/$id/Main.jpg");
copy("photos/$id/small/1.jpg","photos/$id/small/Main.jpg");
$this->bigMainImage = "photos/$id/Main.jpg";
$this->smallMainImage = "photos/$id/small/Main.jpg";
}
//вывод страницы на экран
public get_html()
{
echo"<title>$this->name $this->surname</title>";
echo "
<table>
<tr>
<td>
<img src=\"$this->bigMainImage\"><br>Рейтинг:
</td>
<td>
<b>$this->name $this->surname</b>,<br>
$this->city
</td>
</tr>
</table>";
}
public newFile($id)
{
$intPage = fopen("page/".$id.".php",w);
}
}
?>
Ржу не магу.
+164
std::string str(bool val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(short val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(unsigned short val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(int val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(unsigned int val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(long val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(unsigned long val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(float val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(double val) {
std::stringstream ss;
ss << val;
return ss.str();
}
std::string str(long double val) {
std::stringstream ss;
ss << val;
return ss.str();
}
Вот что значит невыспанная голова!
Чуть позже переделал в это
template<class T>
std::string str(T val) {
std::stringstream ss;
ss << val;
return ss.str();
}
+170
function varEnb(a) {
n=true
try {
z=eval(a)
} catch(e) {
n=false
}
if(n==true){
return true
} else {
return false
}
}
Проверяем наличие переменной
+148
$isOccupy=($valdet['isOccupy']=='1')?0:1;
а все по тому что кое кто перепутал логику атрибута=\
+176
//вторая форма
$n2 = $_GET['n2'];//Компания
$n10 = $_GET['n10'];//Ф.И.О:
$n11 = $_GET['n11'];// Должность:
$n12 = $_GET['n12'];//Телефон:
$n13 = $_GET['n13'];//E-mail:
$n14 = $_GET['n14'];//
$n15 = $_GET['n15'];
$n16 = $_GET['n16'];
$n17 = $_GET['n17'];
$n18 = $_GET['n18'];
$n19 = $_GET['n19'];
$n20 = $_GET['n20'];
$n21 = $_GET['n21'];
$n22 = $_GET['n22'];
$n23 = $_GET['n23'];
$n24 = $_GET['n24'];
$n25 = $_GET['n25'];
$n26 = $_GET['n26'];
$n27 = $_GET['n27'];
$n28 = $_GET['n28'];
$n29 = $_GET['n29'];
$n30 = $_GET['n30'];
$n31 = $_GET['n31'];
$n32 = $_GET['n32'];
$n33 = $_GET['n33'];
$n34 = $_GET['n34'];
$n35 = $_GET['n35'];
$n37 = $_GET['n37'];//value - другое:
$n38 = $_GET['n38'];
$n39 = $_GET['n39'];
$n40 = $_GET['n40'];//new form - Картонные карты - Тираж(от 10 000 шт.):
$n41 = $_GET['n41'];
$n42 = $_GET['n42'];
$n43 = $_GET['n43'];
$n44 = $_GET['n44'];
$n45 = $_GET['n45'];
$n46 = $_GET['n46'];
$n47 = $_GET['n47'];//new form - Услуги сборки - Количество комплектов:
$n48 = $_GET['n48'];
$n49 = $_GET['n49'];
$n50 = $_GET['n50'];
$n51 = $_GET['n51'];
$n52 = $_GET['n52'];
$n53 = $_GET['n53'];
$n54 = $_GET['n54'];
$n55 = $_GET['n55'];
$n56 = $_GET['n56'];
$n57 = $_GET['n57'];
$n58 = $_GET['n58'];
$n59 = $_GET['n59'];//new form - Мейлинг - Есть
$n60 = $_GET['n60'];
$n61 = $_GET['n61'];
$n62 = $_GET['n62'];
$n63 = $_GET['n63'];
$n64 = $_GET['n64'];
$n65 = $_GET['n65'];
$n66 = $_GET['n66'];
$n67 = $_GET['n67'];
$n68 = $_GET['n68'];
$n69 = $_GET['n69'];
$n70 = $_GET['n70'];
$n71 = $_GET['n71'];
$n72 = $_GET['n72'];
$n73 = $_GET['n73'];
$n74 = $_GET['n74'];
$n75 = $_GET['n75'];
$n76 = $_GET['n76'];
$n77 = $_GET['n77'];
$n78 = $_GET['n78'];
$n79 = $_GET['n79'];
$n80 = $_GET['n80'];
$n81 = $_GET['n81'];
$n82 = $_GET['n82'];
$n83 = $_GET['n83'];
$n84 = $_GET['n84'];
$n85 = $_GET['n85'];
$n86 = $_GET['n86'];
$n87 = $_GET['n87'];
$n88 = $_GET['n88'];
$n89 = $_GET['n89'];
$n90 = $_GET['n90'];
$subject2 = "Онлайн просчет";
$headers2 = "MIME-Version: 1.0\n";
$headers2 .= "Content-type: text/html; charset=utf-8\n";
$text2 = "<table border='0' cellspacing='0' cellpadding='0' width='100%' align='center' bgcolor='#f0f0f0'> <tr>
<td><table border='0' cellspacing='0' cellpadding='0' width='600' align='center' bgcolor='#f0f0f0'> <tr>
<td width='178' height='50' valign='center'><font size='2'> Компания* :</font></td> <td
width='329'><input type=TEXT name='n2' value='".$n2."' readonly='readonly' size='49' style='border: 2;
background: #e2e2e2' /></td> </tr> <tr> <td height='50' valign='center'><font
этот пиздец был найден в коде одного проекта на жумле, в файле темплейта
в конечном итогде это все отправлялось на мыло
+133
Below is a list of the warning message(s) produced when checking your document.
Line 91, Column 31: NET-enabling start-tag requires SHORTTAG YES
alt="Правильный CSS!" /> </a> ✉
The sequence <FOO /> can be interpreted in at least two different ways, depending on the DOCTYPE of the document...
Валидатор ругается на иконку, подаренную валидатором