- 1
foreach($query->result_array() as $row) $res[] = $row;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+160
foreach($query->result_array() as $row) $res[] = $row;
P.s на сайте не работает галочка "принять рецензию" в 4 хроме, а в 6 ие(который я включил, чтобы здесь накласть) не видно текстареи, но вроде работает :)
−130.3
Public Overrides Sub OnViewInitialized()
Dim userId As String = _guard.GetCurrentUserId()
BindGroups()
Bind()
DoHackyStuff()
End Sub
Private Function GetUrls() As Dictionary(Of String, String)
Dim dic As New Dictionary(Of String, String)
For Each assembly In AppDomain.CurrentDomain.GetAssemblies()
For Each type In assembly.GetTypes.Where(Function(q) q.FullName.EndsWith("Url"))
Dim url = CType(_container.GetByType(type), IUrl).Page
Dim name = type.FullName.Split(".".ToCharArray)
dic.Add(url, name.Reverse.First + ", " + name.Reverse.Skip(1).First)
Next
Next
Return dic
End Function
Private Sub DoHackyStuff()
Dim siteMap = _container.Get(Of ISiteMapGenerator)().GetSiteMap()
Dim urls = GetUrls()
Dim sb As New StringBuilder
For Each top In siteMap.Nodes
sb.AppendLine(String.Format("<top display-name=""{0}"" id=""{1}"">", top.Name, urls(top.Url)))
For Each group In top.Nodes
sb.AppendLine(String.Format("<group display-name=""{0}"">", group.Name))
For Each item1 In group.Nodes
sb.AppendLine(String.Format("<item display-name=""{0}"" id=""{1}""/>", item1.Name, urls(item1.Url)))
Next
sb.Append("</group>")
Next
sb.Append("</top>")
Next
End Sub
Быстро пытался сгенерить xml-ку по ран-тайм структуре.
+158
for($i=$start; $i<$end; $i++) {
$v=$items[$idx[$i]];
}
$start = 0;
$end = count($items);
if (is_array($idx))
{
}
else
{
unset($idx);
$idx[0] = 0;
}
Хоть и вырвано из контекста, но общая красота от этого не теряется.
+160
//Из библиотеки prototype
....
unescapeHTML: function() {
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
....
Смеяться надо из-за того, что замена & на & идёт первой, таким образом &lt замениться на <, а не на <
+153.1
function thaw() {
$this->get_lock();
$vals = $this->that->ac_get_value($this->id, $this->name);
eval(sprintf(";%s",$vals));
}
vals, this, that.. еще не хватает комментов типа // eval something, return nothing
lock видимо отпускать и не надо...
+169.6
echo "<td valign=".chr(34)."middle".chr(34)." align=".chr(34)."center".chr(34).">";
не умеем экранировать кавычки :))))
+134.8
//аджакс убираем нах!!111 пыщь пыщь пыщь
/*}else{//code to show html
+159.1
$from = 'UTF-8';
$to = 'windows-1251';
if(!$decode) {
$from = $to;
$to = 'UTF-8';
}
Обмен переменными в обвеске для iconv, одной мало известной cms
−148.5
switch (c)
{
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '_':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case 127: case 128: case 129: case 130: case 131: case 132:
case 133: case 134: case 135: case 136: case 137: case 138:
case 139: case 140: case 141: case 142: case 143: case 144:
case 145: case 146: case 147: case 148: case 149: case 150:
case 151: case 152: case 153: case 154: case 155: case 156:
case 157: case 158: case 159: case 160: case 161: case 162:
case 163: case 164: case 165: case 166: case 167: case 168:
case 169: case 170: case 171: case 172: case 173: case 174:
case 175: case 176: case 177: case 178: case 179: case 180:
case 181: case 182: case 183: case 184: case 185: case 186:
case 187: case 188: case 189: case 190: case 191: case 192:
case 193: case 194: case 195: case 196: case 197: case 198:
case 199: case 200: case 201: case 202: case 203: case 204:
case 205: case 206: case 207: case 208: case 209: case 210:
case 211: case 212: case 213: case 214: case 215: case 216:
case 217: case 218: case 219: case 220: case 221: case 222:
case 223: case 224: case 225: case 226: case 227: case 228:
case 229: case 230: case 231: case 232: case 233: case 234:
case 235: case 236: case 237: case 238: case 239: case 240:
case 241: case 242: case 243: case 244: case 245: case 246:
case 247: case 248: case 249: case 250: case 251: case 252:
case 253: case 254: case 255:
continue;
default:
phase1_ungetc (c);
break;
}
нашел в недрах gettext
+85
pocedure TForm1.line(x, y, N: integer; l: real; d: boolean);
var
x1,x2,x3,x4,y1,y2,y3,y4: integer;
begin
if l>2 then
begin
if d then
case N of
1: begin
x1:=x; y1:=y;
x2:=x1; y2:=y1-round(1);
x3:=x1+round(1); y3:=y1-round(1);
x4:=x1+round(1); y4:=y1;
end;
2: begin
x2:=x; y2:=y;
x1:=x2; y1:=y2+round(1);
x3:=x2+Round(1); y3:=y2;
x4:=x2+Round(1); y4:=y2+round(1);
end;
3: begin
x3:=x; y3:=y;
x1:=x3-round(1); y1:=y3+round(1);
x2:=x3-round(1); y2:=y3;
x4:=x2+round(1); y4:=y2+round(1);
end;
4: begin
x4:=x; y4:=y;
x1:=x4-round(1); y1:=y4;
x2:=x4-round(1); y2:=y4-round(1);
x3:=x4; y3:=y4-round(1);
end;
end
else
case N of
1: begin
x1:=x; y1:=y;
x2:=x1; y2:=y1+round(1);
x3:=x1+round(1); y3:=y1+round(1);
x4:=x1+round(1); y4:=y1;
end;
2: begin
x2:=x; y2:=y;
x1:=x2; y1:=y2-round(1);
x3:=x2-Round(1); y3:=y2;
x4:=x2-Round(1); y4:=y2-round(1);
end;
3: begin
x3:=x; y3:=y;
x1:=x3+round(1); y1:=y3-round(1);
x2:=x3+round(1); y2:=y3;
x4:=x2-round(1); y4:=y2-round(1);
end;
4: begin
x4:=x; y4:=y;
x1:=x4+round(1); y1:=y4;
x2:=x4+round(1); y2:=y4+round(1);
x3:=x4; y3:=y4+round(1);
end;
end;
with Canvas do
begin
Pen.Color :=RGB(Random(256),Random(256),Random(256));
MoveTo(x1,y1);
LineTo(x2,y2);
LineTo(x3,y3);
LineTo(x4,y4);
LineTo(x1,y1);
Brush.Color:=Pen.Color;
FloodFill((x2+x3) div 2, (y2+y1) div 2, Pen.Color,fsBorder);
if l=200 then line (x1,y1,1,1/2, not d);
if n<>1 then line (x1,y1,1,1/2, not d);
if n<>2 then line (x2,y2,2,1/2, not d);
if n<>3 then line (x3,y3,3,1/2, not d);
угадайте...:D