[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 / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily PROGRAMMING Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

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

Thread replies: 255
Thread images: 53
File: 1452154265094.jpg (49 KB, 680x680) Image search: [Google]
1452154265094.jpg
49 KB, 680x680
FUCK OFF DELUSIONAL WEB FAG RETARDS

Previous thread: >>54063063

What are you working on, /g/?
>>
Please use an anime image next time.
>>
File: 1460577020386.png (38 KB, 227x367) Image search: [Google]
1460577020386.png
38 KB, 227x367
>>54066471
This. Only if it's not a trap image though.
>>
>>54066467
Web dev here, AMA
>>
File: xperiax2dropped.png (331 KB, 640x320) Image search: [Google]
xperiax2dropped.png
331 KB, 640x320
>>54066467
I was working on learning Vulkan the last few days
Then I suddenly realized it doesn't have any kind of fullscreen support at the moment
>>
File: intel.jpg (9 KB, 246x227) Image search: [Google]
intel.jpg
9 KB, 246x227
TRIPFAGS
SNEKFAGS
WEBFAGS
JAVAFAGS
JSFAGS
PUREFAGS
GCFAGS
LITERAL FAGS

OOUUUUUUUUUUTTTTTTTTTT
REEEEEEEEEEEEEEEEEEEEEE

https://www.youtube.com/watch?v=OSCiMbMVDLI
https://www.youtube.com/watch?v=OBwS66EBUcY
>>
>>54066482
please ban
>>
File: yay.png (61 KB, 1031x444) Image search: [Google]
yay.png
61 KB, 1031x444
Just started learning Python on Codecademy.
Having a lot of fun here.
Any tips, tricks or good advice?
>>
>>54066500
>Python
>Codecademy
you didn't listen to any of us, did you
>>
>>54066500
Don't cheat yourself. Realize this is literally only teaching you the basics and logic flow, but a good introduction tool.

>>54066513
>didn't listen
Muh primary language isn't being learned
>>
>>54066500
learn python3 instead
>>
>>54066529
>the basics and logic flow
literally the first day of java
>>
>>54066480
Though this is the imperative way, I'm pretty sure in LISP, you just recursively call the next function with b, a+b straight out
>>
>>54066542
The first day of Java takes like 7 days due to its verbosity lmao
>>
Why is Ruby code so elegant?

Is it because it was created by the Japanese?

Why are all other languages so fugly compared?
  (1..100).each{|i|
x = ''
x += 'Fizz' if i%3==0
x += 'Buzz' if i%5==0
puts(x.empty? ? i : x);
}


I don't want to demean other languages, but this can be understood intuitively even by non-programmers

it's magical because it's very expressive and intuitive while being compressed

how can other languages even compete?

It's digital poetry
>>
>>54066558
Very funny. Ha ha.
>>
>>54066573
With Java, everything's a joke haha
>>
Why would I ever pick C over C++?
I can only think of 2 reasons

>No C++ compiler available
>You want to provide binding for other languages

But every relevant platform has a C++ compiler and I don't care about other meme languages.

If you don't like OOP you can still write C styled C++ with the added bonus of function parameter overloading, more type safety, safer memory (de)allocations, templates, ect...


Is /g/ pulling my leg when they say they prefer C over C++? Why would you pick C over C++ if those 2 reasons above don't apply.
>>
File: tumblr_ldwvynuZOE1qd8754.gif (39 KB, 500x396) Image search: [Google]
tumblr_ldwvynuZOE1qd8754.gif
39 KB, 500x396
>>54066578
>>
>>54066587
C++ is an improvement over C, like the name implies.

There's no reason to use C in 2016 when C++ is available

It's like using Windows Me or Windows 95 instead of Windows 7 or 10. Makes no sense whatsoever.
>>
>>54066587
It's portable
>>
>>54066520
>>54066570
Whoops, you seem to have posted this twice! Please delete this.

>>54066570
>>
>>54066587
C is SHIT
>>
>>54066536
N00b here. What is the general difference between 2 and 3?
>inb4 "Python 2.x is legacy, Python 3.x is the present and future of the language"
How well would one go from having learned 2.x, to working with 3.x?
>>
>>54066587
C++ is design-by-commitee garbage. ANYTHING would be better than C++.
>>
>>54066603
It's a different thread you mong.
>>
>>54066611
nice meme fucking retarded fag as if a sub-100 IQ dutch unwashed RETARD can do it better himself
>>
>>54066570
fucking kill yourself retard
>>
>>54066620
Have you ever used a language other than C++?
It's fucking trash.
>>
>>54066620
Niet schelden aub.
>>
>>54066630
have you ever used a language other than py?
IT'S FUCKING TRASH FUCKING KILL YOURSELF STUPID SHITKID
>>
>>54066608
Due to tiny things like proper unicode support. Python 3 will, unfortunately for the many of us used to Python 2, eventually be the standard. Even Django will stop using Python 2, and various other package devs will follow suit
>>
>>54066657
KILL YOURSELF WEBKEK FAG
>>
>>54066646
Python is pretty shitty as well.
I like languages that have focus, not just "include everything that we can, because somehow that will make the language better".
>>
File: 1457058536312.jpg (26 KB, 222x222) Image search: [Google]
1457058536312.jpg
26 KB, 222x222
>>54066666
NICE DIGITS FAMALAM. MIND IF I SAVE THEM?
>>
>>54066663
No

>>54066666
Nice quints, but Python stopped "including everything that we can" for a long time. Additional packages are a choice
>>
>>54066681
>>>/g/wdg
>>>/g/wdg
>>>/g/wdg
>>>/g/wdg
>>>/g/wdg
>>
>>54066686
>Nothing found
Shame, looks like I'll stay
>>
>>54066608
if with "learned" you mean what you've learned from codeacademy then this is literally all the change there is:
>print "Hello, " + name + ", nice to meet you."
becomes
>print("Hello", name, ", nice to meet you.")
or
>print("Hello, ", name, ", nice to meet you.", sep="")

>raw_input()
becomes
>input()

and you don't have to worry about unicode errors anymore (unless windows)
>>
>>54066696
look again
>>
>>54066712
None of the usual wdg details. Looks like I'll stay
>>
>>54066729
kill yourself fag i sincerely hope you die a very slow and very painful death
>>
>>54066696

I liked your Chip8 emulator, but please no wobdev.

All the best,
GTP.
>>
File: fizz.png (402 KB, 1024x768) Image search: [Google]
fizz.png
402 KB, 1024x768
>>54066570
>>
>>54066735
You sound very negative mate, I hope things turn around for you

>>54066738
lmao I won't. I just mentioned it was my new job (which is why I haven't done anything new recently). What have you been working on the past month?

Kind regards,
Chip8dev
>>
File: gnl.png (29 KB, 1108x518) Image search: [Google]
gnl.png
29 KB, 1108x518
>>54066754
>What have you been working on the past month?

project for the FAA. Before that, I was working on my not-LISP, though.
>>
>>54066765
I remember not-LISP, any additional features?

>FAA
is that the frog thing?
>>
python is literally the best programming language it has... BAHAHAHAHA i can't do this
>>
I have a python script that scrapes my country's version of craigslist and saves as much info as possible into a simple pickle database
Now what I want to do is host a simple (single) webpage that will allow me to interactively filter my local database much like amazon/ebay's search filters but preferabbly without reloads anywhere
I hope that made sense

Is there an API or python package or something that can let me do this?
Or should I just write another python script that writes the html?
>>
>>54066810
>is there a pre-built babby library that does everything for me?
>>
>>54066772
>I remember not-LISP, any additional features?

None yet. I'm going to go back to SPP and turn it into a transpiler rather than an interpreter, though.
>>
>>54066810
You should do it yourself, look at ajax for the "no reload" part. The rest can be made in PHP easily if you already have everything in a database.
>>
>>54066772
>is that the frog thing?

What frog thing?
>>
File: regex.jpg (14 KB, 489x291) Image search: [Google]
regex.jpg
14 KB, 489x291
regex + python

match text, ignoring diacritics

'wor' would match 'wör'
'epo' would match 'épô'

Any simple way?
>>
File: FUCK THIS.png (45 KB, 1078x851) Image search: [Google]
FUCK THIS.png
45 KB, 1078x851
Anyone here knows web-related/boostrap/css? This shit is driving me nuts

My structure goes basically like this

div.row
div.col-sm-12
div.row.data-container
div.col-md-4.data-panel
h2
div.well
my shit here



well seems to be fucking shit up with it's padding, how do I fix this?
>>
>>54066892
It's going to take some work because I don't know anything about php/ajax but I wasn't expecting otherwise
Thanks, I might just do this
>>
Is this /dpt/ or /wdg/?
>>
>>54067025
/fpg/
>>
> Job title - Bespoke Software Artisan

What do you guys think?
>>
>>54066972
Give a bit more detail and show me a live example of the problem
>>
>>54067079
kill yourself
>>
File: Art Modern.png (4 KB, 640x400) Image search: [Google]
Art Modern.png
4 KB, 640x400
I tried in the previous thread, but I couldn't really grasp the answers.

So the question simplified: I'm trying to apply a rotation along the black X axis onto the red positional matrix. How would I do this? Because just changing the red one would rotate it along red's X matrix, not black.
It should be simple, right?
>>
>>54067079
>Bespoke Software Artisan
>>
>>54066883
>SPP
I have horrid memory, what is this again?
>>54066903
The drawing. I wasn't sober enough asking that question, I'm assuming FAA refers to the aviation company?
>>
>>54066964
w[öoô]r
[ée]p[öoô]
>>
>>54067241
>I have horrid memory
>I wasn't sober enough
webtards everyone
>>
>>54067262
yeah, I need universal
not just occurrences I know will happen
>>
>>54067274
regex is not for you
>>
>>54067268
I'm primarily an emulator/game programmer tho

>>54067274
What context? The easiest way is to replace your search string so that letters with diacritics are replaced with their diacritic set and regex with that
>>
>>54066471
I'm looking forward to the day you kill yourself
>>
>>54067290
>The easiest way is to replace your search string
By this, I mean when the user clicks or calls the search function, there is that 1 layer before actually searching where it converts your string, you don't have to go elsewhere to convert it. Probably obvious, just wanted to be sure
>>
>>54066467
>WEB FAG
I could almost hear some heavy breathing of a pathetic smelly autist typing shit really hard since he got triggered
>>
>>54067338
keep believing your jewnity webgl shit is a AAA game
>>
I wonder if everybody starts swearing either in their minds or vocally when they find the error. Specially stupid shit, like that while(true) that you forgot to remove yesterday and spent 5 hours searching for.
>>
>>54067405
I sometimes blame the jews for every little thing that goes wrong, even though I like jews, especially the girls
>>
>>54067179
Rotation is a tricky one, just FYI. I learned some stuff at school recently, and with anon's Wikipedia link I think I was able to reconstruct something.

Think about it, anon: how do you specify a rotation in 3D? There's a center of course, but also more than one angle...

Pic related: three elementary rotations. They can rotate along an axis, but only with the center at the origin. The first one especially does it around the x axis (the black one in your case, right?) Now, since your center isn't at the origin, you should IMHO write a center->origin translation matrix (requires 4x4 size), multiply it with the R_x(θ) matrix, and end with the inverse translation. No?

Rotations along a non-base vector can be done with the same trick, but with another rotation instead of the translation I think.
>>
>>54067315
>>54067290
yeah, I guess thats the way

now I am trying to find out if I can do it within the standard library
>>
>>54067429
Senpai, there is a string replace function, so yes you can
>>
File: 1460771163450.jpg (207 KB, 920x900) Image search: [Google]
1460771163450.jpg
207 KB, 920x900
>>54067374
>Mental gymnastics of a smelly /v/ faggot
Kill self and do your disappointed parents a favour
>>
>>54067405
maybe not literally swear but definitely some kind of thought or gesture to the same effect like "jeesh"
>>
File: wea.jpg (47 KB, 640x422) Image search: [Google]
wea.jpg
47 KB, 640x422
>>54067441
its bit more complicated
for example german umlau 'ß' is convereted to 'ss' or something like that..
of course I can do everything in standard if I am willing to recreate a library that already does it..
>>
>>54067179
>>54067427
Use quaternions
>>
>>54067471
>for example german umlau 'ß' is convereted to 'ss' or something like that..
That's not more complicated. Regex lets you catch whatever you want. It's up to your algorithm to parse the string into a suitable regex string.

exampless -> [e set]x[a set]mpl[e set][(ss)|ß]


If there are diacritics for either of the non-blocked letters, replace those too. If there are diacritics for s, it becomes

 [([s set][s set])|ß]


It gets a bit trickier with more s' next to each other, but either way, the regex is easy to understand, your work is in string parsing
>>
>>54067537
what I meant by it was that I am not willing to go through all that knowledge that I dont have
that its not just [ô|ó|ǒ] = o
>>
>>54067564
Well, what's the context anyway? There might be a library for it already but if the limit of what you need isn't so massive, then it's not going to be a complex task
>>
>>54066964
Down-convert to ASCII before matching?
>>
File: gif_1460816318.gif (59 KB, 535x270) Image search: [Google]
gif_1460816318.gif
59 KB, 535x270
>>54067580
I am doing file search on linux
new sqlite extension FTS5 brings ignoring of the diacritics on its own which is awesome
https://www.sqlite.org/fts5.html

but in the search results I am making the searched text bold
but now when FTS5 is used and user searches for something and it shows in result something with accent, theres no indication why was it matched

and I kinda liked to keep the non standard library to minum or have it included or something
>>
File: FUCK THIS.png (41 KB, 1078x851) Image search: [Google]
FUCK THIS.png
41 KB, 1078x851
>>54067164
Here you go

https://jsfiddle.net/L37w7f74/1/
>>
>>54067490
How
>>
>>54067756
i think this is more like the problem
https://jsfiddle.net/L37w7f74/2/
>>
Tfw u fell head over heels for the rust meme
>>
>>54067756
>>54067855
Ok i've seen your examples, what is it you want? If some container is not the same size as the other then they ajust to that? Is that a "masonry layout" you want?
>>
File: 1454754407247.jpg (78 KB, 677x475) Image search: [Google]
1454754407247.jpg
78 KB, 677x475
Writing a framework for synthetic differential geometry in Haskell.
>>
>>54068216
Just want them to to align equally and not show fucked up, the biggest the screen the more rows I want to show up side by side
>>
File: 1446445951114.jpg (241 KB, 1013x1276) Image search: [Google]
1446445951114.jpg
241 KB, 1013x1276
>>54066467
>mfw when all uppercase files pass
>>
I want to pad my github with resume fodder,

what are some things I could implement? I was going to do a command line chat server in C but I also want to do something with python and java/c# just to show I'm capable in them. anything non-trivially but not a major project.
>>
>>54068713
Creating GUIs with Python GTK (and Glade) is super easy. Plus, Python can interface with C. You should try and kill two birds with one stone and make a Python/C chat program, maybe where C handles the server.
>>
Every time I press one button, the other button goes back to displaying "X On", I tried removing the variable declaration because I know PHP runs parallel like but the problem persists. Any idea how to fix this?

<?php
if (isset($_POST['LockToggleOn'])) {
exec("sudo python /home/pi/PythonScripts/UpdateDB.py 1 Lock");
echo $varLock=1; }
if (isset($_POST['LockToggleOff'])) {
exec("sudo python /home/pi/PythonScripts/UpdateDB.py 0 Lock");
echo $varLock=0; }
if (isset($_POST['LightToggleOn'])) {
exec("sudo python /home/pi/PythonScripts/UpdateDB.py 1 Light");
echo $varLight=1; }
if (isset($_POST['LightToggleOff'])) {
exec("sudo python /home/pi/PythonScripts/UpdateDB.py 0 Light");
echo $varLight=0;
} ?>
<div class="center">
<form method="post">
<?php if ($varLock==0): ?>
<button class="button" name="LockToggleOn">Lock On</button>
<?php else: ?>
<button class="button" name="LockToggleOff">Lock Off</button>
<?php endif ?>
<?php if ($varLight==0): ?>
<button class="button" name="LightToggleOn">Light On</button>
<?php else: ?>
<button class="button" name="LightToggleOff">Light Off</button>
<?php endif ?>
</form>
</div>
>>
>>54068905
oh boy, not the php, exec sudo guy
>>
>>54068895
that's a good idea anon, thanks!
>>
>>54068926
If I made them all
exec("python /home/pi/PythonScripts/UpdateDB.py 0 Light");

would you be happy?
>>
>>54068963
>python /home...
>not ./home...
Set your files up correctly
>>
>>54068992
Not him: wtf are you on?
>>
>>54068992
Just to entertain you I tried every combination with/without sudo and ./home and the one I'm using is the only one that works.
>>
>>54068992
>>54069008
>>54069037

Boy are you guys retarded.
If you place '#! /usr/bin/python' or whatever at the top of your .py file and give it x permissions, you can do './file.py' instead of 'python file.py'. He's saying you should do the former instead of the latter.
>>
>>54069095
#!/usr/bin/env python
>>
>>54066467
I have only ever worked on non-critical projects and I rarely finish them entirely. Since I started actual software courses and learning some algorithm basics I have been reducing lines of code while acheiving more robust code. Future looks bright senpaitachi. :^)
>>
>>54069095
>>54069105
Cranking the permissions up did let me drop sudo but even with #!/usr/bin/env python instead of #! /usr/bin/python I can't get ./anything to work whether it's the entire location or just the .py.
>>
>>54069179
You want setuid?
>>
>>54069179
whereis python

then put that in. For me, I had to do the direct path rather than dir then space then python
>>
>>54069214
No luck calling "./home/pi/PythonScrips/UpdateDB.py", "./UpdateDB.py", "python ./home/pi/PythonScrips/UpdateDB.py" or "python ./UpdateDB.py" with either "#!whereis python", "!whereis python", "whereis python", "#!/usr/bin/env python" or "#! /usr/bin/python".
>>
File: 20160410_104201.png (72 KB, 233x289) Image search: [Google]
20160410_104201.png
72 KB, 233x289
>>54069095
OMG I SHOULD HAVE GUESSED!!! No seriously how did I not decipher that?>>54069179
The rule for finding a shell command is:
- just a word without slash: look it up in /usr/bin and such (all of $PATH) ;
Starts with a slash or contains a slash: it's a filename already, so the usual rules apply: / at the beginning means the root, ./file is somewhere in the current directory, .. is the parent of the current directory if nothing comes before, but ../../a is "a" in the parent of the parent of the working directory.dot and dot-dot can appear anywhere in a path, but most of the time it's useless. Finally: a/b refers to b inside a inside the working directory, in which case it's just as good as ./a/b at the shell. Really the most important discriminating character when examining commands is the slash, not the dot.

Some anons here can be real twats.
>>
>>54069324
>"#!whereis python", "!whereis python", "whereis python"
jesus mate
>>
>>54066467
Starting learning python through codecademy last week. Finished the course and make a project that scraped a forum I post on for a user's post history. Then uses that to generate markov chains and tweet them
>>
>>54069324
whereis is a command, anon suggested looking at the results of executing it. Really you just proved yourself inept and lacking the most basic clear understanding of what you are doing.
>inb4 immersion
Learning by immersion is a meme if you can't google properly.
>>
>>54069324
>./home
That assumes you have /home/pi in your current working directory lol.
>>
>>54069341
Makes sense. Is it safe to assume php is executing the command from it's location in "/var/www/html"? It won't take too long to work it out through trial and error if it's not.
>>54069375
I think >>54069388 covers it pretty well. I basically know fuck all about the os past the bare minimum of what I need for it to work.
>>
does this line of code seem intentionally obscured?

int readfromclient(Client *c) {
char *startptr = &c->buf[c->curpos];
//rest of code
}


why would you call &c then dereference its member? Does that even work? buf is a char array btw.
>>
>>54069526
you dereference the char at the array position
>>
Sorry to barge in.

I'm a C++ dev and I'm just considering learning a server-side scripting language like PHP. Now PHP gets a lot of shit and I haven't really figured out why. But I'm considering ruby with ruby on rails because of it.

Are these a good idea or should I just find a C++ web-framework? Because sites like Facebook decided on C++ and have appreciated that I think maybe knowing webdev (well I don't even know what role PHP has in web. Need to know that too) as a C++ programmer would be a good idea.

What's the best path to follow here?
>>
>>54069526
The & is taking the address of the char in the buffer, not taking the address of c.

The right-hand side of the assignment is equivalent to c->buf + c->curpos
>>
>>54069488
Maybe. If you want to know, just extract the result of http://php.net/manual/en/function.getcwd.php however you can and be done with it. You should probably refer /home/pi/Scripts from the root tho, it's clearer and it doesn't change anything. Also the working directory is inherited by child processes, that is, your python scripts's working directory will also be /var/www or whatever, even tho the code is at /home/...
>>
>>54069605
>PHP
>RoR
What is this, 2005?
>>
File: spooccy.png (22 KB, 301x340) Image search: [Google]
spooccy.png
22 KB, 301x340
>>54066467
>What are you working on, /g/?
A Speccy "clone" for Arch.

Parsing strings suck. I hope command line utils start supporting machine-readable output in the near term.
>>
>>54069630
Cool, I'll mess around with it and work it out. Thanks for the help anon.
>>
>>54069526
>
&c->

Should be
c.
I think.
c->curpos

Ok so curpos is a pointer to an int (presumably). That's fine.
so
c.buf[c->curpos];

Seems to make more sense to me. But it's hard to tell without knowing more. Taking the address to the c pointer just to use the arrow seems more like the programmer doesn't want to use '.'.
>>
>>54069560
>>54069624
ah, I thought the & would dereference c first not c->buf. what's the precedence for that operator?
>>
>>54069666
You're wrong satan.

>>54069680
http://en.cppreference.com/w/c/language/operator_precedence

& has the least priority of the three used operators.
>>
>>54069666
Nevermind. I see my error.
>>54069560
>>54069624
Are correct.
>>
>>54069639
By "start supporting machine-readable output" I mean start using FreeBSD's libxo

https://juniper.github.io/libxo/libxo-manual.html
https://wiki.freebsd.org/LibXo
https://github.com/Juniper/libxo

Also, I hope OpenBSD's pledge() makes it's way into Linux somehow. Having to implement IPC just so you minimize the attack surface sucks.
>>
So I'm going through the C# Player's Guide. I got some help from y'all last night about the heap vs. the stack and now I've got a question about the 'Internal' access modifier.

If you have a class set to Public and a class method set to Internal is the method only usable within the assembly/project even though the class is available everywhere?
>>
File: 1449012854445.gif (811 KB, 480x320) Image search: [Google]
1449012854445.gif
811 KB, 480x320
kinda stupid question but is there some place where I can get a free short domain that is not tk/freenom?
>>
>>54069795
I was recommended this in sqt when I was asking a similar question.
https://www.dynu.com/en-US/
Didn't get my email verification email though. Pretty frustrating.
>>
>>54069795
>he can't afford to spend $5-10 on a domain
>>
>>54069821
isn't that for hosting shit locallly?
>>
>>54069849
Well its for hosting anything on a machine you have access to as I understand it.
But looking closely you get options between .dynu.com, .dynu.net and .freeddns.org
Not exactly sure what your goal is here.

If you're looking to make something people should visit then buy a name.
>>
File: 1393123404186.png (39 KB, 499x404) Image search: [Google]
1393123404186.png
39 KB, 499x404
Fuck all your discussions

Post your programming font
>>
Common Lisp or Scheme? Why?
>>
>>54069955
Racket.
>>
File: font.png (2 KB, 236x88) Image search: [Google]
font.png
2 KB, 236x88
>>54069943
Consolas.
>>
>>54069943
Inconsolata
>>
>>54070032
yeah me too

any other good fonts out there?
that's actually what I'm interested in
>>
Where can i start learning python to make addons or app involves requests from websites?
>>
>>54070091
learn python anywhere
get the requests library
profit
>>
>>54069955
Scheme because I learnt scheme
hehe
no, a few reasons
1. is small
2. MIT used it
3. sicp
4. has a cooler name than common LIShP
>>
>>54069943
consolas 10
>>
>>54069943
comic sans 12
>>
>>54069943
gohufont
http://font.gohu.org/
>>
File: BudapestQT.webm (3 MB, 1370x1038) Image search: [Google]
BudapestQT.webm
3 MB, 1370x1038
INTRO TO JAVA QUESTION:

I have to edit this code snippet:

 
public void frontDoor() {
JOptionPane.showMessageDialog(null, "You are now at the front door.");

String ans = JOptionPane.showInputDialog(null, "Would you like to walk into the \"living room\", \"dining room\", or up the \"stairs\"?");

switch (ans) {
case "living room":
livingRoom();
break;
case "dining room":
diningRoom();
break;
case "stairs":
upStairs();
break;
default:
JOptionPane.showMessageDialog(null, "Sorry, that is not an option.");
frontDoor();
break;
}
}


into a do-while loop (to the most that you can) while adding an option for the person to leave the house, EXCEPT the first time.

I've tried a few different things, but I just can't figure it out. I was thinking of using a boolean canExit = false, and then once the user picks a room it turns true and then the next time they're at the front door they have the option to exit/leave the house. The thing is that a do-while loop won't check the boolean till after doing it once and then i feel like theres no point to the "while" part of the do-while if I'm using a switch that breaks. Man, I don't know
>>
File: Source Code Pro.png (2 KB, 238x103) Image search: [Google]
Source Code Pro.png
2 KB, 238x103
>>54070066
Source Code Pro is pretty OK too. But hardly much different.

Anything monospaced is good enough really..
>>
>>54070291
post the rest
upStairs(), diningRoom() and livingRoom() are missing
what's in these functions? any special rules?
>>
>>54069605
You have a lot of options for the backend, and most of them suck (eg: PHP, Ruby, Node.js).

>Now PHP gets a lot of shit and I haven't really figured out why.
It is simply not a good language. Google "php a fractal of bad design" to learn more.

>I don't even know what role PHP has in web
Backend systems handle business logic and make things happen. They can interact with your database and do things like render a HTML response or return JSON encoded data. This lets you make a blog, forums, or whatever kind of dynamic data-driven web service you want.

>...should I just find a C++ web-framework?
No.

Try Golang. You can learn the entirety of the language in a couple of days, and it will be familiar to your C++ eyes.

Look at Haskell if you want a challenge. Yesod looks powerful and majestic.
>>
>>54070372
just a bunch of if-else statements, soon to be while/for loops once i get to them. But it just asks the user simple questions like if they want to explore an item or go into another room, which would be another method of similar questions. If they make their way back to the frontdoor they should be able to exit once i figure this out.
>>
>>54070291
Use a counter and a flag.

int loopCount =0;
boolean flag=true;
do{
/*Switchcase
*/
if(loopCount++>0 && theExitRoomOptionWasSelected){
flag=false;
}
}while(flag)


Or just loopCount++&&theExitRoomOption..
>>
>>54070413
you can use a local variable instead of a global variable if you just "return;" in the other functions when you type "front door" instead of jumping in a new instance of "frontDoor()"
>>
File: sd.jpg (42 KB, 600x476) Image search: [Google]
sd.jpg
42 KB, 600x476
It's perfectly safe to mess with the mains using relays, right?
>>
>>54069095
>If you place '#! /usr/bin/python' or whatever at the top of your .py file
Bloats up the file.
>>
>>54070487
not this meme
>>
>>54070487
i'll bloat your mom's vagina with my cock
>>
File: 1460820803127.jpg (174 KB, 629x875) Image search: [Google]
1460820803127.jpg
174 KB, 629x875
sup /dpt/,
a little question from a programmer noob.
got this code here
int kalk(int a,int b,char mod){
int erg=a;
char kon;
while(1){
if(mod==0x2B){erg=erg+b;}
if(mod==0x2D){erg=erg-b;}
if(mod==0x2A){erg=erg*b;}
if(mod==0x2F){erg=erg/b;}
cout<<"= "<<erg;
cin>>kon;
if(kon==0x2B || kon==0x2D || kon==0x2F || kon==0x2A){
mod=kon;
cin>>b;
}else{break;}
}
}


Now if you look at the picture, this is what happens when i exit the while-loop ( not typing one of the values from the if clause to kon )

Could someone explain me why?
>>
Is there a C equivalent of the C++ Boost library?
I need to do multi platform File I/O.
>>
>>54070509
Indent your code, use descriptive variable names.
>>
>>54070509
ups, wrong picture
>>
>>54070479
I hope so, but given I'm the php exec sudo guy I'm probably going to kill myself fucking with it.
>>
>>54070509
nice picture fag
>>
File: 1460828886619.png (269 KB, 600x476) Image search: [Google]
1460828886619.png
269 KB, 600x476
>>54070479
Yes.
>>
>>54070537
Just use C++. No one but kernel and driver developers use C anymore.
>>
>>54070537
glib
>>
File: prettyGirl.png (300 KB, 629x875) Image search: [Google]
prettyGirl.png
300 KB, 629x875
>>54070509
How is anyone even supposed to know what this is supposed to do?
>>
>>54066467
How the fuck is this a "programming" thread? These fucking pagans always brag about languages and they haven't or didn't(some of you are already dead) wrote a single fucking line of code.

Also if anywho finds this fucking thread in this godblessed eternal hell thread will adress us as autistic weeaboos.

Just ban anime images mods pls.
>>
>>54070509
I guess you're doing
cout << b
outside of the kalk function right? Add an ampersand to
int& b
and it should work. Then get someone to explain it to you.
>>
>>54069955
>Common Lisp or Scheme?
Scheme
>Why?
It's the official extension language of GNU.
>>
File: C++.png (139 KB, 593x1189) Image search: [Google]
C++.png
139 KB, 593x1189
>>54066587
>>54066599
>>54066605
>>
>>54070661
Whats not clear about it?
First time posting in /dpt/, so iam sorry.

Calling function with 3 parameters:
number 1
operator (+-*/)
number 2

then in the while loop i just calculate the numbers based on the operator, print the result and write something in con.
if con ist one of the values (+-*/), it keeps going with a new number2 and the new operator typed in con. otherwise it breaks.

and this is what happens when i abort the function
>>54070549
>>
>>54066483
https://en.wikipedia.org/wiki/Vulkan_(API)
This?

Any interesting resources?
>>
File: gnu+bola.png (444 KB, 1489x2048) Image search: [Google]
gnu+bola.png
444 KB, 1489x2048
>>54070712
You mentionned it brother! GNU shall bless you with software all over. STAY STRAIGHT on the path to computer heaven.
>>
>>54070706
this is how i call the function.
renamed the values
a is num1
b is num2
mod is op
>>
>>54070808
>triple indirection
Why would I want to be a 3-star programmer
>>
>>54070734
The 6297024 part is your problem right? IT HAPPENS IN YOUR CODE OUTSIDE OF kalk MORON!!! Consider your I/O operations and find on what line this uninitialised value gets printed. Because:
int n; // no initial value, just a declaration
cout << n; // outputs a randomly generated garbage number... or not! It's totally unspecified.
>>
File: 1459698725402.png (1 MB, 1357x1281) Image search: [Google]
1459698725402.png
1 MB, 1357x1281
>>54070795
aah figured it out. it was the funtion call that lead to the problem. removed the cout infront of it and now it works.
>>
>https://www.youtube.com/watch?v=h_3wjNvu6NM
>not gamma correcting your web app shit gaym
>2016
>>>54067203
>>
>>54070808
Keep overflowing the stack, Hime!
>>
>>54070864
She's still doing string concatenation above that. Better than some of the newbies in this thread.
>>
>>54070795
>renamed the values
Incorrect. These are other variables with the same value at one point in time, which could just as easily have the same name since it's not the same context.
>a is num1
>b is num2
>mod is op
Easily inferred from the call to kalk, see?
>>
File: 1460830238025.png (745 KB, 593x2130) Image search: [Google]
1460830238025.png
745 KB, 593x2130
>>54070734
Right. What confused me was that you were using hex and not stuff like
if(kon=='+' || kon=='-' || kon=='/' || kon=='*'){

Which imo is way clearer.

But I'm not seeing exactly what's going on in your picture though.
>>54070864
>pic
Atleast do a tree.

Someone should guide her a bit for these pictures. Come on.
>>
>>54070451
thanks, i adjusted this a little, but its working great
>>
>>54070922
are you serious
>>
How would I read input into a char pointer using C++?
>>
>>54071162
http://www.cplusplus.com/reference/cstdio/scanf/
>>
>>54071201
If the char pointer is initialized to nullptr can I read input into it or does it need to be initialized to something else?
>>
>>54071232
if it's not const what's your question exactly?
>>
>>54071232
You need a pointer to memory to put the input.
Use malloc or new.
Alternatively take a static array you have somewhere.
>>
>>54071162
>>54071232
G O O G L E
O
O
G
L
E
>>
>>54071245
>>54071275
>if it's not const what's your question exactly?
If I initially set it to nullptr I get an error when I try to read input into it with cin. If I initially set it to "malloc(sizeof(char) * SIZE" I get an error about "cannot convert void * to char *". And if I set it to a string literal or something I won't be able to modify it later.

So I'm not sure how to read input into it.
>>
>>54071369
Add a cast to char*
arr=(char*)malloc(someNumber);
>>
File: YbhzSDf.webm (1 MB, 720x404) Image search: [Google]
YbhzSDf.webm
1 MB, 720x404
Ask your much beloved programming literate anything (IAMA)

>>54069943
https://github.com/chrissimpkins/codeface

>>54069955
Racket because libs, static typing, pattern matching, structures, good documentation, dr racket, ...

>>54070712
>It's the official extension language of GNU.
The official desktop environment of GNU, GNOME, favored javascript over gnu guile.

>>54067374
Unreal engine and unity have both a html5 backend.

>>54070730
He starts by saying that c++ is a horrible language but then attacks some libraries (STL, Boost), not the language.

"""
- inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app.
"""

Funny because he did the same with linux.


>>54071162
cin.get(ptr, maxsize);

http://ideone.com/gxCMEm

>>54071369
char *ptr = new char[SIZE];
>>
>>54071460
why haven't you killed yourself yet?
>>
>>54066611
That's why HURD is better than Linux.
>>
>>54070808
Go away hime! i don't want to manage my own memory!
>>
>>54071598
kill yourself and stop samefagging fucking fag
>>
What are binary trees for, exactly?
I wanna try implementing one without taking the easy way out and copying the psuedocode on wikipedia.
>>
>>54071613
He's not samefagging. That was my post.
>>
>>54071598
>i don't want to manage my own memory!
Why not?
Just make a pool of memory and grab from it.
Way better than GC. Not at all hard to do.
>>
>>54071396
>casting your malloc
not this meme again
>>
File: hIIM6TS.jpg (42 KB, 720x960) Image search: [Google]
hIIM6TS.jpg
42 KB, 720x960
>>54071517
Please, don't bully.

>>54071616
google binary search three
>>
File: CompleteBinaryTree_1000.gif (7 KB, 412x249) Image search: [Google]
CompleteBinaryTree_1000.gif
7 KB, 412x249
>>54071616
This is a binary tree.
Every dot is a node. Every line is a pointer.
The value is the numbers.

The point of a binary tree is to have a sorted system where you have o(n) search time worst case. And o(log(n)) on average.

Note that the tree has bigger values on the right of the tree and smaller values on the left.
>>
>>54066613
I'm calling you out on posting the same shitty post twice. Don't fucking repost word for word because the old thread died, that's autistic as shit.
>>
>>54071663
Why is that a meme?
>>
    pub fn new(boot_rom: &[u8]) -> Self {
let mut ret = GB {
boot_rom: [0; 256],
...<fields ommitted>...
};
ret.boot_rom.clone_from_slice(&boot_rom);
ret
}


is there a more idiomatic way to initialize this?
>>
>>54071790
Because of completely irrelevant reasons that don't matter in the slightest.
Second answer gives you a more sane reason for casting. First mentions the very slight issues
http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc
>>
>his language of choice allows implicit casting from void*
disgusting
>>
>>54067241
>I have horrid memory, what is this again?

My other meme-lang. The one that looks like MIPS.

>I'm assuming FAA refers to the aviation company?

Government agency, but yes.
>>
File: inserttaa_kuvan_punchline_tahan.png (167 KB, 455x893) Image search: [Google]
inserttaa_kuvan_punchline_tahan.png
167 KB, 455x893
I'm learning python.


hahahahahhhahahaahahhahahaahahahahhh
>>
>>54070053
>>54070214
>>54070391
>>54070514
>>54070605
web fags confirmed for literal faggots
>>
>>54071973
/care
>>
>>54066587
If it's not for embedded system then its for...

fun

christ don't you people ever do things for shits and giggles or is it all work and no play with you pajeets. Same with assembly, no point in it but it's /cool/.
>>
>>54071973
>learning python
Done yet?
>>
>>54068253
i'm interested
>>
I remember asking this awhile back but I don't think I ever got a clear answer
I'm doing Project Euler and for tidiness I'm keeping it in a single solution file (Writing in C#), and each problem is it's own class with a single method Run()
They are all public static void so I don't have to create a new object every time I want to test run a problem.

Is there a way to programmatically run any given one of those Run() methods within a class, that doesn't involve manually writing out a gigantic switch case (or dictionary, or whatever) to point to every classes Run() method?
something like
int Choice = Console.ReadLine();
Object.Select(p => p.contains(Choice)).Run();

That's obviously pseudo garbage code, but you get the idea?
>>
File: sarvakuja.jpg (62 KB, 700x1000) Image search: [Google]
sarvakuja.jpg
62 KB, 700x1000
>>54072021
Thisäs is funyn Fishnush mene
>>
>>54072054
swap from using classes to using loose functions, put the functions themselves in an array
>>
>>54072020
It's not just pajeets.
Most people who go into CS only see it as a means to an end for making money
These are the same people who throw a shit fit when they find out a portfolio is pretty much REQUIRED and then they complain about "being expected to like programming so much that you do it for free in your free time", I've lost count of how often I've seen this sentiment.
>>
>>54072054
I think you need reflection.

Perhaps something like

Assembly.GetExecutingAssembly().GetTypes().Where(type => type.Name.Equals("Problem_" + choice).First().GetMethod("Run").Invoke(new object[0]);


Working from memory there but it would be something like that.
>>
>>54072070
Hers'es tarnsalate

>where helps?
<I ate poop
>>
>>54072083
Not all of the problems are solved within a single method though. A lot of them have a few private methods for the specific problem.

>>54072098
I think that's exactly what I need to do, I totally forgot that was a thing.
>>
>>54072128
so have them be loose too
can you store static member functions in C#?
in C++ you'd do &class::run

>>54072098
jesus christ no
fuck off oop
>>
>>54072096
>These are the same people who throw a shit fit when they find out a portfolio is pretty much REQUIRED and then they complain about "being expected to like programming so much that you do it for free in your free time", I've lost count of how often I've seen this sentiment.

I've started noticing those sentiments from some people now that I'm finishing up my 3rd year. Many of them can't even program for shit when an assignment doesn't spoonfeed the general structure.
>>
>>54072020
please stop this "use shit langs for fun" meme
>>
>>54072277
I code for free in my free time, but nobody ask me a portfolio. It's stupid.
>>
>>54066587
Related
I've been learning PHP (and everything else) from the O'Reilly web dev book as I plan to work on building a framework (as a project). Aside from retaining that knowledge afterwards to update the project when it's necessary, what I'll want to focus on afterwards is building signal processing plugins/software.
The resource/s I'm using has been pretty good so far in regards to introducing me to basic programming concepts, control flow and how the syntax works etc. but would C++ be my best choice in working in DSP (in addition to Pure Data/MATLAB or whatever else I'll need to learn), and if so, would it be best for me to learn C first? Seems to me like the 'teaching bad practices' argument only applies if you can't structure your code properly in the first place.
>>
How shit is my personal website? I redesigned a bit of it recently to make it look better. Did it work?

http://anthony.noided.media/
>>
>>54072598
They way your GPG key expands is all fucked up
>>
writing a genetic algorithm to come up with a good mancala score heuristic
bullshit and novel but fun
>>
>>54072598
>3 blogs
>>
Started learning to program in Java. Found out I really enjoy reading about algorithms but learning all the rules and syntax is a bit of a bore. Is there a good way to learn the latter without having to rely on textbooks?
>>
>>54072369
tl;dr C before C++?
>>
>>54072598
get a better photo. website looks ok, a bit shitty which would be ok for a programmer, but since you're a web dev you should work on it more.
>>
>>54072782
no, go straight into C++
>>
>>54072911
>>54072782
lmao C++ is a shitter language.
Just go with python
>>
>>54072745
Fixed.

>>54072652
I made the animation slower, does that make it better?

>>54072813
I'm not a very good designer, which is why it looks bad. I'm gradually trying to make it better. I just improved how shitty the blog post list was. It's still not perfect, but I think I'm improving.
>>
File: gpg.png (179 KB, 1920x959) Image search: [Google]
gpg.png
179 KB, 1920x959
>>54072973
Here's what it looks like on my screen when I expand it.
>>
>>54072996
What the fuck

What browser are you currently using?
>>
>>54073023
Chome Version 49.0.2623.112 m although getting this number has triggered an update, I'll let you know if it fixes it.
>>
>>54073023
>>54073053
Nope still present on Version 50.0.2661.75 m (Up to date)
>>
>>54072335
Good. If anyone asks about your personal projects you tell them to frick off. It sets a bad precedence in the industry where employers implicitly expect you to be a good goy and produce free labor for them.
>>
When using your git to showcase your projects for jobs should you delete the simpler things?
>>
>>54072996
same thing happens to me on google chrome, it's fine if i have a super big vertical resolution, the problem is that the text box doesn't adjust when it doesn't fit the screen
>>
>>54073072
You can tell them what you do in free time, but if you publish nothing you can't show them something.
>>
>>54073104
show off your left-pad with pride
>>
>>54073053
>>54073071
Huh. For some reason setting height to 100% is causing it to fill up the entire height of the screen, which is weird.


Should be fixed now.
>>
>>54073199
Much better now
>>
>>54073113

You don't need to contribute to free software communism, though. You could have a private portfolio.
>>
for (i=0; (c=getchar()) != EOF; i++)


How would one do the equivalent for-loop of this in C++ using cin? I keep getting stuff like "binary !=: no operator found which takes a left-hand operand of type "std::basic_istream..." and so on.

Basically why can't I evaluate (cin >> variable) as true or false and then compare it to EOF?
>>
>>54073232
Today free software ain't communism.
>>
>>54073243
I mean why can't I use cin to assign a value to something, and then compare the value of that in a true false statement. In C you can just do "(c=getchar()) != EOF" or something like that.
>>
>>54073072
>>54072335
for any job (programming or otherwise) you should tell them what you've worked on in the past. you could show them software you've worked on without giving out the source code. and if it's just something small you can show the source code, the crap you shat out in a couple of weekends isn't worth much anyway.
Thread replies: 255
Thread images: 53

banner
banner
[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 / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.