- 1
- 2
- 3
- 4
....
SELECT * BULK COLLECT INTO dbg FROM debug_codes;
FOR i IN 1..dbg.COUNT LOOP
....
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−196
....
SELECT * BULK COLLECT INTO dbg FROM debug_codes;
FOR i IN 1..dbg.COUNT LOOP
....
PL/SQL
Вся таблица запихивается в коллекцию.
2 миллиона строк — серверу плохо, скрипт работает около 8 часов.
после исправления (в коллекцию вставляются строки пачками по 10 000 штук) стал работать полчаса.
+160
TINY.accordion=function(){
function slider(n){this.n=n; this.a=[]}
slider.prototype.init=function(t,e,m,o,k){
var a=T$(t), i=s=0, n=a.childNodes, l=n.length; this.s=k||0; this.m=m||0;
for(i;i<l;i++){
var v=n[i];
if(v.nodeType!=3){
this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
if(o==s){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1} s++
}
}
this.l=s
};
slider.prototype.pr=function(f,d){
for(var i=0;i<this.l;i++){
var h=this.a[i].h, c=this.a[i].c, k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
if((k!=1&&c.d==-1)&&(f==1||i==d)){
c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
}else if(k>0&&(f==-1||this.m||i==d)){
c.d=-1; h.className=''; su(c,-1)
}
}
};
function su(c){c.t=setInterval(function(){sl(c)},20)};
function sl(c){
var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
};
return{slider:slider}
}();
http://installauto.ru/ajax/script.js
чья-то реализация аккордиона. и почему же оно хреново в ИЕ пашет?
+147
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#define N 5
#define TSK "durak"
using namespace std;
int m[N];
int main(void){
freopen(TSK".in", "rt", stdin);
freopen(TSK".out", "wt", stdout);
scanf("%d%d%d%d", &m[0], &m[1], &m[2], &m[3]);
sort(m, m + 4);
int ans(0);
for(int i = 1; i < 4; i++){
if(m[i] == m[i-1] && m[i] != 0)
ans++;
}
printf("%d\n", ans);
return 0;
}
+155
void CVC6_SampleCodeDlg::OnCHECKForceGDI()
{
// TODO: Add your control notification handler code here
CButton *pBut = (CButton *) GetDlgItem(IDC_CHECK_ForceGDI);
m_vportsdk.SetForceGDI(pBut->GetCheck());
if(pBut->GetCheck() == 0)
m_ForceGDI = false;
else if(pBut->GetCheck() == 1)
m_ForceGDI = true;
}
VPort ActiveX SDK PLUS от Moxa
часть 3
+156
void CVC6_SampleCodeDlg::Onbuttonstartrecord()
{
// TODO: Add your control notification handler code here
CString strFileName, strFileTime, strFileSize, strTemp;
GetDlgItem(IDC_EDIT_filepath)->GetWindowText(strFileName);
GetDlgItem(IDC_EDIT_filetime)->GetWindowText(strFileTime);
GetDlgItem(IDC_EDIT_filelength)->GetWindowText(strFileSize);
GetDlgItem(IDC_button_startrecord)->GetWindowText(strTemp);
m_vportsdk.SetRecordVideoPath(strFileName);
m_vportsdk.SetRecordMaxFileTimeLength(atoi(strFileTime));
m_vportsdk.SetRecordMaxFileSize(atoi(strFileSize));
CComboBox *pRecordType = (CComboBox *) GetDlgItem(IDC_COMBO_recordtype);
if(strTemp == "Start Record"){
if(pRecordType->GetCurSel() == 0)
m_vportsdk.StartRecording(0);
else
m_vportsdk.StartRecording(1);
GetDlgItem(IDC_button_startrecord)->SetWindowText("Stop Record");
}
else{
if(pRecordType->GetCurSel() == 0)
m_vportsdk.StopRecording(0);
else
m_vportsdk.StopRecording(1);
GetDlgItem(IDC_button_startrecord)->SetWindowText("Start Record");
}
}
VPort ActiveX SDK PLUS от Moxa
часть 2
+145
function CalculateShippingCost() {
return 20.00;
}
Из одного "реального" интернет-магазина!
−859
CREATE Procedure [dbo].[usp_InsertFleets]
@SSQL text
As
EXEC(@SSQL)
GO
Минутка индусского кода
+145
// php5.1 to php4 functional, thanks for nic.ru fucked hosting
function html_decode($str){
if(function_exists("htmlspecialchars_decode")){
return stripslashes(htmlspecialchars_decode($str, ENT_QUOTES));
}else{
return stripslashes(str_replace(array("&", """, "'", "<", ">"), array("&", "\"", "'", "<", ">"), $str));
}
}
+101
procedure TSomeForm.DBGridEhDrawColumnCell(SomeParams);
begin
ShowRecordCount(GridDataSet);
end;
...
procedure ShowRecordCount(const FibDataSet: TpFibDataSet);
begin
FormMain.StatusBar1.Panels[2].Text := 'записей='+ IntToStr(FibDataSet.VisibleRecordCount);
FormMain.StatusBar1.Refresh;
end;
По ходу решения задачи решил-таки глянуть, почему так дико тормозит главная, вся цветная грида формы, ожидая там дикие отрисовки, а там...
+122
public enum SqlCallType {
Text = 1,
StoredProcedure = 2
}
private SqlCallType ConvertToSqlCallType(int sqlCallType) {
SqlCallType type = (SqlCallType)0;
if (sqlCallType == (int)SqlCallType.Text) {
type = SqlCallType.Text;
}
else if (sqlCallType == (int)SqlCallType.StoredProcedure) {
type = SqlCallType.StoredProcedure;
}
return type;
приведение enum-->int по индусски для enum'а с двумя значениями....