- 1
- 2
- 3
- 4
- 5
- 6
- 7
protected function readConfig($configPath) {
$ini = parse_ini_file($configPath);
foreach ($ini as $key => $value) {
$config[$key] = $value;
}
return $config;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
protected function readConfig($configPath) {
$ini = parse_ini_file($configPath);
foreach ($ini as $key => $value) {
$config[$key] = $value;
}
return $config;
}
+147
if ($a = 1) {
...бла-бла-бла
}
−99
Dim byteOut(64) As Byte
Dim i As Integer
Try
byteOut(0) = Len(outCName) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H0 'Box Number - 1
byteOut(5) = Len(outCName) + 1 'message size with null terminator
For i = 1 To Len(outCName) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outCName, i, 1))
Next
byteOut(Len(outCName) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outCName) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Try
byteOut(0) = Len(outWState) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H1 'Box Number - 1
byteOut(5) = Len(outWState) + 1 'message size with null terminator
For i = 1 To Len(outWState) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outWState, i, 1))
Next
byteOut(Len(outWState) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outWState) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
<..ещё один раз..>
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Try
byteOut(0) = Len(outWindC) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H3 'Box Number - 1
byteOut(5) = Len(outWindC) + 1 'message size with null terminator
For i = 1 To Len(outWindC) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outWindC, i, 1))
Next
byteOut(Len(outWindC) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outWindC) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Try
byteOut(0) = Len(outHum) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H4 'Box Number - 1
byteOut(5) = Len(outHum) + 1 'message size with null terminator
For i = 1 To Len(outHum) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outHum, i, 1))
Next
byteOut(Len(outHum) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outHum) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Говнокод почти трёхлетней давности. Понадобилось мне посмотреть, как я реализовывал "общение" по блютусу с Mindstorms NXT, и напоролся на вот это...
+154
function sajax_get_common_js() {
global $sajax_debug_mode;
global $sajax_request_type;
global $sajax_remote_uri;
$t = strtoupper($sajax_request_type);
if ($t != "GET" && $t != "POST")
return "// Invalid type: $t.. \n\n";
ob_start();
?>
// remote scripting library
// (c) copyright 2005 modernmethod, inc
var sajax_debug_mode = <?php echo $sajax_debug_mode ? "true" : "false"; ?>;
var sajax_request_type = "<?php echo $t; ?>";
function sajax_debug(text) {
if (sajax_debug_mode)
alert("RSD: " + text)
}
function sajax_init_object() {
sajax_debug("sajax_init_object() called..")
var A;
try {
A=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
A=new ActiveXObject("Microsoft.XMLHTTP");
} catch (oc) {
A=null;
}
}
if(!A && typeof XMLHttpRequest != "undefined")
A = new XMLHttpRequest();
if (!A)
sajax_debug("Could not create connection object.");
return A;
}
function sajax_do_call(func_name, args) {
var i, x, n;
var uri;
var post_data;
uri = "<?php echo $sajax_remote_uri; ?>";
if (sajax_request_type == "GET") {
if (uri.indexOf("?") == -1)
uri = uri + "?rs=" + escape(func_name);
else
uri = uri + "&rs=" + escape(func_name);
for (i = 0; i < args.length-1; i++)
uri = uri + "&rsargs[]=" + escape(args[i]);
uri = uri + "&rsrnd=" + new Date().getTime();
post_data = null;
} else {
post_data = "rs=" + escape(func_name);
for (i = 0; i < args.length-1; i++)
post_data = post_data + "&rsargs[]=" + escape(args[i]);
}
x = sajax_init_object();
x.open(sajax_request_type, uri, true);
if (sajax_request_type == "POST") {
x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
x.onreadystatechange = function() {
if (x.readyState != 4)
return;
sajax_debug("received " + x.responseText);
var status;
var data;
status = x.responseText.charAt(0);
data = x.responseText.substring(2);
if (status == "-")
alert("Error: " + data);
else
args[args.length-1](data);
}
x.send(post_data);
sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
sajax_debug(func_name + " waiting..");
delete x;
}
<?php
$html = ob_get_contents();
ob_end_clean();
return $html;
}
Из PHPList
PHP и JS в перемешку.
Это печально...
+136
particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.emit = Mathf.Sin(Random.value*Mathf.PI*2) <= 1;
Строчка из кода в Unity3D.
+131
static public int IIF(bool condition, int a, int b)
{
int x = 0;
if (condition)
{
x = a;
}
else
{
x = b;
}
return x;
}
static public bool IIF(bool condition, bool a, bool b)
{
bool x = false;
if (condition)
{
x = a;
}
else
{
x = b;
}
return x;
}
static public Single IIF(bool condition, Single a, Single b)
{
float x = 0;
if (condition)
{
x = a;
}
else
{
x = b;
}
return x;
}
static public Double IIF(bool condition, double a, double b)
{
double x = 0;
if (condition)
{
x = a;
}
else
{
x = b;
}
return x;
}
static public decimal IIF(bool condition, decimal a, decimal b)
{
decimal x = 0;
if (condition)
{
x = a;
}
else
{
x = b;
}
return x;
}
+167
var war;
Объявляем войну :)
Не говнокод, но весело.
+130
char unsigned c;
DWORD m;
DWORD n;
int i = 0;
BOOL b = TRUE;
HANDLE hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("Could not open File");
return NULL;
}
// узнаем размер файла
while (b)
{
b = ReadFile(hFile, &c, 1, &m, NULL);
if (m == 0)
{
printf("STOP ");
printf("%i\n", i);
break;
}
i++;
}
собственно узнаем размер файла, что тут еще скажешь)
+143
Hello, <em>ujkbktj</em>!<br />
<br />
Пользователь <a href="http://govnokod.ru/user/1997">istem</a> ответил на Ваш комментарий к <a href="http://govnokod.ru/5120">говнокоду #5120</a>!<br />
<br />
Напомним, Вы <a href="http://govnokod.ru/5120#comment66331">написали</a>:<br />
<em><span style="text-decoration:blink;">это не код!!</span></em><br />
<br />
На что получили <a href="http://govnokod.ru/5120#comment66347">ответ</a>:<br />
<em>И чё ж у Вас айдишник-то не 666...</em>
<br /><br /><br />
С уважением, Ваш <a href="http://govnokod.ru">Говнокод</a>.
...
+161
// If iMode!=0, non-blocking mode is enabled.
u_long iMode=1;
ioctlsocket(Socket,FIONBIO,&iMode);
// Main loop
for(;;)
{
// Display message from server
char buffer[1000];
memset(buffer,0,999);
int inDataLength=recv(Socket,buffer,1000,0);
std::cout<<buffer;
int nError=WSAGetLastError();
if(nError!=WSAEWOULDBLOCK&&nError!=0)
{
std::cout<<"Winsock error code: "<<nError<<"\r\n";
std::cout<<"Server disconnected!\r\n";
// Shutdown our socket
shutdown(Socket,SD_SEND);
// Close our socket entirely
closesocket(Socket);
break;
}
Sleep(1000);
}
http://www.win32developer.com/tutorial/winsock/winsock_tutorial_3.shtm
Вот как нада работать с сокетами... (строка 27).