- 1
- 2
- 3
- 4
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+141
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
И опять регулярки, но уже на уровне гигантов...
http://framework.zend.com/manual/2.0/en/user-guide/routing-and-controllers.html
+157
var temp = new Date(),
diff = parseInt(($('#calrlimit1').data('datebox').theDate - temp) / ( 1000 * 60 * 60 * 24 ));
diffstrt = (diff * -1)-1; // If you want a minimum of 1 day between, make this -2 instead of -1
diffend = diff + 11; // Why 11 instead of 10? No idea...
Документация к плагину jQuery Mobile DateBox2
+125
sed -e 's/^/;;/g;s/$/ /g' -e :a -e '1!x;1h;s/.*\(.\)$/\1/;p;x;s/\(.*\).$/\1/;h;ta' ~/src/find_world.sh | sed -e :a -e 'N;s/\n//g;ba' | sed -e 's/;;/\n/g' -e 's/^[ ]*//g'
rev
+71
// *** Функция truncation - округление числа до сотых ***
// ******************************************************
function truncation($number)
{
global $n;
$n = strpos($number,'.');
if ($n > 0) {$n = substr($number,0,$n).substr($number,$n,3);} else {$n = $number;}
return;
}
Комментарии излишни
+134
private string GetNextDishCode()
{
string[] vesCode = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
for (int i = 0; i < vesCode.Length; i++)
if (!CheckDishes(vesCode[i]))
return vesCode[i];
return "AA";
}
В одном, довольно крупном и дорогом проекте.
+122
Уважаемые знатоки, вопрос такой:
sizeof('a') для С и Сpp имеет различное значение и это вам известно из
C99 Standard: 6.4.4.4 Character constants Para 2
и
C++03 Standard: 2.13.2 Character literals Para 1.
Интересует ваше предположение/мнение/версия/etc, для чего такое приняли?
Стандартоособенности и внезапнонесовместимости.
+67
if ($_GET['search'] == ' Поиск' || $_GET['search'] == 'Поиск') {
$_GET['search'] = '';
}
if ($_GET['date'] == ' Дата' || $_GET['date'] == 'Дата') {
$_GET['date'] = '';
} else {
$_GET['date'] = preg_replace('/(\d+).(\d+).(\d+)/i','$3-$2-$1', $_GET['date']);
}
Уж не знаю, что и сказать... А вдруг перед текстом попадутся 2 пробела? Или 3?
−92
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
self.view.frame=CGRectMake(10,10, 300, 200);
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.selectionStyle=UITableViewCellSelectionStyleNone;
switch (indexPath.row) {
case 0:
//ToDo: Add UserInfo's view into TableView
[cell.contentView addSubview:upperView];
break;
case 1:{
//Remove preous view/tableview
for (id vw in cell.contentView.subviews) {
if ([vw isKindOfClass:[UITableView class]]) {
[vw removeFromSuperview];
}
}
//
//Add View which contain tableview
EditListViewController *editlistvw=[[EditListViewController alloc] initWithNibName:@"EditListViewController" bundle:nil] ;
editlistvw.view.frame=CGRectMake(10, 10, 300, 20);
[cell.contentView addSubview:editlistvw.tableView];
//
break;
}
case 2:
//Remove previous view/tableview
for (id vw in cell.contentView.subviews) {
if ([vw isKindOfClass:[UITableView class]]) {
[vw removeFromSuperview];
}
}
break;
default:
break;
}
return cell;
}
Творение индийского джуниора, совместно с которым приходится делать проект
+137
public class Problem33 {
public static void main(String arg[]){
long l1 = Calendar.getInstance().getTimeInMillis();
int amount = 0;
for(int a=1; a<=9; a++){
for(int b=1; b<=9; b++){
for(int c=1; c<=9; c++){
for(int d=1; d<=9; d++){
int numerator = a*10+b;
int denominator = c*10+d;
double fraction = 1.0*numerator/denominator;
if(numerator < denominator){
if(
(a==c && (1.0*b/d == fraction)) ||
(a==d && (1.0*b/c == fraction)) ||
(b==c && (1.0*a/d == fraction)) ||
(b==d && (1.0*a/c == fraction))
){
amount++;
System.out.println(a + "" + b + "/" + c + "" + d);
}
}
}
}
}
}
System.out.println(amount);
long l2 = Calendar.getInstance().getTimeInMillis();
System.out.println("Time: " + (l2-l1) + "ms");
}
}
http://projecteuler.net/problem=33
http://projecteuler.net/thread=33
+137
[ExposeProperty]
public bool Exhausted {
get {
if (this.State > FatigueConsts.globalNormalRange)
return true;
else
return false;
}
set {
if (this.State > FatigueConsts.globalNormalRange)
Exhausted = true;
else
Exhausted = false;
}
}
И потом полчаса сидел, понимал, почему Юнити зависает, когда я пытаюсь открыть инспектор с этим объектом ) Потом поставил в сеттер return;, ибо для костыля [ExposeProperty] требуются и геттер, и сеттер.