- 1
jQuery("#myId"+object+".myTr"+array.length-1).append(JSON.parse(object));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
jQuery("#myId"+object+".myTr"+array.length-1).append(JSON.parse(object));
Appending result to grid table
+155
public function getByAllParameters()
{
$fields = array_keys($this->getFields());
unset($fields[0]);
sort($fields);
if($this->getByConditions(array('id_user', 'status', 'card_bin', 'card_suffix', 'id_card_type', 'card_token'))){
$processing = new Processing();
$processing->id = $this->id_processing;
return $processing->getByPrimary() && $processing->enabled == 1;
}
return false;
}
+156
foreach($PROP as $k1 => $val1)
{
if(is_array($val1))
{
foreach($val1 as $k2 => $val2)
{
$text_name = preg_replace("/([^a-z0-9])/is", "_", "PROP[".$k1."][".$k2."][VALUE][TEXT]");
if(array_key_exists($text_name, $_POST))
{
$type_name = preg_replace("/([^a-z0-9])/is", "_", "PROP[".$k1."][".$k2."][VALUE][TYPE]");
$PROP[$k1][$k2]["VALUE"] = array(
"TEXT" => $_POST[$text_name],
"TYPE" => $_POST[$type_name],
);
}
}
}
}
foreach($PROP as $k1 => $val1)
{
if(is_array($val1))
{
foreach($val1 as $k2 => $val2)
{
if(!is_array($val2))
$PROP[$k1][$k2] = array("VALUE" => $val2);
}
}
}
bitrix
как вам организация цикла(ов)
+155
function showHelp() {
var $is_hidden = document.getElementById('help_btn').style.display == '' ? true : false;
document.getElementById('help_btn').style.display = $is_hidden ? 'none' : '';
document.getElementById('help_text').style.display = $is_hidden ? '' : 'none';
return false;
}
Больше тернарников богу тернарников!
http://83.102.180.29/ (заглушка "Билайна")
+154
switch($step) {
case 0:
setup_config_display_header();
?>
<p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
<ol>
<li><?php _e( 'Database name' ); ?></li>
<li><?php _e( 'Database username' ); ?></li>
<li><?php _e( 'Database password' ); ?></li>
<li><?php _e( 'Database host' ); ?></li>
<li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
</ol>
<p><strong><?php _e( "If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
<p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…" ); ?></p>
<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p>
<?php
break;
case 1:
setup_config_display_header();
//...
case 2:
foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
$$key = trim( wp_unslash( $_POST[ $key ] ) );
$tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
if ( empty( $prefix ) )
wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
// Validate $prefix: it can only contain letters, numbers and underscores.
if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) );
// Test the db connection.
/**#@+
* @ignore
*/
define('DB_NAME', $dbname);
define('DB_USER', $uname);
define('DB_PASSWORD', $pwd);
define('DB_HOST', $dbhost);
/**#@-*/
// We'll fail here if the values are no good.
require_wp_db();
// еще двести строк свитча с html, обработкой данных прямо на лету и даже небольшим количеством инлайн-js
Захотел я подцепиться к внутреннему api установки вордпресса, чтобы эту самую установку делать через конфиг-файлы и композер. В результате проще оказалось имитировать окружение веб-сервера, заполнять всякие $_GET-$_POST и просто подключать нужный файл. А как они сами с этим адом работают - для меня остается загадкой
Целиком https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/setup-config.php и https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/install.php
+159
$(function () {
$('#Who').click(whoAre);
});
function whoAre() {
var who = document.getElementById('whoAreyou');
var value = who.style.display;
var aspnetRoles = document.getElementById('aspnetRoles');
if (value == "none") {
who.style.display = "block";
aspnetRoles[0].value = "Агент";
aspnetRoles[1].value = "Арендодатель";
aspnetRoles[0].text = "Агент";
aspnetRoles[1].text = "Арендодатель";
} else {
who.style.display = "none";
aspnetRoles[0].value = "Moderator";
aspnetRoles[1].value = "Moderator";
aspnetRoles[0].text = "Moderator";
aspnetRoles[1].text = "Moderator";
}
}
меняет элементы, option
+128
ng-include="'views/partials/header.html'"
- class="navbar navbar-static-fixed-top nav"></div>
+ /*class="navbar navbar-static-fixed-top nav"*/></div>
<ui-view id="main" class="container" id="mainContainer"></ui-view>
GIT commit diff for Angular template
+55
//--------------------------------------------------------------------------
#define DEF_P(X, Y, N) X##N
#define DEF_D(X, Y, N) X##N Y##N
#define DP1(DT, X, Y) DT(X, Y, 0)
//--------------------------------------------------------------------------
#define DP2(DT, X, Y) DP1(DT, X, Y), DT(X, Y, 1)
#define DP3(DT, X, Y) DP2(DT, X, Y), DT(X, Y, 2)
#define DP4(DT, X, Y) DP3(DT, X, Y), DT(X, Y, 3)
#define DP5(DT, X, Y) DP4(DT, X, Y), DT(X, Y, 4)
#define DP6(DT, X, Y) DP5(DT, X, Y), DT(X, Y, 5)
#define DP7(DT, X, Y) DP6(DT, X, Y), DT(X, Y, 6)
#define DP8(DT, X, Y) DP7(DT, X, Y), DT(X, Y, 7)
#define DP9(DT, X, Y) DP8(DT, X, Y), DT(X, Y, 8)
#define DP10(DT, X, Y) DP9(DT, X, Y), DT(X, Y, 9)
#define DP11(DT, X, Y) DP10(DT, X, Y), DT(X, Y, 10)
#define DP12(DT, X, Y) DP11(DT, X, Y), DT(X, Y, 11)
#define DP13(DT, X, Y) DP12(DT, X, Y), DT(X, Y, 12)
#define DP14(DT, X, Y) DP13(DT, X, Y), DT(X, Y, 13)
#define DP15(DT, X, Y) DP14(DT, X, Y), DT(X, Y, 14)
//--------------------------------------------------------------------------
// define functor for params count 0
//--------------------------------------------------------------------------
#define TEMP_DEF_PARAM(N)
#define TEMP_SPC_PARAM(N)
#define FUNC_PTR_PARAM(N)
#define FUNC_INV_PARAM(N)
#define FUNC_DEF_PARAM(N)
DEFINE_FUNCTOR(0);
#undef TEMP_DEF_PARAM
#undef TEMP_SPC_PARAM
#undef FUNC_PTR_PARAM
#undef FUNC_INV_PARAM
#undef FUNC_DEF_PARAM
//--------------------------------------------------------------------------
// define functor for other params counts
//--------------------------------------------------------------------------
#define TEMP_DEF_PARAM(N) ,DP##N(DEF_P, typename T,)
#define TEMP_SPC_PARAM(N) ,DP##N(DEF_P, T,)
#define FUNC_PTR_PARAM(N) DP##N(DEF_P, T,)
#define FUNC_INV_PARAM(N) DP##N(DEF_P, p,)
#define FUNC_DEF_PARAM(N) DP##N(DEF_D, T, p)
DEFINE_FUNCTOR(1);
DEFINE_FUNCTOR(2);
DEFINE_FUNCTOR(3);
DEFINE_FUNCTOR(4);
DEFINE_FUNCTOR(5);
DEFINE_FUNCTOR(6);
DEFINE_FUNCTOR(7);
DEFINE_FUNCTOR(8);
DEFINE_FUNCTOR(9);
DEFINE_FUNCTOR(10);
DEFINE_FUNCTOR(11);
DEFINE_FUNCTOR(12);
DEFINE_FUNCTOR(13);
DEFINE_FUNCTOR(14);
DEFINE_FUNCTOR(15);
Весь пиздец https://github.com/Evil-Spirit/Nutmeg/blob/master/CoreSrc/Common/Functor.h
Дети, не программируйте на C++
−88
class DataModel(dict):
_SCHEME_VERSION = 0
_transform = dict()
_additional = dict()
_migration = None
def __init__(self, data=None, network=None, conf=None):
if network and conf:
_scheme = map(lambda x: x.strip(), conf.get(network).keys())
_map = map(lambda x: x.strip(), conf.get(network).values())
self._scheme = int(conf._scheme)
map(lambda x: setattr(self, x[0], data.get(x[1], None)),
[(_scheme[i], _map[i]) for i in xrange(0,len(_map))])
if self._transform.get(network, False):
map(lambda x: setattr(self, x, getattr(self._transform[network], x)(getattr(self, x))),
[k for k in self._transform[network].__dict__.keys() if not k.startswith('__')])
else:
dict.__init__(self, data)
if self.get('_scheme', 0)<self._SCHEME_VERSION and self._migration is not None:
k = [int(k.split('_')[1]) for k in self._migration.__dict__.keys() if not k.startswith('__')]
k.sort()
[k.remove(x) for x in k if x<=self.get('_scheme', 0)]
map(lambda x: getattr(self._migration, 'scheme_%s' % x)(self), k)
self._scheme = self._SCHEME_VERSION
map(lambda x: setattr(self, x, getattr(self._additional, x)(self)),
[k for k in self._additional.__dict__.keys() if not k.startswith('__')])
def __setattr__(self, name, val):
if name in self.__dict__:
self.__dict__[name]= val
else:
self[name] = val
def __getattr__(self, name):
if name in self.__dict__:
return self.__dict__[name]
else:
return self[name]
Mongo migration, written in Python, for human beings.
+153
$date=date(Ymd);
$day=substr($date,6,2);
$month=substr($date,4,2);
$year=substr($date,0,4);
list($date,$month,$year) = explode("/",date("D/M/Y"));