- 1
my_age = [lambda k, f=f: f**k for f in xrange(10) if 'I want'][4](2) + 2
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−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 и т.д. в начале...
+160
// File: /controllers/register.php
//......
$sql = 'INSERT INTO `users` SET `ID`=NULL, `login`="'.mysql_real_escape_string(substr($_POST['login'], 0, 12)).'", `pass`= blah blah blah....';
//......
// File: /templates/default/index.tpl
/*
//...
<td><div>Hello, <b>{LOGIN}</b></div><!---- blah blah blah ---><div>Server time: <?php echo getCurrentTime();?></div>
//
*/
//File: /index.php
//......
$sql = 'SELECT * FROM `users` WHERE `id`=........';
$data = SYS::$db->getDataRow($sql);
if(sizeof($data)>0) {
showTeplate(TEMPLATE_NAME, 'index', $data);
}
//......
//Function showTeplate();
function showTeplate($tpl_name, $file_name, $data) {
$template_code = file_get_contents(TPL_PATH.'/'.$tpl_name.'/'.$file_name.'.'.TPL_EXT);
foreach($data as $name=>$value) {
$template_code = str_replace('{'.strtoupper($name).'}', $value, $template_code);
}
//......
eval($template_code);
//......
}
Внимание, загадка! Найти уязвимость.
+164
function withoutCyr(inрut) {
var value = inрut.value;
var re = /а|б|в|г|д|е|ё|ж|з|и|й|ё|к|л|м|н|о|п|р|с|т|у|ф|х|ц|ч|ш|щ|ъ|ы|ь|э|ю|я/gi;
if (re.test(value)) {
value = value.replace(re, '');
inрut.value = value;
}
}
+146
$urt = 'uArts';
$urt1 = 'искуств';
$urt2 = 'сайт';
alert($urt.$urt2.$urt1)//Соединим две переменные используем .
$us = 2;
$us2 = 9;
alert($us + $us2);// Сложение получим 11
Автор писал первую статью для начинающих: http://uarts.ucoz.ru/load/veb_masteru_lt/php/php_rabota_s_peremennymi/17-1-0-25
Но зачем alert из DS? :D
Как вывести переменную?!
есть много способов для создания сайтов используют echo или print и alert
в Ds нужно с("elem")->caption
и код выше =)