- 1
- 2
- 3
- 4
- 5
- 6
- 7
if (false) {}
else
{
//какие-то действия
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+140
if (false) {}
else
{
//какие-то действия
}
+71
app_preferences = PreferenceManager.getDefaultSharedPreferences(context);
mApplication = (MyApplication)context;
if(mApplication.nomgor == 0 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID","");//в работе
}
if(mApplication.nomgor == 1 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID1", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID1","");//в работе
}
if(mApplication.nomgor == 2 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID2", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID2","");//в работе
}
if(mApplication.nomgor == 3 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID3", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID3","");//в работе
}
if(mApplication.nomgor == 4 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID4", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID4","");//в работе
}
if(mApplication.nomgor == 5 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID5", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID5","");//в работе
}
if(mApplication.nomgor == 6 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID6", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID6","");//в работе
}
if(mApplication.nomgor == 7 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID7", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID7","");//в работе
}
if(mApplication.nomgor == 8 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID8", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID8","");//в работе
}
if(mApplication.nomgor == 9 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID9", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID9","");//в работе
}
if(mApplication.nomgor == 10 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID10", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID10","");//в работе
}
if(mApplication.nomgor == 11 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID11", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID11","");//в работе
}
if(mApplication.nomgor == 12 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID12", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID12","");//в работе
}
if(mApplication.nomgor == 13 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID13", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID13","");//в работе
}
if(mApplication.nomgor == 14 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID14", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID14","");//в работе
}
if(mApplication.nomgor == 15 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID15", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID15","");//в работе
}
if(mApplication.nomgor == 16 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID16", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID16","");//в работе
}
if(mApplication.nomgor == 17 ){
mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID17", "0"));
mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID17","");//в работе
}
кто-то с детства привык копипастить
+136
if (ds2.Rows[l]["MIMETYPE"].ToString().Length >= 5 && ds2.Rows[l]["MIMETYPE"].ToString().Substring(0, 5).ToLower() == "image"){
// кучка гуана
}
Наверное определяется тип вложения.
Path для лохов
+139
public class Switch
{
public Switch(object switchElement)
{
Object = switchElement;
}
public object Object{get; private set; }
}
public static class SwitchExtensions
{
public static Switch Case<T>(this Switch switchCase, Func<T, bool> isTrue, Action<T> action) where T : class
{
return Case(switchCase, isTrue, action, false);
}
public static Switch Case<T>(this Switch switchCase, Func<T, bool> isTrue, Action<T> action, bool fallThrough) where T : class
{
if (switchCase == null)
return null;
var obj = switchCase.Object as T;
if (obj != null)
if (isTrue(obj))
{
action(obj);
return fallThrough ? switchCase : null;
}
return switchCase;
}
}
//пример использования
IImporter<AccountModel> result = null;
new Switch(type)
.Case<string>(x => x == ".xls", y => result = new ExcelImporter())
.Case<string>(x => x == ".csv", y => result = new CsvImporter());
return result;
У нас будет свой Switch/Case с преферансом, куртизанками и экстеншен методами
+136
var regex = new Regex(@"{[\w\d]+}");
var keys = (regex.Matches(m_Format.Format)
.Cast<object>()
.Select(match => match.ToString()
.Replace("{", ""))
.Select(replace => replace.Replace("}", "")))
.ToList();
+135
bool exit = false;
while (!exit)
{
if (Console.KeyAvailable)
{
ConsoleKeyInfo key = Console.ReadKey(true);
exit = true;
}
}
Православная замена Console.ReadKey();
−101
def Find(dir):
def walk(a,b,files):
t1=0
for i in files:
t1+=1
if i[-4:]==".sis" or i[-4:]==".Sis" or i[-4:]==".SIs" or i[-4:]==".SIS" or i[-4:]==".SiS" or i[-4:]==".sIS" or i[-4:]==".siS" or i[-5:]==".sisx" or i[-5:]==".Sisx" or i[-5:]==".SIsx" or i[-5:]==".SISx" or i[-5:]==".SISX" or i[-5:]==".sISX" or i[-5:]==".siSX" or i[-5:]==".sisX" or i[-5:]==".SisX" or i[-5:]==".SIsX" or i[-5:]==".SiSX" :
list1.append(cn(i))
list2.append(cn("%s\%s"%(b,i)))
Когда еще была жива симба, под нее был интерпретатор питона. Этот отрывок - творение некоего китайского товарища под PyS60.
+128
#include "unpacker.h"
Unpacker::Unpacker(char *name) {
_splitString = new char*[16];
_ctx = SDL_RWFromFile(name, "rb");
}
Unpacker::~Unpacker() {
delete _splitString;
SDL_RWclose(_ctx);
SDL_FreeRW(_ctx);
}
Dir *Unpacker::getDir(char *path) {;
int index = 1;
char pth[256];
char name[80];
char *str = "";
if (!path)
return NULL;
_split(path);
SDL_RWseek(_ctx, 2, SEEK_SET);
pth[0] = '/'; pth[1] = '\0';
while (_splitString[index]) {
Uint16 count;
Uint32 hash;
str = _splitString[index];
hash = _hash(str);
count = SDL_ReadLE16(_ctx);
for (int i=0; i<count; i++) {
Uint32 h;
Uint32 offset;
h = SDL_ReadLE32(_ctx);
offset = SDL_ReadLE32(_ctx);
if (hash == h) {
Uint8 size;
Uint32 curPos = SDL_RWtell(_ctx);
SDL_RWseek(_ctx, offset, SEEK_SET);
SDL_RWread(_ctx, &size, 1, 1);
SDL_RWread(_ctx, name, size, 1);
name[size] = '\0';
if (!strcmp(str, name)) {
if (_splitString[index+1]) {
strcat(pth, str);
strcat(pth, "/");
}
break;
} else {
if (i == count-1)
return NULL;
SDL_RWseek(_ctx, curPos, SEEK_SET);
}
}
}
index++;
}
Dir *dir = new Dir;
strcpy(dir->name, str);
strcpy(dir->path, pth);
dir->dirsCount = SDL_ReadLE16(_ctx);
dir->dirsOffset = SDL_RWtell(_ctx);
SDL_RWseek(_ctx, dir->dirsCount*8, SEEK_CUR);
dir->filesCount = SDL_ReadLE16(_ctx);;
dir->filesOffset = SDL_RWtell(_ctx);
return dir;
}
File *Unpacker::getFile(char *path) {
char pth[256];
char nm[80];
int index = 2;
_split(path);
if (!_splitString[1])
return NULL;
if (_splitString[2]) {
strcpy(pth, "/");
strcpy(pth, _splitString[1]);
strcat(pth, "/");
} else {
Dir *dir = getDir("/");
return getFile(dir, _splitString[1]);
}
while (1) {
if (_splitString[index+1]) {;
strcat(pth, _splitString[index]);
strcat(pth, "/");
} else {
strcpy(nm, _splitString[index]);
break;
}
index++;
}
Нашел у себя на диске - старое творенье, когда я был мал и глуп... Распаковщик архива на своего формата на основе zlib.
+70
// there is class PlayerExt, which extends class Player...
// min >= 0
// max <= players.size()
List<PlayerExt> players = playerManager.getPlayers(contestId);
Player[] response = new Player[players.size()];
for (int i = min; i < max; i++) {
response[i] = players.get(i);
if (!players.get(i).isQualified()) {
response[i].setChipStack(BigDecimal.valueOf(-1));
}
response[i].setPosition(i + 1);
response[i].setCustomerId(players.get(i).getCustomerId());
}
Для таких начальных условий, как обозначено в комментарии в начале кода, формируем список игроков.
Особенно вдохновляет самая последняя инструкция в теле цикла.
+27
function makehash($str,$salt='',$strength='08'){
if (!$salt):
$salt = "";
for ($i = 0; $i < 22; $i++) {
$salt .= substr("./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", mt_rand(0, 63), 1);
}
endif;
return crypt($str, "$2a$".$strength."$".$salt);
}
no comments