- 1
- 2
//Insert record into database
$result = mysql_query("INSERT INTO people(Name, Age, RecordDate) VALUES('" . $_POST["Name"] . "', " . $_POST["Age"] . ",now());");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+161
//Insert record into database
$result = mysql_query("INSERT INTO people(Name, Age, RecordDate) VALUES('" . $_POST["Name"] . "', " . $_POST["Age"] . ",now());");
Из документации к jTable http://www.jtable.org/GettingStarted
+156
function EngineListCtrl($scope, $timeout, $http)
{
$scope.engines = {};
$scope.workers = [];
$scope.checkEngines = function(){
$http.get(engineUrl + '&type=json&jcmd=getClients').success(function(req){
var engines = {};
var workers = {};
$scope.workers = []; // Это в отрисовке не используется.
// Сначала распихиваю всех по местам
angular.forEach(req, function(ob, i){
if( ob.info.type == 'engine' )
engines[ob.info.engine] = ob;
if( ob.info.type == 'worker' ){
if( workers[ob.info.engine] == undefined )
workers[ob.info.engine] = {};
workers[ob.info.engine][ob.info.worker] = ob;
if( ob.task && ob.task.state )
ob.info.state = ob.task.state;
$scope.workers.push(ob);
}
});
// Перебераю уже имеющиеся объекты
angular.forEach($scope.engines, function(engineOb, engineName){
var needRemove = true;
angular.forEach(engines, function(val, key){
if( engineName == key ){
angular.extend($scope.engines[engineName], val);
needRemove = false;
}
});
if( needRemove == false && $scope.engines[engineName] ){
$scope.checkEngineEvents($scope.engines[engineName]);
if( workers[engineName] != undefined ){
if( $scope.engines[engineName].workers == undefined )
$scope.engines[engineName].workers = {};
angular.extend($scope.engines[engineName].workers, workers[engineName]);
}else
$scope.engines[engineName].workers = {};
}
if( needRemove == true ){
delete $scope.engines[engineName];
}
});
// А теперь новые добавляю
angular.forEach(engines, function(engineOb, engineName){
if( $scope.engines[engineName] == undefined ){
$scope.engines[engineName] = engineOb;
if( workers[engineName] != undefined ){
if( $scope.engines[engineName].workers == undefined )
$scope.engines[engineName].workers = {};
angular.extend($scope.engines[engineName].workers, workers[engineName]);
}
$scope.checkEngineEvents($scope.engines[engineName]);
}
});
$timeout($scope.checkEngines, 2000);
});
}
$timeout($scope.checkEngines, 1000);
+13
/////////////////////////////////////////////////////////////////////////////////////////
template< typename TT_multimap_type >
void copy_val_vect_into_multimap_with_mapped_val_ordering_with_comparator
(
T_val_vect const & val_vect,
TT_multimap_type & multimap,
T_rand_rev_compare_val_with_comparators const & swap_compare_val
)
{
T_insert_with_ordering_in_multimap_with_comparator< TT_multimap_type >
insert_with_ordering_in_multimap_with_comparator
(
multimap,
swap_compare_val
);
std::for_each
(
val_vect.begin (),
val_vect.end (),
insert_with_ordering_in_multimap_with_comparator
);
}
/////////////////////////////////////////////////////////////////////////////////////////
http://goo.gl/1oiTBt
вырвиглазный code-style
+1
chunksLst.erase(++it1);
−164
Процедура глЗагрузитьЗаказы() Экспорт
ОткрытьФорму("Отчет",,"\\SQLDSTR\1C\ExtERT\InvoiceLoader.ert");
КонецПроцедуры
Встретил в самописке в клюшках. Если поменяется имя сервера или каталога - всё рухнет).
+108
if (needParce)
{
try
{
count = decimal.Parse(tb_count.Text.Replace(".", ","));
}
catch
{
count = decimal.Parse(tb_count.Text.Replace(",", "."));
}
}
+133
[Serializable]
public class CSScriptCompiler
{
//file name of script including full path
string sFileNameWithPath;
System.Reflection.Assembly m_assembly = null;
public CSScriptCompiler(string ScriptFileName)
{
this.sFileNameWithPath = Path.GetFullPath(ScriptFileName);
try
{
//load Assembly of *.cs file
m_assembly = CSScript.Load(sFileNameWithPath, null, true);
}
catch (Exception ex)
{
m_assembly = null;
MessageBox.Show(ex.Message);
throw (ex);
}
}
public bool Initialize(params object[] InitArgs)
{
if (m_assembly == null)
{
return false;
}
try
{
var InitFuntion = m_assembly.GetStaticMethod("*.Initialize", InitArgs);
//call initialize function
InitFuntion(InitArgs);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
return true;
}
public object CallFunction(String sFunctionName, params object[] args)
{
object result = null;
sFunctionName = "*." + sFunctionName;
try
{
var theFunction = m_assembly.GetStaticMethod(sFunctionName, args);
//call the method with your own arguements
result = theFunction(args);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return result;
}
}
Ну что тут скажешь...
Велосипедист...
+138
public string GetStringOfEnum(object myEnum)
{
string sValue = "";
sValue = Enum.GetName(myEnum.GetType(), myEnum);
return sValue;
}
Nuff said...
+155
function deposit(){
if(document.getElementById("no_of_year").value=="1") {
document.getElementById("interest_rate").value="9.5"
}
if(document.getElementById("no_of_year").value=="2") {
document.getElementById("interest_rate").value="10"
}
if(document.getElementById("no_of_year").value=="3") {
document.getElementById("interest_rate").value="10.5"
}
if(document.getElementById("no_of_year").value=="4") {
document.getElementById("interest_rate").value="11"
}
if(document.getElementById("no_of_year").value=="5") {
document.getElementById("interest_rate").value="11.5"
}
}
отсюда - http://stackoverflow.com/questions/24236980/values-not-passing-in-to-database
+164
function EscapePHPString($str)
{
$str = str_replace("\\", "\\\\", $str);
$str = str_replace("\$", "\\\$", $str);
$str = str_replace("\"", "\\"."\"", $str);
return $str;
}
function UnEscapePHPString($str)
{
$str = str_replace("\\\\", "\\", $str);
$str = str_replace("\\\$", "\$", $str);
$str = str_replace("\\\"", "\"", $str);
return $str;
}
Bitrix.