- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
Controller.cs
public ActionResult SomeAction()
{
return View("My message");
}
SomeAction.cshtml
@{
Layout = null;
}
@Html.Raw(string.Format("{0}", Model.ToString()))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+122
Controller.cs
public ActionResult SomeAction()
{
return View("My message");
}
SomeAction.cshtml
@{
Layout = null;
}
@Html.Raw(string.Format("{0}", Model.ToString()))
Да, это ASP.Net MVC
+104
// старый "медленый" код, проверяем размеры по именам файлов (последний параметр):
if((checkFileLimits(_logTimeLimit,_logSizeLimit,_logStartTime,_traceFile1)>0) ||
(checkFileLimits(_logTimeLimit,_logSizeLimit,_logStartTime,_traceFile2)>0) ||
(checkFileLimits(_logTimeLimit,_logSizeLimit,_logStartTime,_traceFile3)>0) ||
(checkFileLimits(_logTimeLimit,_logSizeLimit,_logStartTime,_traceFile) >0) )
// новый "быстрый" код, проверяем размеры по файл хэндлам:
FILE* fp1 = fopen(_traceFile1, "r");
FILE* fp2 = fopen(_traceFile2, "r");
FILE* fp3 = fopen(_traceFile3, "r");
FILE* fp4 = fopen(_traceFile, "r");
if((checkFileLimitsHandle(_logTimeLimit,_logSizeLimit,_logStartTime,fp1)>0) ||
(checkFileLimitsHandle(_logTimeLimit,_logSizeLimit,_logStartTime,fp2)>0) ||
(checkFileLimitsHandle(_logTimeLimit,_logSizeLimit,_logStartTime,fp3)>0) ||
(checkFileLimitsHandle(_logTimeLimit,_logSizeLimit,_logStartTime,fp4) >0) )
setTraceFile(NULL);
fclose(fp1);
fclose(fp2);
fclose(fp3);
fclose(fp4);
наши бенчмаркеры чего-то там тестировали (на NFS!!!) и нашли что некоторые модули/библиотеки используют stat() вместо fstat()/ftell() для определения размера лог/трейс файлов (для ротации этих файлов). stat() берет как параметр не хэндл, а имя файла и поэтому дороже с точки зрения производительности. в особенности на NFS. ну начальник R&D и постановил: все stat()ы заменить на fstat()/ftell(). сказано - сделано. кусок сверху из модуля который пользуется внешней либой для логов и трейсов и у которого доступа к хэндлам нету. но герои не ищут легких путей: открываем файлы, получаем хэндлы, проверяем оптимальным образом размер файлов по хэндлам, закрываем файлы, гатова!
−120
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
stage.addEventListener(KeyboardEvent.KEY_UP, key_up);
//left - 37; up - 38; right - 39; down - 40
var up:Boolean = false ;
var down:Boolean = false;
var left:Boolean = false;
var right:Boolean = false;
function key_down (e:KeyboardEvent):void
{
trace (e.keyCode);
if (e.keyCode == 37 || e.keyCode == 65)
{
left = true;
}
if (e.keyCode == 38 || e.keyCode == 87)
{
up = true;
}
if (e.keyCode == 39 || e.keyCode == 68)
{
right = true;
}
if (e.keyCode == 40 || e.keyCode == 83)
{
down = true;
}
}
function key_up (e:KeyboardEvent):void
{
trace (e.keyCode)
if (e.keyCode == 37 || e.keyCode == 65)
{
left = false;
}
if (e.keyCode == 38 || e.keyCode == 87)
{
up = false;
}
if (e.keyCode == 39 || e.keyCode == 68)
{
right = false;
}
if (e.keyCode == 40 || e.keyCode == 83)
{
down = false;
}
}
addEventListener(Event.ENTER_FRAME, moveHero);
function moveHero (e:Event):void
{
if (left)
{
hero.x --;
}
if (up)
{
hero.y --;
}
if (right)
{
hero.x ++;
}
if (down)
{
hero.y ++;
}
}
}
−112
appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
allEventsArray=[[NSMutableArray alloc]init];
allEventsArray=appDelegate.eventsArray;
внимание, сейчас мы сделаем утечку! плеать, это что, диверсия?
−86
def search_with_city(obj1, obj2, obj3):
print '------------Search by latitude, longitude and city------------'
list1 = []
list_new = []
while True:
line = file_airport.readline().lower()
if obj3 in line:
Str_file = ''.join(line)
List_file2 = Str_file.split(',')
if obj3 in List_file2[7]:
list1.append(List_file2)
for item in list1:
item.append(sqrt((float(item[11]) - float(obj1))**2 + (float(item[12]) - float(obj2))**2))
list_new = sorted(list1, key = lambda x: x[-1], reverse = False)
config = yaml.load(open('findairport.conf'))
outs = config['output']
for List_file in list_new:
if List_file2[3] != List_file[3]:
for out in outs:
out = out % dict(airportcode = str(List_file[0]).upper(), distance = List_file[-1],\
airportname = str(List_file[13]).title(), sa = str(List_file[8]).title(), street = str(List_file[10]).title(),\
city = str(List_file[7]).title(), state = str(List_file[5]).upper(), zip = List_file[3],\
country = str(List_file[2]).upper(), lat = str(List_file[11]), lon = str(List_file[12]+'\n'))
print out
if not line:
break
try:
if not obj1 in line and not obj2 in line and not obj3 in line:
print 'Nothing more is been found'
except:
pass
else:
pass
file_airport.seek(0)
PHP'шники наступают! :)
+145
;
Пример реализации абстрактного класса
https://lh6.googleusercontent.com/-rKfFtpL_K1A/Tuh34-faW_I/AAAAAAAAAi8/B05ygbQKIu8/w402/abstract_class.png
+76
public int RemoveEquals(AtASEData[] ar,int ln) {
if (ln==0) return 0;
int i=1;
int j=0;
while (i<ln) {
if (((Integer)ar[i].inData).intValue()==((Integer)ar[j].inData).intValue())
ar[i].SetRootData(ar[j]); else ar[++j]=ar[i];
i++;
}
return j+1;
}
+980
private string doubleToString(double v)
{
if (v < 0)
return "-" + (-(int)v).ToString() + "." + (-(v - (int)v) * 10000000).ToString("0000000.");
return ((int)v).ToString() + "." + ((v - (int)v) * 10000000).ToString("0000000.");
}
Превращаем double в строку. Разделитель - надо точку, а то "блин, он ставит запятую, SQL-сервер потом это не понимает" (с)
+1002
string Daumants::getReverse()
{
string message = this->data();
char *reverseMessage = new char[this->length()];
for (int i = this->length() - 1, j = 0; i >= 0; i--, j++)
{
reverseMessage[j] = message[i];
}
for (int i = 0; i < this->length(); i++)
{
message[i] = reverseMessage[i];
}
return message;
}
Даумант ХУЙ!
+158
<!--//
calendar = new Date();
day = calendar.getDay();
document.write("<table width=100 border=1><tr><td><center><font size=2>")
if (day == 0) {
document.write("<font color=#ff0000>Воскресенье</font>")
}
if (day == 1) {
document.write("Понедельник")
}
if (day == 2) {
document.write("Вторник")
}
if (day == 3) {
document.write("Среда")
}
if (day == 4) {
document.write("Четверг")
}
if (day == 5) {
document.write("Пятница")
}
if (day == 6) {
document.write("<font color=#ff0000>Суббота</font>")
}
document.write("</font></center></td></tr><tr><td><center><font size=2>")
month = calendar.getMonth();
if (month == 0) {
document.write("Январь")
}
if (month == 1) {
document.write("Февраль")
}
if (month == 2) {
document.write("Март")
}
if (month == 3) {
document.write("Апрель")
}
if (month == 4) {
document.write("Май")
}
if (month == 5) {
document.write("Июнь")
}
if (month == 6) {
document.write("Июль")
}
if (month == 7) {
document.write("Август")
}
if (month == 8) {
document.write("Сентябрь")
}
if (month == 9) {
document.write("Октябрь")
}
if (month == 10) {
document.write("Ноябрь")
}
if (month == 11) {
document.write("Декабрь")
}
document.write("</font></center></td></tr><tr><td><center><font size=6>")
date = calendar.getDate();
document.write(date)
document.write("</font></center></td></tr><tr><td><center><font size=2>")
year = calendar.getYear();
if (year < 100) {
document.write("19" + year + "")
}
else if (year > 1999) {
document.write(year)
}
document.write("</font></center></td></tr></table>")
//-->
Вывод даты в человеко-понятном формате. Найдено в коде одного украинского МВДшного сайта.