- 1
- 2
$is_alias=substr($_SERVER[SCRIPT_FILENAME],-strlen($_SERVER[SCRIPT_NAME])) != $_SERVER[SCRIPT_NAME] ? true : false;
define('HOSTROOT',($is_alias ? $root_dir : realpath(substr($_SERVER[SCRIPT_FILENAME],0,-strlen($_SERVER[SCRIPT_NAME])))));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+167
$is_alias=substr($_SERVER[SCRIPT_FILENAME],-strlen($_SERVER[SCRIPT_NAME])) != $_SERVER[SCRIPT_NAME] ? true : false;
define('HOSTROOT',($is_alias ? $root_dir : realpath(substr($_SERVER[SCRIPT_FILENAME],0,-strlen($_SERVER[SCRIPT_NAME])))));
Определяем путь до папки со скриптом. (c) RapidGet
+158.6
$query = "SELECT * FROM `HTML_ocHoBa`";
$res = mysql_query($query);
while($row = mysql_fetch_array($res)){
$HTML_ocHoBa_MetaAuthor = $row['Meta_Author'];
$HTML_ocHoBa_MetaKeywords = $row['Meta_Keywords'];
$HTML_ocHoBa_Title = $row['Title'];
$HTML_ocHoBa_CSSurl = $row['CSS_url'];
$HTML_ocHoBa_CSS = $row['CSS'];
$HTML_ocHoBa_ScriptUrl = $row['Script_url'];
$HTML_ocHoBa_Script = $row['Script'];
}
echo <<<HD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<HTML>
<Head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="$HTML_ocHoBa_MetaAuthor">
<meta name="keywords" content="$HTML_ocHoBa_MetaKeywords">
<title>$HTML_ocHoBa_Title</title>
<link rel="stylesheet" type="text/css" href="$HTML_ocHoBa_CSSurl">
<style type="text/css"><!--
$HTML_ocHoBa_CSS
--></style>
<script type="text/javascript" language="javascript" src="$HTML_ocHoBa_ScriptUrl"></script>
<script type="text/javascript" language="javascript"><!--
$HTML_ocHoBa_Script
--></script>
</Head>
<Body><Table class="tbl_0"><tr><td>
$HTML_ocHoBa_cogepwaHue
</td></tr></Table></Body>
</HTML>
HD;
Отседова)))
http://forum.vingrad.ru/forum/topic-294895/kw-%D1%87%D1%82%D0%B5%D0%BD%D0%B8%D0%B5.htm l
−157.2
Select @clientMoney_DayEnd = coalesce([Money], 0.0)
FROM dbo.AccountOperation
where
OperationDateTime = (
select max(OperationDateTime)
from dbo.AccountOperation
where
cast(year(OperationDateTime) as varchar(4)) +
right('0' + cast(month(OperationDateTime) as varchar(2)), 2) +
right('0' + cast(day(OperationDateTime) as varchar(2)), 2) <=
(
select cast(datepart(year, max(QuoteDateTime)) as varchar(4)) +
right('0' + cast(datepart(month, max(QuoteDateTime)) as varchar(2)), 2) +
right('0' + cast(datepart(day, max(QuoteDateTime)) as varchar(2)), 2) + ' 23:59'
from CloseQuote
where
QuoteDateTime < dateadd(day, 1, @currDate)
) and
[Money] is not null and
ClientID = @clientID
) and
[Money] is not null and
ClientID = @clientID
order by ID desc
Разбить datetime на год, месяц, день. Отдельно каждое начение привести к чару, собрать из них строку даты... Ну и посравнивать ее с такой же шедеврашьной строкой...
А да... и все это в мега-курсоре для каждой даты...
Другой вариант для данной задачи, хотябы cast(OperationDateTime as date) cast(QuoteDateTime as date), неприемлем категорически:):):):):)::)
+113
public partial class Form1 : Form
{
// ...
public Form1()
{
InitializeComponent();
// If Connection string empty
if (XmlConfig.GetPropetry("ConnectionString", "ConnectionString") == "")
{
MessageBox.Show("Type connection option in the next window", "Connection String is empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
frmOptions dlg = new frmOptions();
dlg.ConnectionString = true;
if (dlg.ShowDialog() == DialogResult.OK)
{
System.Diagnostics.Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Application.exe"));
}
Close();
}
// ...
}
// ...
}
В конструкторе главного окна приложения проверяется есть ли в конфиге строка подключения к базе. Если нет, то открывается окошко с опциями для ввода параметров подключения к базе. При успешном вводе сохраняется строка подключения в конфиг и программа перезапускается, чтобы загрузиться с новой строкой подключения))) Пришлось вот переделывать такую программу, после другого программиста. Как можно было до такого додуматься понять не могу)))
+118.4
//Находит строку и возвращает строку под ней
public string FindRowUnder(string str)
{
string nextRes = string.Empty;
var res = _oSheet.get_Range("A1", "Z100").Find(str,...);
if (!String.IsNullOrEmpty(res))
{
int iCol = Convert.ToInt32(_oSheet.get_Range("A1", "Z100").Find(str...).Column);
int iRow = Convert.ToInt32(_oSheet.get_Range("A1", "Z100").Find(str...).Row);
iRow++;
nextRes = _oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2.ToString();
}
return nextRes;
}
// Находит строку и забирает 2 строки под ней
public string FindDoubleRowUnder(string str)
{
string res = _oSheet.get_Range("A1", "F100").Find(str...).Value2.ToString();
if (!String.IsNullOrEmpty(res))
{
int iCol = Convert.ToInt32(_oSheet.get_Range("A1", "F100").Find(str...).Column);
int iRow = Convert.ToInt32(_oSheet.get_Range("A1", "F100").Find(str...).Row);
iRow = iRow + 1;
if (_oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2 != null)
{
nextRes = _oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2.ToString();
}
iRow++;
if (_oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2 != null)
{
nextRes += " " + _oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2;
}
}
return nextRes.Trim();
}
// Находит строку и забирает 3 строки под ней
public string FindTripleRowUnder(string str)
{
... думаю писать не стоит так как там почти то же самое, что и выше
}
Интересно, когда надо будет получить 4 или 5 строк товарищ будет писать еще один метод?
+144.4
for (var i = 1; i <= 4; i++) {
var el = O.get('#upcoming' + i);
if (el == undefined) {
continue;
}
O.countdown('#upcoming' + i, '<b>%D% %DT% %H% %HT% %M% %MT% %S% %ST%</b>', {
leadingZeroes: false,
overrideSeconds: O.get('#upcoming' + i + ' input').value
});
}
отличный каунт даун от Opera
http://my.opera.com/community/countup/
дергаем данные с сервера до посинения
фаерфокс умер через 5 минут)
+86.4
//#ifdef Slowpoke
private static final int MILLIS = 1100;
//#else
private static final int MILLIS = 1000;
//#endif
Сколько миллисекунд в секунде?
+105.4
using System;
using System.Data;
using System.Configuration;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
public class GridViewExportUtil
{
static HSSFWorkbook hssfworkbook;
static MemoryStream WriteToStream()
{
//Write the stream data of workbook to the root directory
MemoryStream file = new MemoryStream();
hssfworkbook.Write(file);
return file;
}
static void InitializeWorkbook()
{
hssfworkbook = new HSSFWorkbook();
////create a entry of DocumentSummaryInformation
DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
dsi.Company = "";
hssfworkbook.DocumentSummaryInformation = dsi;
////create a entry of SummaryInformation
SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
si.Subject = "";
hssfworkbook.SummaryInformation = si;
}
/// <param name="fileName"></param>
/// <param name="gv"></param>
public static void Export(string fileName, GridView gv)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Charset = System.Text.Encoding.Unicode.EncodingName;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode;
HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; // NPOI
HttpContext.Current.Response.AddHeader(
"content-disposition", string.Format(
"attachment; filename=Report.xls"));//, fileName)); // Need .XLS file
HttpContext.Current.Response.Clear();
InitializeWorkbook();
HSSFSheet sheet1 = hssfworkbook.CreateSheet("Таблица");
//sheet1.CreateRow(0).CreateCell(0).SetCellValue("Таблица");
using (StringWriter sw = new StringWriter())
{
// Create a form to contain the grid
Table table = new Table();
// add the header row to the table
if (gv.HeaderRow != null)
{
GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
table.Rows.Add(gv.HeaderRow);
}
// add each of the data rows to the table
foreach (GridViewRow row in gv.Rows)
{
GridViewExportUtil.PrepareControlForExport(row);
table.Rows.Add(row);
}
// add the footer row to the table
if (gv.FooterRow != null)
{
GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
table.Rows.Add(gv.FooterRow);
}
sheet1.DisplayGridlines = true;
HSSFCellStyle style1 = hssfworkbook.CreateCellStyle();
style1.Alignment = HSSFCellStyle.ALIGN_CENTER;
sheet1.SetColumnWidth(0, 10000);
sheet1.SetColumnWidth(1, 5000);
sheet1.VerticallyCenter = true;
for (int j = 2; j < table.Rows[0].Cells.Count; j++)
{
sheet1.SetColumnWidth(j, 4000);
sheet1.SetDefaultColumnStyle(short.Parse(j.ToString()), style1);
}
double Temp=0;
+149.9
program TheEnd2;
uses Windows;
begin
repeat
WinExec('TheEnd2.exe',SW_HIDE);
until false;
end.
Добрая программа!
+160.5
$indextype = (isset($_REQUEST['indextype'])) ? intval($_REQUEST["indextype"]) : $indextype;
function indexType($val='')
{
static $indextype;
if (is_null($indextype)) {
$indextype = ($val == '') ? 1 : $val;
} else {
$indextype = ($val == '') ? $indextype : $val;
}
return $indextype;
}
if (!isset($adminside)) $adminside = 0;
if (!isset($indextype)) $indextype = 1;
adminSide($adminside);
indexType($indextype);
$adminside = adminSide();
$indextype = indexType();
$REQUEST = $_REQUEST;