- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
int getObjectsCount() const { ... }
...
void restoreObjects()
{
...
const unsigned int objectsCount = restoreInt();
assert(objectsCount == objects.getObjectsCount());
...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+59
int getObjectsCount() const { ... }
...
void restoreObjects()
{
...
const unsigned int objectsCount = restoreInt();
assert(objectsCount == objects.getObjectsCount());
...
}
Ансайнд, туда и обратно
+137
for (i = 1; i < argc; i++) {
p = argv[i];
if ((*p != '-') && (*p != '/'))
{
printf("Unknown option %s\n", p);
return 1;
}
p++;
if (strncmp(p, "pcir=", 5) == 0)
{
sscanf(p+5, "%lli", &pci_raddr);
opt |= 1;
}
if (strncmp(p, "pciw=", 5) == 0)
{
sscanf(p+5, "%lli", &pci_waddr);
opt |= 2;
}
if (strncmp(p, "rwlen=", 6) == 0)
sscanf(p+6, "%i", &rwlen);
if (strncmp(p, "count=", 6) == 0)
sscanf(p+6, "%i", &count);
if (strncmp(p, "ch=", 3) == 0)
channel = p+3;
if (strncmp(p, "poll", 4) == 0)
poll = 1;
if (strncmp(p, "fpga_read=", 10) == 0)
{
sscanf(p+10, "%i", &offset);
fpga_read_flag = 1;
}
if (strncmp(p, "fpga_write=", 11) == 0)
{
sscanf(p+11, "%i", &offset);
fpga_write_flag = 1;
}
if (strncmp(p, "data=", 5) == 0)
{
sscanf(p+5, "%i", &data);
data_valid = 1;
}
if (strncmp(p, "dump_to_file=", 13) == 0)
{
filename = p+13;
dump_to_file = 1;
}
if (strncmp(p, "loadnios", 8) == 0)
{
filename = p+8;
load_nios = 1;
}
if (strncmp(p, "DUMP", 4) == 0) // -DUMP
dump = 1;
if (strncmp(p, "flash_read", 10) == 0) // -flash_read
{
flash_read_flag = 1;
}
if (strncmp(p, "file_to_flash", 13) == 0) // -file_to_flash
file_to_flash = 1;
if (strncmp(p, "file=", 5) == 0) // -file
{
fname = p+5;
}
if (strncmp(p, "base=", 5) == 0) // -base
{
sscanf(p+5, "%i", &base);
basevalid = 1;
}
if (strncmp(p, "card=", 5) == 0) // -crd
sscanf(p+5, "%i", &card);
if (strncmp(p, "ver", 3) == 0)
ver = 1;
if (strncmp(p, "dev=", 4) == 0) // -deм
dev = p+4;
}
"А я напишу свой собственный комманд лайн парсер, с хуитой и говном"
+157
var times, source_date,
date = "20.11.2014";
if (date) {
times = date.split('.');
source_date = new Date();
source_date.setFullYear(parseInt(times[2]));
source_date.setMonth(parseInt(times[1]) - 1);
source_date.setDate(parseInt(times[0]));
}
return source_date ;
+166
public function isRequisitesCorrect()
{
switch (true) {
case $this->isRequisitesSigned() :
return true;
default:
return false;
}
}
−117
def onRefreshReaders( self, event ):
#try:
self.readersListBox.Clear()
readers = self.burner.getReaders()
if isinstance(readers,BaseException):
raise BaseException("Can't find burner app!")
self.readersListBox.AppendItems( readers)
self.readersListBox.SetSelection( 0 )
#except OSError as e:
#wx.MessageBox("Signer cant be empty!\n", "Error",wx.OK | wx.ICON_ERROR)
qj,fysqhjn
+58
#include "stdafx.h"
#define n 3
void PrintMatrix(vector<vector<float> >imatrix)
{
for (size_t i = 0; i < n; ++i)
{
cout << endl;
for (size_t j = 0; j < n; ++j)
{
cout.precision(3);
cout << " " << imatrix[i][j];
}
}
}
void ReverseMatrix(vector<vector<float> >imatrix, float determ)
{
float t = 0;
for (size_t i = 0; i < n; i++)
{
for (size_t j = 0; j < n; j++)
{
t = imatrix[i][j] * (1 / determ);
imatrix[i][j] = t;
}
}
PrintMatrix(imatrix);
}
void TransposedMatrix(vector<vector<float> >imatrix, float determ)
{
float t = 0;
for (size_t i = 0; i < n; i++)
{
for (size_t j = i; j < n; j++)
{
t = imatrix[i][j];
imatrix[i][j] = imatrix[j][i];
imatrix[j][i] = t;
}
}
ReverseMatrix(imatrix, determ);
}
void MinorMatrix(vector<vector<float> >imatrix, float determ)
{
vector<vector<float> >imatrix2(n);
float t = 0.0;
for (size_t i = 0; i < n; ++i)
{
imatrix2[i].resize(n);
for (size_t j = 0; j < n; ++j)
{
if (i == 0)
{
switch (j){
case 0: imatrix2[i][j] = imatrix[i + 1][j + 1] * imatrix[i + 2][j + 2] - imatrix[i + 1][j + 2] * imatrix[i + 2][j + 1]; t = imatrix2[i][j];break;
case 1: imatrix2[i][j] = (imatrix[i + 1][j - 1] * imatrix[i + 2][j + 1] - imatrix[i + 2][j - 1] * imatrix[i + 1][j + 1]) * (-1); t = imatrix[i][j]; break;
case 2: imatrix2[i][j] = imatrix[i + 1][j - 2] * imatrix[i + 2][j - 1] - imatrix[i + 1][j - 1] * imatrix[i + 2][j - 2];t = imatrix2[i][j];break;
}
}
if (i == 1)
{
switch (j){
case 0: imatrix2[i][j] = (imatrix[i - 1][j + 1] * imatrix[i + 1][j + 2] - imatrix[i - 1][j + 2] * imatrix[i + 1][j + 1]) * (-1);t = imatrix2[i][j];break;
case 1:imatrix2[i][j] = imatrix[i - 1][j - 1] * imatrix[i + 1][j + 1] - imatrix[i - 1][j + 1] * imatrix[i + 1][j - 1];t = imatrix2[i][j];break;
case 2:imatrix2[i][j] = (imatrix[i - 1][j - 2] * imatrix[i + 1][j - 1] - imatrix[i - 1][j - 1] * imatrix[i + 1][j - 2]) * (-1);t = imatrix2[i][j];break;
}
}
if (i == 2)
{
switch (j){
case 0: imatrix2[i][j] = imatrix[i - 2][j + 1] * imatrix[i - 1][j + 2] - imatrix[i - 1][j + 1] * imatrix[i - 2][j + 2];t = imatrix2[i][j];break;
case 1:imatrix2[i][j] = (imatrix[i - 2][j - 1] * imatrix[i - 1][j + 1] - imatrix[i - 1][j - 1] * imatrix[i - 2][j + 1]) * (-1);t = imatrix2[i][j];break;
case 2: imatrix2[i][j] = imatrix[i - 2][j - 2] * imatrix[i - 1][j - 1] - imatrix[i - 2][j - 1] * imatrix[i - 1][j - 2];t = imatrix2[i][j];break;
}
}
}
}
imatrix.clear();
TransposedMatrix(imatrix2, determ);
}
void FindDeterminant(vector<vector<float> >imatrix)
{
float determ = imatrix[0][0] * imatrix[1][1] * imatrix[2][2] + imatrix[2][0] * imatrix[0][1] * imatrix[1][2] + imatrix[1][0] * imatrix[2][1] * imatrix[0][2] - imatrix[2][0] * imatrix[1][1] * imatrix[0][2] - imatrix[0][0] * imatrix[2][1] * imatrix[1][2] - imatrix[1][0] * imatrix[0][1] * imatrix[2][2];
if (determ == 0)
{
cout << "Determinant = 0 ==> Reverse matrix doesn't exist";
system("pause");
exit(0);
}
MinorMatrix(imatrix, determ);
}
Вот таких студентов учить приходится. От оно как матрицы 3*3 инвертируют.
Больше лучей ненависти тут:
https://github.com/PLaGInc/Lab1/issues/3
+129
for(const auto & row : table; const auto & element : row) {
handle(element);
}
// versus
for(const auto & row : table) {
for(const auto & element : row) {
handle(element);
}
}
Всякого ненужного говна в новые крестостандарты насовали, а о простых вещах не подумали. Ну ведь удобней же было бы!
Но не-ет, нам нужна функциональщина в крестах, ведь нам мало мозгоклюйства с другими языками; а давайте засунем в стандартную библиотеку либкайро, чтобы разработчики стандартных библиотек соревновались, кто быстрее запилит частичную поддержку в 95% случаев ненужной либы полутра операционными системами, куда-ах-тах-тах!
Забавно, только что узнал, что в vs2013 есть шорткат ^ko, который переключает между заголовком и реализацией. ^ko^ko^ko
+141
int fpga_read(char *dev, unsigned int base_addr, unsigned int offset, int len, unsigned char *buf)
{
unsigned long long pci_raddr;
int actual;
FILE *fi;
fi = fopen(dev, "r");
if (fi == NULL) {
printf("Failed to read from FPGA - Error opening device\n");
return 1;
}
pci_raddr = (unsigned long long) 2 << 32 | (base_addr + offset);
setvbuf(fi, NULL, _IONBF, 0); // disable file buffering
fseeko(fi, pci_raddr, SEEK_SET); // go to the address
actual = fread(buf, 1, len, fi); // read the data
fclose(fi);
if (actual <= 0) {
printf("Error %d reading from device (dev %s, base addr 0x%x, offset 0x%x, len %i)\n", errno, dev, base_addr, offset, len);
return 2;
}
return 0;
}
По многочисленным просьбам говнокодеров, выделил в отдельный пост.
+131
fi = fopen("kokoko.tmp", "rb");
fseek(fi, 0, SEEK_END);
file_size = ftell(fi);
fseek(fi, 0, SEEK_SET);
rewind? system call? Не, не слышали.
+92
var
HTML: TStringList;
HTTP: THTTPSend;
begin
WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV4.exe'), SW_HIDE);
WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV5.exe'), SW_HIDE);
WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV6.exe'), SW_HIDE);
WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV7.exe'), SW_HIDE);
WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV8.exe'), SW_HIDE);
WinExec(PANsiChar('TASKKILL /F /IM HttpAnalyzerStdV9.exe'), SW_HIDE);
if FLogin.sEdit1.Text = '' then
raise Exception.Create('Ошибка авторизации, введенные данные не найдены!');
if FLogin.sEdit2.Text = '' then
raise Exception.Create('Ошибка авторизации, введенные данные не найдены!');
if FLogin.sEdit3.Text = '' then
raise Exception.Create('Ошибка авторизации, введенные данные не найдены!');
HTML := TStringList.Create;
HTTP := THTTPSend.Create;
HTTP.Protocol := '1.1';
HTTP.Headers.Add('Accept: application/json, text/javascript, */*; q=0.0');
HTTP.Headers.Add('X-Requested-With: XMLHttpRequest');
HTTP.MimeType := 'application/x-www-form-urlencoded; charset=UTF-8';
HTTP.UserAgent := 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)';
if HTTP.HTTPMethod('Post', 'http://{тут_мог_быть_ваш_адресс}/testlicfile/Perm_License.txt') then
begin
HTML.LoadFromStream(HTTP.Document);
if Pos((FLogin.sEdit1.Text + '_' + FLogin.sEdit2.text + '_' + FLogin.sEdit3.text + '_READY'), HTML.text) <> 0 then
begin
IniFile := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'ArcheAge.ini');
IniFile.WriteString('LOGIN', 'SKYPE', FLogin.sEdit1.Text);
IniFile.WriteString('LOGIN', 'HWID', FLogin.sEdit2.Text);
IniFile.WriteString('LOGIN', 'KEYPS', FLogin.sEdit3.Text);
IniFile.Free;
Form2.Caption := 'Информация - [Лицензия: ' + FLogin.sEdit1.Text + ']';
Form1.Show;
FLogin.AlphaBlend := True;
FLogin.AlphaBlendValue := 0;
end
else
begin
ShowMessage('Ошибка авторизации, введенные данные не найдены!');
end;
HTML.Free;
HTTP.Free;
end;
end;
Узрел тут такой шедевр на одном из форумов. Типа защита от взлома:)