[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
/dpt/ - Daily Programming Thread
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

You are currently reading a thread in /g/ - Technology

Thread replies: 346
Thread images: 21
File: spaghetti.jpg (374 KB, 1000x1000) Image search: [iqdb] [SauceNao] [Google]
spaghetti.jpg
374 KB, 1000x1000
old thread: >>52441370
Fun fact: mods deleted the last 7 /dpt/s posted.

What are you working on, /g/?
>>
Are function pointers idiomatic C?
>>
>>52446984
DONT DELETE PLS THX
>>
>>52446984
ThirD
Reading through this
>>
x-macros are really cool.
>>
>>52447009
save yourself a lot of pages

visualgo.net
>>
>>52446992
>idiomatic C
In my experience, there's no such thing anon. C has been around long enough that "idiomatic C" is whatever conforms to the style guide of the project you're working on.

But yeah, function pointers are fine as long as you've got a good reason to use them. And shoehorning in functional programming doesn't count as a good reason.
>>
Removing whitespace or putting everything on one line doesn't make your code smaller.
>>
>>52447031
Idiomatic C means conforming to the design patterns encouraged by the language spec and not trying to abuse structs in an object oriented fashion.
>>
>>52447033
optimization does that for you anyways lel
>>
>>52447031
What about writing a state transition table for a finite state machine?
>>
>>52447073
what about it?
>>
>>52447073
I wouldn't know about that. I just know that I work on a frankenstein's monster of an embedded system cobbled together from several different open source projects written in C, and each of them has a completely different coding style. Each project claims to have found the "idiomatic" way of writing C, and each codebase sucks just as much as the last.
>>
I will literally program all replies to this post in the C programming language.
>>
which is better
for (i = 0; i < 10; i++){
stuff;
}

or
for (i = 0; i < 10; i++)
{
stuff;
}
>>
>>52447026
this website would be much nicer if it wasn't full of slow animations
as if anyone actually needs the play-by-play psuedocode highlighting
>>
>>52447144
int i;
for (i = 0; i < 10; i++)
{
stuff(i);
}
>>
>>52447144
I've always preferred the second, it looks much cleaner to me.
>>
>>52447144
literally the same. C optimization takes care of that shit anyways

>>52447154
it helps you understand what it's doing. If it was so intuitive in the first place there wouldn't be whole classes devoted to the subject.
>>
>>52447033
it does when your code isn't compiled
>>
>>52447166
>>52447167
b-but
>>
>>52447218
K&R only advocates that style because it saves space in the book
it's called K&R style for a reason
>>
>>52447195
Your hard disk has block alignment though, so unless you can save a ridiculous amount of spaces, it won't make your file any smaller in reality.
>>
>>52447225
i have a friend who swears by it though
>>
>>52447229
I was implying that its for transferring the code over the wire, to users.

(hint: javascript)
>>
>>52447142
Well that was easy.
>>
>>52447307
it looks difficult to read in nested loops
>>
>>52446984
>What are you working on, /g/?

Moving my application servers off Linode after the whole.. Linode situation.
>>
OCAML IS LOVE, OCAML IS LIFE!
>>
>>52446984
>>52446828
>>52446617
>>52446588
>>52446550
Post your memes in your favorite meme, everyone. Bonus points for meme editors.
const readline = require('readline');                                       

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.question("Enter dank meme: ", (answer) => {
console.log(answer);
console.log(answer.slice(1).split('').join('\n'));

rl.close();
});
>>
>>52447115
Whether it's a good reason to use function pointers.
>>
>>52447408
#include <stdio.h>
#define BUFF_SIZE 1024
int main () {
int i;
char str[BUFF_SIZE];

printf("Enter whatever: ");
fgets(str, BUFF_SIZE, stdin);

printf("\n%s", str);
for (i = 1; i < strlen(str); i++) {
printf("%c\n", str[i]);
}
return 0;
}
>>
>>52446984
>Fun fact: mods deleted the last 7 /dpt/s posted.
good. maybe we won't have to post early threads to """"""""compete"""""""" against the trap poster
>>
>>52447408
#include <stdio.h>

int main(int argc, char **argv)
{
if (argc != 2)
{
printf("%s %s\n", argv[0], "\"text to meme\"");
goto end;
}
printf("%s\n", argv[1]);
int i;
for (i = 0; argv[1][i]; i++)
{
printf("%c\n", argv[1][i]);
}
end: return 0;
}
>>
>>52447408
Why do your line numbers go backwards?
>>
need a quote for some freelance work.

Need a program which can add a product to a shopping cart (HTTP post method) then check out as fast as possible (running this task at a certain time).

reddit quoted me literally thousands of dollars -.-
>>
>>52447502
It prints the first character twice ie
me
m
e

It also doesn't allow for spaces.
>>
>>52447532
fixed it, just change the starting index to i = 1
$ ./meme "ayy lmao"
ayy lmao
y
y

l
m
a
o
>>
i like functional programming

levels the playing field for me and my non CS degree. I took way more math than CS people.
>>
>>52447517
Yes, thousands of dollars.
Don't you value your time?
>>
File: relativenumber.png (41 KB, 810x278) Image search: [iqdb] [SauceNao] [Google]
relativenumber.png
41 KB, 810x278
>>52447511
They don't. The zero follows my cursor. I'm using vim, so being able to tell exactly how far away a line I'm trying to jump to is fantastic.
>>
>>52447545
I never realised that putting quotes around input args made them one argument.
>>
>>52447546
kill yourself
>>
>>52447517
>coming here butthurt because redditors won't work for free
>>
>>52447609
I'm not asking them to work for free. I just can't see it being a project which takes more than 10 hours.
>>
>>52447618
You're asking them to build you a working product.
You have right to be undercutting them just because your non-technical ass thinks this is 10 hours worth of work.
>>
>>52447641
*no right
>>
>>52447423
wait you dont need #include <string.h> for strlen()?
>>
>>52447618
then do it yourself if you think that
>>
>>52447595
> I never realised that putting quotes around input args made them one argument.
In Unix, that's down to the shell. argv[] is whatever the caller passes to execve().

On Windows, programs get a single string and it's up to the start-up code to parse it into argv[] (assuming you're actually using main() rather than WinMain() or custom start-up code). The rules for escaping quotes and backslashes are a level of bullshit only Microsoft is capable of (and the rules for cmd.exe are far worse).
>>
>>52447517
these things literally cost thousands of dollar stupid shitkid

go on some freelancing website and get some pajeet to do it for you for $10 and see how that goes...
>>
WHO WANTS TO MAKE A GAEM
>>
>>52447618
even if were to take no more than 10 hours then at $100 an hour it's still $1000
>>
File: 1448744645876.jpg (70 KB, 518x376) Image search: [iqdb] [SauceNao] [Google]
1448744645876.jpg
70 KB, 518x376
>>52447584
muh nigga
>>
>>52447693
for how much
>>
>>52447693
I can make the logo.
>>
>>52447695
>$100 an hour
>HTML
>>
>>52447655
You do, but compilers are helpful and I'm an idiot.

#include <stdio.h>
#define BUFF_SIZE 1024
int main () {
int i = 1;
char str[BUFF_SIZE];

printf("Enter whatever: ");
fgets(str, BUFF_SIZE, stdin);

printf("\n%s", str);
while (str[i] != '\n') {
printf("%c\n", str[i]);
i++;
}
return 0;
}
>>
>>52447618
10 hours my ass. It will probably take two hours just for you to explain what you need done in enough detail to get them started.

Writing the code probably won't take long, but they'd need to test it and do their research to make sure it works right. And if you want it to be flexible at all, then that's more work right there.

And sure, maybe if everything goes perfectly, it'll only take 10 hours or so, but that's not the point. The point is they can charge that much because you CAN'T do it. Programmers are expensive as fuck, and freelancers even more so because they don't get 401k or benefits like salary programmers.
>>
crypto hash 1/2
def unpack_factors(bits):   
""" Unpack encoded (prime, power) pairs and compose them into an integer.
Each contiguous 1-bit increments the exponent of the current prime.
Each zero advances to the next prime and composes the current prime and
exponent into the output.

For example:

11001101

Is interpreted to mean:

(2 ** 2) * (3 ** 0) * (5 ** 2) * (7 ** 1)

The bits that previously represented the number 205 are composed and
result in the integer 700. """
if '1' not in bits:
return 0
variables = prime_generator()
variable = next(variables)
power = 0
output = 1
last_bit = len(bits) - 1
for bit in bits[:-1]:
if bit == '1':
power += 1
else:
output *= variable ** power
power = 0
variable = next(variables)
if bits[-1] == '1':
power += 1
output *= variable ** power
return output


pic unrelated
>>
>>52447708
however much you think the result of your efforts is worth :^)

>>52447711
just fuck off with that meemee
>>
>>52447695
breh

maybe $50 an hour
>>
>>52447712
have you any idea what web dev salaries are like in first world countries? if it's so easy and takes so little work then just do it yourself
>>
>>52447726
2/3
def hash_function(hash_input, key='', output_size=None, iterations=1):
""" A tunable, variable output length hash function. Security is based on
the hardness of the well known problem of integer factorization. """
input_size = str(len(hash_input))
state = binary_form(hash_input + input_size)
state += binary_form(input_size + str(len(state)))
# print state

for round in range(iterations):
state = binary_form(unpack_factors(state))# + binary_form(str(len(state)))
random_index = pow(17, int(state, 2), len(state))
state = rotate(state[:random_index] + state[random_index+16:],
int(state[random_index:random_index+16], 2))

state_size = (len(state) / 8) - 1
if output_size and state_size < output_size:
return hash_function(state + str(state_size) + hash_input,
output_size=output_size)
else:
return rotate(byte_form(state[:-8])[:output_size], int(state[-8:], 2))
>>
>>52447726
Did you know the matrix characters are reversed japanese characters?
>>
>>52447722
You don't know how to program and yet you have the nerve to lowball freelancers because you have no idea how long it takes to build your shitty web store?

I hope this is a troll.
>>
>>52447726
>implying that isn't just matrix text
>>
>>52447738
>web dev
>programming
first of all, web dev is not programming
>>
>>52447746
3/3
import itertools   

def rotate(input_string, amount):
if not amount or not input_string:
return input_string
else:
amount = amount % len(input_string)
return input_string[-amount:] + input_string[:-amount]

def binary_form(_string):
try:
return ''.join(format(ord(character), 'b').zfill(8) for character in _string)
except TypeError:
return format(_string, 'b')

def byte_form(bitstring):
slice_count, remainder = divmod(len(bitstring), 8)
output = ''
for position in range((slice_count + 1 if remainder else slice_count)):
_position = position * 8
output += chr(int(bitstring[_position:_position + 8], 2))
return output

def prime_generator():
primes = [2]
yield 2
for test_number in itertools.count(3, 2):
for prime in primes:
if not test_number % prime:
break
else:
yield test_number
primes.append(test_number)


and the helper functions. It's just a toy, nobody uses my code.
>>
>>52447737
$50 hours x 40 hours a month x 12 months = $24k

web devs make $50-100k in the us

and freelancing costs more per hour
>>
>>52447754
meant for >>52447618
>>
>>52447722
>2 hours

if you were my boss I'd kill myself
>>
>>52447748
I did not. The screensaver thing I did in about 10 minutes because someone mentioned it'd be cool to see. I don't claim it accurately reflects the symbols from the matrix, it's just a bunch of random crap.
>>
>>52447760
HTML isn't programming either
>>
>>52447769
that should be 40 hours a week but whatev you know what i mean
>>
>>52447769
40 hours a month

huh
>>
>>52447781
that's what i said
>>
>>52447760
>I don't know what I'm talking about the post
>>
>>52447792
that would make it $104,000 then...
>>
>>52447805
you are not making your point very clear. look back through the conversation and see where it went wrong
>>
>>52447715
i had to add fflush(stdout); before fgets because using msys
>>
>>52447812
which is a normal web dev SALARY. FREELANCING/CONSULTING/CONTRACTING is more expensive per hour because it's not a steady stream of income and you don't get the same benefits as with an employment.
>>
>>52447809
>>52447814
retarded retards are not allowed to post on 4chan. leave
>>
>>52447815
That's probably the safer thing to do.
>>
>>52447840
you're the retard in this case
>>
>>52447829
m8. Average is $59
>>
>>52447840
>projecting this hard
>>
and you wonder why dpts get deleted.
please read the replies to this thread
>>
>>52447842
>>52447849
>thinks web dev is programming
>claims web dev is programming
>in /dpt/
how new are you?
>>
>>52447778

I've got a job implement a password policy on a website for a Government agency. The project tracker is at 41 hours and counting and all we've done is meet people let them bikeshed about their feelings on passwords.
>>
>>52447847
sweet jesus

how do I get into web dev?
>>
>>52447847
>although I know freelance web designers that charge $100 an hour
also that pic talks about DESIGN not making a shopping cart. those designers can't even make such a thing
>>
>>52447856
>am I fitting in yet mom?
>>
>>52447842
retards are allowed on 4chan, they just won't last long
>>
>>52447870
Butthurt pajeet detected. Watch out, he'll DEDICATE this thread!
>>
>>52447856
i replied to >>52447712 which clearly talked about HTML, not programming.
>>
>>52447868
so easy it hurts
>>
>>52447876
>didn't use to
FTFY
>>
>>52447870
hahahaha you actually think web dev is programming. haha you should kill yourself hahahahaha
>>
File: ab.png (8 KB, 547x157) Image search: [iqdb] [SauceNao] [Google]
ab.png
8 KB, 547x157
Why is my actionBar white? It's supposed to be the color of the blue square on the left.
>>
>>52447815
Why are you using set relativenumber and set number? If you want to see the line number you're currently on, take set number out of your vimrc and use set ruler.
>>
File: 3mLydMU.png (70 KB, 243x200) Image search: [iqdb] [SauceNao] [Google]
3mLydMU.png
70 KB, 243x200
>>52447893
NO ONE ITT SAID WEB DEV IS PROGRAMMING YOU FUCKING RETARD

JUST ADMIT YOU WERE WRONG OR SHUT THE FUCK UP IDIOT
>>
>>52447905
woah lad cool those jets m8
>>
>>52447881
web dev includes html, tardfriend
>>
>>52447914
HOW DO YOU MAKE THE LOGICAL JUMP FROM
>WEB DEV ISN'T PROGRAMMING
>HTML ISN'T PROGRAMMING
>WEB DEV INCLUDES HTML
TO
>WEB DEV IS PROGRAMMING

FUCKKKKKKKKKKKKKKKK
>>
>>52447073

Yeah, that gets done sometimes. Other times, people just use switch statements and let the compiler optimize them out to jump tables.

https://en.wikipedia.org/wiki/Branch_table#Alternative_implementation_using_addresses

>>52447144

Whichever is used by whatever group you're working with. If you're working on a new project, I personally am of the opinion that Linux Kernel Style or Stroustrup Style (which use the former) is better.
>>
>>52447905
quote the post where i'm "wrong". you can't, faggot
>>
>>52447905
butthurt webdevs are the most hilarious, hahahaha!
>>
>>52447928
>>52447760
>implying anyone was talking about programming
>>
>>52447584
wow thats useful
>>
>>52447922
i really pity you and your low-IQ
>>
>>52447933
epin trole xdd such a great use of your time on earth xdddd
>>
>>52447936
I will literally program anything anyone tells me to.
>>
-- left          -- right
V V
+----------------+----------------+
|i:f: :(:m:y:_:\0|v:a:r: :=:=: :\0|
+--------^-------+----^-----------+
| |
begin end


What would be the correct way to extract a token split between two buffers? It's delimited by the begin and end pointers.
>>
>>52447941
literally retarded

>>52447949
ok?
>>
>>52447900
i tried what you said and it doesn't really work the way i want it to
>>
>>52447951
what are your delimiters?
>>
>>52447584
or you can program in a decently sized window so you don't have to crawl line by line through your code base
>>
>>52447970
or you could use vim
>>
>>52447988
relative code line numbers are the dumbest thing i've seen all day and i've seen some pretty damn dumb things today
>>
>>52447999
trips for hyper-retardation.
>>
>>52447964
Pointers. Begin points to 'm' and end points to 'v'. The \0 at the end of the buffer should not be included in the token.
>>
>>52447999
But if i want to move down to a certain line i can do it with 2 keystrokes since i know how many lines to move down. also checked.
>>
what program brings my dog back to life
>>
>>52447970
>>52447970
>so you don't have to crawl line by line through your code base
That's the idea. When I'm working on a big ass screen, it's nice to be able to say 48j instead of hitting j a bunch of times or moving my hands from the memerow and to my mouse.
>>
>>52448016
just keep track of whether you finished a token (probably a space or something) and continue appending from the next buffer.
>>
>>52447856

I'm not a fan of web development myself, but quite frankly...

Some aspects of web development (server/database code, client Javascript) are programming.

Some aspects of web development (HTML, CSS, anything that templates either of these) are not programming.
>>
>>52447936
the poster that i replied to was indeed implying that web development is programming because this is in fact the daily programming thread where the subject matter should only relate to programming and not web development. even the fact that he presupposes web development as a feat by challenging me to attempt web development leads me to question his intelligence and not even his extremely overly inflated reverence for web development will take away from the fact that web development is for script kiddies
>>
>>52448020
you can move to it with 1 click
>>
>>52448038
>mousefags
>>
>>52448038
but i'd have to move the mouse and stuff :/
>>
>>52448035
FOR FUCK'S SAKE YOU FUCKING SPERGLORD NOT EVERYTHING IN /DPT/ IS ABOUT PROGRAMMING. THE POST IT WAS REPLYING TO: >>52447712
>>$100 an hour
>>HTML

>HTML

LITERALLY RETARDED KILL YOURSELF OR FUCK OFF TO REDDIT SPERG FAG
>>
>>52448035
nice. u win
>>
>>52448035
>even the fact that he presupposes web development as a feat by challenging me to attempt web development
JUST DO IT YOURSELF IF YOU DON'T WANT TO PAY FOR THE WORK SIMPLE AS THAT YOU SMUG ENTITLED MILLENNIAL SHITKID FUCCBOI
>>
>>52448062
wow, he seems upset now after i owned him
>>
>>52448062
NICE SAMEFAG FUCKING IDIOT
>>
>>52448080
i know. what a weirdo
>>
>>52448080
OBVIOUS SAMEFAGGING OR FUNPOSTING
>>
>>52448088
KILL YOURSELF UNDERAGE FAG
>>
Pure, unadulterated autism
>>
>>52448030
My question is how to extract the token, I want to have a string "my_var". Naturally I can't just copy from begin to end because it's split between two buffers.
>>
>>52448088
damn he's still going.>>52448089
huh??
>>
>>52448144
ok kid
>>
this thread is quite DESIGNATED
>>
>>52448089
>>52448099
only autists can get this upset
>>
>>52448254
only underage kids samefag after getting rekt
>>
>>52448266
what's your deal?
>>
>>52448295
what's YOUR deal? a number of people on reddit and on here have already quoted a price in the thousands of dollars. so you're a kid who doesn't have that kind of money to spend on a business application, then maybe you should work on it yourself unless you can settle with hiring some pajeet to do some very low quality work for you for cheaper.
>>
>>52448391
that wasn't me you dickhead
>>
>>52448414
k /care
>>
>>52448424
well reddit'd
>>
can we talk about something interesting again... fucking children

whats the point of function pointers
>>
>>52448531
2 uses I've seen
you can feed a function with a function pointer to another function to mitigate C's lack of dynamic types

you can also put them in structs and pretend that C supports member functions.
You can also put them in a vtable so as not to bloat up your structs with N*4kb of pointers inside of every struct.
>>
>>52448038
> clicking
lel
>>
>>52447999
you haven't looked in a mirror today
>>
>>52447144
former, because in the latter, the loop conditions feel separated from the code block
>>
>>52447584
adding this to my vimrc
>>
>>52447335
just add a newline
>>
>>52448050
you have to move your eyes anyway and with the mouse you don't have to read the line number, you don't even need to show line numbers at all
>>
>>52448622
how?
>>
So dpt, I wanted to learn JAVA since all the upcoming classes will use it for OOP projects except the three or five specializations which demand functional programming ala Haskell.

I have delved into the g wiki for some Java books I can learn from and use as a reference but following problem occurred to me as I looked up customer reviews for the books and I haven't bought and read any yet:

Herbert Schildt's Beginner book on JAVA:
http://www.amazon.com/review/R2EFLHDRLUZ7FC/ref=cm_cr_dp_title?ie=UTF8&ASIN=0071809252&channel=detail-glance&nodeID=283155&store=books

The Headfirst Java has some years under it's belt and is clearly very old for the version of Java I will use.

And then I have Think Java as an option, but it is also not going deep enough for acquiring deeper skills.
Sure it will teach me skills the on gist of programming, but it isn't sporting the functional aspects of java I am also interested
In other words, this book would be good, if it were updated for the current year.

Could someone be so kind and waste some time on my problem?
>>
>>52448663
>not showing line numbers at all
when my compiler gives me an error on line blah blah blah how am I supposed to navigate to that line I might as well be using notepad
>>
>>52448684
http://lmgtfy.com/?q=vim+relative+line+numbers
>>
>>52448860
kek
don't teach them how to code better
the market is saturated enough as it is

> newfags thinking people use terminals to be edgy
>>
>>52448663
>you don't even need to show line numbers at all
>>
>>52447335
get better eyes
>>
>>52447167
gay
>>
>>52448860
>how am I supposed to navigate to that line

http://vim.wikia.com/wiki/Go_to_line
>>
>>52449000
>>>/v/
>>
>>52449007
no u
>>
>>52447335
I literally don't get how this is possible.
>>
>>52449016
>literally
as opposed to figuratively not understanding how this is possible?
wow stop posting any time
>>
Is there another IDE I could use C# in? Using visual studio means I can just play around wih code, I have to actually implement it into controls.

            Console.WriteLine("Enter Dank Meme: ");
string memetext = Console.ReadLine();
for (int i = 1; i <= memetext.Length; i++)
{
Console.WriteLine(memetext[i]);
}


doesn't work because of the way the shit is initialised.
>>
>>52449023
autism
>>
>>52449024
that's not -- you know what nevermind
>>
>>52449016
>>52449023
as much as I hate people that use the word literally that way, he's right
1) it doesn't make it harder to read, you just suck
2) it's wasting a line for nothing
3) ????
4) fuck you
>>
>>52449044
I'm relatively new to programming, all I've been doing so far is working with controls, literally haven't touched the console.
>>
>>52449024
I think there's an open source thing called monodevelop, but if you're writing C# then you should be using visual studio
>>
>>52449059
I'd like a place to write little things that use the console so I can try shit out without having to try and sort out all the controls.
>>
File: no_u.jpg (30 KB, 640x454) Image search: [iqdb] [SauceNao] [Google]
no_u.jpg
30 KB, 640x454
>>52449015
>>
>>52447951
>>52448016
>>52448112
Anyone?
>>
>>52449009
clearly you need the exercise.
I suggest tetris or stepmania because they require strenuous eye motion and and quick recognition
>>
>>52449023
>>52449049
Sorry, when you grow up in the south you get used to hearing stupid shit like this and it's hard to unlearn
>>
>>52449070
I donno. I don't windows. Maybe PowerShell? or a different language? Python, Ruby, Something Else?
>>
>>52449124
I specifically want to practice with C#, want to be able to check exactly how different things work so when I implement them into my application I know what it'll do, instead of having to test it inside of a bunch of other code and having no idea what is actually causing the problem.
>>
>>52449123
Don't apologize, it's just autists who can't handle the fact that words can change meaning
>>
>>52449070
File -> New Project -> Console Application

Was that so hard?
>>
>>52446984

One of the few "two hour" projects I am working on. Let me know what you think.

https://play.google.com/store/apps/details?id=com.terminaltwofourty.rmgsoftware
>>
File: taken-aback-gif.gif (577 KB, 320x144) Image search: [iqdb] [SauceNao] [Google]
taken-aback-gif.gif
577 KB, 320x144
>>52449123
> my reaction when I was baiting an angry reaction but you apologize instead
the whole thing is pretty subjective. it's a divisive issue that doesn't matter one way or the other. Don't be drawn into either camp, you will be the stronger.

>>52449165
That would make him the autist.
>>
File: 1285244821880.png (99 KB, 247x248) Image search: [iqdb] [SauceNao] [Google]
1285244821880.png
99 KB, 247x248
>>52449191
I even looked for it, I spent 10 minutes looking for a console application thing, and I didn't even see it.
>>
>>52449191
>https://play.google.com/store/apps/details?id=com.terminaltwofourty.rmgsoftware
willingly giving up your anonymity, that's bad juju
you're lucky this isn't /b/ or /pol/
>>
>>52449221
I was about to say this isn't that much of a bad thing to do until I looked at the comment section... lol
>>
how the fuck do I play a wav file in SDL without SDL_Mixer? I just want to play a simple wav file
>>
>>52449289
first make sure your working directory is where the wav file is. It wont know where to read it otherwise
>>
>>52449289
i don't know
>>
>>52449289
you don't. if you don't know how to a link a library, then you're still a noob.
>>
>>52449289
first google result, what the fuck are you trying to pull
https://gist.github.com/armornick/3447121
>>
>>52449300
It is. I've successfully loaded it, I just don't know how anything else works. I'm assuming I need to call my audiospec's callback function, but when loading a wav file, it doesn't fill the audiospec's userdata, and I've tried copying the wav buffer to it with no luck
>>
>>52449316
holy shit, thanks anon, I'll try it
>>
>>52447049
>abuse

oop is idiomatic C
>>
Question, how do designers of hash algorithms know two hashes won't ever be the same? Is there a probability or prevention for that sort of thing or is it even needed? Thanks, I'm just interested.
>>
>>52449382
those are called collisions and they're not guaranteed to not happen. handling collisions is up to the person using the hashes.
>>
>>52449403
Ah, cool. I'm going to go research that, thank you.
>>
for (size_t 
i, x, y = x = i = 0;

i < n;

i++,
(y = i / h),
(x = i % h),
std::cout << i << ": " << x << ", " << y << '\n'
);
>>
>>52449211
What version of VS?
>>
>>52448024
that post made me very uncomfortable
>>
>>52448024
rm -rf
>>
>>52449431
2015 Community.

Pretty damn great IDE if you ask me.
>>
>>52449422
>(y = i / h),
>(x = i % h),

It's shit.
>>
>>52449454
I said that jokingly in ##linux one time
mother hen lost their shit so hard
>>
>>52449457
>any microsoft product is remotely good
microshill detected
>>
>>52449457
Thank you Pajeet!
₹2 has been deposited into your Microsoft® Account.
>>
>>52449475

fucking called it
>>52449473
>>
>>52449473
>>52449475
the original question was what version of Visual Studio to use. you're both dicks.
>>
>>52449457
https://youtu.be/8lk6BSsX2g4?t=1m58s
>>
>>52449491
>>52449473

i was being sarcastic
it was satire
>>
>>52449457
I got VS2015 Ultimate for free through my school. That's the only reason why I think it's good. You can do the same shit in any other free IDE really.
>>
>>52449598
I defy you to find a framework better than WPF for creating UI's quickly and easily with databinding.
>>
Can anyone recommend a string building library for C?
>>
>>52449634
The C standard library
>>
>>52449634
what do you mean by string building. If it's what I think it means, <cstring>
>>
>>52449634
string.h
>>
>>52449648
Building strings character-by-character or by concatenation.

I know the standard library has strcat but it's not ideal.
>>
>>52449704
big buffers and strcpy
>>
>>52449721
>big buffers
That's exactly what's not ideal. I could roll my own string pool but I would rather just use a proper library.
>>
>>52449704
if you want a guaranteed way to make perfectly sized strings without allocating big buffers, realloc your string with every new char in your string builder loop.
>>
>Tfw everything works
this is such a fantastic feeling
>>
>>52446984
Is engineering superior to CS?
>>
>>52449887
CS is engineering
>>
>>52449422
>this is what C is supposed to look like
>>
>>52449903
No, computer science is a science, engineering is the application of said science
>>
>>52449922
Software Engineering is required for Computer Science
>>
>>52449903
Nope

> is a science
From what I've heard on /g/ it's more like applied mathematics for computer purposes.
>>
>>52449930
>this is what code monkeys actually believe

>>52449935
>/g/ has taught me all I need to know about cs
>>
>>52449944
>everyone but me is wrong

explain how you do physics without instrumentation
>>
>>52449972
>he thinks I know anything about physics
Nah, I leave that shit to monkeys like yourself
>>
>>52449916
That's C++ though.
>>
File: 1451683583776.gif (2 MB, 400x600) Image search: [iqdb] [SauceNao] [Google]
1451683583776.gif
2 MB, 400x600
I did it lads, I finished my CHIP-8 interpreter in C. I'm pretty sure my code is shit, but for a first C project, at least I got it to work now.

Now time to make an assembler
in python
>>
>>52449916
>C
>std::cout <<
>>
>>52447144
I honestly don't give a fuck so long as everyone uses the same style within a code base.
>>
>>52449997
>>52450086

>this is what C is supposed to look like
>>
>>52447144
First is objectively better
>>
>>52450048
I can never get over just how much this woman looks like my cousin, it's insane.
>>
>>52450162
I would take her out even if she was my cousin

tbf I could say that about a lot of my actual cousins though
>>
>>52450165
I feel you, having attractive cousins is the worst
>>
File: 1451683513443.gif (2 MB, 400x225) Image search: [iqdb] [SauceNao] [Google]
1451683513443.gif
2 MB, 400x225
>>52450173
>tfw spooning your younger innocent cousin

so yeah virtual machines
>>
>>52447049
I don't think the C standard encourages any particular design pattern.
>>
ITT:
codemonkies
trolls
incest
>>
>>52450205
What's wrong with wincest?
>>
Why isn't my rot function working correctly?
http://pastebin.com/kwsdfQQc


rot[encrypt|5|dicks]
Rot5 Output: inhpn

rot[decrypt|5|inhpn]
Rot5 Output: dscus
>>
>>52450276
Another example, can't quite get my head around why it's happening.

rot [ encrypt | 4 | penis in vagina ]
Rot4 Output: lijmo mj rekmje

rot [ decrypt | 4 | lijmo mj rekmje ]
Rot4 Output: hefis if vagifa
>>
>>52450301
>benis
>>
>>52450301
>n is being encrypted to j
>j is being decrypted to f
start there, and debug it breh
>>
>>52450327
I've been trying, but I just can't seem to work it out, my first instinct wasn't to post here, but I ran out of ideas.
>>
>Working on some shitty database
>Uses seprate databases instead of separate schemas
>Guid primary keys
>Primary key is the clustering key
>Fucking NEWID() clustering everywhere
>No foreign key constraints
>Every column is nullable
>Application runs with sysadmin rights
>Devs log in to production for ad-hoc queries with sysadmin rights

So these faggots are moaning about performance issues, but "I can't change the schema, just do some dba tweaks. And you can't have any downtime/maitenece window longer than 10 seconds"

Please /g/, what's the most painless method of suicide
>>
>>52450327
>>52450301
You are decrypting/encrypting some letters twice nigger.
Holy shit you are retarded
>>
>>52450333
'n' is greater than 'm', so it gets encrypted by subtracting rotval, which puts it below 'm', so it gets decrypted by subtracting rotval again, which is not a reversal of the process
>>
>>52450378
>>52450370

Hmm, how do I avoid this problem then?
>>
>>52450392
well I don't know what the fuck you're trying to do so...
>>
>>52450392
turn your brain on for a start.
>>
>>52450402
Rot encryption.

>>52450403
It was on to write this in the first place, now I'm completely fucking lost, so obviously it's a bit beyond me.
>>
>>52450392
Always move in the same direction (e.g. '+' for encrypt, '-' for decrypt). Use xor to wrap the values.
>>
>>52450428
My problem is I didn't know how to loop back to the start of the alphabet, that's why i wrote it like this initially.

I can't find any concrete ways to do it anywhere.
>>
>>52449935
CS is the science of how to do stuff.
It is a special field because it combines math, physics, kinematics, biology and language.

It is not about learning the syntax of a programming language, not about proving physics, not about implementing a function someone else designed.
It is about coming up with algorithms and data structures and describing how to solve problems.

If it is used to build cool stuf then it is engineering.
If it is used to expand the understanding of how to do stuff it is science.
>>
>>52447951
Please respond. I'm seriously struggling to find an elegant way to do this.
>>
>>52450516
>CS is the science of how to do stuff.
No, CS is the science of what you cannot do.
>>
>>52450516
>>52450583

No, CS is the best FPS
prove me wrong
protip: you can't
>>
>>52450509
this spaghetti C should get you started. the idea is that if you want to encrypt you just rot one way and if you want to decrypt just use the same function with the reverse parameter.

void rot (const char * in, int n) {
int m = 'z' - 'a';
n = (2 * n) % m;
for (char * c = (char *) in; * c != '\0'; c++) {
putchar(((* c) + n - 'a' + m) % m + 'a');
}
}[/code
>>
Anyone think of a good coding project that would make use of a (SQL) database?
>>
>>52450599
Completely useless to me, that's just an entirely unreadable block of nonsense as far as I'm concerned.
>>
>>52450509
pseudocode:

string output
string input
int rotvalue

for each char c in input
if c >= 'a' and c <= 'z'
output += (c - 'a' + 26 + rotvalue) mod 26 + 'a' //append the encrypted lower case
else if c >= 'A' and c <= 'Z'
output += (c - 'A' + 26 + rotvalue) mod 26 + 'A' //append the encrypted upper case
else
output += c //append character without doing anything to it

assuming input is an initialised string, and rotvalue is a number between -26 and +26

okay so you use c - 'a' to get a number from 0-25 representing 'a' to 'z', then you add 26 to get a number from 26-51 representing 'a' to 'z', then you add rotvalue, then you mod 26 (gets the remainder from integer division), which will get back to a number from 0-25, then you add 'a' again to get it back to an ascii character representing 'a' to 'z'

we add the 26 so we can decrypt by passing in a negative rotvalue without getting a negative number from that expression

this relies on whatever language you're using being able to implicitly convert between char and byte
>>
>>52450613
replace variable names with longer ones if you want someone to hold your hand.
>>
>>52450599
Why are you discarding the const on 'in'?
>>
>>52450639
because i don't like compiler warnings and c won't be const.
>>
>>52450646
You're not modifying the value pointed to by 'c' though. Discarding const is fucking stupid.
If you ARE going to modify it, don't make the argument const.
>>
>>52450509
Sorry, use mod (%) not xor.
https://en.wikipedia.org/wiki/Modular_arithmetic

Look at this
0 mod 3 = 0
1 mod 3 = 1
2 mod 3 = 2
3 mod 3 = 0
4 mod 3 = 1
5 mod 3 = 2
6 mod 3 = 0

see how it wraps back to 0?
This guys done most of the work for you
>>52450614
>>
>>52450654
good point, guess I haven't really woken up yet.
>>
>>52450614
$ ./caesar
Please insert something to encrypt
>Just to prove it works
Lwuv vq rtqxg kv yqtmu
Please insert something to decrypt
>Lwuv vq rtqxg kv yqtmu
Just to prove it works
>>
Is Cracking the Coding interview enough to be ready for a grad level job on top of University? Should I throw in some CLRS?
>>
File: lol.jpg (9 KB, 289x175) Image search: [iqdb] [SauceNao] [Google]
lol.jpg
9 KB, 289x175
>>52450762
>grad level job
>>
>>52450664
>encrypt
You mean encode.
>>
>>52450830
is a cipher not technically a form of encryption?

I'm not into crypto at all, so I don't know the lingo
>>
>>52450857
Encode is synonymous with encrypt.
>>
Is it possible to make money from programming without having an actual programming-related job?
>>
CHIP-8 interpreter in all its disgusting glory
https://github.com/vinheim3/CHIP-8/blob/master/chip8.c

literally my first C project, and it's not refined, so it's going to look a bit shit
>>
>>52450614
Thanks, for trying.

Tried multiple different versions of what you gave me, and nothing works, tried slamming brackets everywhere, shifting the thing around, removing and adding stuff, still refuses to play ball.
>>
>>52450890
no, and you're retarded.
>>
>>52450952
Looks bretty gud tbqf chap. You might want to split up the emulatecycle function to improve readability.
>>
>>52451011
Wait, do you mean you couldn't get the syntax working?
this is it in D if it helps
string rot(string input, int n)
{
char[] output;
foreach(char c; input)
{
//c - 'a' gets 0 from a, 1 from b, etc, rather than ascii values
//adding 26 just means I can subtract without reaching negative values
//adding n does what you'd think
//MOD 26 gets the remainder (0-25) for (a-b)
//adding 'a' afterwards gets it back to ascii values

if (c >= 'a' && c <= 'z')
{
output ~= (c - 'a' + 26 + n) % 26 + 'a';
}
else if (c >= 'A' && c <= 'Z')
{
output ~= (c - 'A' + 26 + n) % 26 + 'A';
}
else
{
output ~= c;
}
}

return to!string(output);
}


I think the mod operator in java is % as well, so that might help
appending a character to a string in java is += as far as I can remember, rather than ~= in D, and instead of char[], I think you can just use string output (strings are immutable in D, so I had to use char[])

You need to write it from scratch based on the algorithm in that pseudocode, rather than paste it in and try and get it working
>>
>>52450816
le funny no job meme
>>
>>52451011
>not capable of fixing basic syntax errors
>>
>>52451084
Yeah I was recommended before to use function pointers for it. It is quite shite as it is now

Thanks lad
>>
File: jsj.png (1 MB, 823x533) Image search: [iqdb] [SauceNao] [Google]
jsj.png
1 MB, 823x533
>>52450946
maybe, but it will be the most excruciating work you've ever done with very little rewards.
>>
>>52451122
>>52451099
>Syntax

I know I'm a moron but I have more than 2 functioning braincells, syntax isn't the issue, the actual maths is the issue.
>>
>>52451054
Do you have anything to your argument besides ad hominem? Maybe you want to call the dictionary retarded too?

http://www.merriam-webster.com/dictionary/encrypt
>>
>>52451156
what do you have a hard time understanding?
>>
>>52451156
>the actual maths is the issue
I've tested it man, it works
$ ./caesar
Please insert something to encrypt
>I'm using 1 for my rotvalue to encrypt, and -1 to decrypt
J'n vtjoh 1 gps nz spuwbmvf up fodszqu, boe -1 up efdszqu
Please insert something to decrypt
>J'n vtjoh 1 gps nz spuwbmvf up fodszqu, boe -1 up efdszqu
I'm using 1 for my rotvalue to encrypt, and -1 to decrypt


post the code you've got and we'll be able to tell you what's wrong
>>
>>52451191
I'm not sure if you're pretending or you're really this stupid.
First result from Google, go educate yourself.
https://danielmiessler.com/study/encoding_encryption_hashing/
>>
>>52451215
>not including numbers in your rotation
>>
>>52451245
Not him but:
>countering the dictionary entry with a blog post
ebin
>>
>>52451259
>edvntn jlzgg ckdtxln tfdn vki ipxqoc vhhucx cn ogcidwoszysg olel ie tkyvg ymyxcb
>>
>>52451275
If you're on /g/ and think Merriam-Webster is an accurate representation of technical terms I have some sad news for you.
>>
>>52451278
wait fuck that was the wrong cipher I don't think anyone's going to autistic enough to decode that
>>
>>52451245
>this random blog post is more authoritative than a dictionary
In the English language, encode is synonymous with encrypt, deal with it.

If you want to use your own language, fine, but don't expect anyone to join you as this is an English language image board.
>>
>>52451292
>going to autistic enough to decode that
going to be autistic enough to want to decode that, I mean
>>
>>52451275
You're trying to counter industry professionals using industry terminology versus a dictionary written by a committee of know-nothing plebeians that think they don't need to bring in outside perspective because English is rigid and doesn't change for some reason.
>>
>>52451298
see
>>52451304
>>
>>52451298
Maybe it's acceptable if it's fox news reporting on the hacker named 4chan, but if you're not a degenerate retard and/or actually a real computer scientist you call it encrypt and never encode
>>
>>52451291
Can you back up that claim other than "I don't like the definition so it must be wrong"?
>>
>>52451304
Surely the industry professionals must have written books about the topic that you can use as a reference. Those would at least actually count as a credible source.
>>
>>52451325
If you don't know the difference between encoding and encryption then what are you doing in this thread?
>>
>>52450952
Seems decent.
Most of the things I can say about it a very minor and superficial.

You have a lot of global variables. That shit normally bothers me, but for that type of program, it's permissible.

>unsigned short
>unsigned char
Just use the stdint.h types, uint8_t and uint16_t. It gets the meaning across better and is more portable.

>Lines 58-63 & 69-70
Your initialize function does a lot of pretty redundant stuff, especially considering it's only called once.
All global/static variables are guaranteed to be set to zero on the program starting, and you could just assign them at the declaration anyway if you wanted to.

>Lines 66-67
memset would look cleaner.

>Line 97
buffer is never freed and casting malloc is pointless

emulateCycle is a huge function and should probably be split up into something smaller

>Line 408 & 513
>atexit(SDL_Quit);
I'm pretty sure you're going to end up calling it twice. I don't know if SDL handles that properly or not.

>Lines 453-507
A lot of duplicated code. I can think of ways to make that a lot shorter.
static const int key_map[SDLK_LAST] = {
// 1 greater than index, because 0 is used for empty value
[SDLK_1] = 1,
[SDLK_2] = 2,
[SDLK_3] = 3,
[SDLK_4] = 4,
[SDLK_q] = 5,
[SDLK_w] = 6,
[SDLK_e] = 7,
[SDLK_r] = 8,
[SDLK_a] = 9,
[SDLK_s] = 10,
[SDLK_d] = 11,
[SDLK_f] = 12,
[SDLK_z] = 13,
[SDLK_x] = 14,
[SDLK_c] = 15,
[SDLK_v] = 16,
};

while (SDL_PollEvent(&event)) {
int sym = event.key.keysym.sym;

if (sym == SDLK_ESCAPE)
quit = true;
else if (key_map[sym])
key[key_map[sym] - 1] = (event.type == SDL_KEYDOWN);
}

But that might be too much C magic.
>>
>>52451337
>asking for a source that's not a blog post
>NO U R STOOPID
nice arguments you got there
>>
>>52451325
https://en.wikipedia.org/wiki/Cryptography

ctrl+f "encrypt"
>68 results

ctrl+f "encode"
>0 results

Have fun watching fox news
>>
>>52451337
You have yet to prove that you know.

>>52451361
>wikipedia
>>
>>52451361
>2016
>still doesn't know what a credible source is
I'll be waiting then
>>
>>52451331
>books
Those more inclined towards academia, which invent the terminology, generally publish their results in journals and conferences rather than books.
>>
>>52451377
>Thinks Merriam-Webster is a credible source, demands others look up books as references.
>>
>>52451347
>memset
memcpy I mean
>>
>>52451374
>>52451377
>pick a random paper wikipedia cites
http://www.fortify.net/related/cryptographers.html

ctrl+f "encrypt"
>48 results

ctrl+f "encode"
>0 results

Have fun watching fox news
>>
>>52451384
Then what stops you from posting those?

>>52451390
>thinks a blog or wikipedia is a MORE credible source than a professional producer of dictionaries for over 200 years
>>
>>52451396
According to a dictionary the two words are synonymous. Showing that a publication uses only one of them is pointless.
Post the definition of those words.
>>
>>52451390
Merriam-Webster have been producing English language dictionaries for the past 150 years, that's more than can be said for a blog post or a freely editable online encyclopedia.
>>
>>52451402
>my sources are better than yours
top kek mate, go be autistic somewhere else
>>
>>52451347
Jesus christ mate, this is a lot of good advice, all of it will definitely be in my next commit, thanks a ton!
>>
God
fucking
damn

I am sorry I said the word 'encrypt' half an hour ago

you people have too much autism
>>
>>52451411
A dictionary doesn't define the English language, usage does

So if Webster accidentally omitted "the" from their latest publication of the dictionary, would you learn french because of your newfound inability to communicate until they post an errata?

Besides, English is a lot older than any dictionary
>>
/!\ A L E R T /!\

new thread
>>52451429
>>52451429
>>52451429

/!\ A L E R T /!\
>>
>>52451396
Are you literally retarded?

ctrl+f "faggot"
2

ctrl+f "you"
206

They both occur so they must be synonymous, right? My source is this thread.
>>
>>52451433
Fuck off. The thread isn't even on page 10 yet.
>>
>>52451105
graduating university does not make you more employable unless, like a uni student, you do fuck all in those years
>>
>>52451412
>check both the Oxford English dictionary and the Oxford American English dictionary
>neither say encrypt and encode are synonymous
>where's your "dictionaries are the ultimate truth" god now?
>>
>>52447307
>bringing your friends into this
pussy
>>
>>52448032
>tfw not actually programming at my first job

i feel worthless now, t-thanks
>>
>>52451591
c-callum?
>>
>>52451671
no.
>>
>>52451671
john?
>>
>>52451706
m-mom???
>>
>>52451712
brother?
>>
how come the bubble sort in "absolute beginner's guide to C" seems slightly different from the bubble sort on youtube and wikipedia? in the book it compares the first number with the second, then the first with the third and so on, whereas on wikipedia/youtube they compare the first pair, then the second pair. is it still bubble sorting just a different way of doing it?
>>
>>52451712
>>52451719

called it
>>52450205
>>
>>52447584
SPC-t-r
in spacemacs, just so you all know. (and
SPC-t-n
if needed to enable line numbering itself)
>>
>>52451754
wew lad
good job, so smart
>>
>>52448531
callback functions obviously!
>>
>>52448531
higher order functions you pleb
>>
>>52449815
it's written receive ffs
Thread replies: 346
Thread images: 21
Thread DB ID: 425250



[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.