- 1
Язык Богов
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
Язык Богов
+145
public function parse_url($url)
{
return parse_url($url);
}
Модель из моего диплома... Всё по фен-шуй!
+152
function Order(obj) {
var frm = $(obj);
var first_name = frm.find("input[name='first_name']").val();
var last_name = frm.find("input[name='last_name']").val();
var email = frm.find("input[name='email']").val();
var phone = frm.find("input[name='phone']").val();
var text = frm.find(".coment-form-textarea").val();
var captcha = frm.find("input[name='captcha']").val();
var valid = true;
MsgErrorDestroy(frm, '#order-first_name', 'input[name="first_name"]');
MsgErrorDestroy(frm, '#order-last_name', 'input[name="last_name"]');
MsgErrorDestroy(frm, '#order-email', 'input[name="email"]');
MsgErrorDestroy(frm, '#order-phone', 'input[name="phone"]');
MsgErrorDestroy(frm, '#order-text', '.coment-form-textarea');
if (first_name == '') {
MsgError(frm, 'Введите ваше имя.', '#order-first_name', 'input[name="first_name"]');
valid = false;
}
if (last_name == '') {
MsgError(frm, 'Введите вашу фамилию.', '#order-last_name', 'input[name="last_name"]');
valid = false;
}
if (!emailValid(email)) {
MsgError(frm, 'Введите ваш email.', '#order-email', 'input[name="email"]');
valid = false;
}
if (phone == '') {
MsgError(frm, 'Введите ваш номер телефона.', '#order-phone', 'input[name="phone"]');
valid = false;
}
if (text == '') {
MsgError(frm, 'Введите ваше сообщение.', '#order-text', '.coment-form-textarea');
valid = false;
}
if (captcha == '') {
MsgError(frm, 'Введите капчу.', '#comment-capcha', 'input[name="captcha"]');
valid = false;
}
if (valid == false) {
return false;
}
}
function MsgError(frm, msg, select_msg, select_input) {
if (select_msg != 0) {frm.find(select_msg).html(msg);}
if (select_input != 0) {frm.find(select_input).addClass('input-error');}
if (select_msg != 0) {frm.find(select_msg).removeClass('hide');}
//frm.find('#'+'profile-'+key).addClass('show');
}
function MsgErrorDestroy(frm, select_msg, select_input) {
if (select_msg != 0) {frm.find(select_msg).html('');}
if (select_input != 0) {frm.find(select_input).removeClass('input-error');}
if (select_msg != 0) {frm.find(select_msg).removeClass('show');}
//$('#'+'profile-'+key).addClass('hide');
}
Валидация какого-то там заказа. Автор вероятно не слышал про массивы и объекты.
−165
delete
from liaison
where
type = 'UsersGroup' and
`group` = 'static_' || (select id from usergroup where name = :grp)
Час назад вынес этим запросом все связи между группами и юзерами в боевой базе ;)
P.S. Почему в mysql все дерьмо, работающее совсем не так, как оно работает почти во всех остальных СУБД, включено по умолчанию?
+160
$query = "INSERT INTO analiz SET
obegin = $duss,
vbegin = $leas,
lbegin = $duls,
opodk = $dusc,
vpodk = $leac,
lpodk = $dulc,
oend = $duse,
vend = $leae,
lend = $dule,
ozatr = $dusZ,
vzatr = $leaZ,
lzatr = $dulZ,
ooplat = $dusU,
voplat = $leaU,
loplat = $dulU,
opay = $dusN,
vpay = $leaN,
lpay = $dulN,
date = '$dnow'";
cOde = $pzDc
+86
@Override
public boolean equals(Object obj)
{
return obj != null && obj.equals(this);
}
+140
[WebMethod]
public void runCompareService(string mAuthToken, int documentId, int origVerNum, int revisedVerNum)
{
//string result = null;
DirectoryInfo tmpDirInfo = getTempDirectoryPath(documentId);
try
{
//authToken = authClient.AuthenticateUser(username, password);
authToken = mAuthToken;
otAuth.AuthenticationToken = authToken;
try
{
string origFilePath = String.Format(tmpFilePath, tmpDirInfo.ToString(), origVerNum);
string revisedFilePath = String.Format(tmpFilePath, tmpDirInfo.ToString(), revisedVerNum);
string resultFilePath = String.Format(tmpResFilePath, tmpDirInfo.ToString(), origVerNum, revisedVerNum);
string origContextId = getDocContextId(documentId, origVerNum);
string revisedContextId = getDocContextId(documentId, revisedVerNum);
try
{
downlodFileByContextId(origContextId, origFilePath);
downlodFileByContextId(revisedContextId, revisedFilePath);
try
{
doCompare(origFilePath, revisedFilePath, resultFilePath);
try
{
DownloadToBrowser(resultFilePath);
//uploadResultToCS(targetId, resultFilePath);
}
catch (Exception e)
{
throw new Exception(String.Format("Failed to Download To Browser. Error: {0}", e.ToString()));
}
}
catch (Exception e)
{
throw new Exception(String.Format("Failed to do compare method . Error: {0}", e.ToString()));
}
}
catch (Exception e)
{
throw new Exception(String.Format("Failed to create and download file. Error: {0}", e.ToString()));
}
}
catch (Exception e)
{
throw new Exception("Failed to get Context ID for version Exeption details: " + e.ToString());
}
}
catch (Exception e)
{
throw new Exception("Failed to auth user. Exeption details: " + e.ToString());
}
finally
{
docManClient.Close();
contentServiceClient.Close();
if (Directory.Exists(tmpDirInfo.ToString()))
{
tmpDirInfo.Delete(true);
}
}
}
+138
/// <summary>
/// Преобразование системных наименований клавиш в "понятные пользователю"
/// </summary>
/// <param name="key">Нажатая системная клавиша</param>
/// <returns>Понятное представление</returns>
public static string ReplaceKeyCode(System.Windows.Forms.Keys key)
{
switch (key)
{
case Keys.OemQuestion: return "'?'";
case Keys.OemOpenBrackets: return "'{'";
case Keys.Oemtilde: return "'~'";
case Keys.Next: return "PageDown";
}
switch (key)
{
case Keys.A: return "A";
case Keys.Add: return "Num'+'";
case Keys.Alt: return "Alt";
case Keys.B: return "B";
case Keys.Back: return "Backspace";
case Keys.C: return "C";
case Keys.Cancel: return "Cancel";
case Keys.Clear: return "Clear";
case Keys.ControlKey: return "Ctrl";
case Keys.D: return "D";
case Keys.D0: return "0"; case Keys.D1: return "1"; case Keys.D2: return "2"; case Keys.D3: return "3";
case Keys.D4: return "4"; case Keys.D5: return "5"; case Keys.D6: return "6"; case Keys.D7: return "7";
case Keys.D8: return "8"; case Keys.D9: return "9"; case Keys.Decimal: return "Num'.'";
case Keys.Delete: return "Delete";
case Keys.Divide: return "Num'/'";
case Keys.Down: return "Down";
case Keys.E: return "E";
case Keys.End: return "End";
case Keys.Escape: return "Esc";
case Keys.F: return "F";
case Keys.F1: return "F1";
case Keys.F10: return "F10";
case Keys.F11: return "F11";
case Keys.F12: return "F12";
case Keys.F2: return "F2";
case Keys.F3: return "F3";
case Keys.F4: return "F4";
case Keys.F5: return "F5";
case Keys.F6: return "F6";
case Keys.F7: return "F7";
case Keys.F8: return "F8";
case Keys.F9: return "F9";
case Keys.G: return "G";
case Keys.H: return "H";
case Keys.Home: return "Home";
case Keys.I: return "I";
case Keys.Insert: return "Insert";
case Keys.J: return "J";
case Keys.K: return "K";
case Keys.L: return "L";
case Keys.M: return "M";
case Keys.N: return "N";
case Keys.Next: return "Next";
case Keys.NumPad0: return "Num0";
case Keys.NumPad1: return "Num1";
case Keys.NumPad2: return "Num2";
case Keys.NumPad3: return "Num3";
case Keys.NumPad4: return "Num4";
case Keys.NumPad5: return "Num5";
case Keys.NumPad6: return "Num6";
case Keys.NumPad7: return "Num7";
case Keys.NumPad8: return "Num8";
case Keys.NumPad9: return "Num9";
case Keys.O: return "O";
case Keys.Oem1: return "';'";
case Keys.Oem5: return "'/'";
case Keys.Oem6: return "'{'";
case Keys.Oem7: return "\"";
case Keys.OemMinus: return "'-'";
case Keys.OemPeriod: return "'>'";
case Keys.Oemcomma: return "'<'";
case Keys.Oemplus: return "'+'";
case Keys.P: return "P";
case Keys.PageUp: return "PageUp";
case Keys.Q: return "Q";
case Keys.R: return "R";
case Keys.S: return "S";
case Keys.ShiftKey: return "Shift";
case Keys.Space: return "Space";
case Keys.Subtract: return "Num'-'";
case Keys.T: return "T";
case Keys.Tab: return "Tab";
case Keys.U: return "U";
case Keys.Up: return "Up";
case Keys.V: return "V";
case Keys.W: return "W";
case Keys.X: return "X";
case Keys.Y: return "Y";
case Keys.Z: return "Z";
case Keys.Menu: return "Alt";
case Keys.Multiply: return "Num'*'";
default: return string.Empty;
}
}
+16
BOOL EnsureThreadIsSuspended (HANDLE hThread, Thread* pThread)
{
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
WRAPPER_CONTRACT;
CONTEXT ctx;
ctx.ContextFlags = CONTEXT_INTEGER;
BOOL ret;
ret = ::GetThreadContext(hThread, &ctx);
return ret;
}
А ведь и правда, никто не гарантирует, что поток будет остановлен к тому моменту, когда SuspendThread() вернет управление...
+77
public static long[] intArrayToLongArray(int[] in) {
long[] out = new long[in.length];
for (int i=0, n=in.length; i<n; i++)
out[i] = in[i];
return out;
}
public static void vibrateByResource(Context context, int resId) {
Vibrator vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = intArrayToLongArray(context.getResources().getIntArray(resId));
vibrator.vibrate(pattern, -1);
}
vibrateByResource(this, R.array.vibroPatternSuccess);
vibrate() принимает только long[], но не int[], в ресурсах могут храниться только int[] но не long[]. В результате родился вот такой говнокодик.