- 1
- 2
- 3
- 4
- 5
checkTableFilters () {
if (this._activeTableFilter && this._filter.filter._filters.get(this._activeTableFilter)) {
this._filter.filter._filters.get(this._activeTableFilter).Update();
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
checkTableFilters () {
if (this._activeTableFilter && this._filter.filter._filters.get(this._activeTableFilter)) {
this._filter.filter._filters.get(this._activeTableFilter).Update();
}
}
"Так вышло" - хороший ответ.
1. this._filter.filter._filters (фильтры фильтра фильтра?..)
2. Зачем имитировать приватность полей класса соглашением о наименовании, если её игнорируют как могут?..
3. ... дополните сами
+2302
http://govnokod.ru/20924
Запрашиваемая страница не найдена!
Возможно, её и не было никогда
http://dump.bitcheese.net/files/pimarut/%D0%93%D0%BE%D0%B2%D0%BD%D0%BE%D0%BA%D0%BE%D0%B4_%2320924_%E2%80%94_C___%E2%80%94_%D0%93%D0%BE%D0%B2%D0%BD%D0%BE%D0%BA%D0%BE%D0%B4.%D1%80%D1%83.html
но бекап я сделал, так что хуй вам. Я требую продолжения банкета.
+5
function is_assoc( $array ) {
return is_array($array) && substr( json_encode($array), 0, 1 ) == '{';
}
+5
class Db {
private $where;
private $select = '*';
private $limit;
private $order_by;
private $query;
private $set;
private function query_string($table){
$query = ($this->query) ? $this->query : "SELECT $this->select FROM $table WHERE $this->where $this->order_by $this->limit";
return $query;
}
function query($text){
$this->query = $text;
return $this;
}
function where_text($text){
$operator = 'AND';
if (!$this->where){
$this->where = $text;
} else {
$this->where .= $operator." ".$text;
}
return $this;
}
function order_by_text($text){
if (!$this->order_by){
$this->order_by = ' ORDER BY '.$text;
} else {
$this->order_by .= ', '.$text;
}
}
function connect($host,$login_mysql,$password_mysql,$baza_name) {
$db = @mysql_connect("$host", "$login_mysql", "$password_mysql");
mysql_set_charset('utf8',$db);
if (!$db) exit("<p>Sorry, not available MySQL server</p>");
if (!@mysql_select_db($baza_name,$db)) exit("<p>Unfortunately, the database is not available</p>");
}
function select($column){
$this->select = $column;
return $this;
}
function limit($start,$count){
$this->limit = ' LIMIT '.$start.','.$count;
return $this;
}
function order_by($key){
if (is_array($key)){
foreach ($key as $column => $value){
if (!$this->order_by){
$this->order_by = ' ORDER BY '.$column.' '.$value;
} else {
$this->order_by .= ', '.$column.' '.$value;
}
}
} else {
if (!$this->order_by){
$this->order_by = ' ORDER BY '.$key;
} else {
$this->order_by .= ', '.$key;
}
}
return $this;
}
function where($key,$compare = '='){
$operator = 'AND';
if (is_array($key)){
foreach ($key as $column=>$value){
if (!$this->where){
$this->where = $column.$compare."'".$value."' ";
} else {
$this->where .= $operator." ".$column.$compare."'".$value."' ";
}
}
} else {
$key = explode(',',$key);
if (!$this->where){
$this->where = $key[0].$compare."'".$key[1]."' ";
} else {
$this->where .= $operator." ".$key[0].$compare."'".$key[1]."' ";
}
}
return $this;
}
function search($column,$search){
$operator = 'AND';
$search = strtr($search,array(" "=>" +"));
$search = '+'.$search;
$w = 'MATCH('.$column.") AGAINST('".$search."' IN BOOLEAN MODE)";
if (!$this->where){
$this->where = $w;
} else {
$this->where .= $operator." ".$w;
}
return $this;
}
function lines($table,$ext = true){
$msql_query = mysql_query($this->query_string($table));
$line = mysql_fetch_assoc($msql_query);
"Удобный php класс для работы с MySQL"
https://habrahabr.ru/post/277095
+175
function json2array($json_data)
{
$json_array = false;
$json = substr($json, 1, -1);
$json = str_replace(array(":", "{", "[", "}", "]"), array("=>", "array(", "array(", ")", ")"), $json_data);
@eval("\$json_array = array({$json});");
return $json_array;
}
Парсим json
−99
--Поиск минимальной выпуклой оболочки
import Data.List; import Data.Ord
--общие функции и типы
data Point = P{x::Float,y::Float}
deriving (Show,Eq)
getRotate a b c = baX * cbY - baY * cbX
where baX = x b - x a; baY = y b - y a;
cbX = x c - x b; cbY = y c - y b;
sortFunc a b c
|k < 0 = LT
|k == 0 = compare (long a c) (long a b)
|k > 0 = GT
where k = getRotate a b c
long a b = (x b - x a)*(x b - x a) + (y b - y a)*(y b - y a)
getLeftPoint = minimumBy (comparing x)
--Джарвис
getMBOJarvis l = mboJ fp l fp
where fp = getLeftPoint l
mboJ current list fp
|getRotate current next fp > 0 = []
|True = current : mboJ next listWOC fp
where listWOC = filter ((/=)current) list;
next = minimumBy (sortFunc current) listWOC;
--Грехем
getMBOGragam = tail.throwGraham.sortGraham
sortGraham list = fp:sortBy (sortFunc fp) list
where fp = getLeftPoint list
throwGraham (f:s:t) = mboG (s:f:[]) t
mboG fs@(f:s:st) sn@(h:t)
|sortFunc s f h == GT = mboG (s:st) sn
|True = mboG(h:fs) t
mboG fs@(f:st) sn@(h:t) = mboG(h:fs) t
mboG l [] = l
--тесты
testList1 = [P 0 (-1), P (-1) 0, P 0 1,P 1 0,P (-0.5) (-0.5),P 0.5 (-0.5),P (-0.5) 0.5,P 0.5 0.5,P 0 0]
testList2 = [P 0 0, P 1 0, P 0 1,P 2 0,P 1 1,P 0 2,P 2 1,P 1 2,P 2 2]
testJ1 = mapM_ print $ getMBOJarvis testList1
testG1 = mapM_ print $ getMBOGragam testList1
testJ2 = mapM_ print $ getMBOJarvis testList2
testG2 = mapM_ print $ getMBOGragam testList2
Haskell
[сарказм]
Как я могу идти против моды - не заливать этих французских лаб и не выпивать чаю?
Выкладываю, что бы порадовать своего кота Барсика. Барсик, покойся с миром.
А спонсор этого говна - компания "Потролль препода". "Потролль препода" - пиши лабы на хаскелле
[/сарказм]
+52
double cCompositeBlock::determinant4x4(double *d){ // WARNING It's not logically connected with class.
return d[3]*d[6]*d[9]*d[12] -d[2]*d[7]*d[9]*d[12]-
d[3]*d[5]*d[10]*d[12] +d[1]*d[7]*d[10]*d[12]+
d[2]*d[5]*d[11]*d[12] -d[1]*d[6]*d[11]*d[12]-
d[3]*d[6]*d[8]*d[13] +d[2]*d[7]*d[8]*d[13]+
d[3]*d[4]*d[10]*d[13] -d[0]*d[7]*d[10]*d[13]-
d[2]*d[4]*d[11]*d[13] +d[0]*d[6]*d[11]*d[13]+
d[3]*d[5]*d[8]*d[14] -d[1]*d[7]*d[8]*d[14]-
d[3]*d[4]*d[9]*d[14] +d[0]*d[7]*d[9]*d[14]+
d[1]*d[4]*d[11]*d[14] -d[0]*d[5]*d[11]*d[14]-
d[2]*d[5]*d[8]*d[15] +d[1]*d[6]*d[8]*d[15]+
d[2]*d[4]*d[9]*d[15] -d[0]*d[6]*d[9]*d[15]-
d[1]*d[4]*d[10]*d[15] +d[0]*d[5]*d[10]*d[15];
}
+3
#include <iostream>
using namespace std;
class Base {
public:
Base() {
cout << "Base construct\n";
}
virtual ~Base() {
cout << "Base destruct\n";
}
};
class Child: public Base {
public:
Child() {
cout << "Child construct\n";
}
~Child() {
cout << "Child destruct\n";
}
};
int main() {
Base *base = new Child();
delete base;
}
Hy нe oчeвиднo жe! Для тoгo, чтoб вызывaлиcь вce дecтpyктopы, нyжнo oбъявить eгo виpтyaльным. B тo вpeмя кaк кoнcтpyктop бeз мoдификaтopa virtual paбoтaeт тaк жe, кaк виpтyaльный дecтpyктop.
И зaчeм вoбщe ocтaвлять вoзмoжнocть нe виpтyaльнoгo дecтpyктopa - нe мoгy пpeдcтaвить ceбe cлyчaя, кoгдa пpи yдaлeнии oбъeктa нyжeн вызoв дecтpyктopa тoлькo бaзoвoгo клacca.
+4
#include <iostream>
using namespace std;
void enable_misalignment_access_check(){
cout<<"begin "<<__FUNCTION__<<endl;
__asm__(
"pushf\n"
"orl $(1<<18),(%esp)\n"
"popf\n"
);
cout<<"end "<<__FUNCTION__<<endl;
}
void alignedAccess(volatile unsigned char foo[])
{
cout<<"begin "<<__FUNCTION__<<endl;
volatile int t = *(int *)(foo);
cout<<"end "<<__FUNCTION__<<endl;
}
void unalignedAccess(volatile unsigned char foo[])
{
cout<<"begin "<<__FUNCTION__<<endl;
volatile int t = *(int *)(foo+1);
cout<<"end "<<__FUNCTION__<<endl;
}
unsigned char foo[] = { 1, 2, 3, 4, 5, 6 };
int main(void)
{
alignedAccess(foo);
unalignedAccess(foo);
enable_misalignment_access_check();
alignedAccess(foo);
unalignedAccess(foo);
return 0;
}
http://codepad.org/D6b5asES
begin alignedAccess end alignedAccess
begin unalignedAccess end unalignedAccess
begin enable_misalignment_access_check end enable_misalignment_access_check
begin alignedAccess end alignedAccess
begin unalignedAccess
Bus error
+159
/*
-----------------------------------------------------------------
Отмечаем все темы как прочитанные
-----------------------------------------------------------------
*/
$req = mysql_query("SELECT `forum`.`id`
FROM `forum` LEFT JOIN `cms_forum_rdm` ON `forum`.`id` = `cms_forum_rdm`.`topic_id` AND `cms_forum_rdm`.`user_id` = '$user_id'
WHERE `forum`.`type`='t'
AND `cms_forum_rdm`.`topic_id` Is Null");
while ($res = mysql_fetch_assoc($req)) {
mysql_query("INSERT INTO `cms_forum_rdm` SET
`topic_id` = '" . $res['id'] . "',
`user_id` = '$user_id',
`time` = '" . time() . "'");
}
$req = mysql_query("SELECT `forum`.`id` AS `id`
FROM `forum` LEFT JOIN `cms_forum_rdm` ON `forum`.`id` = `cms_forum_rdm`.`topic_id` AND `cms_forum_rdm`.`user_id` = '$user_id'
WHERE `forum`.`type`='t'
AND `forum`.`time` > `cms_forum_rdm`.`time`");
while ($res = mysql_fetch_array($req)) {
mysql_query("UPDATE `cms_forum_rdm` SET
`time` = '" . time() . "'
WHERE `topic_id` = '" . $res['id'] . "' AND `user_id` = '$user_id'");
}
Один из самых популярных мобильных движков - JohnCMS.
Скрипт отмечает темы форума как прочтенные. Частенько бывает за сотню непрочитанных тем. А я посещаю редко, так у меня вообще за тысячу переваливает иногда.