- 1
w = (GtkWidget*)(*((int*)(lw->data)));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+137.6
w = (GtkWidget*)(*((int*)(lw->data)));
Объект для медитаций
+137.6
struct X{template<class T>X(T);X g(){X(this->*&X::g);}};
Короткая программа валит MSVC8 при компиляции
+137.6
public static readonly int daysIn2Weeks = 14;
+137.5
void TWindowTID::SetStyle(GtkWidget* widget, const char *form, gint Red_, gint Green_, gint Blue_)
{
struct _GtkStyle *style;
GdkColor bg;
style=gtk_style_new();
bg.red = Red_;
bg.blue = Blue_;
bg.green = Green_;
if (form=="TEXT")
{
style->fg[GTK_STATE_NORMAL]=bg; //TEXT
}
else
if (form=="BORDER")
{
style->base[GTK_STATE_NORMAL]=bg; //BORDER
}
else
if (form=="ALL")
{
style->bg[GTK_STATE_NORMAL]=bg;
style->base[GTK_STATE_NORMAL]=bg; //BORDER
style->fg[GTK_STATE_NORMAL]=bg; //TEXT
}
else
if (form=="button")
{
style->bg[GTK_STATE_PRELIGHT]=bg;
style->base[GTK_STATE_PRELIGHT]=bg; //BORDER
style->bg[GTK_STATE_SELECTED]=bg;
style->base[GTK_STATE_SELECTED]=bg; //BORDER
}
else
{
style->bg[GTK_STATE_NORMAL]=bg;
}
style->font = gdk_font_load("-adobe-helvetica-*-r-*-*-12-*-*-*-*-*-*-*");
if ((GtkWidget *)widget!=NULL) gtk_widget_set_style((GtkWidget *)widget, style);
}
Сравнение строк умиляет
+137.5
function get($id,$lang_id)
{
// начнем транзакцию
$bresult=ConnectionManager::begin();
if (!$bresult)
{
ConnectionManager::rollback();
return false;
}
$result=$this->db_main->getTPLRow(QUERY_ADMIN_CELLMETHOD_GET, array('id'=>$id,'lang_id'=>$lang_id));
if (!is_array($result))
{
ConnectionManager::rollback();
return false;
}
/*$operators=$this->db_main->getTPLData(QUERY_ADMIN_CELLMETHOD_OPETATORS_GET, array('id'=>$id));
if (!is_array($operators))
{
ConnectionManager::rollback();
return false;
}
$result['operator'] = $operators;*/
// закончим транзакцию
$cresult=ConnectionManager::commit();
if (!$cresult)
{
ConnectionManager::rollback();
return false;
}
if (count($result))
return $result;
else
return true;
}
Метод получает данные из таблицы. getTPLRow делает выборку из таблицы, обратите внимание, что при этом делается begin, commit и rollback
+137.3
private ArrayList GetSubscribers(string condition)
{
ArrayList subscribers = new ArrayList();
ArrayList lst = new user_category_notification().Factory.GetItems(condition, "user_category_notification.id_user");
ArrayList distinc_lst = new ArrayList();
ArrayList distinc_lst_ids = new ArrayList();
ArrayList lst_ids = new ArrayList();
for (int i = 0; i < lst.Count; i++)
{
lst_ids.Add(((user_category_notification) lst[i]).id_user);
}
for (int i = 0; i < lst_ids.Count;i++ )
{
if (distinc_lst_ids.Contains(lst_ids[i])) continue;
else
{
distinc_lst.Add(lst[i]);
distinc_lst_ids.Add(lst_ids[i]);
}
}
foreach (user_category_notification _un in distinc_lst)
{
user _current = (user)new user().Factory.GetByID(_un.id_user);
subscribers.Add(_current);
}
return subscribers;
}
Филтрация :)
+137.1
if (Skin == null || ((Skin != null && Skin.Value == null) || (Skin != null && Skin.Value != null && Skin.Value.Length == 0))) {
Skin = new LocalString("...");
}
проверочко.. ^_^
+137
printk(KERN_CRIT "AAA\n");
Ебу и патчу.
+137
static const uint32_t frequencies[] = {
#include "frequencies.h"
};
+137
#include <iostream>
template <typename T>
struct Symbol {};
template <>
struct Symbol<int> {
static constexpr const char value = 'd';
};
template <>
struct Symbol<float> {
static constexpr const char value = 'f';
};
template<std::size_t N, typename T>
constexpr bool check_arg_part(const char (&s)[N], size_t i, T d)
{
if (i == N)
return true;
if (i < N - 1) {
if (s[i] == '%') {
if (s[i + 1] != Symbol<T>::value)
return false;
}
}
return check_arg_part(s, i + 1, d);
}
template<std::size_t N, typename T>
constexpr bool check_arg(const char (&s)[N], T d) {
return check_arg_part(s, 0, d);
}
int main(int , char*[]) {
std::boolalpha(std::cout);
constexpr bool r = check_arg("foo is int: %d", 1);
std::cout << "Argument integer is correct: " << r << std::endl;
constexpr bool r1 = check_arg("foo is float: %f", 1.0f);
std::cout << "Argument float is correct: " << r1 << std::endl;
constexpr bool r2 = check_arg("foo is float: %f", 1);
std::cout << "Argument int is correct: " << r2 << std::endl;
return 0;
}
По мотивам http://govnokod.ru/17925:
Функция в compile time проверяет соответствие типов. Работает на clang и почему-то валится на gcc.