- 1
- 2
- 3
var ids = form.Keys;
if(ids.Length == 0 || ids.Length > 1) { throw Exception;}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+136.2
var ids = form.Keys;
if(ids.Length == 0 || ids.Length > 1) { throw Exception;}
кидать исключение если ids.Length !=1
+136
"brutushafens", "ebal3_14","ebal_mamu_3_14","putin_xyilo","3_14-pidoraha","gde_siski_blyat","ebal3_14",
"vi_vse_pidarasi","ebanutie_sobaki","peremoga_ili_zrada","da_vi_ohueli","poluebki","3_14_nu_ti_i_mudak",
"3_14-huesos","novorossi9-huesossi9","jjjgirteo", "xyja4it", "StackBlower","bawluntuk", "Kaffier",
"patah", "Xalyazij", "mauntin","sukablya","slava_ukraine","xyilka",
"Parazit", "kalximik", "Sundukovskiy", "Talbin", "eblankah", "krokodildoh", "karbagol", "youloh",
"marixyan", "Germanik", "vavizh", "Bubby", "xavij", "vadim", "isivgr", "Zuruck", "hhhh5", "anawistka",
"NigerFromGabbanah", "Gromov", "maldyn003", "Iydywka", "treoie", "blandermein", "botbatbotbatbot",
"gzhegow", "zabydligah", "celovalnik", "Miwkarik", "tschedosch", "molasessia", "ambipuur", "hinter", "bayanist",
"gazenva85", "kargoudn", "Pikyn", "onnanon"
50 оттенков сала
Для борьбы с вредителями
+136
printf("Enter item code: "); //Prompts user
scanf ("%14s", codenew1); //Read user input
len = strlen(codenew1); //Read each character into variable len
while (len != strspn(codenew1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
{
printf ("Name contains non-alphabet characters. Try again!: "); //Prompts user to try again
scanf ("%14s", codenew1); //Reads user input
len = strlen(codenew1); //Read each character into variable len
} //Endwhile
strncpy(codenew, codenew1,2); //Copy the first two characters from the variable codenew1
codenew[2] = 0; //Store first two characters into variavle codenew
for ( j = 0; j < num_items; j++) //Loop for num_items times
{ //Beginning of for loop
if (strcmp(array[j].code1, codenew) == 0) //If codenew is found in file
{ //Beginning of if statement
price[i] = item_qty[i] * array[j].price1; //Calculating the price of an item
printf("Price : %d", price[i]); //Prints price
printf("\nEnter '%s' to confirm: ", array[j].itemname1); //Confirming the item
scanf("%19s", item_name1[i]);
while (strcmp(item_name1[i], array[j].itemname1 )!=0) //Looping until both item names are the same
{ //Begin while loop
printf("Item name is not %s ,Try Again!: ", array[j].itemname1); //Prompt user to try again
scanf ("%19s", item_name1[i]); //Reads item name into an array
len = strlen(item_name1[i]); //Reads each character into variable len
} //End while loop
len = strlen(item_name1[i]); //Read each character into variable len
while (len != strspn(item_name1[i], "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) //While len contains non alphabetic characters
{ //Beginning while
printf ("Name contains non-alphabet characters. Try again!: "); //Prompts user to try again
scanf ("%19s", item_name1[i]); //Read user input
len = strlen(item_name1[i]); //Read each character into variable len
} //End while
strncpy(item_name[i], item_name1[i], 20); //Copy the first two characters from the variable codenew1
item_name[i][20] = 0; //Store first 20 characters in variable item_name[i]
total_price+= price[i]; //Calculate total price
break; //Terminates loop
} //End of if statement
else
if (strcmp(array[j].code1, codenew) != 0) //If codenew is found in file
{
printf("Invalid input! Try again.");
goto Here;
}
} //End of for loop
Бесценные комментарии!
http://stackoverflow.com/questions/29045067/error-check-files
+136
for (j = 0; j < NUM_DMA_BUFFERS; j++)
*(int *)dev->channel[0].virtDma[j] = 0x1235+j;
ЯННП
+136
#include <stdint.h>
#include <Windows.h>
#include <intrin.h>
typedef long dt;
namespace {
dt InitializationIsInProgress = 0;
dt InitializationIsFinished = 0;
}
dt InterlockedLoad(dt volatile * t){
return InterlockedCompareExchange(t, 0, 0);
}
dt InterlockedAssign(dt volatile * t, dt v){
dt c = 0;
while (c = InterlockedCompareExchange(t, v, c));
}
void InitializeSystem(){
if (InterlockedLoad(&InitializationIsFinished) == 1)
return;
while (InterlockedCompareExchange(&InitializationIsInProgress, 1, 0) == 1) Sleep(0);
//__ReadWriteBarrier();
if (InterlockedLoad(&InitializationIsFinished) == 1)
return;
Work();
InterlockedAssign(&InitializationIsFinished, 1);
InterlockedAssign(&InitializationIsInProgress, 0);
}
Не судите строга. Воспользуюсь как пастебином. Если найдете ошибки - пришлю пирожок.
+136
private static string RemoveInvalidChars(string source)
{
foreach (var c in invalidChars)
source = source.Replace(c.ToString(), "");
return source;
}
public static string Validate(string source)
{
source = RemoveInvalidChars(source);
return source;
}
+136
public static IEnumerable<T> Remove<T>(this IEnumerable<T> source, T key)
{
return source.Where(element => !element.Equals(key));
}
public static IEnumerable<string> Remove(this IEnumerable<string> source, string key)
{
return source.Where(element => element != key);
}
Немного велосипедостроения.
+136
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
label2.Text = "Downloaded " + e.BytesReceived + " of " + e.TotalBytesToReceive;
progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
}
Вычилсяем проценты :D
+136
struct hostent *rc_gethostbyname(const char *hostname)
{
struct hostent *hp;
#ifdef GETHOSTBYNAME_R
#if defined (GETHOSTBYNAMERSTYLE_SYSV) || defined (GETHOSTBYNAMERSTYLE_GNU)
struct hostent hostbuf;
size_t hostbuflen;
char *tmphostbuf;
int res;
int herr;
hostbuflen = 1024;
tmphostbuf = malloc(hostbuflen);
#endif
#endif
#ifdef GETHOSTBYNAME_R
#if defined (GETHOSTBYNAMERSTYLE_GNU)
while ((res = gethostbyname_r(hostname, &hostbuf, tmphostbuf, hostbuflen, &hp, &herr)) == ERANGE)
{
/* Enlarge the buffer */
hostbuflen *= 2;
tmphostbuf = realloc(tmphostbuf, hostbuflen);
}
free(tmphostbuf);
#elif defined (GETHOSTBYNAMERSTYLE_SYSV)
hp = gethostbyname_r(hostname, &hostbuf, tmphostbuf, hostbuflen, &herr);
free(tmphostbuf);
#else
hp = gethostbyname(hostname);
#endif
#else
hp = gethostbyname(hostname);
#endif
if (hp == NULL) {
return NULL;
}
return hp;
}
freeradius-client 1.1.6, казалось бы серьезная либа... Говно мамонта, конечно, но оно валяется в репе бубунты 14.10... Неужели никто еще не заметил? :)
+136
GetDate(string dateTimeText){
DateTime date = new DateTime();
String[] parsedDate = dateTimeText.Split('/');
bool allNumbers = true;
foreach (string s in parsedDate)
{
int value;
if (!int.TryParse(s, out value) && allNumbers)
{
allNumbers = false;
}
}
if (parsedDate.Length == 3 && allNumbers)
{
String newDateText = parsedDate[1] + "/" + parsedDate[0] + "/" + parsedDate[2];
DateTime.TryParse(newDateText, out date);
}
return date;
}
парсинг юзеринпута в датетайм пикере