- 1
- 2
- 3
- 4
$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);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+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;
Из-за данного участка кода было убито очень много нервова
+168
#include <iostream>
using namespace std;
void main()
{
char U='#';
int K;
_asm
{
mov eax, 0
mov al, U
mov K,eax
}
cout<<K<<endl;
}
"Получение десятичного представления числа". C wasm.ru
+167
PopupWindow* GameLocations::getCurrentPopup()
{
if(m_curPopup != nullptr && m_curPopup->needsClose())
{
m_curPopup->onClose();
m_curPopup = nullptr;
m_walker->BeginWalk(m_graph->getClosestNode(m_currentLocationId));
}
return m_curPopup;
}
−170
SELECT 6000 FROM GETS
+77
function formatSpeedBits(speed) {
// format speed in bits/sec, input: bytes/sec
if (speed < 125000) return Math.round(speed / 125) + " Kbps";
if (speed < 125000000) return Math.round(speed / 1250)/100 + " Mbps";
// else
return Math.round(speed / 1250000)/100 + " Gbps"; // wow!
}
JS в интерфейсе прошивки dd-wrt. Не совсе говнокод.
+121
<taskdef resource="flexTasks.tasks" classpath="${FLEX_TASK_JAR}"/>
<target name="tetris_activity">
<mxmlc file="${FREELANCERS_DIR}\orientsys\skyblockwars\src\tetriswars.as"
output="${basedir}\${DEPLOY_DIR}\tetris\tetriswars.swf"
static-link-runtime-shared-libraries="true"
debug="false"
use-network="true">
<load-config filename="${FLEX_HOME}\frameworks\flex-config.xml"/>
<source-path path-element="${basedir}/LIB"/>
<source-path path-element="C:\freelancers\orientsys\skyblockwars\src"/>
<source-path path-element="${basedir}\RoundsDeveloperAPI\src"/>
<library-path dir="${basedir}\LIB\swc">
<include name="fl.swc"/>
<include name="as3corelib.swc"/>
<include name="greensock.swc"/>
<include name="icodecoder.swc"/>
<include name="maccherone-json.swc"/>
<include name="smartfox.swc"/>
</library-path>
<library-path dir="${FLEX_HOME}\frameworks\libs">
<include name="framework.swc"/>
<include name="textLayout.swc"/>
</library-path>
</mxmlc>
<echo>flickr</echo>
</target>
Просто нет слов... мудак, с которым я работаю удалил мои билд файлы и заменил вот этим. Я работаю в Убунту, и у меня даже эмулятора Виндовса нет.