- 1
- 2
- 3
- 4
jQuery(document).ready(function() {
var this = jQuery(this);
this.someMethod();
});
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+150
jQuery(document).ready(function() {
var this = jQuery(this);
this.someMethod();
});
"Почему-то не работает..."
+51
#include<iostream>
#include<istream>
#include<fstream>
#include<string>
using namespace std;
const int con=100;
const int MAX=3;
class movie
{
public:
string title;
string genre;
string country;
int year;
double gainings;
};
int main(); {
{
string* argv = new string[10]={ "Star wars", "Harry Potter" , "Lion king", "Lord of the rings" , "Evgozavur", "Cow's house" , "Snow dogs", "Ice age" , "Shrek", "Dino"};
int n=1,gainigs=10;
int a,b,c;
movie film1;
movie film2;
movie film3;
cout << " Enter the title:"<<endl;
cin>>film1.title;
cout << " Enter the genre:"<<endl;
cin>>film1.genre;
cout << " Enter the country:"<<endl;
cin>>film1.dev;
cout << " Enter the year:"<<endl;
cin>>film1.year;
cout << " Enter the gainings:"<<endl;
cin>>a;
while (a>10){
cout << " Enter the gainings:"<<endl;
cin>>a;
}film1.gainings=a;
cout<<endl<<endl<<endl;
cout<<" Enter the title:"<<endl;
cin>>film2.title;
cout<<" Enter the genre:"<<endl;
cin>>film2.genre;
cout<<" Enter the dev:"<<endl;
cin>>film2.dev;
cout<< " Enter the year:"<<endl;
cin >> film2.year;
cout<<" Enter the gainings:"<<endl;
cin>>b;
while (b>10){
cout<<" Enter the gainings:"<<endl;
cin>>b;
}game2.gainings=b;
cout<<endl<<endl<<endl;
cout<<" Enter the title:"<<endl;
cin>>film3.title;
cout<<" Enter the genre:"<<endl;
cin>>film3.genre;
cout<<" Enter the dev:"<<endl;
cin>>film3.dev;
cout<<" Enter the year:"<<endl;
cin>>film3.year;
cout<<" Enter the gainings:"<<endl;
cin>>c;
while (c>10){
cout<<" Enter the gainings:"<<endl;
cin>>c;
}film3.gainings=c;
for (int j=0; j<n; j++)
{
cout<<""<<endl;
cout<<"Title: " <<film1.title<<endl;
cout<<"Genre: " <<film1.genre<<endl;
cout<<"Year: " <<film1.year<<endl;
cout<<"Gainings: "<<film1.gainings<<endl;
cout<<""<<endl;
cout<< "Title: "<<film2.title<<endl;
cout<< "Genre: "<<film2.genre<<endl;
cout<< "Year: "<<film2.year<<endl;
cout<< "Gainings: " << film2.gainings<<endl;
cout<<""<<endl;
cout<<"Title: " <<film3.title <<endl;
cout<<"Genre: " <<film3.genre <<endl;
cout<<"Year: " <<film3.year <<endl;
cout<<"Gainings: "<<film3.Gainings<<endl;
cout<<"works"<<endl;
}
cout<<"printing works"<<endl;
argv[0]=film1.title;
argv[1]=film1.genre;
argv[2]=film1.year;
argv[3]=film1.gainings;
cout<<"adding works"<<endl;
cout<<endl<<endl<<endl;
cout<<argv[0]<<endl;
cout<<argv[1]<<endl;cout<<argv[2]<<endl;cout<<argv[3]<<endl;
cout<<"print after add works"<<endl;
system("pause");
return 0;
}
Из http://forums.bgdev.org/index.php?showtopic=43872
+136
private AseConnection con;
public void CloseConnection()
{
if (this.con != null && this.con.State == ConnectionState.Open)
{
CloseConnection(this.con);
}
}
public void CloseConnection(AseConnection con)
{
if (con == null)
return;
if (con.State == ConnectionState.Closed)
return;
con.Close();
}
А кому ещё враппэровъ? У меня много ихъ!
+150
var valid = !!files.length;
Fileupload (c)
−122
ObjectUtils.deleteFromDictionary(showTweens, slideView);
Для тех, кто не в курсе:
delete dictionary[key];
+127
#define SOME_MACRO_NAME 4 /* 1 */
−168
-- Процедура формирования таблицы анализа по FIR
CREATE PROCEDURE KojevnikovFir
@DateFo varchar(10),
@DateTo varchar(10)
AS DECLARE @Polet int, @ProcPolet numeric(4,2)
-- определяю кол-во выполненных рейсов в диапазоне дат----
SET @Polet = (SELECT DISTINCT Count(ID) FROM PPLS WHERE
( ( FLI_ENTRY=1 or FLI_EXIT=1 ) or (DEP=1 and DEP_AERODROME like'UK%' ) or
(ARR=1 and DEST_AERODROME Like'UK%') ) and (ENTRY_TIME >=@DateFo and ENTRY_TIME <=@DateTo))
----------- Начало формирования таблицы FIR-------------------
-- Создаем SCROLL курсор 1 для чтения
DECLARE Cursor_All_Pol CURSOR SCROLL KEYSET TYPE_WARNING FOR SELECT Marsrut,All_Polet
FROM Marsr_All_Pol FOR READ ONLY
-- Открытие курсора 1 и наполнение его данными
OPEN Cursor_All_Pol DECLARE @Marsrut char(11), @All_Polet int,@Count1 int,@Count1_end int
SET @Count1=1 SET @Count1_end = @@CURSOR_ROWS
-- ===========обьявляю и заполняю курсор по 2 таблице==============
DECLARE Cursor_Air CURSOR SCROLL KEYSET TYPE_WARNING
FOR SELECT Marsrut,TYPE_AIRCRAFT,kol_TypeAir FROM Marsr_kol_Air FOR READ ONLY
-- Открытие курсора 2 и наполнение его данными
OPEN Cursor_Air
DECLARE @MarsrutAir char(11),@Type nvarchar(4), @Air_Polet int,@Count2 int,@Count2_end int
SET @Count2 = 0 SET @Count2_end = @@CURSOR_ROWS
-- ===========обьявляю и заполняю курсор по 3 таблице==============
DECLARE Cursor_AK CURSOR SCROLL KEYSET TYPE_WARNING
FOR SELECT Marsrut,ICAO,AK,kol_AK FROM dbo.Marsr_kol_AK FOR READ ONLY
-- Открытие курсора 2 и наполнение его данными
OPEN Cursor_AK
DECLARE @MarsrutAK char(11),@ICAO char(3),@AK varchar(60),@kol_AK int,@Count3 int,@Count3_end int
SET @Count3 = 0 SET @Count3_end = @@CURSOR_ROWS
-- цикл по первому курсору
WHILE @Count1 < @Count1_end BEGIN
-- на 1 запись курсора 1
FETCH NEXT FROM Cursor_All_Pol INTO @Marsrut, @All_Polet
-- вставляю строку маршрута и кол-ва полетов в таблицу
SET @ProcPolet = ((@All_Polet * 100)/@Polet)
INSERT KojevnikovAnalizFIR (Marsrut,All_Polet,PrcAll,TYPE_AIRCRAFT,kol_TypeAir,ICAO,AK,kol_AK)
VALUES (@Marsrut,@All_Polet,@ProcPolet,null,null,null,null,null)
SET @Count1 = @Count1 + 1
-- цикл по второму курсору
FETCH FIRST FROM Cursor_Air INTO @MarsrutAir,@Type,@Air_Polet
SET @Count2 = 1
-- Формирую 1 строку маршрут + ВС
IF @Marsrut = @MarsrutAir BEGIN
INSERT KojevnikovAnalizFIR (Marsrut,All_Polet,PrcAll,TYPE_AIRCRAFT,kol_TypeAir,ICAO,AK,kol_AK)
VALUES (null,null,null,@Type,@Air_Polet,null,null,null)
END --IF
WHILE @Count2 < @Count2_end BEGIN
-- увеличиваю счетчик курсора 2
FETCH NEXT FROM Cursor_Air INTO @MarsrutAir,@Type,@Air_Polet
-- Формирую строку маршрут + ВС
IF @Marsrut = @MarsrutAir BEGIN
INSERT KojevnikovAnalizFIR (Marsrut,All_Polet,PrcAll,TYPE_AIRCRAFT,kol_TypeAir,ICAO,AK,kol_AK)
VALUES (null,null,null,@Type,@Air_Polet,null,null,null)
END --IF
-- закрываю цикл WHILE 2 (второй курсор)
SET @Count2 = @Count2 + 1
END
-- цикл по третьему курсору
FETCH FIRST FROM Cursor_AK INTO @MarsrutAK,@ICAO,@AK,@kol_AK
SET @Count3 = 1
-- Формирую 1 строку маршрут + АК
IF @Marsrut = @MarsrutAK BEGIN
INSERT KojevnikovAnalizFIR (Marsrut,All_Polet,PrcAll,TYPE_AIRCRAFT,kol_TypeAir,ICAO,AK,kol_AK)
VALUES (null,null,null,null,null,@ICAO,@AK,@kol_AK)
END --IF
WHILE @Count3 < @Count3_end BEGIN
-- увеличиваю счетчик курсора 3
FETCH NEXT FROM Cursor_AK INTO @MarsrutAK,@ICAO,@AK,@kol_AK
-- Формирую строку маршрут + ВС
IF @Marsrut = @MarsrutAK BEGIN
INSERT KojevnikovAnalizFIR (Marsrut,All_Polet,PrcAll,TYPE_AIRCRAFT,kol_TypeAir,ICAO,AK,kol_AK)
VALUES (null,null,null,null,null,@ICAO,@AK,@kol_AK)
END --IF
-- закрываю цикл WHILE 2 (второй курсор)
SET @Count3 = @Count3 + 1
END
-- закрываю цикл WHILE 1 (первый курсор)
END
-- Закрываю курсор 2
CLOSE Cursor_Air
-- Удаляю курсор 1 как обьект
DEALLOCATE Cursor_Air
-- Закрываю курсор 3
CLOSE Cursor_AK
-- Удаляю курсор 1 как обьект
DEALLOCATE Cursor_AK
-- Закрываю курсор
CLOSE Cursor_All_Pol
-- Удаляю курсор 1 как обьект
DEALLOCATE Cursor_All_Pol
------------Конец--------------------
GO
select * from KojevnikovAnalizFIR
truncate table dbo.KojevnikovAnalizFIR
DELETE from KojevnikovAnalizFIR
exec dbo.KojevnikovFir '2004-01-01','2004-01-05'
курсор головного мозга 2.1
+136
//...
float a = 7;
printf("%d", *(unsigned int *)(&a) >> 23);
// Что напечатает?
//...
На экзамене как-то задали такой вопрос. А ну-ка, кто без компилятора ответит?
+59
#ifndef PORT_H_
#define PORT_H_
#define MAKE_PORT(portName, ddrName, pinName, className, ID) \
class className{\
public:\
typedef uint8_t DataT; /* Alias for the type of data port*/\
private:\
static volatile DataT &data()\
{\
return portName;\
}\
static volatile DataT &dir()\
{\
return ddrName;\
}\
static volatile DataT &pin()\
{\
return pinName;\
}\
public:\
static void Write(DataT value) /*Write value to port PORT = value*/\
{\
data() = value;\
}\
static void ClearAndSet(DataT clearMask, DataT value) /*Clear by mask and set PORT = (PORT & ~clearMask) | value */\
{\
data() = (data() & ~clearMask) | value;\
}\
static DataT Read() /*Read the value written to the port*/\
{\
return data();\
}\
static void DirWrite(DataT value)/*Record the value of the direction of the lines I/O */\
{\
dir() = value;\
}\
static DataT DirRead() /*Read the value of the direction of the lines I/O */\
{\
return dir();\
}\
static void Set(DataT value) /*Set bits in the port PORT |= value;*/\
{\
data() |= value;\
}\
static void Clear(DataT value) /*Clear bits in the port PORT &= ~value;*/\
{\
data() &= ~value;\
}\
static void Togle(DataT value) /*Switch bits PORT ^= value;*/\
{\
data() ^= value;\
}\
static void DirSet(DataT value) /*Set direction bits*/\
{\
dir() |= value;\
}\
static void DirClear(DataT value) /*Clear direction bits*/\
{\
dir() &= ~value;\
}\
static void DirTogle(DataT value)\
{\
dir() ^= value;\
}\
static DataT PinRead()\
{\
return pin();\
}\
enum{Id = ID};\
enum{Width=sizeof(DataT)*8};/*Bit depth*/\
};
#ifdef PORTA
MAKE_PORT(PORTA, DDRA, PINA, Porta, 'A');
#endif
#ifdef PORTB
MAKE_PORT(PORTB, DDRB, PINB, Portb, 'B');
#endif
#ifdef PORTC
MAKE_PORT(PORTC, DDRC, PINC, Portc, 'C');
#endif
#ifdef PORTD
MAKE_PORT(PORTD, DDRD, PIND, Portd, 'D');
#endif
#endif /* PORT_H_ */
Использование СИ++ в микроконтроллерах доставляет....
+115
for (int i = 0; i < 40; i++)
{
GC.Collect();
}
чтоб наверняка :))