- 1
$_SERVER["DOCUMENT_ROOT"] = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))) . '/htdocs';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+158
$_SERVER["DOCUMENT_ROOT"] = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))) . '/htdocs';
+123
public <T extends IOrderSubmitRequest & IApiStoreRef> Order buildOrderFromSubmitRequest(final T request) { ... }
Типы-пересечения для бедных. Нужна была функция, работающая с несколькими классами без общего предка, реализующими сразу два интерфейса.
+159
function get_recaptcha(id)
{
var id;
if(id==1)
{
$.ajax({
type: "POST",
url: "classes/get_captcha.php",
cache: false,
data: "recaptcha=1",
success: function(html)
{
$('#captcha_reg').html(html);
}
});
}
else if (id==2)
{
$.ajax({
type: "POST",
url: "classes/get_captcha.php",
cache: false,
data: "recaptcha=1",
success: function(html)
{
$('#captcha_forget').html(html);
}
});
}
}
История одного проекта.. Часть 3
−396
- (void)isCharityPost: (BOOL)charityPost{
self.charityButton.hidden = charityPost ? NO : YES;
self.cashBadgeButton.hidden = charityPost ? NO : YES;
[self updateCharityButtonWithText:self.charityButton.titleLabel.text];
}
Production-код.
Пунктуация сохранена.
+120
Вот вам всё не нравится wct.. а я могу сказать вам её применение! Wct editor может быть использован для хранения исполняемых файлов в самой программе.
Конечно, есть и другие способы хранить программы в программах, но это - мой способ :)
P.S. Сделал DLL, кому нужен? (Хотя не, что я несу? Никому же не нужен..)
+132
public void Insert(object obj, int id)
{
var a = Convert.ChangeType(obj, Types[id]);
var b = Convert.ChangeType(ObjectSets[id],ObjectSets[id].GetType());
b.GetType().GetMethod("AddObject").Invoke(b,new []{ a });
}
public void Delete(object obj, int id)
{
var a = Convert.ChangeType(obj, Types[id]);
var b = Convert.ChangeType(ObjectSets[id], ObjectSets[id].GetType());
b.GetType().GetMethod("DeleteObject").Invoke(b, new[] { a });
}
Рефлексия и Entity Framework. Продолжение
+135
public JsonResult MusicPlayer(DateTime date)
{
var order = OrdersRepository.FindAll().ToList();
int play = 0;
foreach (var item in order)
{
if (item.Date<=date){
var date2 = date.ToString();
return Json(new { date2});
}
return Json(new { play });
}
return Json(new { play });
}
Отправление данных через Json
+159
$timeout(function(){
$rootScope.presentation_details = {
"name" : $rootScope.presentationDetails.name,
"description" : $rootScope.presentationDetails.description,
"lastUpdatedView" : $rootScope.presentationDetails.lastUpdatedView,
"projectId" : $rootScope.presentationDetails.projectId,
"presentationId" : $rootScope.presentationDetails.presentationId,
"reimbursementRate" : $rootScope.presentationDetails.reimbursementRate,
"isTemplate" : $rootScope.presentationDetails.isTemplate,
"authorId" : $rootScope.presentationDetails.authorId,
"authorName" : $rootScope.presentationDetails.authorName,
"IsNewPresentation" : false,
"gDocsId" : $rootScope.presentationDetails.gDocsId,
"parameters" : {
"widgetURL" : $rootScope.presentationDetails.parameters.widgetURL,
"widgetIFrameUrl" : $rootScope.presentationDetails.parameters.widgetIFrameUrl,
"widgetTextareaContent": $rootScope.presentationDetails.parameters.widgetTextareaContent,
"widgetTotalEGinGasSaved" : $rootScope.presentationDetails.parameters.widgetTotalEGinGasSaved,
"widgetTotalEGinFewerVehicles" : $rootScope.presentationDetails.parameters.widgetTotalEGinFewerVehicles,
"widgetHowDoesSolarWorkStepFourDuration" : $rootScope.presentationDetails.parameters.widgetHowDoesSolarWorkStepFourDuration,
"widgetHowDoesSolarWorkOverallDuration" : $rootScope.presentationDetails.parameters.widgetHowDoesSolarWorkOverallDuration,
"widgetGraphWeather" : $rootScope.presentationDetails.parameters.widgetGraphWeather,
"wIdgetGraphTemperatureChartType" : $rootScope.presentationDetails.parameters.wIdgetGraphTemperatureChartType,
"widgetGraphTemperature" : $rootScope.presentationDetails.parameters.widgetGraphTemperature,
"widgetWeatherType" : $rootScope.presentationDetails.parameters.widgetWeatherType,
"transitionOut" : $rootScope.presentationDetails.parameters.transitionOut,
"transitionIn" : $rootScope.presentationDetails.parameters.transitionIn,
"parametersId" : $rootScope.presentationDetails.parameters.parametersId,
"subheaderFont" : {
"fontId" : $rootScope.presentationDetails.parameters.subheaderFont.fontId,
"size" : $rootScope.presentationDetails.parameters.subheaderFont.size,
"name" : $rootScope.presentationDetails.parameters.subheaderFont.name,
"color" : $rootScope.presentationDetails.parameters.subheaderFont.color,
"visible" : $rootScope.presentationDetails.parameters.subheaderFont.visible,
"label" : $rootScope.presentationDetails.parameters.subheaderFont.label,
"content" : $rootScope.presentationDetails.parameters.subheaderFont.content,
},
"normal2Font" : {
"fontId" : $rootScope.presentationDetails.parameters.normal2Font.fontId,
"size" : $rootScope.presentationDetails.parameters.normal2Font.size,
"name" : $rootScope.presentationDetails.parameters.normal2Font.name,
"color" : $rootScope.presentationDetails.parameters.normal2Font.color,
"visible" : $rootScope.presentationDetails.parameters.normal2Font.visible,
"label" : $rootScope.presentationDetails.parameters.normal2Font.label,
},
"backgroundImage" : $rootScope.presentationDetails.parameters.backgroundImage,
"backgroundImageVisible" : $rootScope.presentationDetails.parameters.backgroundImageVisible,
"backgroundImageLabel" : $rootScope.presentationDetails.parameters.backgroundImageLabel,
"backgroundColor" : $rootScope.presentationDetails.parameters.backgroundColor,
"backgroundColorVisible" : $rootScope.presentationDetails.parameters.backgroundColorVisible,
"backgroundColorLabel" : $rootScope.presentationDetails.parameters.backgroundColorLabel,
"widgetIndex" : $rootScope.presentationDetails.parameters.widgetIndex,
"rowPosition" : $rootScope.presentationDetails.parameters.rowPosition,
"colPosition" : $rootScope.presentationDetails.parameters.colPosition,
"rowCount" : $rootScope.presentationDetails.parameters.rowCount,
"colCount" : $rootScope.presentationDetails.parameters.colCount,
"duration" : $rootScope.presentationDetails.parameters.duration,
"startDate" : $rootScope.presentationDetails.parameters.startDate,
"endDate" : $rootScope.presentationDetails.parameters.endDate,
},
};
}, 10);
Заглянул в код текущего проекта... Зря тимлид не проводит кодревью... У кого есть идеи нахеряки?
+69
"add()\n";
assert((row_indx >= 0 && row_indx <= rows) &&
(col_indx >= 0 && col_indx < cols)
);
if(row_indx == rows)
addRow();
if(init_flag_arr[row_indx][col_indx])
{
std::cout « "in moving\n";
int uninit_i, uninit_j;
bool found = false;
for(int i = row_indx; found == false && i < rows; i++)
for(int j = col_indx; found == false && j < cols; j++)
if(!init_flag_arr[i][j]) // если флаг == false
{
std::cout « "found!\n";
uninit_i = i;
uninit_j = j;
found = true;
}
if(!found)
{
std::cout « "not found!\n";
addRow(); // добовляем новую строку в матрицу (rows++)
uninit_i = rows - 1;
uninit_j = 0;
}
bool exit = false;
for(int i = uninit_i, j = uninit_j; exit == false; i--)
{
for(; ;j--)
{
if(j == col_indx && i == row_indx)
{
exit = true;
break;
}
if(j == 0)
{
matrix[i][j] = matrix[i - 1][cols - 1];
init_flag_arr[i][j] = init_flag_arr[i - 1][cols - 1];
break;
}
matrix[i][j] = matrix[i][j - 1];
init_flag_arr[i][j] = init_flag_arr[i][j - 1];
}
j = cols - 1;
}
}
matrix[row_indx][col_indx] = obj;
init_flag_arr[row_indx][col_indx] = true;
std::cout « "end add()\n";
}
// Для дебага, вывод инициализированных ячеек матрицы
void Matrix::InitTable(std::ostream& os)const // чисто для дебага
{
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
if(!init_flag_arr[i][j])
os « "false\t";
else
os « "true\t";
os « std::endl;
}
}
// Удаление объекта с матрицы
void Matrix::remove(int row_indx, int col_indx)
{
std::cout « "remove()\n";
assert((row_indx >= 0 && row_indx < rows) &&
(col_indx >= 0 && col_indx < cols)
);
matrix[row_indx][col_indx] = 0;
init_flag_arr[row_indx][col_indx] = false;
std::cout « "end remove()\n";
}
void Matrix::removeRow(int row_indx)
{
assert(row_indx >= 0 && row_indx < rows);
int** new_matrix = new int*[rows - 1];
bool** new_init_flag_arr = new bool*[rows];
for(int i = 0; i < rows - 1; i++)
{
new_matrix[i] = new int[cols];
new_init_flag_arr[i] = new bool[cols];
//for(int j = 0; j < cols; j++)
//{
// new_matrix[i][j] = 0;
// new_init_flag_arr[i][j] = false;
//}/
...
+126
GOD BAD DOG GARAGE AGE
;В exe файлы не запихивать в wct editor-е, а то шиндоус пострадает ;-)
Вот такие слова можно составить на системе счисления wct :)
!!! ВНИМАНИЕ !!! В exe файлы не запихивать в wct editor-е, а то шиндоус пострадает ;-)
(ЗЫ: для тех, кто не знает, что такое wct, прошу сюда - vk.com/wct_official, http://wctsite.tk)