- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
int __fastcall TForm1::iscomm(AnsiString str)
{
int i=1;
while (str[i]==' ')
i++;
if (str[i]=='#')
{
return 1;
}
else
{
return 0;
};
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
int __fastcall TForm1::iscomm(AnsiString str)
{
int i=1;
while (str[i]==' ')
i++;
if (str[i]=='#')
{
return 1;
}
else
{
return 0;
};
};
+159
jQuery("select[id='select1']").change(
function ()
{
var city_id = jQuery(this).attr("value");
jQuery("select[id='select_hotel']").html('<option>Выберите категорию</option>');
jQuery("select[name='room']").html('<option>Выберите категорию и отель</option>');
jQuery("select[id='select_5']").change(
function ()
{
....................................
}
);
}
);
обратите внимание на то, как селекторы объектов написаны.. автор вместо "#select1" пишет "select[id='select1']" зачем это делать непонятно.
наговнокодено на сайте el-tour.com
+147
if(!empty(_SESSION['order']['contact']['user_id']))
$user_id = preg_replace('/\D|\s/', '', $_SESSION['order']['contact']['user_id']);
Радует знание регулярных выражений =)
+155
uses crt;
var s:integer;
begin
readln(s);
writeln(ord(s[0]));
readln;
end.
+123
this.Border1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(111)))), ((int)(((byte)(111)))), ((int)(((byte)(111)))));
Встретилось такое внутри сгенеренной системой InitializeComponent()
+143
// find the start and end of the upload file.
static FILE * _uploadGet(request *wp, unsigned int *startPos, unsigned *endPos) {
FILE *fp=NULL;
struct stat statbuf;
unsigned char c, *buf;
if (wp->method == M_POST)
{
fstat(wp->post_data_fd, &statbuf);
lseek(wp->post_data_fd, SEEK_SET, 0);
printf("file size=%d\n",statbuf.st_size);
fp=fopen(wp->post_file_name,"rb");
if(fp==NULL) goto error;
}
else goto error;
//printf("_uploadGet\n");
do
{
if(feof(fp))
{
printf("Cannot find start of file\n");
goto error;
}
c= fgetc(fp);
if (c!=0xd)
continue;
c= fgetc(fp);
if (c!=0xa)
continue;
c= fgetc(fp);
if (c!=0xd)
continue;
c= fgetc(fp);
if (c!=0xa)
continue;
break;
}while(1);
(*startPos)=ftell(fp);
if(fseek(fp,statbuf.st_size-0x200,SEEK_SET)<0)
goto error;
do
{
if(feof(fp))
{
printf("fmmgmt: Cannot find end of file\n");
goto error;
}
c= fgetc(fp);
if (c!=0xd)
continue;
c= fgetc(fp);
if (c!=0xa)
continue;
c= fgetc(fp);
if (c!='-')
continue;
c= fgetc(fp);
if (c!='-')
continue;
break;
}while(1);
(*endPos)=ftell(fp);
return fp;
error:
return NULL;
}
Вот так вот китайцы парсят MIME при загрузке прошивки в роутер.
+122
internal sealed class FontKeeper
{
private static readonly FontConverter s_converter = new FontConverter();
private static readonly Regex s_font = new Regex(@"^(?<name>\w[\s\w]+);\s*(?<size>\d+)pt\s*(?:;(?<style>.*))?$", RegexOptions.IgnoreCase);
private static readonly Regex s_style = new Regex(@"^\s*style\s*=\s*([\w\s,]+)$", RegexOptions.IgnoreCase);
private const int defaultSize = 14;
public FontKeeper(Font font) : this(s_converter.ConvertToString(font)) { }
public FontKeeper(string fontString)
{
Match m = s_font.Match(fontString);
if (!m.Success)
throw new ArgumentException("Неверный формат строки");
Name = m.Groups["name"].Value.Trim();
int sz;
if (!int.TryParse(m.Groups["size"].Value, out sz))
sz = defaultSize;
Size = sz;
//Флаги стиля
ParseStyle(m.Groups["style"].Value);
}
private void ParseStyle(string value)
{
Match m = s_style.Match(value);
if (!m.Success) return;
string[] styles = m.Groups[1].Value.Split(new[] { ',' });
foreach (var style in styles)
{
try
{
Style |= (FontStyle)Enum.Parse(typeof(FontStyle), style.Trim(), true);
}
catch { }
}
}
public string Name { get; set; }
public int Size { get; set; }
public FontStyle Style { get; set; }
public float FontFactor
{
get { return (float)Size / defaultSize; }
set { Size = (int)(value * defaultSize); }
}
public Font CreateFont()
{
return new Font(Name, Size, Style);
}
}
Небольшой класс для хранения и динамического изменения шрифтов
+163
elseif (intval($countryID)>0 && intval($regionID)>0){
$SQL = "SELECT DISTINCT ".TABLE_PREFIX."hotels".LANG_PREFIX.".stars FROM ".TABLE_PREFIX."hotels".LANG_PREFIX.", ".TABLE_PREFIX."regions".LANG_PREFIX."
WHERE ".TABLE_PREFIX."regions".LANG_PREFIX.".id=".TABLE_PREFIX."hotels".LANG_PREFIX.".region_id
AND ".TABLE_PREFIX."regions".LANG_PREFIX.".id =".$regionID."";
$qRS = mysql_query ($SQL) or die ("<hr size=\"1\"><b>Не удалось выполнить: </b> \"" . $SQL . "\"<br>" . mysql_error());
if (mysql_num_rows($qRS)) {
while ($row = mysql_fetch_object($qRS)) {
$stars[$row->stars]++;
}
}
krsort($stars);
foreach ($stars as $key=> $value) {
$ret .= get_hotels($key, 100, $regionID, $countryID);
}
−88
try:
dday = time.strftime("%d", time.localtime(os.path.getmtime(path + d))).lstrip('0')
dmonth = time.strftime("%m", time.localtime(os.path.getmtime(path + d))).lstrip('0')
dhour = time.strftime("%H", time.localtime(os.path.getmtime(path + d))).lstrip('0')
dmin = time.strftime("%M", time.localtime(os.path.getmtime(path + d))).lstrip('0')
screenpath = os.listdir(spath)
for screen in screenpath:
sday = time.strftime("%d", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
smonth = time.strftime("%m", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
shour = time.strftime("%H", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
smin = time.strftime("%M", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
if dday == sday:
if dmonth == smonth:
if dhour == shour:
if dmin == smin:
scr = spath + screen
if scr:
return str(scr)
else:
return None
except:
return "None"
Проверка даты создания двух файлов
−318
self._DEBUG=Debug.Debug(debug)
В библиотеке xmpppy. Дебаг на дебаге.