- 1
com.google.ui:ShadowButtonTextUiConfigFactory
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−99
com.google.ui:ShadowButtonTextUiConfigFactory
Разбираюсь с гуглокодом для Ютуб плеера. Как думаете, что может делать этот класс?
+161
if (array_key_exists('COUPON', $_POST) && !array_key_exists('coupon', $_POST))
{
$_POST["coupon"] = $_POST["COUPON"];
}
В глубинах битрикса...
+134
public void OnKillEvent_ServerOnly(PhotonPlayer player)
{
case MatchTypeInfo.TDM:
if (player != null)
{
var hash = player.customProperties;
if (hash != null)
{
var team = (int) hash["team"];
var realScore = match.GetTeamScores();
var teamAScor = team == 0 ? realScore.x + TeamDeathScores : realScore.x;
var teamBScor = team == 1 ? realScore.y + TeamDeathScores : realScore.y;
//DebugModule("Kill Processed On Server completed: " + team + "// " + teamAScor + "/" + teamBScor);
match.ChangeTeamScores((int)teamAScor, (int)teamBScor);
}
else
{
Debug.LogError("OnKillEvent_ServerOnly ERROR Team hash");
}
}
break;
} {
//через 500 строк кода
private void LocalUpdate()
{
if (Application.isEditor)
{
if (Input.GetKeyDown(KeyCode.Y))
{
switch (MatchType)
{
case MatchTypeInfo.TDM:
ChangeTeamScores((int)(_teamScores.x - 1), (int)(_teamScores.y - 1), true);
break; }
SendTeamScoresToUI();
}
}
switch (MatchType)
{
case MatchTypeInfo.TDM:
// DebugModule("Load TDM type game");
break;
}
}
//ещё 500 строк
public void ChangeTeamScores(int a, int b, bool force = false)
{
if (PhotonNetwork.isMasterClient)
{
// check server rules
var rules = GetGameRules();
if (rules != null)
{
if (!rules.CheckPlayerCountRules() && !force)
{
Debug.LogError("Game is not started, beacuse server has no players: " + rules.MinimumPlayerToPlay + "/" +
PhotonNetwork.room.playerCount);
return;
}
}
else
{
Debug.LogError("Rule error");
return;
}
_teamScores.x = Mathf.Clamp(a, 0, float.MaxValue);
_teamScores.y = Mathf.Clamp(b, 0, float.MaxValue);
var matchIsCompleted = false;
switch (MatchType)
{
case MatchTypeInfo.TDM:
matchIsCompleted = _teamScores.x <= 0 || _teamScores.y <= 0;
break;
}
if (matchIsCompleted)
{
Server_CallEndRound();
}
else
{
// Call Event??
}
}
}
Чтобы я ещё раз полез помогать инди-разработчикам, мать их за ногу.
−103
if [ "valid" == "$x" ]; then
echo "x has the value 'valid'"
fi
One last point (of style): <...> is better because it avoids the possibility of accidentally assigning the string "valid" to x.
Йода-стайл теперь и в вашем баше.
+134
protected static DataTable[] ExecuteDataTablesReader(string ProcedureName, SqlParameter[] Params = null) {
SqlConnection cnn = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand(ProcedureName, cnn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
if (Params != null && Params.Count() > 0) {
cmd.Parameters.AddRange(Params);
}
cnn.Open();
IDataReader rd = cmd.ExecuteReader();
List<DataTable> tables = new List<DataTable>();
do {
DataTable dt = new DataTable();
dt.Load(rd);
tables.Add(dt);
} while (rd.NextResult());
return tables.ToArray();
}
может я чего не понимаю, но какого хера rd.NextResult() кидает мне exception, что ридер закрыт?
+135
public void Login(ClientHandlers<int> actions)
{
var request = GetGetRequest("/user/xml/{0}", _login);
var act = new Action<IRestResponse<GetUserInfoResult>>(response =>
{
if (CheckUserInfo(response))
{
throw new Exception("Невозможно получить информацию о пользователе\r\nНеобработанное исключение");
}
UserInfo = response.Data.UserInfo;
actions.Completed(UserInfo.idUser);
});
_client.ExecuteAsync(request, act);
}
private bool CheckUserInfo(IRestResponse<GetUserInfoResult> response)
{
if (response != null && response.Data != null && response.Data.UserInfo != null && response.Data.UserInfo.idUser != 0)
{
return true;
}
var message = "Невозможно получить информацию о пользователе";
if (response == null)
{
message = string.Format("{0}\r\n{1}",
message,
"Response is null");
throw new Exception(message);
}
message = string.Format("{0}\r\nResponse data is null\r\nContext: {1}",
message,
response.Content);
if (response.Data == null)
{
throw new Exception(message);
}
message = string.Format("{0}\r\nIs exception: {1}\r\nMessage: {2}",
message,
response.Data.IsException,
response.Data.Message);
if (response.Data.UserInfo == null)
{
throw new Exception(message);
}
message = string.Format("{0}\r\nSiteName: {1}\r\nUserName: {2}\r\nUserRole: {3}",
message,
response.Data.UserInfo.SiteName,
response.Data.UserInfo.UserName,
response.Data.UserInfo.UserRole);
if (response.Data.UserInfo.idUser == 0)
{
throw new Exception(message);
}
return false;
}
Внимательность, внимательность и еще раз внимательность...
+71
public static void main(String[] args) {
Map<String, ClassLink<?>> children = new HashMap<String, ClassLink<?>>();
children.put("test1", new ClassLink<Dall>());
children.put("test2", new ClassLink<Son>());
String test = children.get("test1").classObjectGenerator().getName();
test.toString();
}
static class ClassLink<X extends ChildBase> {
public X classObjectGenerator() {
return (X) new Dall();
};
}
static class Dall implements ChildBase {
public String getName() {
return "Ivan";
}
}
static class Son implements ChildBase {
public String getName() {
return "Vera";
}
}
interface ChildBase {
String getName();
}
Фабрика. Загнать в map легковесный класс - создатель, а когда понадобится - создать объект.
+133
if (*wpPat == L'\\')
{
wpCharStart=wpPat;
if (++wpPat >= wpMaxPat) goto Error;
if (*wpPat == L'x')
{
if (++wpPat >= wpMaxPat) goto Error;
if (*wpPat == L'{')
{
wpStrTmp=++wpPat;
for (;;)
{
if (wpPat >= wpMaxPat) goto Error;
if (*wpPat++ == L'}') break;
}
if (lpREGroupItem->nGroupLen != -1 && !bClassOpen)
{
nPatChar=(int)hex2decW(wpStrTmp, (wpPat - 1) - wpStrTmp);
if (nPatChar == -1)
{
wpPat=wpStrTmp;
goto Error;
}
if (nPatChar <= MAXWORD)
lpREGroupItem->nGroupLen+=1;
else
lpREGroupItem->nGroupLen+=2;
}
}
else
{
if (wpPat + 2 > wpMaxPat)
goto Error;
wpPat+=2;
if (lpREGroupItem->nGroupLen != -1 && !bClassOpen)
++lpREGroupItem->nGroupLen;
}
}
else if (*wpPat == L'u')
{
if (wpPat + 5 > wpMaxPat)
goto Error;
wpPat+=5;
if (lpREGroupItem->nGroupLen != -1 && !bClassOpen)
++lpREGroupItem->nGroupLen;
}
Регулярные велосипеды.
Akelpad.
+133
if (wParam == MI_CMDLINEBEGIN)
return xstrcpyW((void *)lParam, wpCmdLineBegin);
if (wParam == MI_CMDLINEEND)
return xstrcpyW((void *)lParam, wpCmdLineEnd);
if (wParam == MI_SHOWMODIFY)
return moCur.dwShowModify;
if (wParam == MI_STATUSPOSTYPE)
return moCur.dwStatusPosType;
if (wParam == MI_STATUSUSERFORMAT)
return xstrcpynW((void *)lParam, moCur.wszStatusUserFormat, MAX_PATH);
if (wParam == MI_WORDBREAKCUSTOM)
return moCur.dwWordBreakCustom;
if (wParam == MI_PAINTOPTIONS)
return moCur.dwPaintOptions;
if (wParam == MI_EDITSTYLE)
return moCur.dwEditStyle;
if (wParam == MI_RICHEDITCLASS)
return moCur.bRichEditClass;
if (wParam == MI_AKELADMINRESIDENT)
return moCur.bAkelAdminResident;
if (wParam == MI_DATELOGFORMAT)
return xstrcpynW((void *)lParam, moCur.wszDateLogFormat, 128);
if (wParam == MI_DATEINSERTFORMAT)
return xstrcpynW((void *)lParam, moCur.wszDateInsertFormat, 128);
if (wParam == MI_AKELUPDATEROPTIONS)
return xstrcpynW((void *)lParam, moCur.wszAkelUpdaterOptions, MAX_PATH);
if (wParam == MI_URLCOMMAND)
return xstrcpynW((void *)lParam, moCur.wszUrlCommand, MAX_PATH);
if (wParam == MI_TABNAMEFIND)
return xstrcpynW((void *)lParam, moCur.wszTabNameFind, MAX_PATH);
if (wParam == MI_TABNAMEREP)
return xstrcpynW((void *)lParam, moCur.wszTabNameRep, MAX_PATH);
if (wParam == MI_ONTOP)
return moCur.bOnTop;
if (wParam == MI_STATUSBAR)
return moCur.bStatusBar;
if (wParam == MI_KEEPSPACE)
return moCur.bKeepSpace;
if (wParam == MI_WATCHFILE)
return moCur.bWatchFile;
if (wParam == MI_SAVETIME)
return moCur.bSaveTime;
if (wParam == MI_SINGLEOPENFILE)
return moCur.bSingleOpenFile;
if (wParam == MI_SINGLEOPENPROGRAM)
return moCur.dwSingleOpenProgram;
if (wParam == MI_TABOPTIONSMDI)
return moCur.dwTabOptionsMDI;
if (wParam == MI_EXECUTECOMMAND)
И такого больше сотни строк.
Akelpad.
+132
LRESULT CALLBACK MainProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE)
{
int *lpSBParts;
int iBorders[3];
CLIENTCREATESTRUCT ccs;
DWORD dwClassStyle;
RECT rcRect;
HMENU hMenu;
hMainWnd=hWnd;
hPopupEdit=GetSubMenu(hPopupMenu, MENU_POPUP_EDIT);
hPopupView=GetSubMenu(hPopupMenu, MENU_POPUP_VIEW);
hPopupCodepage=GetSubMenu(hPopupMenu, MENU_POPUP_CODEPAGE);
hPopupOpenCodepage=GetSubMenu(hPopupCodepage, MENU_POPUP_CODEPAGE_OPEN);
hPopupSaveCodepage=GetSubMenu(hPopupCodepage, MENU_POPUP_CODEPAGE_SAVE);
hPopupHeadline=GetSubMenu(hPopupMenu, MENU_POPUP_HEADLINE);
hMenu=GetSubMenu(hMainMenu, MENU_FILE_POSITION);
hMenuRecentFiles=GetSubMenu(hMenu, MENU_FILE_RECENTFILES_4X);
hMenu=GetSubMenu(hMainMenu, MENU_VIEW_POSITION);
hMenuLanguage=GetSubMenu(hMenu, MENU_VIEW_LANGUAGE_4X);
Плотная простынка, спать можно.
Akelpad.