- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
$em = '';
foreach(array_unique(explode(',', $ae)) as $u) {
if(!$u)
continue;
if($em)
$em .= ',';
$em .= $u;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
$em = '';
foreach(array_unique(explode(',', $ae)) as $u) {
if(!$u)
continue;
if($em)
$em .= ',';
$em .= $u;
}
Кому сколько времени понадобилось, чтоб понять, что делает этот код?
+140
<a href='javascript:go("http://www.site.ru/?id=2167&lang=ru&ct=3&cid=2167&r=2167")' class="A_ThirdSelected"><nobr>Экономика</nobr></a>
Функция go просто переадресовывает на нужный адрес. Видать писать ссылки в href уже не модно
+147
String classToType(Class cls) {
if (cls == Point.class) {
return "int2";
} else if ((cls == Integer.TYPE) || (cls == Integer.class)) {
return "int";
} else if ((cls == Double.TYPE) || (cls == Double.class)) {
return "double";
} else if (cls == String.class) {
return "String";
} else if ((cls == Boolean.TYPE) || (cls == Boolean.class)) {
return "boolean";
} else {
return null;
}
}
−92
my_age = [lambda k, f=f: f**k for f in xrange(10) if 'I want'][4](2) + 2
F**k yeah...
+76
public class ThreadPoolExecutor implements Executor {
private int maximumPoolSize; // ìàêñèìàëüíîå êîëè÷åñòâî ïîòîêîâ
private long keepAliveTime; // âðåìÿ îæèäàíèÿ íîâîé çàäà÷è
private Integer poolSize; // êîëè÷åñòâî ñîçäàííûõ ïîòîêîâ
private Vector workQueue; // î÷åðåäü çàäà÷
private Vector threadPool; // ïóë ïîòîêîâ
public ThreadPoolExecutor(int maxPoolSize, long time) {
this.maximumPoolSize = maxPoolSize;
this.keepAliveTime = time;
this.poolSize = new Integer(0);
workQueue = new Vector();
threadPool = new Vector();
new Thread() {
public void run() {
for (;;) {
try {
Thread.sleep(keepAliveTime);
} catch (InterruptedException e) {
System.out.println("interrupted");
}
interruptIfIdle();
}
}
}.start();
}
public void execute(Runnable task) {
if (task == null)
throw new NullPointerException();
workQueue.addElement(task);
for (;;) {
int status = addIfUnderMaximumPoolSize(task);
if (status > 0)
return;
if (status == 0) {
reject(task);
return;
}
}
}
public void shutdown() {
if (threadPool.size() > 0)
for (int i=0; i < threadPool.size(); i++) {
((Thread) threadPool.elementAt(i)).interrupt();
}
}
public void reject(Runnable task) {
//
}
private int addIfUnderMaximumPoolSize(Runnable task) {
Thread t = null;
int status = 0;
synchronized (poolSize) {
if (poolSize.intValue() < maximumPoolSize) {
Runnable next = (Runnable) workQueue.elementAt(0);
workQueue.removeElementAt(0);
if (next == task) {
status = 1;
} else
status = -1;
t = addThread(next);
}
}
return status;
}
private Thread addThread(Runnable task) {
Thread thread = new Thread(task);
threadPool.addElement(thread);
thread.run();
poolSize = new Integer(poolSize.intValue()+1);
return new Thread();
}
private void interruptIfIdle() {
synchronized (threadPool) {
for (int i=0; i < threadPool.size(); i++) {
try {
((Thread) threadPool.elementAt(i)).interrupt();
} finally {
poolSize = new Integer(poolSize.intValue()-1);
}
}
}
}
}
Junior пишет весьма упрощенный ThreadPoolExecutor для BlackBerry (сорри, не тот пост кинул в прошлый раз).
+152
if (getMaterialDom().ztest_)
{
device.SetRenderState(D3DRS_ZENABLE, TRUE);
device.SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
}
else
device.SetRenderState(D3DRS_ZENABLE, FALSE);
if (getMaterialDom().zwrite_)
device.SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
else
device.SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
Реализация параметров материала z-test и z-write в 3D-движке.
+144
Чтобы удалить или заблокировать пользователя, наведите курсор на его фотографию.
из одноглазников
+174
var reps = 2
var speed = 500
var message = '0';
var p='15';
var T="";
var C=0;
var mC=0;
var s=0;
var sT=null;
if(reps<1)reps=1;
function doTheThing(){
T=message[mC];
A();}
function A()
{
s++
if(s>15){s=1}
if(s==1){document.title='W'}
if(s==2){document.title='WE'}
if(s==3){document.title='WEL'}
if(s==4){document.title='WELC'}
if(s==5){document.title='WELCO'}
if(s==6){document.title='WELCOM'}
if(s==7){document.title='WELCOME'}
if(s==8){document.title='WELCOME T'}
if(s==9){document.title='WELCOME TO'}
if(s==10){document.title='WELCOME TO M'}
if(s==11){document.title='WELCOME TO MY'}
if(s==12){document.title='WELCOME TO MY S'}
if(s==13){document.title='WELCOME TO MY SI'}
if(s==14){document.title='WELCOME TO MY SIT'}
if(s==15){document.title='WELCOME TO MY SITE'}
if(C<(8*reps)){
sT=setTimeout("A()",speed);
C++
}else{
C=0;
s=0;
mC++
if(mC>p-1)mC=0;
sT=null;
doTheThing();}}
doTheThing();
Накопал на древнем сайте по веб-дизайну, какого то самоучки )
ощущение что делалось чтобы показать как не надо делать , но лежало без подписей вообще
+72
package com.uva.concurrent;
import com.uva.log.Log;
import com.uva.log.Message;
public class ThreadExecutor implements Executor {
private final String name;
public ThreadExecutor(String name) {
this.name = name;
}
public void execute(Runnable target) {
new Thread(target, name).start();
}
/** Execute given runnable in separate thread. All exceptions will be caught.
* @param runnable - runnable to execute. */
public void executeSilent(final Runnable runnable) {
new Thread() {
public void run() {
try {
runnable.run();
}
catch (RuntimeException e) {
Log.exception(name, Message.CRITICAL_ERROR, e);
throw e;
}
}
}.start();
}
}
Junior пишет весьма ThreadPoolExecutor для BlackBerry.
+147
{
//-----------------------------------------
// Declare and initialize variables
WSADATA wsaData;
int iResult = 0;
int iError = 0;
INT iNuminfo = 0;
int i;
// Allocate a 16K buffer to retrieve all the protocol providers
DWORD dwBufferLen = 16384;
LPWSAPROTOCOL_INFO lpProtocolInfo = NULL;
// variables needed for converting provider GUID to a string
int iRet = 0;
WCHAR GuidString[40] = { 0 };
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0) {
wprintf(L"WSAStartup failed: %d\n", iResult);
return 1;
}
lpProtocolInfo = (LPWSAPROTOCOL_INFO) MALLOC(dwBufferLen);
if (lpProtocolInfo == NULL) {
wprintf(L"Memory allocation for providers buffer failed\n");
WSACleanup();
return 1;
}
iNuminfo = WSAEnumProtocols(NULL, lpProtocolInfo, &dwBufferLen);
if (iNuminfo == SOCKET_ERROR) {
iError = WSAGetLastError();
if (iError != WSAENOBUFS) {
wprintf(L"WSAEnumProtocols failed with error: %d\n", iError);
if (lpProtocolInfo) {
FREE(lpProtocolInfo);
lpProtocolInfo = NULL;
}
WSACleanup();
return 1;
} else {
wprintf(L"WSAEnumProtocols failed with error: WSAENOBUFS (%d)\n",
iError);
wprintf(L" Increasing buffer size to %d\n\n", dwBufferLen);
if (lpProtocolInfo) {
FREE(lpProtocolInfo);
lpProtocolInfo = NULL;
}
lpProtocolInfo = (LPWSAPROTOCOL_INFO) MALLOC(dwBufferLen);
if (lpProtocolInfo == NULL) {
wprintf(L"Memory allocation increase for buffer failed\n");
WSACleanup();
return 1;
}
iNuminfo = WSAEnumProtocols(NULL, lpProtocolInfo, &dwBufferLen);
if (iNuminfo == SOCKET_ERROR) {
iError = WSAGetLastError();
wprintf(L"WSAEnumProtocols failed with error: %d\n", iError);
if (lpProtocolInfo) {
FREE(lpProtocolInfo);
lpProtocolInfo = NULL;
}
WSACleanup();
return 1;
}
}
}
wprintf(L"WSAEnumProtocols succeeded with protocol count = %d\n\n",
iNuminfo);
for (i = 0; i < iNuminfo; i++) {
wprintf(L"Winsock Catalog Provider Entry #%d\n", i);
--- skipped ---
wprintf(L"\n");
}
if (lpProtocolInfo) {
FREE(lpProtocolInfo);
lpProtocolInfo = NULL;
}
WSACleanup();
return 0;
}
http://msdn.microsoft.com/en-us/library/ms741574(v=VS.85).aspx
Я считаю это говнокодом, т.к. автор данного примера страдает сильнейшие паранойей. Всем переменным он присваивает нолики, например перед return строки 87, 52 и т.д. ... Даже iResult, lpProtocolInfo и т.д. в начале...