- 1
- 2
mov eax, "allahu akbar"
push eax
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
mov eax, "allahu akbar"
push eax
Короче слушай сюда, петушок, я буду объяснять тебе доступными словами, что бы ты понял.
Вот попадаешь ты на зону, тебя встречает DHCP, он говорит тебе какая у тебя камера(Маска подсети), койка(ip адрес) и разъясняет порядок на хате(параметры области). Как только тебя определяют, то об этом узнает местная крыса(DNS), этот ушлый чухан вообще всё обо всех знает и сливает инфу по первому стуку в ебало(nslookup). Поэтому как только попадаешь в хату, представься что ты мужик(nsname), однако этот хуй может всем пиздеть что ты хуйло, или вообще идти в несознанку, поэтому лучше знать несколько крыс. Так вот, сидишь ты такой на своей койке и тебе нужно написать маляву(пакет) корешу, малявы передают через чуханов(маршрутизаторы, концентраторы, коммутаторы). Если ты передашь через чухана-концентратора, то знай, этот олень настолько тупой, что тут же забывает кто ему передал маляву и кому ее надо отдать, поэтому что бы не получить пизды, раздает ее всем, даже тебе. Если ты передаешь через чухана-коммутатора, то знай, он куда смышленей и передаст маляву куда надо, но только в пределах своей хаты, ибо связей не имеет. А вот маршрутизатора уже чуханом назвать сложно, этот тип может доставить маляву куда угодно, даже в соседнюю хату и даже в соседнюю зону, ибо связи решают.
+133
if (textBox[0].Text == "" && textBox[1].Text == "" && textBox[2].Text == "" && textBox[3].Text == "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("");
else if (textBox[0].Text != "" && textBox[1].Text == "" && textBox[2].Text == "" && textBox[3].Text == "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[surname] LIKE '%{0}%'", textBox[0].Text);
else if (textBox[0].Text == "" && textBox[1].Text != "" && textBox[2].Text == "" && textBox[3].Text == "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[name] LIKE '%{0}%'", textBox[1].Text);
else if (textBox[0].Text == "" && textBox[1].Text == "" && textBox[2].Text != "" && textBox[3].Text == "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[midname] LIKE '%{0}%'", textBox[2].Text);
else if (textBox[0].Text == "" && textBox[1].Text == "" && textBox[2].Text == "" && textBox[3].Text != "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("course={0}", textBox[3].Text);
else if (textBox[0].Text == "" && textBox[1].Text == "" && textBox[2].Text == "" && textBox[3].Text == "" && textBox[4].Text != "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("group={0}", textBox[4].Text);
else if (textBox[0].Text != "" && textBox[1].Text != "" && textBox[2].Text == "" && textBox[3].Text == "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[surname] LIKE '%{0}%' and [name] LIKE '%{1}%'", textBox[0].Text, textBox[1].Text);
else if (textBox[0].Text == "" && textBox[1].Text != "" && textBox[2].Text != "" && textBox[3].Text == "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[name] LIKE '%{0}%' and [midname] LIKE '%{1}%'", textBox[1].Text, textBox[2].Text);
else if (textBox[0].Text == "" && textBox[1].Text == "" && textBox[2].Text != "" && textBox[3].Text != "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[midname] LIKE '%{0}%' and course={1}", textBox[2].Text, textBox[3].Text);
else if (textBox[0].Text == "" && textBox[1].Text == "" && textBox[2].Text == "" && textBox[3].Text != "" && textBox[4].Text != "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("course={0} and group={1}", textBox[3].Text, textBox[4].Text);
else if (textBox[0].Text != "" && textBox[1].Text != "" && textBox[2].Text != "" && textBox[3].Text == "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[surname] LIKE '%{0}%' and [name] LIKE '%{1}%' and [midname] LIKE '%{2}%'", textBox[0].Text, textBox[1].Text, textBox[2].Text);
else if (textBox[0].Text == "" && textBox[1].Text != "" && textBox[2].Text != "" && textBox[3].Text != "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[name] LIKE '%{0}%' and [midname] LIKE '%{1}%' and course={2}", textBox[1].Text, textBox[2].Text, textBox[3].Text);
else if (textBox[0].Text == "" && textBox[1].Text == "" && textBox[2].Text != "" && textBox[3].Text != "" && textBox[4].Text != "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[midname] LIKE '%{0}%' and course={1} and group={2}", textBox[2].Text, textBox[3].Text, textBox[4].Text);
else if (textBox[0].Text != "" && textBox[1].Text != "" && textBox[2].Text != "" && textBox[3].Text != "" && textBox[4].Text == "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[surname] LIKE '%{0}%' and [name] LIKE '%{1}%' and [midname] LIKE '%{2}%' and course={3}", textBox[0].Text, textBox[1].Text, textBox[2].Text, textBox[3].Text);
else if (textBox[0].Text == "" && textBox[1].Text != "" && textBox[2].Text != "" && textBox[3].Text != "" && textBox[4].Text != "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[name] LIKE '%{0}%' and [midname] LIKE '%{1}%' and course={2} and group={3}", textBox[1].Text, textBox[2].Text, textBox[3].Text, textBox[4].Text);
else if (textBox[0].Text != "" && textBox[1].Text != "" && textBox[2].Text != "" && textBox[3].Text != "" && textBox[4].Text != "")
myViewStudentsTable.DefaultView.RowFilter = string.Format("[surname] LIKE '%{0}%' and [name] LIKE '%{1}%' and [midname] LIKE '%{2}%' and course={3} and group={4}", textBox[0].Text, textBox[1].Text, textBox[2].Text, textBox[3].Text, textBox[4].Text);
"Есть 5 текстовых полей и желание понять, как можно в зависимости от пустоты или заполненности этих полей, одного или нескольких создать малое количество операторов if else"
Порадовало "малое количество"
+159
/**
* @package mod_jlcurrency
* @author Zhukov Artem ([email protected])
* @version 1.1
* @copyright (C) 2012 by JoomLine (http://www.joomline.net)
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
*
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
$vl = array();
$vl[$params->get('JPY')]=$params->get('JPY');$vl[$params->get('ZAR')]=$params->get('ZAR');
$vl[$params->get('KRW')]=$params->get('KRW');$vl[$params->get('CHF')]=$params->get('CHF');
$vl[$params->get('SEK')]=$params->get('SEK');$vl[$params->get('CZK')]=$params->get('CZK');
$vl[$params->get('UAH')]=$params->get('UAH');$vl[$params->get('UZS')]=$params->get('UZS');
$vl[$params->get('TRY')]=$params->get('TRY');$vl[$params->get('TMT')]=$params->get('TMT');
$vl[$params->get('TJS')]=$params->get('TJS');$vl[$params->get('SGD')]=$params->get('SGD');
$vl[$params->get('XDR')]=$params->get('XDR');$vl[$params->get('RON')]=$params->get('RON');
$vl[$params->get('PLN')]=$params->get('PLN');$vl[$params->get('NOK')]=$params->get('NOK');
$vl[$params->get('MDL')]=$params->get('MDL');$vl[$params->get('LTL')]=$params->get('LTL');
$vl[$params->get('LVL')]=$params->get('LVL');$vl[$params->get('CNY')]=$params->get('CNY');
$vl[$params->get('KGS')]=$params->get('KGS');$vl[$params->get('CAD')]=$params->get('CAD');
$vl[$params->get('KZT')]=$params->get('KZT');$vl[$params->get('INR')]=$params->get('INR');
$vl[$params->get('EUR')]=$params->get('EUR');$vl[$params->get('USD')]=$params->get('USD');
$vl[$params->get('DKK')]=$params->get('DKK');$vl[$params->get('HUF')]=$params->get('HUF');
$vl[$params->get('BRL')]=$params->get('BRL');$vl[$params->get('BGN')]=$params->get('BGN');
$vl[$params->get('BYR')]=$params->get('BYR');$vl[$params->get('AMD')]=$params->get('AMD');
$vl[$params->get('GBP')]=$params->get('GBP');$vl[$params->get('AZN')]=$params->get('AZN');
$vl[$params->get('AUD')]=$params->get('AUD');
Эмм. Это так и должно быть?
+54
// We now have a locale string, but the global locale can be changed by
// another thread. If we allow this thread's locale to be updated before we're done
// with this string, it might be freed from under us.
// Call versions of the wide-to-MB-char conversions that do not update the current thread's
// locale.
//...
/*
* Note that we are using a risky trick here. We are adding this
* locale to an existing threadlocinfo struct, and thus starting
* the locale's refcount with the same value as the whole struct.
* That means all code which modifies both threadlocinfo::refcount
* and threadlocinfo::lc_category[]::refcount in structs that are
* potentially shared across threads must make those modifications
* under _SETLOCALE_LOCK. Otherwise, there's a race condition
* for some other thread modifying threadlocinfo::refcount after
* we load it but before we store it to refcount.
*/
MS VS 2013 CRT
+57
class C3D
{
public:
//C3D() {} // Constructor
//~C3D() {} // Destructor
void(*init)(float R, float A, float B, float Rmin, float Rmax, float Bmin, float Bmax); // Initialize work with 3D standard camera
void(*setCamera)(int iType); // Set type of camera
void(*setPosition)(float x, float y, float z); // Set position
void(*setRender3D)();
UINT(*addMesh)(LPCWSTR sMesh); // Add Mesh
void(*renderMesh)(UINT idMesh, float x, float y, float z);
void(*renderMeshSubset)(UINT idMesh, UINT idSubset, float x, float y, float z);
void(*renderMeshSubsetRotateX)(UINT idMesh, UINT idSubset, float x, float y, float z, float a);
// простыня указателей на функции урезана
void setHModule(HMODULE hLib)
{
m_hLib = hLib;
(FARPROC &)init = GetProcAddress(m_hLib, "init3D"); // Initialize work with 3D standard camera
(FARPROC &)setCamera = GetProcAddress(m_hLib, "setCamera"); // Set type of camera
(FARPROC &)setPosition = GetProcAddress(m_hLib, "setPosition"); // Set position
(FARPROC &)setRender3D = GetProcAddress(m_hLib, "setRender3D");
(FARPROC &)addMesh = GetProcAddress(m_hLib, "addMesh"); // Add Mesh
(FARPROC &)renderMesh = GetProcAddress(m_hLib, "renderMesh");
(FARPROC &)renderMeshSubset = GetProcAddress(m_hLib, "renderMeshSubset");
(FARPROC &)renderMeshSubsetRotateX = GetProcAddress(m_hLib, "renderMeshSubsetRotateX");
// простыня GetProcAddress урезана
}
protected:
HMODULE m_hLib; // NetWars.dll
};
Некий SDK для MMO-игр за авторством одного известного разработчика.
+161
//! Массив типов пользователей
$UserTypes = array();
$result = $db->Query("SELECT 'Физ.лицо' AS type_user_rus, 'human' AS type_user FROM DUAL
UNION ALL
SELECT 'Юр.лицо' AS type_user_rus, 'firm' AS type_user FROM DUAL");
if( $db->isError( $result ) ){
die( $result->getMessage() . " at line " . __LINE__ . " in file " . __FILE__ );
}
while( $row = $result->fetchRow( DB_FETCHMODE_ASSOC ) )
{
$UserTypes[$row['TYPE_USER']] = $row['TYPE_USER_RUS'];
}
Формирование массива с типами клиентов
+156
if (count($vCard) == 1) {
print_r($vCard -> n);
print_r($vCard -> tel);
} else {
foreach ($vCard as $vCardPart)
{
print_r($vCardPart -> n);
print_r($vCardPart -> tel);
}
}
https://github.com/nuovo/vCard-parser
Ну за каким хуем обрабатывать один элемент как отдельный случай?!
+1
struct Vector2f{float x, y;};
struct Vector3f{float x, y, z;};
struct Tensor3f{float xx, xy, xz, yy, yz, zz;};
struct Matrix3x3f{float data[9];};
struct Space2
{
typedef Vector2f Vector;
};
struct Space3
{
typedef Vector3f Vector;
};
template<typename Space>
struct ParticleSystem
{
template<typename T>
struct ParticleData{};
template<>
struct ParticleData<Space2>
{
float orientation;
float invInertia;
};
template<>
struct ParticleData<Space3>
{
typename Matrix3x3f orientation;
typename Tensor3f inertiaTensor;
};
struct Particle : public ParticleData<Space>
{
typename Space::Vector pos, velocity;
};
template<typename T>
void DumpParticle(){}
template<>
void DumpParticle<Space2>()
{
printf("%f %f", particles[0].orientation, particles[0].invInertia);
}
template<>
void DumpParticle<Space3>()
{
printf("%f %f", particles[0].orientation.data[0], particles[0].inertia.xx);
}
void DumpParticles()
{
DumpParticle<Space>();
}
std::vector<Particle> particles;
};
Хочу объединить трехмерный и двухмерный движок.
+13
#include <iostream>
using namespace std;
// -- robot`s internal closed implementation --
int data1[] = { 0, 1, 2 }; char data2[] = { 42 };
// -- robot`s API
const int *GetMechaData1() { return data1; }
size_t GetMechaData1Size() { return 3; }
const char *GetMechaData2(){ return data2; }
size_t GetMechaData2Size() { return 1; }
// -- pentagon`s internal closed implementation --
//--------------------если T равно U, то результат будет D, а иначе - G------------//
template<class T, class U, class D, class G> struct SelectIF { typedef G type; };
template<class T, class D, class G> struct SelectIF<T, T, D, G> { typedef D type; };
// -- pentagon`s API
enum { eMAXBUFER = 200 * sizeof(int) };
template<class T, size_t N>void AcceptData(const T(&src)[N])
{
typedef typename SelectIF<T, char, int, T>::type Cast;
enum { is_char = std::is_same<T,char>::value };
cout << "received data:\n";
const size_t num = (N<eMAXBUFER) ? N : eMAXBUFER;
if (is_char)
for (size_t n = 0; n < num; ++n)
cout << "char code = " << (Cast)src[n] << " : char = '" << src[n] << "'\n";
else
for (size_t n = 0; n<num; ++n)
cout << "item = " << src[n] << endl;
}
// client code
template<class T, size_t N> struct Adapter
{
typedef Adapter<T, N + 1> Next;
void Pass(const T* data, const size_t num)
{
if (N < num)
{
Next().Pass(data, num);
return;
}
T(&arr)[N] = reinterpret_cast< T(&)[N] > (mBuf);
for (size_t n = 0; n< N; ++n) arr[n] = data[n];
AcceptData(arr);
}
size_t mLen;
T mBuf[eMAXBUFER];
};
template<class T> struct Adapter<T, eMAXBUFER>
{
void Pass(const T* data, const size_t)
{
for (size_t n = 0; n< eMAXBUFER; ++n) mBuf[n] = data[n];
AcceptData(mBuf);
}
size_t mLen;
T mBuf[eMAXBUFER];
};
Adapter<int, 1> adapter1;
Adapter<char, 1> adapter2;
int main()
{
{
const auto data = GetMechaData1();
const auto num = GetMechaData1Size();
adapter1.Pass(data, num);
}
{
const auto data = GetMechaData2();
const auto num = GetMechaData2Size();
adapter2.Pass(data, num);
}
}
Крестушки раскрестушились, а подраться не решились.
Под катом ещё несколько вариантов.
+1
std::AIDS