- 1
- 2
- 3
- 4
public static bool IsEmpty(this string input)
{
return String.IsNullOrEmpty(input);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+143
public static bool IsEmpty(this string input)
{
return String.IsNullOrEmpty(input);
}
А почему бы и да?
+144
$ git log --pretty=oneline
c8220f95d1b11d2e8a2d57cf4349c40a180bd7f3 Commit 33
6eeac872fa772c2ea1d57faf286f6520fc831777 Commit 32
fba42d3f0a6678e670d477bcc0c56819cafd34f9 Commit 31
4292c5dc9cb9c4360f7ad03b2d5ecabbeb451a55 Commit 30
2ba640394371f0fd44296c41b99fd42f6abfaf95 Commit 29
80aa4d6754e5f82f3b111075747fd74f63e1a26c Commit 28
7f43aa08d9d94e6c09f6435635942010320a824e Commit 27
574524bf2b0dcb8070ce46ced75cec626e7c84ad Commit 26
eb620063a690c489e746e2f5633771da66df0903 Commit 25
...
https://github.com/gikraychik/bets
+142
public function uninstall()
{
if (!Configuration::deleteByName('YC_SHOPID')
|| !Configuration::deleteByName('YC_SCID')
|| !Configuration::deleteByName('YC_SHOPPASSWORD')
|| !!Configuration::deleteByName('YC_ALLOW_YANDEXMONEY')
|| !!Configuration::deleteByName('YC_ALLOW_BANK_CARD')
|| !!Configuration::deleteByName('YC_ALLOW_MOBILE')
|| !!Configuration::deleteByName('YC_ALLOW_TERMINAL')
|| !!Configuration::deleteByName('YC_ALLOW_WEBMONEY')
|| !!Configuration::deleteByName('YC_ALLOW_SBERBANK')
|| !!Configuration::deleteByName('YC_ALLOW_MPOS')
|| !!Configuration::deleteByName('YC_DEMO_MODE')
|| !parent::uninstall())
return false;
return true;
}
https://github.com/anisimow/yacassa/blob/master/yacassa/yacassa.php#L64
−119
def has_children_pages(id)
unless Page.where(:parent_id => id, :public => true).blank?
return true
end
return false
end
мне сказали, что этот проект php-шники писали
+144
// Класс валидации в PrestaShop
class ValidateCore
{
...
public static function isIp2Long($ip)
{
return preg_match('#^-?[0-9]+$#', (string)$ip);
}
public static function isAnything()
{
return true;
}
...
+141
string log;
...
try
{
Logger.SaveLog(fullPath, log);
}
catch (Exception ex)
{
Logger.SaveLog(fullPath, ex.ToString());
}
Senior developer...
−85
local sol_lines = {}
local i = 1; local j = 0;
while (i <= solution:len()) do
local begin_pos = i
while(i <= solution:len() and solution:sub(i, i) ~= '\n') do
i = i + 1
end
if i > solution:len() then
i = solution:len()
end
local cur_line = solution:sub(begin_pos, i)
sol_lines[j] = trim(cur_line)
i = i + 1
j = j + 1
end
Lua
Как я разбивал строку на отдельные линии. Вместо того, чтобы использовать string.find(s, "\n", i + 1). Так я писал код 0.027397 года назад назад.
+142
public void AllocateMemory(ref int[] segmentSizeProcess)
{
int[] difference;
int j = 0;
int tempo = 0;
for (int i = 0; i < segmentSizeProcess.Count(); i++)
{
difference = new int[memory.Count]; // храним разность размера блока памяти и требуемого размера для процесса
for (int count = 0; count < memory.Count; count++)
{
difference[count] = -2; // предварительно инициализируем
}
for (int count_memory=0; count_memory<memory.Count();
count_memory++)
{
if (memory[count_memory].size - segmentSizeProcess[i] >= 0) // если равно 0, значит
// сегмент полностью распределён
{
if (!memory[count_memory].isAllocate)
{ difference[count_memory] = memory[count_memory].size - segmentSizeProcess[i]; }
else
{ difference[count_memory] = -1; } // если сегмент занят -
// то он недоступен
}
}
tempo = GetMinDifference(ref difference); // получаем индекс минимальной разности
// если результат "-", значит секторы заняты, выходим из цикла
if (difference[tempo] >= 0)
{
memory.ElementAt(tempo).isAllocate = true; // процесс занял сегмент
if (difference[tempo] > 0) // если остаётся фрагмент памяти
{
CreateDifferenceSegment(difference[tempo]); // создаем новый сегмент, равный
// наименьшей разности памяти сегмента и памяти для процесса
}
memory[tempo].size = segmentSizeProcess[i]; // распределяем память
}
else
{
break;
}
}
}
Примерная реализация алгоритма best-fit
+142
orders_list_app.constant('User', {
auth : ('False' == 'True') ? true : false,
contractor : ('' == 'True') ? true : false,
user_id : ('False' == 'True') ? None : false
});
// goes in another place
angular.forEach(rootCategory.categories, function(category_2){
angular.forEach(category_2.service_orders, function(service_2){
rootCategory.service_orders.push(service_2);
angular.forEach(category_2.categories, function(category_3){
angular.forEach(category_3.service_orders, function(service_3){
rootCategory.service_orders.push(service_3);
});
});
});
});
rootCategory.service_orders.push({name:"Другие услуги" ,text: "", title: "Другие услуги"});
});
На одном из отечественном сайте в продакшыне..
+144
public String tommorowCalendarCountry(String date, String country){
String tommorowCountry = null;
if(date.equals(getTommorow())){
tommorowCountry = country;
}
return tommorowCountry;
}
public String tommorowCalendarIndicator(String date, String indicator){
String tommorowIndicator = null;
if(date.equals(getTommorow())){
tommorowIndicator = indicator;
}
return tommorowIndicator;
}
public String tommorowCalendarImportance(String date, String importance){
String tommorowImportance = null;
if(date.equals(getTommorow())){
tommorowImportance = importance;
}
return tommorowImportance;
}
public String tommorowCalendarForecast(String date, String forecast){
String tommorowForecast = null;
if(date.equals(getTommorow())){
tommorowForecast = forecast;
}
return tommorowForecast;
}
public String tommorowCalendarPrevious(String date, String previous){
String tommorowPrevious = null;
if(date.equals(getTommorow())){
tommorowPrevious = previous;
}
return tommorowPrevious;
}
public String tommorowCalendarActual(String date, String actual){
String tommorowActual = null;
if(date.equals(getTommorow())){
tommorowActual = actual;
}
return tommorowActual;
}
public String tommorowCalendarDescription(String date, String description){
String tommorowDescription = null;
if(date.equals(getTommorow())){
tommorowDescription = description;
}
return tommorowDescription;
}
public String tommorowCalendarPeriod(String date, String period){
String tommorowPeriod = null;
if(date.equals(getTommorow())){
tommorowPeriod = period;
}
return tommorowPeriod;
}
public String tommorowCalendarLocation(String date, String location){
String tommorowLocation = null;
if(date.equals(getTommorow())){
tommorowLocation = location;
}
return tommorowLocation;
}
пришло с аутсорса. Такого в проекте очень много)