- 1
SET_CCC="CCC= ${CCC}"
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−117
SET_CCC="CCC= ${CCC}"
Где-то в макросах для autotools.
−93
# Source: python3.4/distutils/dir_util.py
# cache for by mkpath() -- in addition to cheapening redundant calls,
# eliminates redundant "creating /foo/bar/baz" messages in dry-run mode
_path_created = {}
# I don't use os.makedirs because a) it's new to Python 1.5.2, and
# b) it blows up if the directory already exists (I want to silently
# succeed in that case).
def mkpath(name, mode=0777, verbose=1, dry_run=0):
"""Create a directory and any missing ancestor directories.
If the directory already exists (or if 'name' is the empty string, which
means the current directory, which of course exists), then do nothing.
Raise DistutilsFileError if unable to create some directory along the way
(eg. some sub-path exists, but is a file rather than a directory).
If 'verbose' is true, print a one-line summary of each mkdir to stdout.
Return the list of directories actually created.
"""
global _path_created
# Detect a common bug -- name is None
if not isinstance(name, basestring):
raise DistutilsInternalError, \
"mkpath: 'name' must be a string (got %r)" % (name,)
# XXX what's the better way to handle verbosity? print as we create
# each directory in the path (the current behaviour), or only announce
# the creation of the whole path? (quite easy to do the latter since
# we're not using a recursive algorithm)
name = os.path.normpath(name)
created_dirs = []
if os.path.isdir(name) or name == '':
return created_dirs
if _path_created.get(os.path.abspath(name)):
return created_dirs
...
Мало того, что метод жив на основании того, что os.makedirs был добавлен только в Python 1.5.2 (мама родная, 2.7 скоро закопаем, а говно всё тянется), так его ещё и умудрились наиндусить на 60 строк кода, да ещё и ХХХ секцию аккуратно положили. Ладно, чего это я придираюсь... Ах да, оно кеширует уже созданные директории, так что если создать папку и удалить её, второй раз её уже никак не создашь...
+134
//#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9)
if (Selection.activeGameObject != null)
control = (IControl)Selection.activeGameObject.GetComponent("IControl");
//#endif
принял код от юнити юниора
+153
document.body.innerHTML = document.body.innerHTML.replace(/guest/g, '');<
+135
bool result = false;
if (xmlString != null)
{
result = reportService.SaveQ360Report(questionnaireId, xmlString, publishReport);
UpdateCurrentReportModel(questionnaireId, reportService);
}
// string errorMessage;
if (result == false)
result = true; //because model is not changed
return Json(new { Success = result, ErrorMessage = DisplayLabels.InvalidModelError });
+53
/* set _god=true temporarily, safely */
class GodScope {
bool _prev;
public:
GodScope();
~GodScope();
};
mongo/db/client.h
Почувствуй простор божий
+121
if (Ints.contains(new int[] { 4, 5 }, statusCode / 100)) {
// error response
} else {
// success response
}
Насколько я знаю, Apache HTTP Client не содержит "официального" метода для определения категории кода состояния. Приходится так.
+156
if (varform)
{
switch (response.variants.length % 10)
{
case 1:
varform=1;
break;
case 2:
case 3:
case 4:
varform=2;
break;
case 0:
case 5:
case 6:
case 7:
case 8:
case 9:
varform=3;
break;
}
}
if (response.variants.length>=11 && response.variants.length<=14)
varform=3;
switch (varform)
{
case 0:
caption.innerHTML="<b>Адрес распознан удачно</b>";
break;
case 1:
caption.innerHTML="<b>Плохой адрес. Найден " + response.variants.length.toString()+" вариант</b>";
break;
case 2:
caption.innerHTML="<b>Плохой адрес. Найдено " + response.variants.length.toString()+" варианта</b>";
break;
case 3:
caption.innerHTML="<b>Плохой адрес. Найдено " + response.variants.length.toString()+" вариантов</b>";
break;
}
Постыдство с сайта http://strela-ru.ucoz.ru/pa_query.html
+117
@Override
public void afterPersistenceInit() {
val conn = emProvider.get().unwrap(Connection.class);
try {
log.info("Transaction isolation level: {}", getLevelString(conn.getTransactionIsolation()));
} catch (final SQLException e) {
log.error("Error getting transaction isolation level", e);
}
}
private String getLevelString(final int isolationLevel) {
// Poor man's enums. Use reflection to find a constant with the given value
try {
for (val maybeLevelConstant: Connection.class.getDeclaredFields()) {
if (maybeLevelConstant.getType() == int.class && maybeLevelConstant.getName().startsWith("TRANSACTION_")
&& maybeLevelConstant.getInt(null) == isolationLevel) {
return maybeLevelConstant.getName();
}
}
} catch (final IllegalArgumentException | IllegalAccessException e) {
return "UNKNOWN";
}
return "UNKNOWN";
}
Ищем рефлексией константу с нужным значением. И всё для того, чтобы напечатать её в логе. Вот что крест животворящий отсутствие энумов в legacy API делает.
+159
<script>
$(function() {
$('#current').load('current.php');
}
</script>
// Тем временем в current.php :
<?
$result = ... ; // данные как-то вытаскиваются из базы
ob_start();?>
<table><?
foreach($result as $res) {?>
<tr><td><?=$res[0]?></td><td><?=$res[1]?></td><td><?=$res[2]?></td></tr>
<?}?>
</table>
<?$table = ob_get_clean();?>
<script>
$('#current').empty();
$('#current').append('<?=str_replace(array("\r","\n"),"",$table)?>');
</script>
Извиняюсь за возможные опечатки: сократил, чтобы оставить только самую мякотку.