- 1
- 2
- 3
- 4
- 5
{{sectionelse}}
<script language="javascript">
window.location = '/megasection/megapage.html?step='+{{if $step eq '2'}}'3'{{else}}'1'{{/if}};
</script>
{{/section}}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
{{sectionelse}}
<script language="javascript">
window.location = '/megasection/megapage.html?step='+{{if $step eq '2'}}'3'{{else}}'1'{{/if}};
</script>
{{/section}}
PHP, Smarty, редиректы уже не в моде
+165
Ckey::Ckey(const String& name, const String& suffix1, const String& suffix2, const String& suffix3)
{
ASSERT(name.Size(), "Key with emty name are invalid!");
if (!name.Size())
{
return;
}
PushBack(name);
if (!suffix1.Size())
{
return;
}
PushBack(suffix1);
if (!suffix2.Size())
{
return;
}
PushBack(suffix2);
if (!suffix3.Size())
{
return;
}
PushBack(suffix3);
}
Ну просто замечательный конструктор класса.
Собственно сам класс унаследован (public-ом, причем) от местной реализации класса vector, отсюда загадочные методы PushBack.
А String - это не менее замечательная, местная, реализация строк.
+160
//create a list of rules to block
var blockRules = ["http://example.com/images/*",
"*://example.org/css/*"];
// add them to the content blocker
for (var rule in blockRules) {
opera.extension.urlfilter.block.add(blockRules[rule])
}
Экзампле из официальной документации одного браузера, отчаянно пытающегося прекратить катиться в сраное говно и набрать популярность.
Будет растащено хомячками на копипасту.
И, striker, убери уже этот долбанный trim для leading spaces
+132
<A\n <BR / href="http://www.site.ru" >Некий текст</A>
<P Иванов id=Значение_без_кавычек_кирилицей><P>Некий текст</P>
<SPAN><SPAN Л.И. Некий текст</SPAN>
Вот несколько кривых кусков HTML кода с одного государственного портала
+74
public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWrapper {
@SuppressWarnings("unchecked")
private void setPropertyValue(PropertyTokenHolder tokens, PropertyValue pv) throws BeansException {
String propertyName = tokens.canonicalName;
String actualName = tokens.actualName;
if (tokens.keys != null) {
// Apply indexes and map keys: fetch value for all keys but the last one.
PropertyTokenHolder getterTokens = new PropertyTokenHolder();
getterTokens.canonicalName = tokens.canonicalName;
getterTokens.actualName = tokens.actualName;
getterTokens.keys = new String[tokens.keys.length - 1];
System.arraycopy(tokens.keys, 0, getterTokens.keys, 0, tokens.keys.length - 1);
Object propValue;
try {
propValue = getPropertyValue(getterTokens);
}
catch (NotReadablePropertyException ex) {
throw new NotWritablePropertyException(getRootClass(), this.nestedPath + propertyName,
"Cannot access indexed value in property referenced " +
"in indexed property path '" + propertyName + "'", ex);
}
// Set value for last key.
String key = tokens.keys[tokens.keys.length - 1];
if (propValue == null) {
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName,
"Cannot access indexed value in property referenced " +
"in indexed property path '" + propertyName + "': returned null");
}
else if (propValue.getClass().isArray()) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
Class requiredType = propValue.getClass().getComponentType();
int arrayIndex = Integer.parseInt(key);
Object oldValue = null;
try {
if (isExtractOldValueForEditor()) {
oldValue = Array.get(propValue, arrayIndex);
}
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType,
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), requiredType));
Array.set(propValue, arrayIndex, convertedValue);
}
catch (IndexOutOfBoundsException ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Invalid array index in property path '" + propertyName + "'", ex);
}
}
else if (propValue instanceof List) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
Class requiredType = GenericCollectionTypeResolver.getCollectionReturnType(
pd.getReadMethod(), tokens.keys.length);
List list = (List) propValue;
int index = Integer.parseInt(key);
Object oldValue = null;
if (isExtractOldValueForEditor() && index < list.size()) {
oldValue = list.get(index);
}
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType,
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), requiredType));
if (index < list.size()) {
list.set(index, convertedValue);
}
else if (index >= list.size()) {
for (int i = list.size(); i < index; i++) {
try {
list.add(null);
}
catch (NullPointerException ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Cannot set element with index " + index + " in List of size " +
list.size() + ", accessed using property path '" + propertyName +
"': List does not support filling up gaps with null elements");
}
}
list.add(convertedValue);
}
}
else if (propValue instanceof Map) {
//...
}
}
}
}
Spring...
+162
function db_date_time($time = null) {
if (is_null($time)) {
$time = time();
}
$s = explode('.', date("d.m.Y.H.i.s", $time));
return $s[2] . '-' . $s[1] . '-' . $s[0] . ' ' . $s[3] . ':' . $s[4] . ':' . $s[5];
}
−179
class Student(models.Model):
fio = models.CharField(max_length=100)
birthday = models.DateField()
stud_tick = models.IntegerField()
group = models.ForeignKey("Group")
starosta = models.BooleanField()
class Meta:
unique_together = (("group", "starosta"),)
class Group(models.Model):
name = models.CharField(max_length=20)
admin.site.register(Student)
admin.site.register(Group)
+165
ID3DBlob* pErrorBlob;
hr = D3DX11CompileFromFile( szFileName, NULL, NULL, szEntryPoint, szShaderModel,
dwShaderFlags, 0, NULL, ppBlobOut, &pErrorBlob, NULL );
if( FAILED(hr) )
{
if( pErrorBlob != NULL )
OutputDebugStringA( (char*)pErrorBlob->GetBufferPointer() );
if( pErrorBlob ) pErrorBlob->Release();
return hr;
}
if( pErrorBlob ) pErrorBlob->Release();
Текст примера из MS DXSDK. Проверка - а вдруг pErrorBlob самоуничтожается после прочтения?
+70
public static void m()
{
cO = cO + "3659";
RecordStore recordstore;
if((recordstore = RecordStore.openRecordStore("saves", true)) != null)
{
if(recordstore.getNumRecords() == 20)
recordstore.closeRecordStore();
for(; recordstore.getNumRecords() < 20; recordstore.addRecord(null, 0, 0));
byte abyte0[] = recordstore.getRecord(6);
recordstore.setRecord(20, abyte0, 0, abyte0 == null ? 0 : abyte0.length);
recordstore.closeRecordStore();
}
return;
JVM INSTR dup ;
Exception exception;
exception;
printStackTrace();
cQ.concat("fuck ur hax, nigers :) muahaha :D");
cQ + "x";
return;
}
Не поверите, но это было найдено в недрах java игрушки :)
−369
n=' '.join((n[::-1][n[::-1].find('_')+1:])[::-1].lower().replace('_',' ').split()).split()
Нашел у себя в коде. Что делает уже не осилил вспомнить.