- 1
logs.splice.apply(logs, [j, 1].concat(line.split("\n")));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+155
logs.splice.apply(logs, [j, 1].concat(line.split("\n")));
+76
private void spreadBullets() {
bulletItemsWip.clear();
for (AbstractInventoryItem item : inventoryItemsSortedByValue) {
if (item instanceof RangeBulletItem) {
bulletItemsWip.add((RangeBulletItem) item);
}
}
rangeUnitsQueueWip.clear();
for (Unit unit : areaObject.getUnits()) {
if (unit.getSpecialization().equals(Unit.UnitSpecialization.RANGE)) {
rangeUnitsQueueWip.add(unit);
}
}
while (rangeUnitsQueueWip.size > 0 && bulletItemsWip.size > 0) {
Iterator<Unit> unitsIterator = rangeUnitsQueueWip.iterator();
while (unitsIterator.hasNext()) {
// find suitable bullets or remove unit from queue
Unit rangeUnit = unitsIterator.next();
RangeBulletItem foundBulletItemInInventoryForUnit = searchBulletFor(rangeUnit);
if (foundBulletItemInInventoryForUnit == null) {
// remove unit from bullets queue
unitsIterator.remove();
} else {
// bullet was found
RangeBulletItem unitBulletsItem = rangeUnit.getEquipment().getRangeBulletsItem();
if (unitBulletsItem == null) {
unitBulletsItem = foundBulletItemInInventoryForUnit.split(1);
rangeUnit.getEquipment().setRangeBulletsItem(unitBulletsItem);
} else {
if (unitBulletsItem.getClass().equals(foundBulletItemInInventoryForUnit.getClass())){
if (!unitBulletsItem.isFull()) {
foundBulletItemInInventoryForUnit.moveQuantity(1, unitBulletsItem);
}
} else {
rangeUnit.getEquipment().dropRangeBullets();
unitBulletsItem = foundBulletItemInInventoryForUnit.split(1);
rangeUnit.getEquipment().setRangeBulletsItem(unitBulletsItem);
}
}
if (foundBulletItemInInventoryForUnit.isEmpty()) {
// remove item from inventory
bulletItemsWip.removeValue(foundBulletItemInInventoryForUnit, true);
remove(foundBulletItemInInventoryForUnit);
}
if (unitBulletsItem.isFull()) {
// remove unit from bullets queue
unitsIterator.remove();
}
if (bulletItemsWip.size == 0) {
// stop spreading
break;
}
}
}
}
// sync quantities to inventory
for (AbstractInventoryItem item : bulletItemsWip) {
getItem(item.getClass()).setQuantity(item.getQuantity());
}
}
Раздать пули отряду...
+81
class GetDataFromMySQL extends AsyncTask<String, String, String> {
protected String doInBackground(String[] params) {
runOnUiThread(new Runnable() {
public void run() {
...
...
//абсолютно вся логика здесь.
}
Мастер многопоточного ПОГРОМмирования под Ондроид...
−114
cur.execute("""SELECT EXTRACT(dow from DATE %(date)s)""", {"date" : datetime})
week = cur.fetchone()
Я конечно знаю, что ГК про даты это плохой тон, но такого я еще не видел.
+76
private List< String > extractMetaDataLines()
{
final ArrayList< String > metaDataLines = new ArrayList< String >();
int currentLineIndex = 0;
int start = 0;
int end = 0;
for ( final String line : getLines() )
{
if ( line.contains( METADATA_TAG ) )
{
if ( line.contains( "</" ) )
{
end = currentLineIndex
- ( getLines().get( currentLineIndex - 1 ).contains( "]]>" ) ? 1
: 0 );
if ( line.contains( "<fx" )
|| line.contains( "<mx" ) )
{
start = end;
}
break;
}
if ( line.contains( "<" ) )
{
start = currentLineIndex
+ ( getLines().get( currentLineIndex + 1 ).contains( "CDATA[" ) ? 2
: 1 );
}
}
currentLineIndex++;
}
metaDataLines.addAll( getLines().subList( start,
end ) );
return metaDataLines;
}
build.xml:413: java.lang.IllegalArgumentException: fromIndex(12) > toIndex(11)
at java.util.ArrayList.subListRangeCheck(ArrayList.java:964)
at java.util.ArrayList.subList(ArrayList.java:954)
at com.adobe.ac.pmd.files.impl.MxmlFile.extractMetaDataLines(MxmlFile.java:262)
at com.adobe.ac.pmd.files.impl.MxmlFile.copyScriptLinesKeepingOriginalLineIndices(MxmlFile.java:191)+159
null != localStorage.getItem("lock") && "2" == localStorage.getItem("lock") &&
($(".up_link").css("bottom", 0), $(".popular").removeClass("open")),
e.find(".door").on("click", function() {
return "2" == localStorage.getItem("lock") ?
($(".up_link").css("bottom", 80), e.addClass("open"),
localStorage.setItem("lock", "1")) :
($(".up_link").css("bottom", 0), e.removeClass("open"),
localStorage.setItem("lock", "2")), !1
});
Пример кода с echo.msk.ru
+53
{
...
_tswfstring contentID = fileName;
_tswfstring::size_type index = fileName.find_last_of ( _T("\\") );
if ( index != -1 )
contentID.erase(0, index + 1);
TCHAR name[10] = {0};
memcpy(name, contentID.c_str() + contentID.length() - 9, 9 * sizeof(TCHAR));
if(name[6] == _T('B') || name[6] == _T('b')) //to upper case if .bmp
{
name[6] = _T('B');
name[7] = _T('M');
name[8] = _T('P');
}
}
−109
if form.cleaned_data.has_key('replace_id') and type(form.cleaned_data['replace_id']) == type(32):
...
Логично, чо
+159
...
$personInfos = $query->getResult();
foreach ($personInfos as $personInfo) {
return $personInfo;
}
/* we lost our person */
return false;
Ребята-оутсорсеры насмешили наш отдел))
+159
var saveButtonStatus = (saveBtn.length != 0 && (!saveBtn.hasClass('disabled') && !saveBtn.is(':disabled') && !saveBtn.hasClass('ignore')) ) ? true : false;
if(saveButtonStatus) {
return true;
}
....
Валидация