- 1
- 2
- 3
- 4
bool DoYouWannaRealyDoThisFunctionYesNo(T*(f)(T...), bool answer)
{
return answer;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
bool DoYouWannaRealyDoThisFunctionYesNo(T*(f)(T...), bool answer)
{
return answer;
}
Microsoft style
+146
<?php
// Calculate the age from a given birth date
// Example: GetAge("1986-06-18");
function GetAge($Birthdate)
{
// Explode the date into meaningful variables
list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $Birthdate);
// Find the differences
$YearDiff = date("Y") - $BirthYear;
$MonthDiff = date("m") - $BirthMonth;
$DayDiff = date("d") - $BirthDay;
// If the birthday has not occured this year
if ($DayDiff < 0 || $MonthDiff < 0)
$YearDiff--;
return $YearDiff;
}
?>
добыто в интернете.
Опять пхп и опять даты. Похоже, это вечное...
+159
bool Document::_Parse_Auto (char sym)
{
bool error = 0;
switch (mInfo.AutoState)
{
case 0:
{
if (is_stag (sym))
mInfo.AutoState = 1;
else
mInfo.AutoState = 14;
break;
}
case 1:
{
if (is_name (sym))
mInfo.AutoState = 24;
else if (is_delim (sym))
mInfo.AutoState = 2;
else if (is_prcom (sym))
mInfo.AutoState = 11;
else if (is_info (sym))
mInfo.AutoState = 25;
else if (is_ekey (sym))
mInfo.AutoState = 21;
else
error = true;
break;
}
<100500 строк case'ов>
case 26:
{
if (is_etag (sym))
mInfo.AutoState = 0;
else
error = true;
break;
}
}
return error;
}
void Document::_Parse_React (char sym)
{
switch (mInfo.AutoState)
{
case 0:
{
switch (mInfo.NodeType)
{
case ParseInfo::preproc:
{
delete mInfo.CurrentNode;
mInfo.CurrentNode = mInfo.LastTextNode;
break;
}
case ParseInfo::info:
{
delete mInfo.CurrentNode;
mInfo.CurrentNode = mInfo.LastTextNode;
break;
}
case ParseInfo::close:
{
if (mInfo.name == mInfo.CurrentNode->name)
mInfo.CurrentNode = mInfo.CurrentNode->parent;
else
{ mInfo.Error = 51; return; }
mInfo.name.clear ();
break;
}
}
break;
}
<ещё 100500 строк case'ов>
case 25:
{
mInfo.NodeType = ParseInfo::info;
mInfo.LastTextNode = mInfo.CurrentNode;
mInfo.CurrentNode = new Node;
break;
}
}
switch (mInfo.LastAutoState)
{
<и ещё 100500 строк case'ов>
Это я в 10 классе писал XML парсер, работающий на конечном автомате, в котором было 27 состояний.
+160
##### grab the full name of the agent
$stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five from vicidial_users where user='$VD_login' and pass='$VD_pass'";
$rslt=mysql_query($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01007',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$LOGfullname = $row[0];
$user_level = $row[1];
$VU_hotkeys_active = $row[2];
$VU_agent_choose_ingroups = $row[3];
$VU_scheduled_callbacks = $row[4];
$agentonly_callbacks = $row[5];
$agentcall_manual = $row[6];
$VU_vicidial_recording = $row[7];
$VU_vicidial_transfers = $row[8];
$VU_closer_default_blended = $row[9];
$VU_user_group = $row[10];
$VU_vicidial_recording_override = $row[11];
$VU_alter_custphone_override = $row[12];
$VU_alert_enabled = $row[13];
$VU_agent_shift_enforcement_override = $row[14];
$VU_shift_override_flag = $row[15];
$VU_allow_alerts = $row[16];
$VU_closer_campaigns = $row[17];
$VU_agent_choose_territories = $row[18];
$VU_custom_one = $row[19];
$VU_custom_two = $row[20];
$VU_custom_three = $row[21];
$VU_custom_four = $row[22];
$VU_custom_five = $row[23];
if ( ($VU_alert_enabled > 0) and ($VU_allow_alerts > 0) ) {$VU_alert_enabled = 'ON';}
else {$VU_alert_enabled = 'OFF';}
$AgentAlert_allowed = $VU_allow_alerts;
### Gather timeclock and shift enforcement restriction settings
$stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts,agent_status_viewable_groups,agent_status_view_time from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_query($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01052',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$forced_timeclock_login = $row[0];
$shift_enforcement = $row[1];
$LOGgroup_shiftsSQL = eregi_replace(' ','',$row[2]);
$LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL);
$LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')";
$agent_status_viewable_groups = $row[3];
$agent_status_viewable_groupsSQL = eregi_replace(' ','',$agent_status_viewable_groups);
$agent_status_viewable_groupsSQL = eregi_replace(' ',"','",$agent_status_viewable_groupsSQL);
$agent_status_viewable_groupsSQL = "user_group IN('$agent_status_viewable_groupsSQL')";
$agent_status_view = 0;
if (strlen($agent_status_viewable_groups) > 2)
{$agent_status_view = 1;}
$agent_status_view_time=0;
if ($row[4] == 'Y')
{$agent_status_view_time=1;}
Оказывается, у меня на работе стоит чуть переделанный VICIdial.
Это звездец.
−126
#!/usr/bin/perl
@zips = ();
while(<>){
@zips = m{([a-z]5[a-z])}igx;
for(my $j=0;$j<=$#zips;$j++){
$i = index($_,$zips[$j]);
print "$zips[$j] pos $i\n";
};
print "$zips\n";
}
Находит комбинацию буква 5 буква
+160
if ( (CheckDEADcall > 0) && (VD_live_customer_call==1) )
{
if (CheckDEADcallON < 1)
{
if( document.images ) { document.images['livecall'].src = image_livecall_DEAD.src;}
CheckDEADcallON=1;
}
}
Оттуда же.
+148
preg_replace('/^(.*)\s(.*)$/i', '$1', $item['updated']);
+107
static void Main(string[] args)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int c = int.Parse(Console.ReadLine());
Math.Cos(double x) = (b * b + c * c - a * a) / (2 * b * c);
Math.Cos(double x)=i;
if(-1>i>0) Console.WriteLine("Треугольник тупоугольный");
if()
}
Не столько смешно, сколько хочется плакать от тупоугольности таких вот студентов...
+161
else
{
fronter = user;
LasTCID = MDnextResponse_array[0];
document.vicidial_form.lead_id.value = MDnextResponse_array[1];
LeaDPreVDispO = MDnextResponse_array[2];
document.vicidial_form.vendor_lead_code.value = MDnextResponse_array[4];
document.vicidial_form.list_id.value = MDnextResponse_array[5];
document.vicidial_form.gmt_offset_now.value = MDnextResponse_array[6];
document.vicidial_form.phone_code.value = MDnextResponse_array[7];
if ( (disable_alter_custphone=='Y') || (disable_alter_custphone=='HIDE') )
{
var tmp_pn = document.getElementById("phone_numberDISP");
if (disable_alter_custphone=='Y')
{
tmp_pn.innerHTML = MDnextResponse_array[8];
}
}
document.vicidial_form.phone_number.value = MDnextResponse_array[8];
document.vicidial_form.title.value= MDnextResponse_array[9];
document.vicidial_form.first_name.value = MDnextResponse_array[10];
document.vicidial_form.middle_initial.value = MDnextResponse_array[11];
document.vicidial_form.last_name.value = MDnextResponse_array[12];
document.vicidial_form.address1.value = MDnextResponse_array[13];
document.vicidial_form.address2.value = MDnextResponse_array[14];
document.vicidial_form.address3.value = MDnextResponse_array[15];
document.vicidial_form.city.value= MDnextResponse_array[16];
document.vicidial_form.state.value= MDnextResponse_array[17];
document.vicidial_form.province.value = MDnextResponse_array[18];
document.vicidial_form.postal_code.value = MDnextResponse_array[19];
document.vicidial_form.country_code.value = MDnextResponse_array[20];
document.vicidial_form.gender.value= MDnextResponse_array[21];
document.vicidial_form.date_of_birth.value = MDnextResponse_array[22];
document.vicidial_form.alt_phone.value = MDnextResponse_array[23];
document.vicidial_form.email.value= MDnextResponse_array[24];
document.vicidial_form.security_phrase.value = MDnextResponse_array[25];
var REGcommentsNL = new RegExp("!N","g");
MDnextResponse_array[26] = MDnextResponse_array[26].replace(REGcommentsNL, "\n");
document.vicidial_form.comments.value = MDnextResponse_array[26];
document.vicidial_form.called_count.value = MDnextResponse_array[27];
previous_called_count = MDnextResponse_array[27];
previous_dispo = MDnextResponse_array[2];
CBentry_time = MDnextResponse_array[28];
CBcallback_time = MDnextResponse_array[29];
CBuser = MDnextResponse_array[30];
CBcomments = MDnextResponse_array[31];
dialed_number = MDnextResponse_array[32];
dialed_label = MDnextResponse_array[33];
source_id = MDnextResponse_array[34];
document.vicidial_form.rank.value= MDnextResponse_array[35];
document.vicidial_form.owner.value= MDnextResponse_array[36];
// CalL_ScripT_id = MDnextResponse_array[37];
script_recording_delay = MDnextResponse_array[38];
CalL_XC_a_NuMber= MDnextResponse_array[39];
CalL_XC_b_NuMber= MDnextResponse_array[40];
CalL_XC_c_NuMber= MDnextResponse_array[41];
CalL_XC_d_NuMber= MDnextResponse_array[42];
CalL_XC_e_NuMber= MDnextResponse_array[43];
timer_action = campaign_timer_action;
timer_action_message = campaign_timer_action_message;
timer_action_seconds = campaign_timer_action_seconds;
lead_dial_number = document.vicidial_form.phone_number.value;
var dispnum = document.vicidial_form.phone_number.value;
var status_display_number = phone_number_format(dispnum);
+164
if (VDIC_web_form_address.match(regWFAcustom))
{
URLDecode(VDIC_web_form_address,'YES');
TEMP_VDIC_web_form_address = decoded;
TEMP_VDIC_web_form_address = TEMP_VDIC_web_form_address.replace(regWFAcustom, '');
}
else
{
web_form_vars =
"&lead_id=" + document.vicidial_form.lead_id.value +
"&vendor_id=" + document.vicidial_form.vendor_lead_code.value +
"&list_id=" + document.vicidial_form.list_id.value +
"&gmt_offset_now=" + document.vicidial_form.gmt_offset_now.value +
"&phone_code=" + document.vicidial_form.phone_code.value +
"&phone_number=" + document.vicidial_form.phone_number.value +
"&title=" + document.vicidial_form.title.value +
"&first_name=" + document.vicidial_form.first_name.value +
"&middle_initial=" + document.vicidial_form.middle_initial.value +
"&last_name=" + document.vicidial_form.last_name.value +
"&address1=" + document.vicidial_form.address1.value +
"&address2=" + document.vicidial_form.address2.value +
"&address3=" + document.vicidial_form.address3.value +
"&city=" + document.vicidial_form.city.value +
"&state=" + document.vicidial_form.state.value +
"&province=" + document.vicidial_form.province.value +
"&postal_code=" + document.vicidial_form.postal_code.value +
"&country_code=" + document.vicidial_form.country_code.value +
"&gender=" + document.vicidial_form.gender.value +
"&date_of_birth=" + document.vicidial_form.date_of_birth.value +
"&alt_phone=" + document.vicidial_form.alt_phone.value +
"&email=" + document.vicidial_form.email.value +
"&security_phrase=" + document.vicidial_form.security_phrase.value +
"&comments=" + document.vicidial_form.comments.value +
"&user=" + user +
"&pass=" + pass +
"&campaign=" + campaign +
"&phone_login=" + phone_login +
"&original_phone_login=" + original_phone_login +
"&phone_pass=" + phone_pass +
"&fronter=" + fronter +
"&closer=" + user +
"&group=" + group +
"&channel_group=" + group +
"&SQLdate=" + SQLdate +
"&epoch=" + UnixTime +
"&uniqueid=" + document.vicidial_form.uniqueid.value +
"&customer_zap_channel=" + lastcustchannel +
"&customer_server_ip=" + lastcustserverip +
"&server_ip=" + server_ip +
// ...еще строчек 30...
"&user_custom_five=" + VU_custom_five + '' +
"&preset_number_a=" + CalL_XC_a_NuMber + '' +
"&preset_number_b=" + CalL_XC_b_NuMber + '' +
"&preset_number_c=" + CalL_XC_c_NuMber + '' +
"&preset_number_d=" + CalL_XC_d_NuMber + '' +
"&preset_number_e=" + CalL_XC_e_NuMber + '' +
"&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' +
"&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' +
webform_session;
var regWFspace = new RegExp(" ","ig");
web_form_vars = web_form_vars.replace(regWF, '');
var regWF = new RegExp("\\`|\\~|\\:|\\;|\\#|\\'|\\\"|\\{|\\}|\\(|\\)|\\*|\\^|\\%|\\$|\\!|\\%|\\r|\\t|\\n","ig");
web_form_vars = web_form_vars.replace(regWFspace, '+');
web_form_vars = web_form_vars.replace(regWF, '');
var regWFAvars = new RegExp("\\?","ig");
if (VDIC_web_form_address.match(regWFAvars))
{web_form_vars = '&' + web_form_vars}
else
{web_form_vars = '?' + web_form_vars}
TEMP_VDIC_web_form_address = VDIC_web_form_address + "" + web_form_vars;
var regWFAqavars = new RegExp("\\?&","ig");
var regWFAaavars = new RegExp("&&","ig");
TEMP_VDIC_web_form_address = TEMP_VDIC_web_form_address.replace(regWFAqavars, '?');
TEMP_VDIC_web_form_address = TEMP_VDIC_web_form_address.replace(regWFAaavars, '&');
}