- 1
- 2
- 3
- 4
- 5
public static IEnumerable<TItem> GetNextItemFrom<TItem>(IEnumerable<TItem> Collection)
{
foreach (var Item in Collection)
yield return Item;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+126
public static IEnumerable<TItem> GetNextItemFrom<TItem>(IEnumerable<TItem> Collection)
{
foreach (var Item in Collection)
yield return Item;
}
+148
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
public class Main extends JFrame{
static int a=100;
BufferedImage offscreen = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
static double p1[][]={{-a},{0},{a}};
static double p2[][]={{0},{-a},{a}};
static double p3[][]={{a},{-a},{a}};
static double p4[][]={{a},{a},{a}};
static double p5[][]={{-a},{a},{a}};
static double p6[][]={{-a},{0},{-a}};
static double p7[][]={{0},{-a},{-a}};
static double p8[][]={{a},{-a},{-a}};
static double p9[][]={{a},{a},{-a}};
static double p10[][]={{-a},{a},{-a}};
static double mas[][][]=new double[10][][];
public static void main(String[] args) {
Main mf=new Main();
mf.setVisible(true);
mf.setSize(800,800);
mf.setDefaultCloseOperation(EXIT_ON_CLOSE);
Matrix P1=new Matrix(p1);
Matrix P2=new Matrix(p2);
Matrix P3=new Matrix(p3);
Matrix P4=new Matrix(p4);
Matrix P5=new Matrix(p5);
Matrix P6=new Matrix(p6);
Matrix P7=new Matrix(p7);
Matrix P8=new Matrix(p8);
Matrix P9=new Matrix(p9);
Matrix P10=new Matrix(p10);
double a=0;
while(true){
Matrix ox=new OX(a);
Matrix oy=new OY(a);
Matrix oz=new OZ(a);
Matrix m=ox.multiplication(oy.multiplication(oz));
mas[0]=m.multiplication(P1).getData();
mas[1]=m.multiplication(P2).getData();
mas[2]=m.multiplication(P3).getData();
mas[3]=m.multiplication(P4).getData();
mas[4]=m.multiplication(P5).getData();
mas[5]=m.multiplication(P6).getData();
mas[6]=m.multiplication(P7).getData();
mas[7]=m.multiplication(P8).getData();
mas[8]=m.multiplication(P9).getData();
mas[9]=m.multiplication(P10).getData();
a+=0.06;
//a=0;
mf.repaint();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void paint(Graphics g){
super.paint(g);
this.display(mas);
}
public void display(double m[][][]){
Graphics g= this.getGraphics();
g.setColor(Color.BLACK);
for(int i=0;i<m.length;i++){
m[i][0][0]+=300;
m[i][1][0]+=300;
}
g.drawLine((int)m[0][0][0],(int)m[0][1][0],(int)m[1][0][0],(int)m[1][1][0]);
g.drawLine((int)m[1][0][0],(int)m[1][1][0],(int)m[2][0][0],(int)m[2][1][0]);
g.drawLine((int)m[2][0][0],(int)m[2][1][0],(int)m[3][0][0],(int)m[3][1][0]);
g.drawLine((int)m[3][0][0],(int)m[3][1][0],(int)m[4][0][0],(int)m[4][1][0]);
g.drawLine((int)m[4][0][0],(int)m[4][1][0],(int)m[0][0][0],(int)m[0][1][0]);
g.drawLine((int)m[5][0][0],(int)m[5][1][0],(int)m[6][0][0],(int)m[6][1][0]);
g.drawLine((int)m[6][0][0],(int)m[6][1][0],(int)m[7][0][0],(int)m[7][1][0]);
g.drawLine((int)m[7][0][0],(int)m[7][1][0],(int)m[8][0][0],(int)m[8][1][0]);
g.drawLine((int)m[8][0][0],(int)m[8][1][0],(int)m[9][0][0],(int)m[9][1][0]);
g.drawLine((int)m[9][0][0],(int)m[9][1][0],(int)m[5][0][0],(int)m[5][1][0]);
g.drawLine((int)m[0][0][0],(int)m[0][1][0],(int)m[5][0][0],(int)m[5][1][0]);
g.drawLine((int)m[1][0][0],(int)m[1][1][0],(int)m[6][0][0],(int)m[6][1][0]);
g.drawLine((int)m[2][0][0],(int)m[2][1][0],(int)m[7][0][0],(int)m[7][1][0]);
g.drawLine((int)m[3][0][0],(int)m[3][1][0],(int)m[8][0][0],(int)m[8][1][0]);
g.drawLine((int)m[4][0][0],(int)m[4][1][0],(int)m[9][0][0],(int)m[9][1][0]);
Graphics g2 = offscreen.getGraphics();
g2.setColor(Color.WHITE);
g2.fillRect(0, 0, getWidth(), getHeight());
g2.setColor(Color.BLUE);
g2.fillRect(0, 0, 100, 100);
g.drawImage(offscreen, 0, 0, null);
}
}
Говнолаба по предмету "компьютерная графика".
Задача: нарисовать куб с усеченным углом, повернутый на произвольный угол вокруг трех осей (OX, OY, OZ).
Вот как эту задачу решает мой однокурсник.
Вместо того, чтобы использовать одну матрицу поворота, он создает 10 матриц для каждой из 10 точек...
Впрочем, код лучше расскажет...
+179
public:
void* getThis(void){return this;};;;;
+137
rem ID generator
:idgen
set nsmb=36
set idstr=
for /l %%i in (1,1,8) do call :rsadd
echo ID=%idstr%
exit /b
rem Random symbol adding [0-9a-z]
:rsadd
set r=%random%
set /a c=r-r/nsmb*nsmb
if %c% lss 10 set idstr=%idstr%%c%
if %c% == 10 set idstr=%idstr%a
if %c% == 11 set idstr=%idstr%b
if %c% == 12 set idstr=%idstr%c
if %c% == 13 set idstr=%idstr%d
if %c% == 14 set idstr=%idstr%e
if %c% == 15 set idstr=%idstr%f
if %c% == 16 set idstr=%idstr%g
if %c% == 17 set idstr=%idstr%h
if %c% == 18 set idstr=%idstr%i
if %c% == 19 set idstr=%idstr%j
if %c% == 20 set idstr=%idstr%k
if %c% == 21 set idstr=%idstr%l
if %c% == 22 set idstr=%idstr%m
if %c% == 23 set idstr=%idstr%n
if %c% == 24 set idstr=%idstr%o
if %c% == 25 set idstr=%idstr%p
if %c% == 26 set idstr=%idstr%q
if %c% == 27 set idstr=%idstr%r
if %c% == 28 set idstr=%idstr%s
if %c% == 29 set idstr=%idstr%t
if %c% == 30 set idstr=%idstr%u
if %c% == 31 set idstr=%idstr%v
if %c% == 32 set idstr=%idstr%w
if %c% == 33 set idstr=%idstr%x
if %c% == 34 set idstr=%idstr%y
if %c% == 35 set idstr=%idstr%z
exit /b
Windows shell
Собственноручно написанное. Нашел, разбирая старые скрипты.
+137
int bufImin[32]={ 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000};
int bufImax[32]={20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000};
double bufPmin[32]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 315, 0, 0, 0, 0, 0, 0};
double bufPmax[32]={ 6, 10, 1, 10, 40, 10 , 10, 10, 10, -315, 0, 0, 100, 100, 10, 1000};
/*...*/
bufPmin[9]=(double)CR1_Lb1_4mA*5-500.0;
bufPmax[9]=(double)CR1_Lb1_20mA*5-500.0;
Presh[9]=CurrentToPresh(I_9, bufImax[9],bufImin[9],bufPmax[9],bufPmin[9]);
bufPmin[10]=(double)CR1_Lb2_4mA*5-500.0;
bufPmax[10]=(double)CR1_Lb2_20mA*5-500.0;
Presh[10]=CurrentToPresh(I_10, bufImax[10],bufImin[10],bufPmax[10],bufPmin[10]);
/*...*/
bufPmax[10]=(double)CR5_Tg_max;
Presh[15]==CurrentToPresh(I_15, bufImax[15],bufImin[15],bufPmax[15],bufPmin[15]);
Разгребаю г*вно от предыдущего программиста...
- зачем массивы на 32 элемента, если их всегда 16.
- зачем массивы с одинаковыми данными.
- зачем инициализировать массив числами, которые никогда не используются.
- массивы используются только для передачи значений в функцию.
- 17 строка. Это ж надо спутать индекс; как незаметно.
- 18 строка. :) ==3
- "Presh" отнюдь не значит "precious", как подумали б американцы. Это Pressure по своей сути.
+147
$url_view = 'pages/news';// страница вида
$data = array(); //Создаем массив дата
// сегменты урл
$data['segment_1'] = $filter_1;
$data['segment_2'] = $filter_2;
$limit = 10; // вывод новостей
$num_links = 4; // кол-во страниц во круг текущей
$uri_segment = 5; // сегмент ссылки
$offset = ($page - 1) * $limit; // переводим page в offset
if(!is_numeric($filter_2)) {$filter_2 = iconv('utf-8', 'windows-1251', urldecode($filter_2));}
$base_url = '/page/filter/'.$filter_1.'/'.$filter_2.'/';
// разбираем 1 фильтр для проверки
$filter_global = explode("_",$filter_1);
if($filter_global[0] == 'user') {$filter_1 = 'user'; $user_id = (int)$filter_global[1];}
// описание каждого элемента фильтра
switch($filter_1) {
case 'date':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'date_day':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'date_month':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'date_year':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'rating':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'random':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'moderation':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'user':
$filter_1 = $filter_global[0].'_'.$filter_global[1]; // собираем обратно
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
default:
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
}
$this->auxiliary->pagination($base_url,$uri_segment,$num_links,$total,$limit);//настройки пагинации
$this->auxiliary->general_view($data,'title_best','description_best','keywords_best',$url_view); // общий вид
проверьте на наличие гавно кода .
Контроллер фильтра выдачи в Codeigniter
+101
double k;
if(deviceType == "firstType"){
for(int i = 0;i < 100000;i++)
k = pow(2,10);
}
else if(deviceType == "secondType"){
for(int i = 0;i < 700000;i++)
k = pow(2,10);
}
Думаю этот даунизм поймут все. Маразм крепчал)
+162
ModuleManagerImpl::ModuleManagerImpl()
{
ModuleManager::loadPlugins();
Config config = ProfileDialog::profilesInfo();
#ifdef QUTIM_SINGLE_PROFILE
bool singleProfile = true;
#else
bool singleProfile = false;
#endif
singleProfile = config.value("singleProfile", singleProfile);
if (singleProfile) {
if (!config.hasChildGroup("profile")) {
QWidget *wizard = new ProfileCreationWizard(this, QString(), QString(), true);
wizard->setAttribute(Qt::WA_DeleteOnClose, true);
wizard->setAttribute(Qt::WA_QuitOnClose, false);
SystemIntegration::show(wizard);
} else {
config.beginGroup("profile");
if(ProfileDialog::acceptProfileInfo(config, QString())) {
QTimer::singleShot(0, this, SLOT(initExtensions()));
} else {
qWarning("Can't login");
QDialog *dialog = new ProfileDialog(config, this);
SystemIntegration::show(dialog);
}
config.endGroup();
}
} else {
QDialog *dialog = new ProfileDialog(config, this);
SystemIntegration::show(dialog);
}
}
не знаю как вам, а мне не нравится объявление singleProfile.
qutim/core/src/modulemanagerimpl.cpp
+158
for (int i = 0; i < n; i++)
if (i == n + 2)
//действия
=)
+140
return (a >= factor || (a == factor && (c & 1) == 1)) ? 1 : 0;
https://github.com/mono/mono/blob/master/mono/metadata/decimal.c