- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
public int GetModuleId(int userId)
{
return moduleIdGet(userId);
}
protected int moduleIdGet(int userId)
{
int moduleId;
// calculate moduleId
// ...
return moduleId;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+136
public int GetModuleId(int userId)
{
return moduleIdGet(userId);
}
protected int moduleIdGet(int userId)
{
int moduleId;
// calculate moduleId
// ...
return moduleId;
}
Дал открытый доступ, но в то же время как бы сохранил защищённый.
+16
QVector<Line> Converter::convert(QImage &image, Modes mode/*, int left, int top, int right, int bottom*/){
QVector<Line> result;
/* if(left < 0) left = 0;
if(top < 0) top = 0;
//if(right > image.width()) right = image.width();
//if(bottom > image.height()) bottom = image.height();
//points.clear();
//pix.fill(Qt::black);
if(left > right){
left ^= right;
right ^= left;
left ^= right;
}
if(top > bottom){
top ^= bottom;
bottom ^= top;
top ^= bottom;
}*/
int left = 0,top = 0,right = image.width(),bottom = image.height();
for( int i = left; i < right; ++i){
for( int j = top; j < bottom; ++j){
Line p;
p.x1 = p.x2 = i;
p.y1 = p.y2 = j;
p.z1 = qGray(image.pixel(i,j));
p.c = p.z1;
QVector<int> v;
if(i!=left) v.push_back(qGray(image.pixel(i-1,j)));
if(i < right-1) v.push_back(qGray(image.pixel(i+1,j)));
if(j!=top) v.push_back(qGray(image.pixel(i,j-1)));
if(j < bottom-1) v.push_back(qGray(image.pixel(i,j+1)));
if(i!=left && j!= top) v.push_back(qGray(image.pixel(i-1,j-1)));
if(i < right-1 && j!=top) v.push_back(qGray(image.pixel(i+1,j-1)));
if(j < bottom-1 && i!=left) v.push_back(qGray(image.pixel(i-1,j+1)));
if(i < right-1 && j < bottom-1) v.push_back(qGray(image.pixel(i+1,j+1)));
int min = *(std::min_element(v.begin(),v.end()));
if(min < qGray(image.pixel(i,j))){
/* for( unsigned k = 0; k < p.c-min; ++k){
Point p0;
p0.x = i;
p0.y = j;
p0.z = qGray(image.pixel(i,j))-(k+1);
p0.c = qGray(image.pixel(i,j));
points.push_back(p0);
}*/
p.z2 = p.z1 - min;
}else{
p.z2 = p.z1;
}
result.push_back(p);
}
}
/*origin.x = 0;
origin.y = 0;
origin.z = 0.0;*/
switch (mode) {
case ISO:
rotate(result, 3.1415/180*35.2,3.1415/4,-3.1415/4);
//rotate(result, 0,,0);
//rotate(result, 0,0,-3.1415/4);
break;
case BOTTOM:
rotate(result, 3.1415/180*90,0,0);
break;
case LEFT:
rotate(result, 3.1415/180*90,0,0);
rotate(result, 0, 3.1415/180*90,0);
break;
case RIGHT:
rotate(result, 3.1415/180*90,0,0);
rotate(result, 0, -3.1415/180*90,0);
break;
default:
break;
}
return result;
}
Картинка превращается, превращается...
+138
const bool ShowOkIfAllIsCool = true;
book OK()
{
return ShowOkIfAllIsCool;
}
bool GetFileExists(string filePath)
{
return File.Exists(filePath);
}
int GetLengthFileName(string filePath)
{
return filePath.Lenght;
}
int SetMaxValue(int maxValue)
{
_OPENWINDOWSAFTERINITIALIZATION = maxValue;
}
Программированием занимаюсь много лет, а так и не могу понять, для чего создавать подобные методы в 1 строку и константы заглавными буквами огромной длины? Их люди пишут или это автоматически созданный код какой-то прогой? В чужих программах такое часто можно встретить.
+121
private static bool ProductGT10(Point p)
{
if (p.X * p.Y > 100000)
{
return true;
}
else
{
return false;
}
}
Классический пример из MSDN
http://msdn.microsoft.com/ru-ru/library/bfcke1bz.aspx
+108
bool getSelectedFile(wchar_t *out, bool skip) {
HWND hwndFind = GetForegroundWindow();
TCHAR g_szPath[BUF_SIZE];
TCHAR g_szItem[BUF_SIZE];
//g_szPath[0] = TEXT('\0');
//g_szItem[0] = TEXT('\0');
memset(g_szPath, 0, sizeof(TCHAR) * BUF_SIZE);
memset(g_szItem, 0, sizeof(TCHAR) * BUF_SIZE);
IShellWindows *psw;
if(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows, (void**)&psw) != S_OK) return false;
VARIANT v;
v.vt = VT_I4;
IDispatch *pdisp;
bool fFound = false;
bool pExtracted = false;
bool nExtracted = false;
for (V_I4(&v) = 0; !fFound && psw->Item(v, &pdisp) == S_OK; V_I4(&v)++) {
IWebBrowserApp *pwba;
if(SUCCEEDED(pdisp->QueryInterface(IID_IWebBrowserApp, (void**)&pwba))) {
HWND hwndWBA;
if (SUCCEEDED(pwba->get_HWND((LONG_PTR*)&hwndWBA)) && hwndWBA == hwndFind) {
fFound = true;
IServiceProvider *psp;
if(SUCCEEDED(pwba->QueryInterface(IID_IServiceProvider, (void**)&psp))) {
IShellBrowser *psb;
if(SUCCEEDED(psp->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&psb))) {
IShellView *psv;
if(SUCCEEDED(psb->QueryActiveShellView(&psv))) {
IFolderView *pfv;
if(SUCCEEDED(psv->QueryInterface(IID_IFolderView, (void**)&pfv))) {
IPersistFolder2 *ppf2;
if(SUCCEEDED(pfv->GetFolder(IID_IPersistFolder2, (void**)&ppf2))) {
LPITEMIDLIST pidlFolder;
if(SUCCEEDED(ppf2->GetCurFolder(&pidlFolder))) {
if(SHGetPathFromIDList(pidlFolder, g_szPath)) {
pExtracted = true;
if(skip) {
lstrcpy(out, g_szPath);
out[lstrlen(g_szPath)] = 0;
return true;
}
}
int iFocus;
if(SUCCEEDED(pfv->GetFocusedItem(&iFocus))) {
LPITEMIDLIST pidlItem;
if (SUCCEEDED(pfv->Item(iFocus, &pidlItem))) {
IShellFolder *psf;
if (SUCCEEDED(ppf2->QueryInterface(IID_IShellFolder, (void**)&psf))) {
STRRET str;
if(SUCCEEDED(psf->GetDisplayNameOf(pidlItem, SHGDN_INFOLDER, &str))) {
StrRetToBuf(&str, pidlItem, g_szItem, 1024);
nExtracted = true;
int psz = lstrlen(g_szPath);
int isz = lstrlen(g_szItem);
if(pExtracted) {
lstrcpy(out, g_szPath);
out[psz] = '\\';
}
lstrcpy(out+psz+1, g_szItem);
out[psz + isz + 2] = 0;
}
psf->Release();
}
CoTaskMemFree(pidlItem);
}
}
CoTaskMemFree(pidlFolder);
}
ppf2->Release();
}
pfv->Release();
}
psv->Release();
}
psb->Release();
}
psp->Release();
}
}
pwba->Release();
}
pdisp->Release();
}
psw->Release();
return (pExtracted && nExtracted);
}
Две очаровательных (говно) лестницы из какой-то очередной переназначалки горячих клавиш в Windows.
Оригинал тут: https://github.com/mapseamoff/KeyBinder/blob/master/ShellHelper/ShellHelper/main.cpp
+129
function assemble(var w:word;s:string):boolean;
.....
else if length(cmd)=3 then
begin
{ТРЕХБУКВЕННЫЕ КОМАНДЫ}
case cmd[1] of
'a':case cmd[2] of
'c':if cmd[3]='i' then
begin
code:=$ce;
typ:=7;
end;
'd':case cmd[3] of
'd':begin
code:=$80;
typ:=4;
end;
'c':begin
code:=$88;
typ:=4;
end;
'i':begin
code:=$c6;
typ:=7;
end;
end;
..... еще 500 подобных строк ....
end;
Прочитал http://govnokod.ru/10002 и вспомнил, как когда-то писал асм\дизасм\эмуль для 8080 на паскале.
+90
@Override
public Object clone() {
try {
return super.clone();
} catch (Exception e) {
return this;
}
}
"Клонирование"
+86.6
if Mode = True then
из исходников FastReport
+170.2
mov eax, pony
jnz pony
jmp magiccastle
Поне!
+1
In order to fund the development work on speeding CPython by a factor of five, something like $2M will be required.
This seems like a sizeable sum, but compared to the amount of money spent on Python development and the
cost of running Python applications, it is quite a modest sum.
---
The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages,
each stage increasing the speed of CPython by (approximately) 50%.
1.5**4 ≈ 5
---
The interpreter will adapt to types and values during execution, exploiting [b]type stability[/b] in the program
---
Improved performance for [b]integers of less than one machine word[/b].
Improved peformance for [b]binary operators[/b].
---
Simple "JIT" compiler for small regions. Compile small regions of specialized code, using a relatively simple, fast compiler.
Extend regions for compilation. Enhance compiler to generate [b]superior machine code[/b].
питонисты готовят новую версию интерпретатора с революционной фичей - возможностью отъема денег у населения. Ожидается, что нововведение позволит языку быстро заработать очки на рынке пускания пыли в глаза.
https://github.com/markshannon/faster-cpython