[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: 45
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>54244786

What are you working on /g/?
>>
>>54253840
thank you for not using a fag image
>>
File: solution.png (14 KB, 851x330) Image search: [Google]
solution.png
14 KB, 851x330
>>
second for php is objectively the best language ever
>>
What should I call an object to be drawn to the screen?

Also is there a resource to name things in game engines? I have no idea what to call things and its driving me crazy.
>>
>>54253891
True that
>>
>>54253907
wrong trip
>>
>>54253897
Off you go
>>>/v/
>
>
/
v
/
>>
>>54253923
Are you stupid?
>>
>>54253897
Sprite
>>
>>54253897
ObjectToBeDrawnToScreen

Just use lots of words. The more words the better.

t. Senior Java Engineer
>>
>>54253897
it depends on how your game engine is laid out

maybe you want a namespace like Draw::fag and Draw::cuck etc
>>
How many of you have actually read SCIP?
Would you recommend it to anyone?
>>
I'll just leave this here.
http://forum.dlang.org/post/[email protected]

>>54253969
Yes, to beginners. People who copy-paste Stackoverflow need not apply.
>>
File: 1231231231.jpg (2 KB, 125x92) Image search: [Google]
1231231231.jpg
2 KB, 125x92
>>54253999
>garbage collection for video processing app
>>
Wich one is better language for low level programming to beginner who can only program in python. C or C++?
>>
Lets all program a Captcha Solver in C together. Lets collab guys
>>
>>54254041
Hands down, C.
>>
>>54254054
Which kind of captcha?
>>
>>54254038
>being incapable of reading comprehension
>>
File: ve2d-filters.jpg (206 KB, 1304x768) Image search: [Google]
ve2d-filters.jpg
206 KB, 1304x768
>>54253999
Wow, this is some ugly-ass GUI, they managed to fuck up fonts on Windows app.
>>
>>54254071
The one that solves the picture ones or text ones I am okay with either one
>>
>>54254121
>fonts on a rescaled image look blurry
No fucking shit, Sherlock!
>>
>>54254138
>rescaled
how do you know?
>>
desu I feel like scope/pass by reference/pass by address/pass by value are seriously not focused on enough

I struggle with this shit all the time and I don't think we ever went over it in any of the classes I took
>>
>>54254121
>windows fonts
>ever looking good
lol
>>
File: ve2e-save.jpg (198 KB, 1304x768) Image search: [Google]
ve2e-save.jpg
198 KB, 1304x768
>>54254138
The one in the title looks fine, and the images are not rescaled.
>>
>>54254138
Looks like an alt+prtscn, not a resize.
>>
>>54253832
>default value in an initialiser list
What do you mean by that? Are you trying to initialize a class member in a constructor or doing list initialization with braced init list?
>>
>>54254176
they literally look better than anything else
>>
>>54254332
lol
>>
>>54254332
>I have never seen any other font rendering
Jesus christ, you can't be serious.
>>
>>54254176
For the last 10 years I spend hours after each reinstall to make fonts in my linux look like Windows fonts.
>>
>>54254372
Do you use Arch?
>>
>>54254372
cuckOS
>>
>>54254372
>Install infinality
>Done
Wow, so hard.
>>
>>54254372
Hours? Infi takes like 2 minutes to install and the defaults blow Windows out of the water.
>>
>>54253897
>What should I call an object to be drawn to the screen?
Drawable

>Also is there a resource to name things in game engines?
Noe

>I have no idea what to call things and its driving me crazy
welcome to programming
>>
>>54254386
As a matter of fact I do.
>>54254390
>>54254393
Yeah, it easier now than it was 5 years ago, nowadays I don't have to recompile FreeType2 with AA. Still, I have to fix some xmls to get the look I like.
>>
>>54254353
i literally have, there have been threads on /g/ about it, you loonix and mac fags are fucking delusional
>>
Wow, I knew having a client & server communicate on localhost, but this is instantaneous. No delay at all!

Now to simulate packet loss so I don't get bitch slapped again...
>>
>>54254589
You need to get your fucking eyes checked.
>>
>>54254617
>huhuh muh vintage 80s pixelated font *sips frap*
kys
>>
>>54254589
>>54254637
Oh look, the guy who keeps "trolling" in the dpt is back in this thread again.
>>
>>54254673
show your gentoo masterrace font rendering pls
>>
>>54254102
you're saying that he can read
>>
I have a UDP server architecture that in C++ that is running pretty solid, except for when a client joins the server, it sometimes crashes.

This is obviously a thread double access problem, one thread tries to add a player to a vector, other tries to read it at the same time and poof.

To any C++ experts, is it a good idea to make an array of atomic object pointers with a fixed size like 32? So when I add a player, it checks for the next NULL in the array of atomics and assigns it a pointer to a new player and the reader reads until it reaches a NULL pointer or the last object?
>>
>>54255056
Just use a mutex.
>>
>>54255056
It'll work, but lockless data structures are error prone and hard to reason about, just use mutexes.
>>
>>54255086
this
>>
>>54255151
>lockless data structures
do they even work at all (on ARM as well)? like there was an example of a lockless ring buffer for native android audio but it was a shitter tutorial and it wasn't thread safe
>>
>>54255170
>Do they work at all
If designed properly, yes.
>>
>>54255086
Also make sure to use std::lock_guard so that you don't end up with a deadlock in case of an exception.

Something along these lines would work:
void Server::onClientConnected(Socket *socket)
{
std::lock_guard<decltype(this->mutex)> guard{this->mutex};

Client *client = new Client(socket);
this->clients.push_back(client);
}

Client *Server::getClient(u32 id) const
{
std::lock_guard<decltype(this->mutex)> guard{this->mutex};

auto it = std::find_if(std::begin(this->clients), std::end(this->clients), [&id](Client *client) {
return client->id == id;
});

if (it == this->clients.end()) {
// log failure
return nullptr;
}

return *it;
}
>>
>>54255056

This is a well known problem in concurrency and solutions already exist. Please consider the following literature:

https://en.wikipedia.org/wiki/Readers%E2%80%93writers_problem
>>
>>54255170
Yes they do, they just hard to design properly, see http://www.1024cores.net/ for lots of articles.
>>
File: ohYou.jpg (157 KB, 735x881) Image search: [Google]
ohYou.jpg
157 KB, 735x881
I have a file named kek.db on my pc and another file kek.db on webserver, I tought that it is good idea to use
content-md5 header

to check md5 file on server and if it is different than md5sum of my file on pc then I assume that file on server is newer and I download it, it looks like content-md5 is deprecated.

My only solution is .txt file on webserver with current md5 or is there a more aesthetic way?
>>
>>54255205
but how the fuck, is there a construct in C++ that guarantees that threads see all the most recent writes to a data structure without using locks?
>>
>>54255236
>http://www.1024cores.net/home/lock-free-algorithms/introduction
>Lock-freedom means that a system as a whole moves forward regardless of anything. Forward progress for each individual thread is not guaranteed (that is, individual threads can starve). It's a weaker guarantee than wait-freedom. Lockfree algorithms usually use atomic_compare_exchange primitive (InterlockedCompareExchange, __sync_val_compare_and_swap).
that's still a lock, it's a spinlock
>>
>>54255254
Yes there are constructs, and they aren't specific to C++. And basically "lockless" is a misnomer. They rely upon locks, they just make locks on hold on constant time operations. If you think about it holding a lock over an O(n) operation is pretty stupid.

And atomic operations rely upon hardware locks so fuck off all you faggots who are going to try to contradict me.
>>
>>54255308
>As can be seen, a thread can "whirl" in the cycle theoretically infinitely. But every repeat of the cycle means that some other thread had made forward progress (that is, successfully pushed a node to the stack).
ok maybe it has some use in some situations
>>
>>54255086
>>54255151
>>54255208
Thanks. I've been trying to not use mutexes for a while but I guess it's better than some insecure hackery way.

Also
>>54255208
This seems pretty elegant, but I'll try to hold off from the id and std::find_if method.
Too bad std::mutex isn't portable so I'll have to resort to boost mutex.
>>
File: stack-graph-1.png (29 KB, 652x404) Image search: [Google]
stack-graph-1.png
29 KB, 652x404
>>54255308
> that's still a lock, it's a spinlock
Locking on traditional mutex results in process being stopped by kernel and placed in a wait-queue of the mutex, just like IO blocking. Spinlocking is better in most cases perfomace-wise, but it wasteful resources-wise. "Lockless" actually means "without locking by kernel", not "without any kind of locks".
>>54255324
> ok maybe it has some use in some situations
No shit, Sherlock.
>>
>>54255324
Also mutexes in Linux actually try to spinlock for a while before they give up and block the process for real, all that to minimize context switches.
>>
>>54255422
>that graph
it's fucking nothing
>>
File: 1453034925764.png (377 KB, 498x497) Image search: [Google]
1453034925764.png
377 KB, 498x497
>>54255402
Switching from std::thread to boost.
>include boost/thread.hpp header
>compile time increases like 3x
>>
>>54255402
>Too bad std::mutex isn't portable so I'll have to resort to boost mutex.
Why do you think that?
>>
>>54255487
shig

>>54255402
use pthread it's on every language version and platform and std::mutex is just a wrapper for pthread mutex
>>
File: 1453542938321.png (378 KB, 1450x1080) Image search: [Google]
1453542938321.png
378 KB, 1450x1080
Came to roll.
>>
>>54255503
It isn't. Shit I might have misread something.

>>54255512
pthread is a pain in the ass. The wrappers have made it much more easier to program threads for me. Besides, pthread doesn't work on Windows, I want my code to be portable.
>>
File: lockfreevsblocking_threads.jpg (31 KB, 619x386) Image search: [Google]
lockfreevsblocking_threads.jpg
31 KB, 619x386
>>54255484
Well, it depends on the task at hand and the number of threads you work with.
>>
>>54255548
there's cygwin and also this thing might work

https://technet.microsoft.com/en-us/library/bb463209.aspx

std::thread didn't compile for me regardless of the version so i just said fuck it and used pthread instead it's easy as fuck to use anyway
>>
>>54255566
a 2x speedup in the best case isn't much to cheer for
>>
>>54255589
>std::thread didn't compile for me
Uh, why wouldn't it compile? Did you remember to link to pass the -pthread option?
>>
>>54255609
>-pthread option
wtf that's retarded and no one in /dpt/ told me about it and it's not on cppreference either look

http://en.cppreference.com/w/cpp/thread/thread
>>
>>54255639
Yeah you have to pass that option because it uses pthread internally.

http://stackoverflow.com/questions/8649828/what-is-the-correct-link-options-to-use-stdthread-in-gcc-under-linux
>>
>>54255652
>pthread linker on windows
What?
>>
>>54255548
>pthread is a pain in the ass. The wrappers have made it much more easier to program threads for me. Besides, pthread doesn't work on Windows, I want my code to be portable.
MinGW comes with winlibpthread on Windows which is automatically linked when building a program that include <thread> or <mutex> headers.
>>
>>54255652
ok then that's good to know for future reference

also what is this lmao
http://programmers.stackexchange.com/questions/195639/is-gcc-dying-without-threads-support-on-windows
>I understood that GCC is falling out of favour because the people maintaining it have become somewhat arrogant, and now that LLVM is here (and is very good) people are voting with the feet.
"somewhat arrogant" is an understatement
>>
>>54255668
Well, if you're considering pthreads as an alternative I assumed you were on a Unix machine, or at least using Cygywin.
>>
>>54255521
Roll
>>
>>54255683
i don't use cygwin but i do use mingw and i haven't tried compiling to a windows target but it should be possible to get it to work one or another
>>
>>54255673
Also, for instance, this code:
#include <thread>
#include <mutex>
#include <iostream>
#include <vector>

static std::mutex g_mutex;
static constexpr unsigned int g_num = 100;

static void synced_print()
{
std::lock_guard<std::mutex> guard{g_mutex};
std::cout << "Hello world!" << std::endl;
}

int main(int, const char **)
{
std::vector<std::thread> threads{};
threads.reserve(g_num);

for (unsigned int i = 0; i < g_num; ++i)
threads.push_back(std::thread(&synced_print));

for (auto &thread: threads)
{
if (thread.joinable())
thread.join();
}

return 0;
}


Compiled with:
{lamb} g++ -std=c++14 -othreading threading.cpp


Results in:
{lamb} ldd threading.exe
(...)
libwinpthread-1.dll => /c/Program Files (x86)/mingw-w64/i686-4.9.2-posix-sjlj-rt_v4-rev2/mingw32/bin/libwinpthread-1.dll (0x64940000)
(...)


So you will only need the -pthread linker option on Linux, which shouldn't be an issue with any build system.
>>
>>54255521
>>54255686
stop this
https://dpt-roll.github.io/
https://better-dpt-roll.github.io/
>>
>>54255703
So std::mutex and std::thread are portable. Thank fuck.
>>
>>54255170
Easiest on x86 (and depending on CPU and/or system bad code can "just werk" by pure circumstance), harder on ARM and you may lose a good chunk of performance versus locks compared to x86, and basically impossible on Alpha.
>>
I‘m rewriting a python cli tool that searches for and torrents anime from when I was absolutely new to programming
>>
>>54255759
Not as portable as just using Java :^)
>>
Any db wizards on here? I'm making a link shortener using postgres and I'd like to count how many times each link gets accessed.

Should I just do an UPDATE or is there some way to automatically increment a value every time the row is accessed? Sorry if that's a dumb question, this is my first time doing anything with SQL.
>>
>>54255967
yes
>>
>>54256002
Very helpful, thanks :^)
>>
I am 65% through codeacademy python

First timer, only coded with pyramid a decade ago
>>
File: Frame2.png (44 KB, 900x346) Image search: [Google]
Frame2.png
44 KB, 900x346
Anyone ever designed their own network frames in Java? My idea was to create a bytearray to contain all of those different specifications, & wrap it in a UDP packet & send it on its' way.

I'm just going to import the CRC-32 checksum. But can I really put all these different types into one bytearray?
>>
>>54256054
>pyramid
I meant pascal
>>
>>54256054
>python
>codeacademy
drake.jpg
>>
>>54256132
No bullying
>>
>>54256062
>no struct in Java
Oh, how I pity you. Enjoy coding your byte array<->network frame class conversion methods.
>>
>>54256155
i'm genuinely trying to help you when i say that python and also codecademy are fucking shit and especially shit for learning programming
>>
>>54256171
Really? Can you go into that? I'm almost done anyways, so I'd like to explore more. My friends with cs degrees tell me I should move up to a big boy language
>>
>>54256164
You're telling me there's a class specifically for frames? I've only seen classes for UDP/TCP packets.
>>
Evening, guys. Been having some issues with git. Do questions about git go here or in the Stupid Questions General?
>>
>>54256197
I can't speak for Codecademy, but Python is a perfectly fine language to learn. Don't listen to the trolls who tell you otherwise.
>>
>>54256212
No. You'd better design a class to represent your own frame format, with a byte array to hold the raw data and methods to switch from class representation to raw representation.
>>
>>54256231
Ah... is this gonna be one of those places where theres too many differing opinions on how to help the noob which lead to a shitposting
>>
Hmm guys?

My quicksort returned a speeding ticket.
Am I in trouble?
>>
>>54256197
http://software-carpentry.org/blog/2012/02/why-not-use-python.html
http://blogs.bu.edu/md/2012/10/10/the-problems-with-python-as-a-teaching-language/
https://www.quora.com/What-are-the-main-weaknesses-of-Python-as-a-programming-language
https://wiki.theory.org/YourLanguageSucks#Python_sucks_because

i can't be bothered to explain it with my own words for the 363rd time but take your friend's advice and move on to java or C++
>>
>>54256300
Thanks senpai. I am gonna check these out... naked
>>
>>54256263
Alright, I'll try that.
>>
>>54256324
No. You'd better design a class to represent your own frame format, with a byte array to hold the raw data and methods to switch from class representation to raw representation.
>>
>>54255521
rawlin
>>
>>54255239
It's probably just deprecated because MD5 is deprecated, for a non-crypto application it's fine.
>>
Anyone have a list of all types in C typedef'd to be one token? i.e. 'unsigned char uchar'', for all of the multi-token types, etc? Thanks
>>
>>54256219
I wouldn't ask /sqt/ for much of anything.
>>
>>54256314
>>54256300
So these are interesting but I don't understand most of what the complaints are about. I'm sure this is reasonable, as I am a novice thru n thru.

But what about what you said about codeacademy being shit?
>>
>>54256426
>But what about what you said about codeacademy being shit?
Not him but too much handholding, doesn't force you to use your brain for problem solving.
>>
>>54256426
https://www.reddit.com/r/webdev/comments/1j485e/why_is_codecademy_so_heavily_criticized/
http://www.makeuseof.com/tag/4-reasons-shouldnt-learn-code-codeacademy/
http://www.attendly.com/why-codecademy-is-overrated-and-missing-its-target-audience/
https://www.quora.com/How-come-the-quality-of-Codecademy-is-so-bad
>>
>>54256426
Just pick up K&R or a Racket book. When I was a beginner I learned more from five pages of K&R than the entire codecademy course.
>>
>>54256389
Okay then. Simplified, the issue is that I seem to have entered a wrong password somehow and I can't find anywhere to enter it again.

Long version: I'm new to git (and compsci in general; this is my first year).
For a school project (in group), we were given a repository to access and store our shit in. It's compulsory to use this repository if we want to get graded, which I would like to be.

So I installed git and tried out the tutorial the official site gave. That worked fine, so I tried connecting to the repository the school gave me via
>git remote add test [url]
I entered the password I thought I was being asked for, the same password that works for the site that allows us to check on that same repository, but now all I get is "invalid username or password".

I tried installing a GUI (SourceTree, as one of my mates recommended) in the hopes it'd allow me to fix the issue, but so far it's run into the same problems. I'm fairly sure I've got the right URL, though.

Usually, I'd just try a different username or password and see what sticks, but I can't find anything in the help for git or git remote that allows me to do that.
>>
My final project for Java 1. Teacher is shit and I'm scared if I don't pass this class I might have to drop out of college. How do you position pictured within a gridpane???
>>
>>54256516
What git frontend does your school use?
>>
>>54256300
>http://software-carpentry.org/blog/2012/02/why-not-use-python.html
He has trouble installing Python and complains that some children have difficulty understanding range(). Really compelling arguments. He also doesn't seem to be aware that Python does in fact have what he calls a "cross-product operator" (wtf?): itertools.product()

>http://blogs.bu.edu/md/2012/10/10/the-problems-with-python-as-a-teaching-language/
His complaint against print is obsolete as of Python3; operator overloading is awesome, and if you dislike % for string formatting you can use .format; Python's error messages are perfectly fine, I'm not sure what he's talking about; IDLE does suck, yes, but that's an IDE, not the language; the only people who seem to dislike Python's whitespace are those that come from C-style languages. Programming new comers never complain; Python's assignment operator is absolutely standard, identical to that of Java and C++; I you don't like eval, don't use it; maybe Python's module system could be improved, but that's hardly a reason to use a different language.
>>
>>54256547
SCM, I think.
>>
I want to learn javascript, where can I start?
>>
>>54256574
Let it put another way, when you login through the website, what kinda authentication is it? Is it HTTP AUTH, a login form, or something else? Do you have a profile on the website? Does the website display either HTTP or SSH for cloning? If the website has a profile, does it have any menu for SSH Keys? Last but not least, are you sure that you're switched to "test" remote when you're attempting any of the commands?
>>
>>54256603
codecademy
>>
>>54256603
>>>/g/wdg
>>
con't from
>>54256549
>https://www.quora.com/What-are-the-main-weaknesses-of-Python-as-a-programming-language
He claims that Python has "scope-confusion" without giving examples of what he means, so I can't comment on it, except to say that I've never had any difficulty with Python scopes; Even the biggest defenders of OOP cannot seriously claim that information hiding is "the biggest advance in programming since FORTRAN 2", but anyway Python has a clear rationale for avoiding information hiding. I can understand why people disagree with it, but for a scripting language it makes sense IMO; He claims that Python is untyped, which is completely false. Python is strongly typed; Python can't support braces because of problems with set and dict. I also don't see why whitespace makes code generation more difficult; his point about "table-based" programming is utterly incomprehensible, list, tuple, named_tuple, etc are not table-based;
>>
>>54256607
>when you login through the website, what kinda authentication is it?
Well, the URL is https:// but it also has a login form.
>Do you have a profile on the website?
I have an account where I can see all the repositories I have access to. I assume that's what you mean by profile.
>Does the website display either HTTP or SSH for cloning?
How do I tell which one it uses?
> If the website has a profile, does it have any menu for SSH Keys?
Not as far as I can tell. The options it gives me are to look into the repositories I have access to, to change my password and to log out.
On clicking the repositories, the options I get are to open a page for the commits or the source. It shows a checkout link of the form
>(git clone) https://my.name@site:8181/scm/git/project-name
and I can open that page, but attempts to use it as an URL for pulling from have run into the password problem.
>Last but not least, are you sure that you're switched to "test" remote when you're attempting any of the commands?
I haven't touched GIT (Bash, GUI, or cmd) since creating that remote. How do I switch remotes? The commands on the git remote help page don't seem to do that.
>>
>>54256912
Okay so what happens when you try to use git clone with the checkout link that's present on the website? Does it clone the repository or does it show any error?
>>
>>54256999
I just tried it with git Bash. This is the result:
>git clone [URL]
>Cloning into [project name]...
>fatal: remote error: Invalid username or password.
>>
File: 1450205806912.jpg (10 KB, 236x326) Image search: [Google]
1450205806912.jpg
10 KB, 236x326
Hey /doublepenetration/

Learning C here; can't help but think this is the wrong way to do it. Basically I want to make sure some text (i.e. "clear", "snow") matches an icon (i.e. \U0000F00D, etc).

Here's my painful code... what's the C way of thing?

    if (strcmp(conditions_buffer, "clear-day")) {
text_layer_set_text(s_condition_layer, "\U0000F00D");
}

if (! strcmp(conditions_buffer, "clear-night")) {
text_layer_set_text(s_condition_layer, "\U0000F02E");
}

if (! strcmp(conditions_buffer, "rain")) {
text_layer_set_text(s_condition_layer, "\U0000F019");
}
>>
>>54257030
Alright and did that prompt you for the password or straight up told you to fuck off?
>>
>>54257088
Straight up told me I was a scrub, yeah. I was prompted for the password before, though.
>>
>>54257147
What if you try any of these?

git clone https://site:8181/scm/git/project-name
git clone https://site:8181/git/project-name
git clone https://site:8181/project-name

git clone https://site:8181/scm/git/project-name.git/
git clone https://site:8181/git/project-name.git/
git clone https://site:8181/project-name.git/


Both don't contain username in hopes that it will prompt you for username & password, I also alternated between paths because the chances are the scm serves under different ones than the web server makes it accessible through and last but not least the latter 3 have .git appended to them, maybe that'll do the trick, it's hard to tell without knowing which interface & version & configuration it's running so it's a long shoot. It's even more suspicious that it gives you a checkout URL that doesn't work. If none of these work, then perhaps it's your git config that attempts to auth with wrong creds that have been stored in your prior attempts.
>>
File: 1449235632495.jpg (373 KB, 1536x1908) Image search: [Google]
1449235632495.jpg
373 KB, 1536x1908
>>54257053
Same anon here.

In python I would write this:

input = "clear_night"

ICONS = [
("clear-day", "\U0000F00d"),
("clear-night", "\U0000F20E"),
("rain", "\U0000F019"),
]

for icon in ICONS:
if input == icon[0]:
print(element[0], element[1])



What's the C equivalent of this? Pls halp /dpt/
>>
>have to use external project that implements _t types

Why do people do this? Do people seriously not give a damn about POSIX?
>>
File: 1461634641592.jpg (120 KB, 780x973) Image search: [Google]
1461634641592.jpg
120 KB, 780x973
>>54257308
Same girl? Why do you keep posting her?
>>
File: 1439512219026.jpg (164 KB, 1536x1917) Image search: [Google]
1439512219026.jpg
164 KB, 1536x1917
>>54257380
I dunno, just going through my qt folders.

Also, don't post thumbnails.

Please help me C bros: >>54257053 >>54257308
>>
File: 180px-PennLeft.png (50 KB, 180x191) Image search: [Google]
180px-PennLeft.png
50 KB, 180x191
>>54257408
>white girl
>in the qt folders
FUCKIN DROPPED
>>
>>54257408
Thanks but the jpg compression feels worse in this one.
>>
>>54257308
So what's the problem? You're already checking the input and setting appropriate label. You could also make it a table like that one though...

I don't really know C but something along these lines:
struct entry {
char name[32];
char icon[32];
};

struct entry entries[] = {
{"clear-day", "\U0000F00D"},
{"clear-night", "\U0000F02E"},
{"rain", "\U0000F019"},
{NULL, NULL}
};

for (entry *e = entries; e != NULL; ++e) {
if (strcmp(conditions_buffer, e->name) == 0) {
text_layer_set_text(s_condition_layer, &e->icon);
break;
}
}
>>
>>54257452
...

Beauty transcends colour, my friend.

Its the ${CURRENT_YEAR}
>>
>>54257053
Put elses before the second and third if so it doesn't run strcmp again if it already found one that works. Also there really isn't a better way. C is nowhere near as abstract as Python.
>>
>>54257053
you should compare the result of strcmp function call with 0 to check that the strings are equal.
>>
>>54257475
>He doesn't unroll his loops
>Wasting space on sentinel values instead of just using sizeof
>allocing arrays in structs
Roberto Ierusalimschy/10.
>>
File: 1193364813582.jpg (46 KB, 600x591) Image search: [Google]
1193364813582.jpg
46 KB, 600x591
>>54257480
but not eyes.
>>
>>54257308

What you posted was the right way to do it in C, since string is not a fundamental type of the language, and is basically a char array, so you can't use ==. The manual way, if you would like, to compare string equality in C without strcmp is to check every single char in each string array to check equivalence. Using strcmp is already pretty short.

But to make it shorter, you can use enums to equate the weather conditions to some integer and then use a switch statement to get something shorter.

So like this:

    enum weather {
CLEAR_NIGHT,
CLEAR_DAY,
RAIN
} weather;

weather input = CLEAR_NIGHT;

switch(input)
{
case CLEAR_NIGHT:
text_layer_set_text(s_condition_layer, "\U0000F02E");
break;
case CLEAR_DAY:
text_layer_set_text(s_condition_layer, "\U0000F00D");
break;
case RAIN:
text_layer_set_text(s_condition_layer, "\U0000F019");
break;
}


People are not kidding when they say it's basically portable assembler.
>>
>>54257220
>>54257220
The first returns invalid username/password.
Second two return that the repository couldn't be found.
Pattern is the same for the second set of three.
>>
>>54257587
This assumes the input is controlled by the programmer. I figured it was user input.
>>
Is it good idea to learn python and C because of pythons C Extensions
>>
>>54257625

Yeah, I figured as much, looking at the more recent replies since that post.

strcmp is basically the only way this person can roll. I don't think it's bad.
>>
Is there any reason to learn assembly in the year of our lord 2016?

I find it comfy to write small programs in, but what kind of employment opportunities are there?
>>
>>54257645
Learning C is always a good idea.
>>
File: 1437353198493.gif (2 MB, 320x320) Image search: [Google]
1437353198493.gif
2 MB, 320x320
>>54257587
Gah... I think I will just do the elif ladder then.

What do you think of this anon's solution?

>>54257475
>>
>>54257655
Maybe I'm wrong. I seriously hope, new as he is, he isn't using strings for parametrization.

>>54257691
It works. It's slightly more involved and less optimal. I wouldn't do it, but that's how some C programmers would (why I mentioned Roberto, it reminded me of his style).
>>
How the fuck do I make this work?
/*
* If this error is set, we will need anything right after that BSD.
*/
static void action_new_function(struct s_stat_info *wb)
{
unsigned long flags;
int lel_idx_bit = e->edd, *sys & ~((unsigned long) *FIRST_COMPAT);
buf[0] = 0xFFFFFFFF & (bit << 4);
min(inc, slist->bytes);
printk(KERN_WARNING "Memory allocated %02x/%02x, "
"original MLL instead\n"),
min(min(multi_run - s->len, max) * num_data_in),
frame_pos, sz + first_seg);
div_u64_w(val, inb_p);
spin_unlock(&disk->queue_lock);
mutex_unlock(&s->sock->mutex);
mutex_unlock(&func->mutex);
return disassemble(info->pending_bh);
}

static void num_serial_settings(struct tty_struct *tty)
{
if (tty == tty)
disable_single_st_p(dev);
pci_disable_spool(port);
return 0;
}

static void do_command(struct seq_file *m, void *v)
{
int column = 32 << (cmd[2] & 0x80);
if (state)
cmd = (int)(int_state ^ (in_8(&ch->ch_flags) & Cmd) ? 2 : 1);
else
seq = 1;
for (i = 0; i < 16; i++) {
if (k & (1 << 1))
pipe = (in_use & UMXTHREAD_UNCCA) +
((count & 0x00000000fffffff8) & 0x000000f) << 8;
if (count == 0)
sub(pid, ppc_md.kexec_handle, 0x20000000);
pipe_set_bytes(i, 0);
}
/* Free our user pages pointer to place camera if all dash */
subsystem_info = &of_changes[PAGE_SIZE];
rek_controls(offset, idx, &soffset);
/* Now we want to deliberately put it to device */
control_check_polarity(&context, val, 0);
for (i = 0; i < COUNTER; i++)
seq_puts(s, "policy ");
}
>>
>>54257475
I'm sure that that code doesn't work.
>>
Daily reminder Java is a pretty good language
>>
trying to get autohotkey to minimize and restore windows
i'm kinda sick of writing in autohotkey, 1,5k lines and it's sorta unpredictable, sometimes it works sometimes it doesn't.
might go for the more robust version, not sure tho
>>
>>54257452
OSGTP when did you get a second tripcode
>>
>>54257732
As I mentioned in my post, I don't know C, it was a rough example based on what I've seen people do in C.
>>
>>54257820
nah, I like Asian girls
we just both agree that white chicks are ugly
>>
>>54253891
I wouldn't wish PHP on my worst enemy.
>>54253915
>paying enough attention to know that
>>
File: 1435020720705.jpg (68 KB, 576x1024) Image search: [Google]
1435020720705.jpg
68 KB, 576x1024
>>54257837
Asians and White, they're both alright
>>
>>54257864
>fat
>>
is there a way to do CRUDshit with a mysql website without using php
>>
File: 1450872991388.jpg (113 KB, 604x604) Image search: [Google]
1450872991388.jpg
113 KB, 604x604
>>54257878
With a waist like that? That's not fat.

You're just LOW TEST
>>
>>54257837
White chicks are one of, if not the, most attractive races
>>
File: shit eater.png (38 KB, 578x712) Image search: [Google]
shit eater.png
38 KB, 578x712
>>54257895
>>
>>54257892
back to the loo, pajeet
>>
>>54257892
Yes, use python
>>
>>54257895
it's fat as hell the legs and waist are all lumpy and her knees are thick as trees
>>
>>54257898
Races are social constructs
>>
>>54257907
rolling your own backend because the startup you were gonna outsource it to got bought up and they SHUT IT DOWN doesn't make you a pajeet

>>54257909
how

i hate python but i'd even use it if it means i don't have to use php
>>
>>54257937
Here's something to read through

http://www.tutorialspoint.com/python/python_database_access.htm
>>
>>54257961
well that looks good

but i'm not 100% on how exactly it works

i haven't paid for the web hosting service which includes 2 mysql databases so i can't just experiment with it yet

if i'm reading it right, in the tutorial they manipulate the database "raw" and not through a server-side script? doesn't that introduce vulnerabilities? i'd like to run a server-side script with python (or anything not php)
>>
I want to make android games without breaking my brain

I tried AppGameKit but it feels outdated and forgotten by now.

What should I try?
>>
>>54258068
if you just want something up and running regardless of quality then try the unity engine
>>
>>54258032
usually if you want to do easy crud, look into django.

what i posted is barebones CRUD using the pymysql lib

>doesn't that introduce vulnerabilities?

They the pymysql lib to interact with the database. Ineracting with a databse inherently introduce vulnerabilities. The most you would worry here is escaping inserts and doing parameritized queries and such.
>>
>>54258032
wait it's actually 100 mysql and 2 mssql databases

>>54258084
does django need to be installed on the server? i'm worried that i won't be able to do this CRUD stuff with just the web hosting service. but most websites are dynamic so it has got to be possible, yeah?
>>
>>54258083
Unity is expensive, I was thinking of something free/affordable.
>>
>>54258140
i think it's free until you make a certain amount of money and then it's like a 5% royalty fee or something like that
>>
>>54258132
Usually if your host let you install phyton on the webserver, you can run it.

Django needs to be installed on server, correct.
>>
>>54258158
ah ok then maybe a cloud service would be required for that particular host for django. but if i understood correctly i should be able to do php with mysql on the web hosting service? like just set up the database and upload a muh_api.php script to the website?
>>
>>54258201
or is the php server-side script support also something i need to ask the host about? like maybe they have phpmyadmin only for the admin to set up the database himself such as on a blog website and not through a server-side script such as through the end user's mobile app?
>>
C wizards. I need some help with something very dumb and hacky.

I'd like to cast a stack array array[r*c] to array[r][c]. Pretty much just reinterpret a contiguous memory space as a 2D array. I've seen it done before on /dpt/ but I forget the particulars.
>>
>>54258281
ok it looks like they support server-side scripting with php at least
>>
>>54258391
you just map indexes
>>
File: 1461781849.png (79 KB, 785x607) Image search: [Google]
1461781849.png
79 KB, 785x607
python question
why does the function check_user_version() knows the variables without them being set with global keyword?
>>
>>54258391
Well I guess I'll tell you what I'm doing.

I get data from an accelerometer as X1, Y1, Z1, X2, Y2, Z2, ... and I'd like to transform the data into a 2D array of [axes][index]. I can't pass a 2D array to a function without specifying the width of the last dimension, which isn't possible unless I make the axes the last dimension which is inefficient as fuck. I can't malloc in the function and pass it back, I'm on an embedded system with no malloc.

So I'd like to pass a 1D array as the destination to the function and then reinterpret the pointer as a pointer to a 2D array after the call. The compiler keeps fussing about it.
>>
>>54258595
switch to C++
>>
File: beforepostingondpt.webm (3 MB, 1329x720) Image search: [Google]
beforepostingondpt.webm
3 MB, 1329x720
Ask your much beloved programming literate anything (IAMA).

>>54256369
https://neetco.de/CodeArtisan/cdptlib/src/master/source/base.h

>>54255458
>try to spinlock for a while before they give up and block the process for real,
Only if the current owner is being executed.

>>54255056
read/write are atomic on x86. if you have something like

consumer
while (NULL == array[i])
yield();

foo = array[i];
array[i] = NULL;


producer
while (NULL != array[i])
yield();

array[i] = ...;


you are safe.

>>54254041
c++
>>
>>54258620
No malloc. What use is C++? If anything it would fuss even more about what I'm trying to do.
>>
File: 1453656893900.png (1021 KB, 870x717) Image search: [Google]
1453656893900.png
1021 KB, 870x717
>>54258656
>C++
>no malloc
>>
>>54258521
which variables?

user_version?
>>
>>54258672
If there is no malloc there is no new you idiot.
>>
>>54258694
Anon... C++ has stack too
>>
>>54258733
You can't allocate a vector's data on the stack.
>oops that push just overwrote a local variable

>>54258595
I'm just going to write it as a macro function. Kill me.
>>
>>54258811
int x[5]; // valid C++ code

magic
>>
>>54258835
You obviously don't understand my problem.
>>
Can someone who's smart review my technical paper?

https://www.scribd.com/doc/310661542/N-Gram-Markov-Chains
>>
File: goodness.webm (3 MB, 1280x720) Image search: [Google]
goodness.webm
3 MB, 1280x720
>>54258694
One of the many advantages of C++ over C: You just have to overload the global new and delete operators to have your own type safe memory allocator.

http://en.cppreference.com/mwiki/index.php?title=cpp/memory/new/operator_new#Global_replacements
>>
>>54258903
Shit's due tomorrow. I don't have time to write my own allocator. Otherwise I might.

>>54258811
Macro function wasn't horrendous. But the fact I have to use them is. I remember specifically seeing someone doing pointer casting to solve this issue. Something like
u8 r = 10, c = 10;
u8 penis[r*c];
u8 (*doubledick)[r][c] = penis;

(*doubledick)[2][5] = 69;
>>
>>54258811
>You can't allocate a vector's data on the stack.
yes you can with custom allocator

https://chromium.googlesource.com/chromium/chromium/+/master/base/stack_container.h
>>
>>54257898
not objectively, on average males from e every race are most attracted to Asian girls
>>
Resharper is telling me to
>use capital first letter for methods,
>lowert 1st for local vars+a underscore in front if instance field,
>non-private/global vars with capital 1st

do you guys agree with this?
>>
>>54259121
>asian
>pakistani
>chinese
>indian

Nice try Pajeet
>>
Visual Studio Community 2015; how do you make an installer out of your C# file? Can't find the shit anywhere.
>>
>>54259198
think you need to download a wizard template
>>
>>54259143
always follow the common style of a language even if you do not agree with it
>>
Does anybody still use the windows registry?
>>
>>54259219
Well that's fucking retarded.
Thanks though.
>>
Why are medior job advertisements so uncommon? 99% of the software dev job postings are junior or senior positions.
>>
>>54259316
because coding is an oversaturated field
there's plenty of shit-tier API monkeys but not enough actual competents who can manage those monkeys.
>>
>>54259198
There's a publish or publish as a oneclick application somewhere, probably the build drop-down menu.
>>
>>54259316
>>54259342
one person to herd the pajeets
>>
File: capybara.jpg (212 KB, 710x408) Image search: [Google]
capybara.jpg
212 KB, 710x408
>>54259342
wow
just wow
>>
>>54259372
That's a cute beaver.
>>
>>54259378
It's actually the world's smallest bear. They live in Brazil.
>>
File: eg4.png (57 KB, 751x543) Image search: [Google]
eg4.png
57 KB, 751x543
>>
>>54259420
Bea(ve)r, and they live with me, in Canada.
Final answer.
>>
>>54258685
cur variable
>>
>>54259443
Canadian bearers have beards, you were so close, sorry :).
>>
>>54259487
>bearers
>>
>>54255521
Roll
>>
>>54259434
need to fix flattenN and try and overload so you don't need to specify
>>
>>54259347
think this is true, dunno tho, i only release my shit in a single exe
>>
>>54259487
Wild ones. Mine have self-respect and keep it trimmed. That is one of mine, clearly, and I want it back.
>>
File: Save.png (56 KB, 467x289) Image search: [Google]
Save.png
56 KB, 467x289
>>54259526
Hi, can anyone identify what layer of security from the OSI model each Model is using? and a little explanation, why?
>>
>>54254038
pic for ants
>>
>>54255521
roll()
>>
just got this:
https://github.com/Nidre/VS2015-Dark-Npp
if anybody else is interested
>>
File: eg5.png (52 KB, 729x540) Image search: [Google]
eg5.png
52 KB, 729x540
>>
>>54259769
text is covered, but it says that they copy which is not ideal (particularly for an embedded system)

I could avoid referencing std::array and then make it safe to cast
>>
>>54259769
change for loop in flattenOnce, should be

for (size_t i = 0; i < M; i++)
for (size_t j = 0; j < N; j++)
result[i*N + j] = arr[i][j];
>>
This is just a quick project I made this evening for fun.
I made a script in Octave that visualizes how an analog signal (some ramps) are turned into a PCM signal which is then modulated using FSK. I couldn't program a decent non-perfect low pass filter so this will have to suffice. Run this through octave and it'll open a bunch of windows with plots the different stages of the signal and create a wav file of the final FSK signal, assuming that it was sampled at 4410 Hz (that's 1/10th CD sampling rate).
I can post the source code if you want.
>>
I know it sounds retarded but i am not able to find how to write a single 0 into the terminal using c's printf. I am doing printf("0") at the moment, nothing shows up.
>>
>>54260329
add flush (stdout);
>>
lads how the fuck do i get the string value of a selected listbox item in c#

this seems like it should be easy but it bloody isn't.

string g2 = dialog.addg2.SelectedItem.ToString();

how dae ah get it to work?
>>
>>54260341
Yeah you are right, tried to print more shit and found a starting zero so i guessed i needed to flush, thanks.
>>
>>54260344
>string g2 = dialog.addg2.SelectedItem.ToString();
No.

(string) dialog.addg2.SelectedItem

If you put string in items in of the listbox you can cast them directly.
>>
if a float type has a magnitude range of (2^-62, 2^62) and can accurately represent all integers between -2^16 and 2^16, then can it represent e.g. (14.125 + 1.0/(2^10)) with full accuracy? and a float type with a magnitude range of (2^-14,2^14) and an integer range of (-2^10,2^10) can not?
>>
Why do so many people know python?
>>
>>54260417
Simple to learn, good-looking code, cross-platform availability, extendable through modules.
>>
>>54260431
>good-looking code
oy vey
>>
>>54259155
I mean East Asian (CJK)
>>54260431
that describes many more languages than you think it does
>>
>>54253840
I posted a block of shit-tier code yesterday, spent the day combing over it and now I think I have something presentable
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import turtle
import random
#setup the display, configures background color
wn = turtle.Screen()
wn.bgcolor("black")

#creates all the turtles and crams them into a list
artists = [turtle.Turtle() for x in range(10)]
#generates rotational angles and movements
move = [random.randrange(40,60) for x in range(10)]
rotate = [random.randrange(0,360) for x in range(10)]

#Configures turtle color
colors = (
"Red","Blue","Purple","Brown","Gold",
"DarkKhaki","OrangeRed","DarkSlateGray",
"MediumSpringGreen","ForestGreen"
)
for artist, color in zip(artists, colors):
artist.color(color)

#set up the turtles to draw the shapes
for a in artists:
a.speed(0)
a.ht()
a.penup()
a.right(random.randrange(0,360))
a.forward(125)
a.pendown()
for i in range(120):
for x in range(0,9):
artists[x].left(rotate[x])
artists[x].forward(move[x])
wn.exitonclick()


be gentle...
>>
>>54260417
Libraries that do everything for you (meaning you can pretend to be capable of anything while being incapable of everything), a hipster culture and being designed with retards in mind
>>
>>54260542
>Libraries that do everything for you
So not wanting to duplicate work that's already been done makes you a worse programmer

Ever used a loop anon?
>>
like in notepad++:
https://visualstudiogallery.msdn.microsoft.com/830a6482-3b8f-41a8-97b5-b9c581e5ad8b
>>
File: proving my point.png (36 KB, 1288x374) Image search: [Google]
proving my point.png
36 KB, 1288x374
>>54260572

Another thing is the complete lack of self awareness of python programmers. Python programmers are so incapable of recognising faults, that they might even suggest that a for loop is comparable to being able to import a graphics context and turtle
>>
File: mascottt.png (1 MB, 532x546) Image search: [Google]
mascottt.png
1 MB, 532x546
Finally finished everything to do with analysing anime from usenet for my indexer. (Also made that shit logo)
80,000 releases analysed, and have a threaded program to analyse new ones every minute. It only took a few hours and 600GB as well which was surprising.

Now just have to clean everything up before I make a repo and throw this dumb shit on github.
>>
>>54253878
brb making a csgrad.jpg out of this
>>
>>54260664
employers will love your anime analytics

>>54260681
newfag
>>
>>54260664
did you embed something in that picture?
>>
I have some beginner's questions:

- Should all my methods be "stand-alone" and easily unit-tested? Like, should I avoid using variables defined in the class and not locally in the method and stuff like that?

- Should I put everything in variables instead of getting it directly, even if I use it only once? I'm not sure if it's good practice to do stuff like DoSomething(GetValue(SomeOtherClass.GetParameters().ToString()))
>>
>>54260725
no, I think I just didn't compress it when saving in photoshop
Thread replies: 255
Thread images: 45

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.