- 1
- 2
- 3
- 4
select
if(t.town_name is null, t.id, t.town_name) as 'town',
...
from towns t;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−858
select
if(t.town_name is null, t.id, t.town_name) as 'town',
...
from towns t;
в sql внезапно тоже есть приведение типов и можно получить вот такое назвение города
1101000010010010110100001011101111010000 1011000011010000101101001101000010111000 1101000010110010110100001011111011010001 1000000111010001100000101101000010111110 1101000010111010
+127
'8, :.
`""`oooob."T,.
,-`".)O;8:doob.'-.
,..`'.'' -dP()d8O8Yo8:,..`,
-o8b- ,..)doOO8:':o; `Y8.`,
,..bo.,.....)OOO888o' :oO. ". `-.
, "`"d....88OOOOO8O88o :O8o;. ;;,b
,dOOOOO""""""""O88888o: :O88Oo.;:o888d
""888Ob...,-- :o88O88o:. :o'"""""""Y8OP
d8888.....,.. :o8OO888:: ::
,dd8". ,-)do8O8o:"""; :::
-"",`(;O"KdOo:: :::
.doo:::""":: :. 'o:
,.. .;ooooooo..o:""""" ::;. ::;. 'o.
,, "' ` .. .d;o:"""' ::o:;::o:: :;
d, , ..ooo::; ::oo:;::o"'.:o
,d'. :OOOOO8Oo::" '.. . ::o8Ooo:; ;o:
,8: o::oO` 88888OOo::: o8O8Oo:::;; ,;:oO88OOo; '
,YP , :;:O: *888o:::: :8888Ooo::::::::::oo888888o;. ,
dPY: :o8O (|)888O:O:; O8888888888OOOO888"" Y8o:O88o; ,
,' O: 'ob` "8888888Oo;;o8888888888888'"' `8OO:.`OOb .
' Y: ,:o: `8O88888OOoo"""""""""""' `OOob`Y8b`
:: ';o: `8O88o:oOoP `8Oo `YO.
`: Oo: `888O::oP 88O :OY
:o; 8oP :888o::P do: 8O:
,ooO:8O' ,d8888o:O' dOo ;:.
;O8odo' 88888O:o' do:: oo.:
''-'`" d:O8oK -hrr- dOOo' :o":
`8O:;7b,. `"8' Y:
`Oo; 8:.
Y8bod.
Ву-гу-гу! Поне! Не забыли ещё?
+68
log.debug("Request: " + requestStr);
System.out.println("Request: " + requestStr);
+165
function writeln($str) {
echo $str."\n";
}
function readln() {
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
fclose($handle);
return $line;
}
Функции для реализации ввода и вывода PHP-CGI в режиме консоли
+150
nPosition = !bInvert ? data->pos_back
: data->pos_front;
+161
if(trim($_POST['Event_Name']) != '') {
if(trim($_POST['StartDate']) != '') {
if(trim($_POST['EndDate']) != '') {
if(trim($_POST['EndDate']) != '') {
if(trim($_POST['Community_Id']) != 0) {
if(trim($_POST['Event_Location']) != '') {
if(trim($_POST['Event_Latitude']) != '' && is_numeric($_POST['Event_Latitude'])) {
if(trim($_POST['Event_Longitude']) != '' && is_numeric($_POST['Event_Longitude'])) {
...................................................
// Далее много строк страшного кода с вызовами самописных методов для работы с датой. Аля:
$hrs = _ampmto24hrs($hrs, $ampm);
$StartDateTime = dateandtime2timestamp($_POST['StartDate'], $hrs, $mins);
.....................................................
// Далее формируется SQL код. Привожу интересный кусок и обращаю внимание на название полей таблицы, вида Darren_XXXXXXX.
// Darren - имя заказчика
$sql .= "`Event_Featured` = '".(($_POST['Event_Featured'] == 'on')?'True':'False')."', ".
"`Submitters_Email` = '', ".
"`Darren_EventDisplayName` = '"._clean($_POST['Darren_EventDisplayName'])."', ".
"`Darren_ShortDesc` = '"._clean($_POST['Darren_ShortDesc'])."', ".
"`Darren_Desc` = '"._clean($_POST['Darren_Desc'])."', ".
........................................................
// Заканчивается сие безобразие все тем же забором
} else {
$error['error_mistake'] = true;
}
} else {
$error['error'] = true;
$error['Event_URL'] = true;
}
} else {
$error['error'] = true;
$error['Event_Longitude'] = true;
}
} else {
$error['error'] = true;
$error['Event_Latitude'] = true;
}
} else {
$error['error'] = true;
$error['Event_Location'] = true;
}
} else {
$error['error'] = true;
$error['Community_Id'] = true;
}
} else {
$error['error'] = true;
$error['EndDate'] = true;
}
} else {
$error['error'] = true;
$error['EndDate'] = true;
}
} else {
$error['error'] = true;
$error['StartDate'] = true;
}
} else {
$error['error'] = true;
$error['Event_Name'] = true;
}
А вот визитная карточка автора этого кода: date_default_timezone_set('Asia/Calcutta'). Думаю, что этим все сказано.
−181
if str(type(code_text)) == "<type 'str'>":
code = self.errors[code_text]
else:
code = code_text
Случайно найдено на просторах гуглокода
+74
public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWrapper {
@SuppressWarnings("unchecked")
private void setPropertyValue(PropertyTokenHolder tokens, PropertyValue pv) throws BeansException {
String propertyName = tokens.canonicalName;
String actualName = tokens.actualName;
if (tokens.keys != null) {
// Apply indexes and map keys: fetch value for all keys but the last one.
PropertyTokenHolder getterTokens = new PropertyTokenHolder();
getterTokens.canonicalName = tokens.canonicalName;
getterTokens.actualName = tokens.actualName;
getterTokens.keys = new String[tokens.keys.length - 1];
System.arraycopy(tokens.keys, 0, getterTokens.keys, 0, tokens.keys.length - 1);
Object propValue;
try {
propValue = getPropertyValue(getterTokens);
}
catch (NotReadablePropertyException ex) {
throw new NotWritablePropertyException(getRootClass(), this.nestedPath + propertyName,
"Cannot access indexed value in property referenced " +
"in indexed property path '" + propertyName + "'", ex);
}
// Set value for last key.
String key = tokens.keys[tokens.keys.length - 1];
if (propValue == null) {
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName,
"Cannot access indexed value in property referenced " +
"in indexed property path '" + propertyName + "': returned null");
}
else if (propValue.getClass().isArray()) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
Class requiredType = propValue.getClass().getComponentType();
int arrayIndex = Integer.parseInt(key);
Object oldValue = null;
try {
if (isExtractOldValueForEditor()) {
oldValue = Array.get(propValue, arrayIndex);
}
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType,
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), requiredType));
Array.set(propValue, arrayIndex, convertedValue);
}
catch (IndexOutOfBoundsException ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Invalid array index in property path '" + propertyName + "'", ex);
}
}
else if (propValue instanceof List) {
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
Class requiredType = GenericCollectionTypeResolver.getCollectionReturnType(
pd.getReadMethod(), tokens.keys.length);
List list = (List) propValue;
int index = Integer.parseInt(key);
Object oldValue = null;
if (isExtractOldValueForEditor() && index < list.size()) {
oldValue = list.get(index);
}
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType,
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), requiredType));
if (index < list.size()) {
list.set(index, convertedValue);
}
else if (index >= list.size()) {
for (int i = list.size(); i < index; i++) {
try {
list.add(null);
}
catch (NullPointerException ex) {
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
"Cannot set element with index " + index + " in List of size " +
list.size() + ", accessed using property path '" + propertyName +
"': List does not support filling up gaps with null elements");
}
}
list.add(convertedValue);
}
}
else if (propValue instanceof Map) {
//...
}
}
}
}
Spring...
+94
program Oracle;
{$APPTYPE CONSOLE}
uses
SysUtils;
Var
sQuestion : String;
i : ShortInt;
bAnswer : Boolean;
Label lExit, lAnswer;
BEGIN
bAnswer := true;
WriteLn('Input question: ');
lAnswer: Read(sQuestion);
If Length(sQuestion) < 4 then
Begin
WriteLn('What "' + sQuestion + '"?');
Goto lAnswer;
End;
If sQuestion[Length(sQuestion)] <> '?' then
Begin
WriteLn('It`s not a question.');
Goto lExit;
End;
Randomize;
If Random(10) = 1 then
Begin
WriteLn('But why you ask?');
Goto lExit;
End;
For i := 1 to Length(sQuestion) do
If bAnswer = true then bAnswer := false
Else bAnswer := false;
If bAnswer = true then WriteLn('Yes.')
Else WriteLn('No.');
lExit: Readln;
END.
> Input question:
> Лурк гавно?
> No.
> А ты всегда даешь верные ответы?
> No.
> В смысле?
> What "В смысле?".
> Ну, в прямом.
> It`s not a question.
> Ты будешь отвечать на мой вопрос???
> No.
> Тогда иди нахуй.
> Сам иди нахуй.
> 0_o
+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 в перемешку.
Это печально...