- 1
class AutocompleteAddressZaplatka2 extends AutocompleteAddressZaplatka
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+192
class AutocompleteAddressZaplatka2 extends AutocompleteAddressZaplatka
Фундаментальные объектно-ориентированные костыли ...
+107
procedure TFCar.Button3Click(Sender: TObject);
begin
gUpload.Visible:= True;
Button3.Enabled:= False;
bClear.Enabled:= False;
bAdd.Enabled:= False;
bCreateOrder.Enabled:= False;
bCloce.Enabled:= False;
mysleep(100);
sleep(10000);
ShowMessage('sleep off');
end;
----------------
procedure mysleep(i:Integer);
var
z:Integer;
begin
for z:=0 to i do
begin
Sleep(5);
Application.ProcessMessages;
end ;
end;
---------------
это немного помогло решить проблему... кнопки становятся неактивными до выполнения sleep(10000);
Немного классического торможения двигателем...
−174
import hashlib
a='letsstart'
def h(inp):
return hashlib.md5(inp).hexdigest()
while h(a) != a:
a=h(a)
print 'I FIND IT!!! ITS ',a
Давно хочу найти эту строку.
+118
object res = DataConnection.ExecuteScalar(sql);
int count = (int)(long)res;
Чтокуда?
+161
//main.cpp
#include "head.h"
int main()
{
//fcii.cpp
#include "head.h"
void odin (vector<Zapis> &mas)
{
Zapis buf;
cout<<"Введите номер УДК: ";
cin>>buf.id;
cout<<"Введите фамилию и инициалы автора: ";
cin>>buf.fio;
cout<<"Введите название книги: ";
cin>>buf.nazv;
cout<<"Введите год издания: ";
cin>>buf.god;
cout<<"Введите количество экземпляров: ";
cin>>buf.kol;
mas.resize(mas.size()+1,buf);
vivod (mas);
}
void dva (vector<Zapis> &mas)
{
char udk[4];
cout<<"Введите УДК книги, которую необходимо удалить: ";
cin>>udk;
int flag=1;
int k=0;
for (vector<Zapis>::iterator i=mas.begin();i!=mas.end();i++)
{
flag=1;
if (strlen(udk)==strlen(mas[k].id))
for (int j=0;udk[j]!=0;j++)
if (udk[j]!=mas[k].id[j])
flag=0;
if (flag==1)
{
mas.erase(i);
flag=-1;
break;
}
k++;
}
if (flag!=-1)
{
cout<<endl<<"Книги с данным УДК не существует"<<endl;
}
else vivod(mas);
}
void tri(vector<Zapis> &mas)
{
vector<int> mas_buf(mas.size());
for (int i=0;i<mas.size();i++)
mas_buf[i]=mas[i].god;
sort(mas_buf.begin(),mas_buf.end()) ;
for (int i=0;i<mas.size();i++)
mas[i].god=mas_buf[i];
vivod(mas);
}
int zapros (vector<Zapis> &mas)
{
int otvet;
cout<<endl<<"Если вы хотите добавить данные о книгах - нажмите 1;"<<endl;
cout<<"Если вы хотите удалить данные о списываемых книгах - нажмите 2;"<<endl;
cout<<"Если вы хотите упорядочить книги по годам издания - нажмите 3;"<<endl;
cout<<"Если вы хотите завершить работу программы - нажмите 0."<<endl;
cin>>otvet;
switch (otvet)
{
case 0: {return 0;}
case 1: {
odin(mas);
zapros(mas);break;
}
Взято отсюда: http://programmersforum.ru/forumdisplay.php?f=14
+153
$dateFrom_array = explode('-', $_REQUEST['intervalFrom']);
$dateUnix = mktime(0, 0, 0, $dateFrom_array[1], $dateFrom_array[2], $dateFrom_array[0]);
$dateUnix -= 60 * 60 * 24 * 30 * 2; // - 2 месяца
$dateFrom = date("Y-m-d", $dateUnix);
+162
foreach(split(',', '101,102,150,1351,2135,22153,351,15321,5351,235') as $key => $val)
$tmparray[] = $val;
разбиваем строку в массив )))
+117
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Caeser_method
{
class Program
{
static void Main(string[] args)
{
int n = 3;
Console.Write("Input string to encoding: ");
string input = Console.ReadLine();
Csr enc = new Csr(n,input);
// Csr dec;
enc.encrypt();
Console.WriteLine(enc);
// dec = new Csr(n, input);
enc.decrypt();
Console.WriteLine(enc);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Caeser_method
{
class Csr
{
public int n;
public string phraze,outputphr;
public Csr(int n, string phraze)
{
this.n = n;
this.phraze = phraze;
this.outputphr = "";
}
public void encrypt()
{
foreach (char c in this.phraze)
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
{
if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
(c + this.n > 'Z' ? ('A' + ((c -'Z' + (this.n - 1)))) : (c + this.n)) :
(c + this.n > 'z' ? ('a' + ((c - 'z' + (this.n - 1)))) : (c + this.n)));
else this.outputphr += c;
}
else
{
if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
(c + this.n > 'Я' ? ('А' + ((c - 'Я' + (this.n - 1)))) : (c + this.n)) :
(c + this.n > 'я' ? ('а' + ((c - 'я' + (this.n - 1)))) : (c + this.n)));
else this.outputphr += c;
}
}
public void decrypt()
{
this.phraze = this.outputphr;
this.outputphr = "";
foreach (char c in this.phraze)
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
{
if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
(c - this.n < 'A' ? ('Z' - (('A' - c + (this.n - 1)))) : (c - this.n)) :
(c - this.n < 'a' ? ('z' - (('a' - c + (this.n - 1)))) : (c - this.n)));
else this.outputphr += c;
}
else
{
if (char.IsLetter(c)) this.outputphr += (char)(char.IsUpper(c) ?
(c - this.n < 'А' ? ('Я' - (('А' - c + (this.n - 1)))) : (c - this.n)) :
(c - this.n < 'а' ? ('я' - (('а' - c + (this.n - 1)))) : (c - this.n)));
else this.outputphr += c;
}
}
public override string ToString()
{
return string.Format("Encoded string: {0}",this.outputphr);
}
}
}
Реализация шифрования методом Цезаря
+158
class Query {
protected $baseTable;
protected $baseTableAlias;
protected $whereGroup;
protected $joins = array();
protected $fields = array();
protected $executed = FALSE;
protected $resource = NULL;
function __construct($base_table = 'node', $alias = 'n') {
$this->whereGroup = new QueryWhereGroup();
$this->baseTable = $base_table;
$this->baseTableAlias = empty($alias) ? $base_table : $alias;
}
function select($fields) {
settype($fields, 'array');
foreach ($fields as $alias => $field) {
if (is_numeric($alias)) {
$this->fields[] = $field;
}
else {
$this->fields[$alias] = "$field as $alias";
}
}
return $this;
}
/**
* @param QueryWhereGroup $whereGroup
* @return Query
*/
function where($whereGroup) {
call_user_func_array(array($this->whereGroup, 'cond'), func_get_args());
return $this;
}
function createWhereGroup() {
return new QueryWhereGroup();
}
function join($table, $alias = NULL, $condition, $join_type = 'INNER') {
if (!$alias) {
$alias = $table;
}
if (is_array($condition)) {
$condition = 'USING ('. join(', ', $condition) .')';
}
if (!preg_match('/^ON|USING/i', $condition)) {
$condition = 'ON '. $condition;
}
$this->joins[$alias] = "$join_type JOIN $table $alias $condition";
return $this;
}
function compile() {
$select_fields = join(', ', array_unique($this->fields));
$joins_list = join("\n", $this->joins);
$where_conditions = $this->whereGroup->compile();
if (!empty($where_conditions)) {
$where_conditions = 'WHERE '. $where_conditions;
}
return "SELECT $select_fields FROM {{$this->baseTable}} {$this->baseTableAlias} \n $joins_list $where_conditions";
}
function args() {
return $this->whereGroup->args;
}
function execute() {
return db_query($this->compile(), $this->args());
}
function fetchAll() {
$res = $this->execute();
while($row = db_fetch_object($res)) {
$rows[] = $row;
}
return $rows;
}
}
построитель запросов (drupal 6)
wheregroup здесь http://govnokod.ru/6076
+77
top = width / 2d;
bottom = width / 2d;
left = height / 2d;
right = height / 2d;
Из-за данного участка кода было убито очень много нервова