- 1
- 2
- 3
appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
allEventsArray=[[NSMutableArray alloc]init];
allEventsArray=appDelegate.eventsArray;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−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>")
//-->
Вывод даты в человеко-понятном формате. Найдено в коде одного украинского МВДшного сайта.
+120
for (; itemList.Parent != null; {
Item parent;
itemList = parent.Parent;
}
)
{
parent = itemList.Parent.Parent.Parent;
list.Add((object) parent);
}
−109
end;
create or replace package body "MUT_TABLE" is
type a_table is table of number index by pls_integer;
position a_table;
empty a_table;
procedure SET_INITIAL_STATE
as
begin
position:=empty;
end SET_INITIAL_STATE;
procedure BEF_TR( ID IN NUMBER, A IN NUMBER)
as
begin
position (ID):= A;
end BEF_TR;
procedure AFT_TR
is
v number;
begin
v:=position.FIRST;
while v is not null loop
update A set
A=1,
B='!!!!!!!!!'
where A = 1;
v:= position.next(v);
end loop;
end AFT_TR;
end "MUT_TABLE";
−111
CREATE TABLE "A"
( "ID" NUMBER,
"A" NUMBER,
"B" VARCHAR2(20),
CONSTRAINT "A_PK" PRIMARY KEY ("ID") ENABLE
)
/
CREATE OR REPLACE TRIGGER "A_2"
AFTER
insert or update on "A"
for each row
begin
mut_table.bef_tr(:NEW.ID,:NEW.A);
end;
/
ALTER TRIGGER "A_2" ENABLE
/
CREATE OR REPLACE TRIGGER "A_3"
AFTER
insert on "A"
declare
b number;
begin
mut_table.aft_tr;
end;
/
ALTER TRIGGER "A_3" ENABLE
/
CREATE OR REPLACE TRIGGER "A_AT"
BEFORE
insert or update on "A"
for each row
declare
v number;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
:NEW.A:=:NEW.A+1;
:NEW.B:='!!!!!!!!!!';
commit;
end;
/
ALTER TRIGGER "A_AT" DISABLE
/
CREATE OR REPLACE TRIGGER "A_I_S"
BEFORE
insert or update on "A"
begin
mut_table.set_initial_state;
end;
/
ALTER TRIGGER "A_I_S" ENABLE
/
CREATE OR REPLACE TRIGGER "A_T1"
BEFORE
insert or update on "A"
for each row
begin
update A set
A = :NEW.A+1,
B = 'was incremented'
where A = :NEW.A;
end;
/
ALTER TRIGGER "A_T1" DISABLE
/
CREATE OR REPLACE TRIGGER "BI_A"
before insert on "A"
for each row
begin
if :NEW."ID" is null then
select "A_SEQ".nextval into :NEW."ID" from dual;
end if;
end;
/
ALTER TRIGGER "BI_A" ENABLE
/
create or replace package MUT_TABLE as
procedure set_initial_state;
procedure bef_tr(ID number,A NUMBER);
procedure aft_tr;