- 1
- 2
- 3
- 4
- 5
- 6
<script type="text/javascript" >
var index = "550000";
var regv=/\d\d\d\d\d\d/;
var result =index.search(regv);
document.write(result);
</script>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
<script type="text/javascript" >
var index = "550000";
var regv=/\d\d\d\d\d\d/;
var result =index.search(regv);
document.write(result);
</script>
Попался мне видео урок одного известного урокмайкера. В уроке он рассказал как сделать рег. выражение проверки корректности почтового индекса. И вот это он показал...
Ув. Автор сего говна объясните людям в своих уроках что так делать не надо. Избавьте людей от написания полукилометровых регулярок, и научите их пользоватся квантификаторами.
+98
function Prime (N: longword): boolean;
var
i : longword;
Max : single;
begin
if N = 2
then Prime := true
else if (N <= 1) or (N mod 2 = 0)
then Prime := false
else begin
Prime := true;
i := 3; Max := sqrt(N);
while i <= Max do begin
if N mod i = 0 then begin
Prime := false;
exit
end;
i := i + 2
end
end
end;
var
a, i : longword;
begin
read(a);
for i := 2 to a do
if Prime(i)
then writeln(i, ' is a prime number');
end.
Нахождение простых чисел.
+158
function getComponentList($state, $unit = '') {
global $smarty;
$suser = _sessionVar('user');
$_GET['state'] = $state;
$_GET['unit'] = $unit;
....
+173
throw (i?getMainException():int());
+154
foreach ($templatedata as $templatedataname=>$templatedatavalue)
$$templatedataname = $templatedatavalue;
include($templatesDir.'/'.$file.'.tpl.php');
Велошаблонизатор, превращающий пары ключ-значение из массива в локальные переменные шаблона.
Шаблон - простой php-файл, в нужных местах выводящий полученные значения (реже с какой-либо логикой вроде обработки массива).
+147
Query query = entityManager.createNativeQuery(
"select * from ("
+ "select g4.id as goodId, g4.name as goodName, g4.code as goodCode, "
+ "u4.name as uomName, sum(bgd.quantity_out) as quantityOut, "
+ " g4.productcode as goodProductCode, sum(bgd.quantity_return) as quantityReturn "
+ "from good g4 "
+ "inner join consignment cs1 on cs1.good_id = g4.id "
+ (customizationUtilSQL == null ? "" : customizationUtilSQL.buildCustomAttributesQueryInnerPart())
+ " inner join "
+ "(select gg.consignment_id, op.sourcestore_id as place_id, " +
" sum(gg.quantity) as quantity_out, sum(coalesce(srset.return_quantity, 0)) as quantity_return "
+ "from motion gg "
+ "inner join operation op " +
" on (gg.operation_id = op.id " +
" and op.company = gg.company" +
(projectId == null ? "" : " and (op.project_id = :projectId) ") +
(contractId == null ? "" : " and (op.contract_id = :contractId) ") +
") "
+ "inner join place pld on op.sourcestore_id = pld.id "
+ " left outer join "
+ " (select ds.demand_id as demand_id, srm.consignment_id as consignment_id, srm.sum as sum, " +
" sum(srm.quantity) as return_quantity from demand_salesreturn ds " +
" inner join operation sr on sr.id = ds.salesreturn_id " +
" inner join motion srm on srm.operation_id = sr.id " +
" where sr.dtype = 'SalesReturn' " +
" and sr.deleted is null " +
(!includeAboardOperations ? " and sr.applicable = true " : "") +
" and (sr.moment between :upToDate and :toDate) " +
" and " + SecurityUtil.companyFilterSQL("sr") +
" group by ds.demand_id, srm.consignment_id, srm.sum) srset " +
" on (srset.demand_id = op.id and srset.sum = gg.sum " +
" and srset.consignment_id = gg.consignment_id) "
+ (agentId == null ? "" :
" left outer join requisite tr on op.targetagentrequisite_id = tr.id "
+ " left outer join requisite sr on op.sourceagentrequisite_id = sr.id "
+ " left outer join agent agt on tr.agent_id = agt.id "
+ " left outer join agent ags on sr.agent_id = ags.id ")
+ "where " + SecurityUtil.companyFilterSQL("op")
+ " and op.deleted is null "
+ (!includeAboardOperations ? " and op.applicable = true " : "")
+ " and (op.moment between :upToDate and :toDate) "
+ " and op.dtype = 'Demand' "
+ (agentId == null ? ""
: " and ((ags.path || ags.id) like ( "
+ "select distinct (a21.path || a21.id || '%') from agent a21 where a21.id = :agentId) or "
всё не влезло, вообще тут 65 строк. пожалуйста выскажите ваше мнение об этом коде. спасибо :)
+135
<td class="displayNone" style="padding-right:13px; width:235px" valign="top">
ticket.rzd.ru
+166
function unlinkFile($filename) {
if(unlink($filename)) {
return true;
}
}
function unsetVar($varname) {
unset($varname);
return true;
}
Одна из "библиотек" крупного зарубежного коммерческого проекта.
+135
<div class="block_container s3 b-text b-static-text user_css_130018946673 user_css_130028521958 user_css_130028524445 user_css_130028527350 user_css_130028529275 user_css_130028546858 user_css_13002855067 user_css_13002855515 user_css_130028558859 user_css_130028563869 user_css_130028573655 user_css_130028575861 user_css_130028716271 " id="e_130012850667">
С одного narod'овского сайта на готовом шаблоне. Я на измене.
+72
public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.content_layout_id);
final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id);
if (checkBox.isChecked()) {
checkBox.setChecked(false);
}
}
}