ITT We show off shitty code that we've made, I'll start with mine in pic related

ITT We show off shitty code that we've made, I'll start with mine in pic related

Other urls found in this thread:

pastebin.com/DQ3gaeK4
pastebin.com/vx8P6baw
youtu.be/o8NPllzkFhE?t=858
hastebin.com/atulidecod
twitter.com/NSFWRedditVideo

>shitty
You sure got that right.

did you just write a fucking goto statement in c#

you should actually be banned for this

Oh boy I know this kind of code, just started computing classes huh, learning about colours and threading

>goto is bad maymay
How to spot a shit programmer 101.

You do realize that goto is pretty common even in C right? Goto is literally a carry over from a function in assembly.

r8 my code

>Non English
>Shitty Apple meme-lang
0/10

Is that Swift? What is this supposed to do?

> 0/10
Thanks user! I will try improving my skills.

> is that Swift?
yes
> What is this supposed to do?
solves a mathematical expression and returns the final result as a string.

>9 lines of actual code
>41 lines
It's like you're trying to meet LoC quotas or something.

>using Console.
>not using a switch statement
>not finding an excuse to use glorious LINQ

>pretty common even in C
That doesn't mean it's right. Also in C is mainly used for error handling to free resources, as C lacks automatic memory management, exception handling and statements like 'using'. So literally no need to use it in C# or other languages besides being a shitty programmer.

Any use of goto can be rewritten without it, its a very lazy habit that easily makes code unmaintainable and would get you fired instantly. If you ever actually made anything over 50 lines long you would soon realise how using goto will fuck you over, especially in a language like c#...

>ermagerd you can write it without goto
>ermagerd it's lazy for some reason
>ermagerd when I used it I ended up with spaghetti code ?!?/1/1/
Kill yourself desu.

> he counted all the lines
autism status = MAXIMUM

Code snobbery vexes me.
OPs code does the job it's supposed to do.
So it's fine.

dpt is busy arguing over anime so here you go: my first ever brainfuck program

++++++++++[>+++++>+++++.

goto is excellent for stack-like cleanup. It can lead to a lot less duplicated code.

yeah if you're using batch not c#.

what the fuck is your bracket style

>just let me bask in my glory :^)

yeah, """glory""" for making a """"program"""" with an if statement that does one thing

Exactly. Op is learning to code, his program does the job intended, and it's readable as fuck. A+ op.

Who are you quoting?

can't tell if you're OP.

But if you are, you should probably neck it considering you can't even use a basic loop.

>OPs code does the job it's supposed to do.
>So it's fine.
It's not elegant though, so I'm going to call it shit.

>readable as fuck

pastebin.com/DQ3gaeK4
I vomit every time.

In case you couldn't figure out what it is, it's an assembler for a virtual architecture.
I only posted the main.c, I can post the rest if you want. You probably don't want that.

>using system
>goto

for(int i=0;in;i++) if(derefSymbol(((symbol**)srefs->objects)[i]->name,0)==-1) throwerror(0,"%s: %s: Implicit declaration\n",opts->asmfilename,((symbol**)srefs->objects)[i]->name);

That hurt my eyes

Goto is completely fine if you absolutely know what you're doing, and OP clearly doesn't know what the fuck he's doing as shown by his extremaely basic program and his decision to use C#.

pastebin.com/vx8P6baw
Second program I ever wrote in c#

About the OP, what would be the best way to keep asking until the right parameter is passed and close the program once it has worked once?

I mean
while (true)
{
read input
if (input is valid)
{
do something
}
}

would keep cycling even when correct parameters are passed, right?
Should I just add Enviroment.Exit(0);
and do something like
while (true)
{
read input
if (input is valid)
{
do something
Enviroment.Exit(0);
}
}
or is there a better way?

...

i made a GUI program in node-webkit
it fucking works
then it's full of things like
var ip = $('li', x).getAttribute('title')
var port = $('li', x).getAttribute('data-port')

that's what break statements are for.
while (True)
if (condition = met)
{
do things;
break;
}
}
or you could use like
do
{
read input
}
while (input != "y" && input!="n")
do things with input

That's just VS's shitty auto formatting, I would put the opening squiggly bracket on the same line as else if if it were up to me

It's C# give me a break

...

return EXIT_SUCCESS;
It quits the program in a good way.
You can also use any int instead of EXIT_SUCCESS and have the exit code be a flag for bugs or as a way to pipe things out to interact with other programs, the possibilities are infinite.

try:
string = string.encode('utf-8').decode('utf-8')
except UnicodeEncodeError:
string = string.encode('utf-8', 'surrogateescape')
encoding = chardet.detect(string)

if encoding['confidence'] > 0.5:
string = string.decode(encoding['encoding']).encode('utf-8').decode('utf-8')

return string
else:
return False


Fucking beautiful

>return string
>return false
>try
It's like 5 different types of AIDS all in once place.

...

arr=({a..z})
# Neat way to get the lenght of an array
arr_len="$(echo "${!arr[@]}"|tr ' ' '\n'|tail -n 1)"

...

Depending on your program you might need to do some cleanup. If you have to add a cleanup function afterwards you'd have to go through your loop and find every single exit.
To be able to simply add cleanup if suddenly needed I'd still write something like below even if it might not be needed right now.
int loop = 1;
while (loop)
{
[...]
if (exitcondition)
{
loop = 0;
break; /* if needed */
}
[...]
}
cleanup();

...

Literally nothing wrong with this code

Did I do good senpai?

test2=test;
how do you define "wrong", it does what is says but it could be way simpler and easier/faster to understand.

There's also nothing wrong with this either then. It does what it's supposed to.

0/10

>while(true)
WHY

>if ( () . )

No

que nojo

Why would anyone write comments, class, variable, function names etc in anything else but English? I'm not a native speaker myself, but I would still never do that.

What the actual fuck?
Why are you casting bools to int, subtracting one from the other, and checking to see if the result is not 0 instead of just using != on the bools

...

public void izreziSliku() throws IOException{
File file = new File("./telNumber/telNumberCorbel.jpg");
FileInputStream fis = new FileInputStream(file);
BufferedImage image = ImageIO.read(fis);
int rows = 1;
int cols = 11;
int chunks = rows * cols;
int chunkWidth = image.getWidth() / cols;
int chunkHeight = image.getHeight() / rows;
int count = 0;
BufferedImage imgs[] = new BufferedImage[chunks];
for (int x = 0; x < rows; x++) {
for (int y = 0; y < cols; y++) {
imgs[count] = new BufferedImage(chunkWidth,
chunkHeight,
image.getType());
Graphics2D gr = imgs[count++].createGraphics();
gr.drawImage(image, 0, 0, chunkWidth, chunkHeight,
chunkWidth * y, chunkHeight * x,
chunkWidth * y +
chunkWidth, chunkHeight * x + chunkHeight,
null);
gr.dispose();
}
}
System.out.println("Rezanje slike je završeno.");
for (int i = 0; i < imgs.length; i++) {
ImageIO.write(imgs[i], "jpg",
new File("telNumber/slika" + i + ".jpg"));
}
System.out.println("Kreiranje slika je završeno.");
}

What makes code "elegant"?

youtu.be/o8NPllzkFhE?t=858

// Converts integer to binary v.0.0.2

#include

int shortint2bin(int j);

int main() {
int num;

puts("\nThis program converts unsigned integers to binaries.");
printf("Enter a number: ");
scanf("%d",&num);

if(num65535) {
printf("\nInvalid input!\n");
main();
}

else {
printf("\n%d in binary equals:\n",num);
shortint2bin(num);
}
return 0;
}

int shortint2bin(int j) {

unsigned int arr[16];
int i;

for(i=0;j!=0;i++) {
arr[i]=j%2;
j=j/2;
}

for(i--;i>=0;i--) {
if(i==0) printf("%d\n\n",arr[i]);
else printf("%d ",arr[i]);
}
return i;
}

V1.0 was even worse:
hastebin.com/atulidecod

why does he talk with his teeth closed?

#include

#define MOD(c,v) ((c%v))

#define FIZZ_i 3
#define FIZZ_s "Fizz"
#define BUZZ_i 5
#define BUZZ_s "Buzz"

#define COUNT 100

int main(void) {

int i;
for(i=0; i

How easy is to troubleshoot, mantain, edit, comprehend or expand

>comparing strings with ==

>for(i--;i>=0;i--)

it just werks

I could do for(int foo=i-1;foo>=0;foo--)

...

Because I'm a beginner. And I remember using something like that when programming a msp430 to loop the main function.

I'll look up the documentation.

I like this, looks very versatile.

Thank you all.

Because I need to know a change has occurred, instead of just assigning the detected bool state to the struct's members. And the IsDlgButtonChecked doesn't return a bool, but a UINT.

Don't have a pic but
>chaining different slices of an SQL command with
"element1.text + ","+element2.text...

SQl injection

...

>Because I need to know a change has occurred, instead of just assigning the detected bool state to the struct's members
In the conditions you retard
>And the IsDlgButtonChecked doesn't return a bool, but a UINT
Doesn't matter. Cast it to a bool if you really want to.

>giving database-abled programs to anyone
It was mainly for avoiding opening SQL server each time a small thing was needed, only me and the sysadmin used it.
Tho i didn't test for that shit.
does c# have a way to do it more securely?

>In the conditions you retard
Yes, I meant that. What's your point?

>"Type here your question:"

You still know a change has occurred if you write the conditions in a non-retarded way

How?

old ass part of my stl extension library. rate and rate

Because it evaluates to exactly the same thing? What aren't you getting here?

I honestly have no idea what I'm doing

google prepared statements for c# if you care.

What are you on about? Evaluates where? You're saying you can write code to check if a change has occurred in a non-retarded way, so how do you propose that?

LINQ to SQL or usage of stored procedures with abstracted calls.

Combine with input sanitizing and you're golden.

see
If you're going to continue being a monkey about this, just post one of the if statements from the code you posted so I can change it without having to hand-copy from your image.

meant for

bool readChkBoxesState(HWND dialogWindow)
{
bool changeOccurred = false;
//difference should be 1 if change occurred, otherwise 0 (1-1) = 0 (0 -0 ) = 0 ||| 1-0 0-1
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER)) - (int)(settings.bRememberLastSizeByUser) )
{
settings.bRememberLastSizeByUser = (bool)(IsDlgButtonChecked(dialogWindow,IDC_PREFS_TOGGLE_WINREMEMBER));
changeOccurred = true;
}
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_bSplashScreen)) - (int)(settings.bSplashScreen))
{
settings.bSplashScreen = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_bSplashScreen));
changeOccurred = true;

}

if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_EXIT_NORMAL_CONFIRM)) - (int)(settings.bConfirmExit))
{

settings.bConfirmExit = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_EXIT_NORMAL_CONFIRM));
changeOccurred = true;

}

if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_FULL_PATH)) - (int)(settings.bShowCompleteFilePathInTitle))
{
settings.bShowCompleteFilePathInTitle = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_FULL_PATH));
changeOccurred = true;
}
if ((int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR)) - (int)(settings.bToolbarActive))
{
settings.bToolbarActive = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR));
changeOccurred = true;

}
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_LINKS)) - (int)(settings.bDetectLinks))
{
settings.bDetectLinks = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_LINKS));
changeOccurred = true;
}

if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR_TEXT)) - (int)(settings.bToolbarText))
{
settings.bToolbarText = (bool)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_TOOLBAR_TEXT));
changeOccurred = true;
}
return changeOccurred;
}

well at least it has some comments...

Patterning out Maybe and Either in Haskell in code that can't, logically, return Nothing.

unsafeMaybe :: Maybe a -> a
unsafeMaybe Nothing = error "unsafeMaybe crash"
unsafeMaybe (Just a) = a


I could refactor the _other_ code to basically not require me to do this but gahhhhhhh.

This is really shitty BTW, for those that don't know Haskell.

>>ermagerd
Take your own advice

R8

oh my, you win, havent seen code this disgusting since i took over a project made by BSc "i kan program" shitters

bretty good

Man I said "one of" the if statements
> bool changeOccurred = false;
if ( (int)(IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER)) - (int)(settings.bRememberLastSizeByUser) )
{
settings.bRememberLastSizeByUser = (bool)(IsDlgButtonChecked(dialogWindow,IDC_PREFS_TOGGLE_WINREMEMBER));
changeOccurred = true;
}

bool changeOccurred = false;
if (IsDlgButtonChecked(dialogWindow, IDC_PREFS_TOGGLE_WINREMEMBER) != settings.bRememberLastSizeByUser) {
settings.bRememberLastSizeByUser = (bool)(IsDlgButtonChecked(dialogWindow,IDC_PREFS_TOGGLE_WINREMEMBER));
changeOccurred = true;
}

>Do you want beep?
No Sanjeep I want nearest shitting street.

thanks, i gotta update it at some point to take any kind of container

This guy sure got that right.

That's cute, OP :3

Suggested next step:

Let the user type e.g. ACF to play the notes A, C and F in order. Type in a little melody