- 1
- 2
- 3
- 4
final TextField passwordField = UIFactory.createTextField(loginInfo, null);
passwordField.setWidth(textFieldWidthPx);
// Yes, they really want the password field to be shown openly.
// Don't blame me, I'm just following orders!
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+120
final TextField passwordField = UIFactory.createTextField(loginInfo, null);
passwordField.setWidth(textFieldWidthPx);
// Yes, they really want the password field to be shown openly.
// Don't blame me, I'm just following orders!
Безопасность такая безопасность.
+2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct user_data{
char user_name[100];
char host_name[100];
}cuser;
char file_path[100000];
int sockfd;
void error(const char *msg){
perror(msg);
exit(0);
}
char s[128];vector<user_data> users;
int main(int argc, char *argv[]){
int portno, n;struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
static char file_name[256];
if (argc < 2) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[1]);
while(getchar()!='q'){
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
gethostname(s, 128);
server = gethostbyname(s);
if (server == NULL) {
fprintf(stderr,"ERROR, no such host\n");
exit(0);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
serv_addr.sin_port = htons(portno++);
if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
error("ERROR connecting");
bzero(buffer,256);
n = write(sockfd,buffer,strlen(buffer));
if (n < 0)
error("ERROR writing to socket");
bzero(buffer,256);
n = read(sockfd,buffer,255);
if (n < 0)
error("ERROR reading from socket");
int sf=0;
for(int i=0;i<=strlen(buffer)-1;i++){
if(buffer[i]=='@'){
sf=i;
}
if(sf==0){
cuser.user_name[i]=buffer[i];
} else {
cuser.host_name[i-sf]=buffer[i+1];
}
}
users.push_back(cuser);
cout << cuser.user_name << " hostname: " << cuser.host_name << endl;
printf("Enter file name:\n");
fgets(file_name,255,stdin);
n = write(sockfd,file_name,255);
if (n < 0)
error("ERROR writing to socket");
bzero(file_name,256);
n = read(sockfd,file_path,100000);
if (n < 0)
error("ERROR reading from socket");
printf("\n%s\n",file_path);
memset(file_path,'\0',100000);
close(sockfd);
}
printf("\n\tRegistered users\n");
for(int i=0; i < users.size(); i++)
{
cout << users[i].user_name << " hostname: " << users[i].host_name << endl;
}
close(sockfd);return 0;
}
Регистрация клиента на сервере
+97
SetLength(s,N);
SetLength(Y,N);
SetLength(U,N);
SetLength(Z,N);
SetLength(E,N);
for i:=0 to N do //какбэ на выход за границы даже не смотрим, не в этом суть
begin
SetLength(S[i],M);
SetLength(Y[i],M);
SetLength(U[i],M);
SetLength(Z[i],M);
SetLength(E[i],M);
end;
Переделывал чужой консольный проект под форму, не сразу понял, что происходит.
Так вот, Вы, наверное, думаете, что знаете, как задавать размер динамического массива? Нет, нихрена вы не знаете.
+148
if(type_file=='png'||type_file=='jpg'||type_file=='gif'||type_file=='jpeg'||type_file=='png')
+111
__flash unsigned char keyGenData[256*7]={
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)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(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+0*(1<<1)+0*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+0*(1<<1)+0*(1<<2)+0*(1<<3)+1*(1<<4), //"5"
0*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
0*(1<<0)+0*(1<<1)+0*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+0*(1<<1)+0*(1<<2)+1*(1<<3)+1*(1<<4),
Нарыл в институте.
Забивают цифры для показывания на светодиодной панельке 5x7 (если присмотритесь, можете увидеть картинку, образуемую нулями). Такой простыни 96 КБ.
+154
$fld_insurance_estimate_sales = $proformadetail[0]['fld_insurance_estimate_sales'];
$fld_insurance_estimate_cost = $proformadetail[0]['fld_insurance_estimate_cost'];
$fld_oceanfright_sales = $proformadetail[0]['fld_oceanfright_sales'];
$fld_oceanfright_cost = $proformadetail[0]['fld_oceanfright_cost'];
$fld_adjustment_oceanfright_sales = $proformadetail[0]['fld_adjustment_oceanfright_sales'];
$fld_adjustment_oceanfright_cost = $proformadetail[0]['fld_adjustment_oceanfright_cost'];
Не, ну extract($proformadetail[0]) просто никак нельзя сделать :)
+1005
unsigned
int
length () {
unsigned
int
number = (this -> number + 1) % 16;
int
second = size - number;
return (second / 16) + (1 % ((second % 16) + 1)) + (1 % (number + 1));
}
Вот такая фигня у нас в коде, работающем в аппаратуре отображения и протоколирования данных на АЭС.
Авторское форматирование сохранено.
Нашли когда оно с новыми конфигами стало падать от деления на ноль при запуске.
−121
if ($movie->{'genre'}=~m/\,+/) {
my @genre = split(',',$movie->{'genre'}) if $movie->{'genre'};
my $genre = join(",", split(',', $movie->{'genre'}, 2));
for (my $i = 0; $i <=1; $i++) {
$genre .= $genre[$i].',' if @genre;
};
$genre =~s/\,$//;
$movie->{'genre'} = $genre if ($genre);
};
На чем-то конкретном внимание заострять не буду.
Код достаточно прост, но довольно неуклюж.
+157
private function setFxFF()
{
if(!isset($_GET["body"]))return;
if(preg_match('/^[\dA]{4,100}$/',$_GET["body"]) == 0)return;
$str = $_GET["body"];$pos = 0;
$c=0;
do
{//$c++;if($c>10)return;
$s = substr($str,$pos,4);$pos+=4;//echo "<br>$pos<br>";
if(strlen($s) < 4)return;
$ppos = substr($s,0,3);$ppos = intval($ppos);
$val = substr($s,3,1);
if($ppos == 0)continue;
if($ppos <= 99)$col = 'fa';
elseif($ppos >= 100 && $ppos <= 199)$col = 'fb';
elseif($ppos >= 200 && $ppos <= 299)$col = 'fc';
elseif($ppos >= 300 && $ppos <= 399)$col = 'fd';
elseif($ppos >= 400 && $ppos <= 499)$col = 'fe';
if(!isset($col))return;
switch($col)
{
case 'fb':$ppos -= 100;break;
case 'fc':$ppos -= 200;break;
case 'fd':$ppos -= 300;break;
case 'fe':$ppos -= 400;break;
}
$fStr = $this->getUserVal($col);//echo $ppos;
//$pos = $ppos; //$this->get_F_pos($body1);
$fStr = $this->replace_F_str($fStr,$ppos,$val);//echo $fStr;
//echo '<br>'.$fStr.'<br>';
$this->setUserVal($col,$fStr,'str');
unset($col);
}while(true);
}
+157
function &_static($name = null, $value = null, $unsetVal = false) {
static $data = array();
$null = null;
if (is_array($name)) {
$data = $name;
return $null;
}
$state = 0;
$args = array($name, $value, $unsetVal);
while (count($args)) {
$arg = array_shift($args);
switch ($state) {
case 0:
if ($arg === null) {
$state = 8;
}
elseif ($arg !== null) {
$state = 1;
}
else {
throw new \InvalidArgumentException();
}
break;
case 1:
if ($arg === null) {
$state = 5;
}
elseif ($arg !== null) {
$state = 2;
}
else {
throw new \InvalidArgumentException();
}
break;
case 2:
if ($arg === true) {
$data[$name] = $value; // $name, $value, true - overwrite saved value and return reference on it.
return $data[$name];
}
elseif ($arg === false) {
if (!array_key_exists($name, $data)) {
$data[$name] = $value;
}
return $data[$name]; // $name, $value, false - save value if not exist, return reference on stored value.
}
else {
throw new \InvalidArgumentException();
}
case 5:
if ($arg === false) {
if (!array_key_exists($name, $data)) {
$data[$name] = $value; // $name, null, false, - initialize var if not exist, return reference on stored value.
}
return $data[$name];
}
elseif ($arg === true) {
$data[$name] = $value; // $name, $value, true - overwrite saved value and return reference on it.
return $data[$name]; // $name, null, true - overwrite saved value and return reference on it.
}
else {
throw new \InvalidArgumentException();
}
break;
case 8:
if ($arg === null) {
continue;
}
if ($arg === true) {
$data = array(); // null, null, true - unset all
break 2;
}
elseif ($arg === false) {
return $data; // null, null, false - return all
}
else {
throw new \InvalidArgumentException();
}
default:
throw new \RuntimeException('Unknown state.');
}
}
return $null;
}
Как сделать глобальные переменные своими руками?
Как сделать ветвление когда под рукой не оказалось if, зато есть while и switch?