- 1
- 2
- 3
- 4
- 5
- 6
public static String hello()
{
String s = "";
s += "Добро пожаловать на наш сайт.";
return s;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+86
public static String hello()
{
String s = "";
s += "Добро пожаловать на наш сайт.";
return s;
}
+163
// Checks if the passed input's value is nothing.
function isEmptyText(theField)
{
// Copy the value so changes can be made..
var theValue = theField.value;
// Strip whitespace off the left side.
while (theValue.length > 0 && (theValue.charAt(0) == ' ' || theValue.charAt(0) == '\t'))
theValue = theValue.substring(1, theValue.length);
// Strip whitespace off the right side.
while (theValue.length > 0 && (theValue.charAt(theValue.length - 1) == ' ' || theValue.charAt(theValue.length - 1) == '\t'))
theValue = theValue.substring(0, theValue.length - 1);
if (theValue == '')
return true;
else
return false;
}
...
function in_array(variable, theArray)
{
for (var i in theArray)
if (theArray == variable)
return true;
return false;
}
+125
protected string getUpdateNotesDE(string fieldNameAlias, string fieldName, string fieldValue, ASPxDateEdit newValue)
{
if (isSaveField("fieldName"))
{
if (fieldValue != "")
return "Field " + locCom.getFieldAlias("payTFNDeclaredOn") + ", Old Value = " + Convert.ToDateTime(fieldValue).ToString("dd/MM/yyyy") + ", New Value = " + Convert.ToDateTime(newValue.Text).ToString("dd/MM/yyyy") + " ; ";
else
if (newValue.Text != "")
return "Field " + locCom.getFieldAlias("payTFNDeclaredOn") + ", Old Value = , New Value = " + Convert.ToDateTime(newValue.Text).ToString("dd/MM/yyyy") + " ; ";
}
return "";
}
protected Boolean isSaveField(string fieldName)
{
if (locCom.getVisible(fieldName))
return true;
return false;
}
public bool getVisible(string fldName)
{
Boolean showall = Convert.ToBoolean(System.Web.Configuration.WebConfigurationManager.AppSettings.Get("Show-all-fields"));
if (showall) return true;
if (fldAccess.Tables.Count == 0) return false;
foreach (System.Data.DataRow item in fldAccess.Tables[0].Rows)
{
if (item["fieldname"].ToString().Replace('@', 'a').Replace("%", "percent").Replace("$", "dollar").ToLower() == fldName.ToLower())
return Convert.ToBoolean(item["visible"]);
}
return false;
}
особенно доставляет
protected string getUpdateNotesDE(string fieldName){
if (isSaveField( !!! "fieldName" !!!)){}
}
+162
public function save() {
try {
try {
$this->create();
} catch (Exception $e) {
//probably dulplicate
$this->update();
}
} catch (Exception $e) {
logger::error($e);
}
}
try-catch много не бывает
+129
public void ReadFromFile()
{
LoadIntervals = new TimeIntervals(Color.Black);
StreamReader tReader = null;
tReader = File.OpenText("DefaultIntervals");
string income = null;
while ((income = tReader.ReadLine()) != null)
{
// string income = tReader.ReadLine();
string colorR = null; string colorG = null; string colorB = null; string colorA = null; string interval = null;
int i = 0;
for (i = 4; i < income.Length; i++)
{
if (income[i] != ',')
{
interval += income[i];
}
else { break; }
}
for (int a = i + 10; a < income.Length; a++)
{
if (income[a] != ',')
{
colorA += income[a];
}
else
{
for (int r = a + 4; r < income.Length; r++)
{
if (income[r] != ',')
{
colorR += income[r];
}
else
{
for (int g = r + 4; g < income.Length; g++)
if (income[g] != ',')
{
colorG += income[g];
}
else
{
for (int b = g + 4; b < income.Length; b++)
if (income[b] != ',')
{
if (income[b] != ']')
colorB += income[b];
}
else
{
break;
}
break;
}
break;
}
}
break;
}
}
TimePoint tp = new TimePoint(Convert.ToDouble(interval), Color.FromArgb(Convert.ToInt32(colorA), Color.FromArgb(Convert.ToInt32(colorR), Convert.ToInt32(colorG), Convert.ToInt32(colorB))));
LoadIntervals.Add(tp);
}
tReader.Close();
Intervals = LoadIntervals;
}
Так мы парсим файл конфигов вида. (Формат придуман автором кода)
Int=3,Color [A=223, R=253, G=4, B=38]
Int=10,Color [A=255, R=86, G=86, B=185]
Int=20,Color [A=200, R=255, G=215, B=0]
Int=50,Color [A=200, R=255, G=165, B=0]
+85
boolean ROLLBACK = new Boolean(false).booleanValue();
И это пишет тимлид (сеньор) в моей конторе
+157
function date_preobr($date, $ind=0) {
$date1=substr($date, 8, 2); $date21=substr($date, 5, 2); $date3=substr($date, 0, 4);
if ($ind==0) $data=$date1.".".$date21.".".$date3;
elseif ($ind==1) $data=$date1.".".$date21.".".substr($date3, 2, strlen($date3)-2);
elseif ($ind==2) {switch ($date21) {case "01":$date21="января";break;case "02":$date21="февраля";break;
case "03":$date21="марта";break;case "04":$date21="апреля";break;case "05":$date21="мая";break;
case "06":$date21="июня";break;case "07":$date21="июля";break;case "08":$date21="августа";break;
case "09":$date21="сентября";break;case "10":$date21="октября";break;case "11":$date21="ноября";break;
case "12":$date21="декабря";break;} $data=$date1." ".$date21." ".$date3;}
return $data;}
Были даты, есть дата, будут даты.
Привожу в первозданном виде.
+128
if (body.ToLower().Contains("pr") ||
subject.Contains("PM") ||
subject.Contains("pm") ||
subject.Contains("Pm") ||
subject.Contains("pM") ||
subject.Contains("PMR") ||
subject.Contains("prs") ||
subject.ToLower().Contains("prt") ||
subject.ToLower().Contains("prm") ||
subject.ToLower().Contains("pmt") ||
subject.ToLower().Contains("pmk") ||
subject.ToLower().Contains("pml") ||
subject.ToLower().Contains("pal"))
{
result = true;
}
Пишут друзья из Норвегии
+70
import java.util.Random;
public class A {
public static void main(String args[]) {
int minimalSuccessTime = Integer.MAX_VALUE;
int maximalSuccessTime = Integer.MIN_VALUE;
for(int i = 0; i < 10000; i++) {
Random rnd = new Random();
boolean state = rnd.nextBoolean();
final byte prisonersCount = 100;
boolean prisoners[] = new boolean[prisonersCount];
byte prisonersCounted = 1;
int daysPassed = 0;
while(true) {
daysPassed++;
int tmp = rnd.nextInt(prisonersCount);
if(tmp == 0) {
if(state) {
state = false;
prisonersCounted++;
if(prisonersCounted == prisonersCount) {
break;
}
}
} else {
if(!state && !prisoners[tmp]) {
state = true;
prisoners[tmp] = true;
}
}
}
if(daysPassed < minimalSuccessTime) {
minimalSuccessTime = daysPassed;
}
if(daysPassed > maximalSuccessTime) {
maximalSuccessTime = daysPassed;
}
}
System.out.println("Minimal success time ~= " + minimalSuccessTime/365 + " years!");
System.out.println("Maximal success time ~= " + maximalSuccessTime/365 + " years!");
}
}
One hundred prisoners have been newly ushered into prison. The warden tells
them that starting tomorrow, each of them will be placed in an isolated cell,
unable to communicate amongst each other. Each day, the warden will choose
one of the prisoners uniformly at random with replacement, and place him in
a central interrogation room containing only a light bulb with a toggle switch.
The prisoner will be able to observe the current state of the light bulb. If he
wishes, he can toggle the light bulb. He also has the option of announcing that
he believes all prisoners have visited the interrogation room at some point in
time. If this announcement is true, then all prisoners are set free, but if it is
false, all prisoners are executed.
The warden leaves, and the prisoners huddle together to discuss their fate.
Can they agree on a protocol that will guarantee their freedom?
+92
public Boolean checkPermission(String login) {
if (login == null && login.trim().length() == 0)
throw new Exception("Не указан логин пользователя.");
/* ... */
}
Чудесное условие. Есть в этом Exception что-то неуловимое - его никто никогда не поймает.