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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 313
Thread images: 40

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>59958401

What are you working on /g/?
>>
>>59962532
can artificial intelligence shit post better then me? would it?
>>
Please do not use an anime image next time. Thank you.
>>
>>59962563
yes i can
>>
>>59962599
>be me
>new green text meme
>dafuq is this shii
>keyboards missing buttons
>just took my sleeping pill
>learned about switch case default
> >>59962582
>>
>>59962649
>>59962654
>be me
>>
I'm going to assume the answer is "no" but:

In C# I can use reflection to refer to any class file that exists in the solution. So if I have 20 class files called "Problem_XX" I can use reflection to dynamically call those files overloaded functions without having to hardcode anything.
e.g. Problem_01 and Problem_02 and etc have a method called Run() and I can just use reflection to take an input of, say, 02, to find and run Problem_02.Run()

I ASSUME there's no similar way to do this in C?
The reason I want to is so I don't have to constantly update and hardcore a driver file when writing exercise problems.
>>
>>59962742
Kill yourself
>>
>>59962754
He kinda has a point though...
>>
>>59962712

Type.GetType(string) and InvokeMember might do what you want.
>>
will someone do my homework for me...I have an folder on mega and there is ten problems, could someone possibly do them for me so I pass my classes?
>>
>>59962712
>>59962786

Wait, nevermind, I didn't read, but the answer is no, you can't do the same in C.
>>
>>59962666
>>be me
>who are you quoting?
>>
>>59962799
javascript
there is no web shit, just little games and shit
>>
>>59962819
Javascript is /wdg/
>>
>>59962834
it's an intro to computer science and all of it is scripts like a guessing game or converting numbers and random numbers
>>
Which one's better?
long long factorial (int f)
{
if (f == 0) return 1;
else return f * factorial(f-1);
}

long long Factorial (int n)
{
long long F = 1;
for (int i = 1; i <= n; i++) F *= i;
return F;
}

[spoiler]and why?[/spoiler]
>>
File: 1469566688975.gif (2MB, 320x240px) Image search: [Google]
1469566688975.gif
2MB, 320x240px
>>59962532

Still learning how to use vim + tmux
>>
>>59962532
Thank you for using an anime image.
>>
>>59962845
>Non tail call recursion for a linearly scaling algorithm
Definitely the second.
>>
>>59962845
int64_t
>>
man's C syntax gets awful when you get into the lower level stuff, example i found on the internet:
>#define DEV_REG (*(unsigned char *)0x80000000)
what the fuck is this shit
>>
>>59962875
t. butt boy
>>
what's the most elegant way to assign str1 to the longest string of two strings, and str2 to the shortest string of two strings in python?
>>
>>59962873
it's simple as fuck, you brainlet. it's a hardcoded memory address that probably has some significance on the target platform, being cast to an "unsigned char*" so that it can be dereferenced, and thus used (almost) as a normal variable.
>>
>>59962875
I don't even know what this means
>>
>>59962896
rude
>>
>>59962885
I am quoting reality.
>>
>>59962907
sorry bb ily
>>
>>59962897
I'm saying you're a butt boy.
>>
>>59962873
fucking idiot
stick to python
>>
>>59962895
and before you say it, doing a = min([str1, str2], key = len), b = max(.. wouldn't be reliable since the strings could be of the same length. i thought of that too
>>
>>59962895
str1,str2 = sorted([str1, str2], key=len)
>>
Python isn't a language, it's a torture device.
>>
>>59962924
Prove it.
>>
>>59962873
>>59962880
It's worse when the header file just references another file and provides a macro/wrapper around another library function in another file and you have to go like 3 layers deep into the darkest depths of the library that was never intended to be read by mortals to find the actual source code of the function.

Example: http://blog.hostilefork.com/where-printf-rubber-meets-road/
>>
Am I a shit programmer if I can't find the motivation to program very often
>>
>>59962946
C is a torture device.
Not Python.
>>
>>59962795
Sure
only if you will mention to your teach that you got help on at 4chan.org/g/dpt
>>
>>59962926
thanks lad. how do you guys learn syntax like this? just from reading books on the language you're learning? i liked haskell because you could do a lot of really elegant things like this without having to memorize quirks. is python just one of those languages with a bunch of hidden features you gotta memorize?
>>
>>59962951
Real negroes program everyday for 10-12 hours
>>
>>59962969
Do you deny your nature?
>>
>>59962742
C hash is a comfy language.
>>
>>59962965
Well I used to do some golfing code challenges in Python for a little while, learned some cool tricks there (I could share some). And I like to write Haskell for fun, because it's pretty much constant golf.
Destructuring syntax is invaluable (even though it fucking sucks compared to actual pattern matching). And sorting a list using len() as the key is the most "clever" solution to your problem.
>>
>>59962873
It literally just means "define DEV_REG as the unsigned byte located at memory address 0x80000000". That's nothing compared to function pointer syntax.
>>
>>59962953
>pointers are hard :-(
>>
A while back I wrote my own vectorN implementation with simd instructions and the whole everything. I was well underway into writing a generic matrix type when I found that there's a fucking library called GLM that does all that shit already.
Goddamnit /g/, why didn't you tell me!?
>>
>>59962873
this is why C++ was invented.
>>
>>59963056
brainlet
>>
>>59963056
*Rust
>>
>>59963094
*Nim
>>
>>59963056

C++ would use the same macro. Unless you wanted to define some struct with an overloaded = operator to wrap around the behavior of dereferencing that address, but that's... overkill.
>>
I made a C# class with 11 inner classes that works perfectly. Should I just ignore everyone who tells me not to have inner classes?
>>
>>59962626
>new
>>
>>59963109
*Haskell
>>
>>59963124
No, it would have a nice RAII type to allocate and deallocate the device memory in the first place with an overloaded dereference operator so you don't need to hardcode memory addresses.
>>
>>59963167
The memory address is hardcoded because there's a specific hardware device mapped to that address. And allocation/deallocation is pointless if you're working with literal memory addresses.
>>
>>59962712
AFAIK there isn't a PORTABLE way to do this, but you can do it. I assume you're using windows, right? You'd have to compile Problem_01, etc as dll files and load them.
>>
>>59962532
Whenever I try to run the program it stops at the 3rd calculation and shits itself "bin.exe stopped working"...why?
#include <stdio.h>
int main(void)
{
int x, y, z;
x=2, y=4, z=6;
x+=y*z;
printf("%d\n",x);
x-=y+z;
printf("%d\n",x);
x*=y-z;
printf("%d\n",x);
x/=(y/z);
printf("%d\n",x);
x%=(y%z);
printf("%d\n",x);
return 0;
}
>>
>>59963212
>windows
everytime
>>
>>59963212
>x-=y+z
Wft?
>>
>>59963212
what the fuck is this?
>>
For Python 3, are there any courses or texts or videos that go over examples of solutions or modules for common problems in depth? It's all very well learning the syntax, but I want to start learning how to put things together meaningfully and to make larger programmes.
>>
>>59963212
use VS debugger, faggot
>>
>>59963253
edx mitx introduction to programming
>>
File: python.jpg (195KB, 1024x576px) Image search: [Google]
python.jpg
195KB, 1024x576px
>>59963253
if you can't do that after reading pic related, you should stop now.
>>
>>59963198
Do you even know how device memory works? You need to get the base address from the PCI registers and then remap it into linear address space. Nobody in their right mind would hardcode that shit. You can't assume anything about the memory layout at runtime.
>>
>>59963244
x-=y+z;
is equivalent to
x=x-(y+z);

>>59963250
i wanted to test results I'd yield by using the (+=, -=, *=, /=) operators
>>
>>59963212
shove print statements after every line to find exactly where the problem is if you don't want to use a debugger
>>
>>59963317
>bin.exe
is your first clue
>>
>>59963317
kys
>>
File: Untitled.jpg (71KB, 896x631px) Image search: [Google]
Untitled.jpg
71KB, 896x631px
Are character inventory databases implemented in either of these ways or is it something else? I'm a little stumped on how you normally make a database that holds inventory and the amount
>>
this may be a dumb question but im a dumb person

>android app
>using fitbit API
>fitbit API requires users to login via custom chrome tabs
>this works
>the user token is then displayed in the localhost URL

is it possible to communicate this URL to my app? i think its probably more a question for the fitbit API than average programmers but is there such a java thing that lets me pull the url from the chrome tab so i can parse it
>>
>>59963365
k i l l
y o u r s e l f
>>
I'm working on a very basic interpreter

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <windows.h>

using namespace std;

int main(void)
{
string command, aux;
system("CLS");
cout << " 4chan\n " << endl;
do
{
cout << ":::~ ";
getline (cin, command);
cout << "The command is " << command << endl;
string aux(strstr(command.c_str(), "help"));
if (aux)
cout << "Help was found";
} while (command != "exit");
}



I'm using strstr to find if "help" is in the string, so if it is then it will print "Help was found". What I want to learn from this is how to use conditionals with strings so I can make more complex functions like asking for an area of an specific shape.

The problem is that I can't compile it because g++ says it can't convert string aux to 'bool'.
>>
>>59963375
My example used video games since it was the first to come to mind but it could've been a chain that's trying to keep track of stock in each of their stores
>>
>>59963384
myself

i thought those words as i typed them, so its all a quote from myself
>>
>>59963416
not as retarded as yours, lad
>>
>>59963416
>Unless you have a recording of you saying all of that

isnt explicit memory/conscious recollection a form of recording ¿

unless i forgot i thought those things, its still a quote senpai
>>
>>59963314

Why yes, and how do you suppose you would read from those PCI registers... perhaps via a hard coded physical memory address, such as... oh I don't know, 0x80000000?

http://wiki.osdev.org/PCI#Configuration_Space_Access_Mechanism_.231
>>
>>59963453
Did you even read what you just linked? 0x80000000 is not a memory address related to the PCI configuration space.
>>
>>59962949
lmao at c-fags thinking that "C is predicable and has few layers of abstraction"
>>
>tfw just used C programs i'd written for K&R exercises a while back for real life
>used entab.c to fix my python program when it was JUST'd from combined tabs and spaces somehow
>used removeTrailing.c to remove trailing whitespace from it to make it neater for my OCD
>for laughs checked how much whitespace was actually removed with count-whitespace.c

feels comfy man, gotta keep focused on this cracking the coding interview in python tho, no C until i finish this
>>
>>59963476

It is used in generating it.
/* create configuration address as per Figure 1 */
address = (uint32_t)((lbus << 16) | (lslot << 11) |
(lfunc << 8) | (offset & 0xfc) | ((uint32_t)0x80000000));
>>
>>59963529
That's just a single bit that needs to be set to enable port 0xCFC.
Not a memory address.
>>
>>59963552
i hope you get banned for low quality posts
>>
>>59963133

It's your code so the choice it up to you. But i would seperate the classes out, as a class should only have one responsiblity and ant change to the class should change its responsibility (S in SOLID). Also, you may end up using portions of the inner classes in different areas of the application, so seperating them out will reduce duplications.
>>
>There's palpable autism in this thread
>>
>>59963581
Remember to
Report
Hide
Sage
>>
>>59963550

It's a base address. While the macro was pretty poor if it was trying to interface PCI, you cannot get around the fact that there will be some hard coded magic numbers in dealing with DMA.
>>
>>59963212
>x/=(y/z)
>x/=(4/6)
>x /= (int).6666...
>x /= 0

You're dividing by zero.
>>
>>59963167
you've never written code for a small device have you desu
>>
i want to make a bot that trawls pictures with certain keywords on twitter and detects whether or not there is a face in the picture. Is this doable for a noob?
>>
>>59963746
It's literally a single bit that enables a subsequent access to port 0xCFC. Calling it an "address" is a misnomer, but crappy code on osdev.net is nothing new. In any case, it doesn't have anything to do with an unsigned char pointer to memory address 0x80000000 which is what the macro referenced.
Just about the only things you can make any assumptions about (and hardcode) when dealing with PCI are the address space ports 0xCF8 and 0xCFC.
Also we didn't quite get to DMA just yet.
>>
>>59963887
no
>>
>>59963866
What part of "zero overhead abstractions" do you not understand?
>>
I always see people discussing functional programming but has anyone ever actually developed a program in a functional language?
>>
>>59962532
I still haven't learned loops in c++, is there a way I could do code related where it just prints how every many values you input?
#include <iostream>

bool isPrime(int x)
{
if (x == 2)
return true;
if (x == 3)
return true;
if (x == 5)
return true;
if (x == 7)
return true;
else
return false;
}

int main()
{
std::cout << "Please enter a key:\n";
char key;
std::cin >> key;
std::cout << key <<" Has an ASCII value of:"<< static_cast<int>(key)<<std::endl;
std::cin >> key;
std::cout << key <<" Has an ASCII value of:"<< static_cast<int>(key)<<std::endl;
std::cin >> key;
std::cout << key <<" Has an ASCII value of:"<< static_cast<int>(key)<<std::endl;
std::cin >> key;
std::cout << key <<" Has an ASCII value of:"<< static_cast<int>(key)<<std::endl;

return 0;
}

fuck these captchas
>just use legacy
fuck you too
>>
>>59963940
of course not, that's impossible.
>>
I have a ritual called "terminator". I crouch in the shower in the "naked terminator" pose. With eyes closed I crouch for a minute and visualize either Arnie or the guy from the 2nd movie. I then start to hum the T2 theme. Slowly I rise to a standing position and open my eyes. It helps me get through my day. The only problem is if the shower curtain sticks to my terminator leg. It sorta ruins the fantasy.
>>
>>59963948
ignore that first part btw, kek
>>
>>59963955
I saw this on /prog/ once.
>>
>>59963948
while (std::cin.good()) { /* ... */ }
also 19 is a prime number
>>
>>59963967
I think you meant to write

>>just use legacy

and if you didn't I'd like to ask who you are quoting as well.
>>
>>59963983
Nice

>>Reddit

Spacing

Amigo
>>
>>59964003
>>>Reddit

Who said this?
>>
>>59963955
does your dream have the improbable red molten burnt bits of wire fence
>>
File: 1492151267224.png (2MB, 1200x630px) Image search: [Google]
1492151267224.png
2MB, 1200x630px
Does shorter code = faster execution?
Serious question.
>>
>>59963426
Feel free to graduate middle school any time.
>>
>>59964042
Nope
>>
>>59964042
yeah .. cos with longer code
the interpreter or the pointer
it has to go thru more lines
more takes longer

remember that
bigger things are harder to encompass, interpret
that takes time
you are welcome
>>
>>59963904
>RAII
>zero overhead abstractions
I seriously hope you're not getting paid for this.
>>
>>59962951
No. Programming is high intensity and stressful. Every programmer burns out because they are expected to program for 8 hours per day, which is impossible. They then spend the rest of their lives trying to avoid programming by attending meetings and become "managers" and so on.
>>
>>59964042
smaller it is, the faster it is
i believe that is 'moores law'
>>
About to create a node project. Can we do async await in express/nodejs yet or not?
>>
>>59964068
false
programmers in organisations spend their entire life trying to get through, organisationally, to do something meaningful
in vast, dysfunctional organisations such as microsoft, the huge number of programmers are there to provide extensions of functionality fast, where it is required

it isn't a job where anyone gets to design anything complete

programmers are like termintes (now) .. but they are required to build little bits, in a very restricted way. original conceivers had the opportunity to design something larger, more sustainable, progressive, but we are stuck with a dysfunctional termite heap that nobody understands

how it is
>>
File: doggos.jpg (30KB, 620x655px) Image search: [Google]
doggos.jpg
30KB, 620x655px
Hey please take a look at my code and leave feedback (if you don't have anything nice to say then don't say anything at all)
int add(int x, int y) //adds two numbers together the Kode way <3
// btw i'm a girl don't hit on me silly boys
{
if x = 1 and y = 1
return 2
else
if x = 1 and y = 2
return 3
else
if x =1 and y = 3
return 4
else
if x =1 and y = 4
return 5
else
if x =1 and y = 5
return 100 // xD it's randum just like me
else
if x =1 and y = 6
return 7
else
if x =1 and y = 7
return 8
else
if x =1 and y = 8
return 9
else
if x =1 and y = 9
return 10
else
if x =1 and y = 10
return 11
else
if x = 10 and y = 1
return 11
else
if x = 9 and y = 1
return 10
else //Check out more kool koding at my website www.kodewithklossy.com
if x =8 and y = 1
return 9
else
if x =7 and y = 1
return 8
else
if x =6 and y = 1
return 7
else
if x =5 and y = 1
return 6
else
if x =4 and y = 1
return 5
else
if x =3 and y = 1
return 4
else
if x =2 and y = 1
return 3
else
if x = 1 and y = 1
return 2
else
return 10000000 // it represents my emotions, okay? don't judge me or my past, if you can't handle me at my worst you dont deserve me at my best k hun? :)
{
>>
>>59964067
have you seen what RAII at the assembly level?
probably not since it's all inlined and optimized into a single mov instruction.
>>
File: 1486757539465.jpg (11KB, 250x241px) Image search: [Google]
1486757539465.jpg
11KB, 250x241px
>>59964094
>it represents my emotions
>>
>>59964080
What the fuck
>>
File: output.png (139KB, 2144x1020px) Image search: [Google]
output.png
139KB, 2144x1020px
My image processing code is slowly coming along

Except for the part where everything is fucking broken, pic related - left is expected for canny edge detect, right is actual

I wish Google could tell me how to implement this shit, I should have paid more attention in school
>>
>>59964067

RAII really is zero overhead though.
>>
>>59964129
What language?
>>
>>59964089
I don't work in bigshittyco though. I make things from start to finish. Do you work in bigshittyco? How much work do you actually do there?
>>
>>59964068
The best 'programming' job to me is one in which you program to improve your own day to day experience, rather than the client's.
I wouldn't go into application development on pain of death tbqh.
>>
>>59964136
C#, but it's all in unsafe regions so I have pointers and shit
>>
>>59963940
part of a compiler
>>
>>59964080
>Coding isn't programming
>>
>>59964094
This is actually how the addition function was implemented in the 1960s.
>>
>>59964153
Yeah I agree. You can only really make good things for yourself anyway. Pretty much all the good inventions and tools in the past were created by people making things for themselves, not for other people.
>>
>>59964129
incredibly cool, anon
>>
File: 1491613723818.jpg (36KB, 401x401px) Image search: [Google]
1491613723818.jpg
36KB, 401x401px
>landed job interview
>they asked me to add 2 numbers without using any arithmetic operators
>>
package fizzbuzz;

public class Fizzbuzz {

public static void main(String[]args)
{
int i;
for(i = 0; i < 101; i++)
{
if (i % 3 == 0)
{
System.out.println("fizz");
}
else if (i % 5 == 0)
{
System.out.println("buzz");
}
else
{
System.out.println(i);
}
}
}
}
>>
>>59964042
No. It depends on the number of assembly instructions used and what assembly instructions are used. E.g. division instructions eat about 100 clock cycles while assignment statements take about 1 clock cycle. It also depends on the locality of your program.

I do wish high schoolers would stop coming on this board.
>>
>>59964186
Math.add(n1, n2);
>>
>>59964185
>Hahaha, I replied with a meme. How will anon ever recover?
>>
>>59964186
- Open Excel
 =SUM(1, 1)

Enjoy life as a professional programmer
>>
>>59964184
Thanks friend

It'd be cooler if it was actually working though
>>
>>59964186
#include <stdio.h>

#define FIRST_OPERAND 5
#define SECOND_OPERAND 201

struct {
char a[FIRST_OPERAND], b[SECOND_OPERAND];
} addition_result;

int main(void) {
printf("%d\n", (int) sizeof(addition_result));
return 0;
}
>>
>>59964205
Cut the attitude, asshole. It's not that serious.
>>
>>59964284
This only works if both operands are in hexadecimal, and in this case, you can just bitshift 4 to the left and bitwise or both numbers together
>>
>>59964313
Fuck off faggot. Nobody wants you here.
>>
>>59964334
>This only works if both operands are in hexadecimal
wat
>>
>>59964313
>asks question
>doesn't like answer

fuck off
>>
>>59964353
Where did I say I didn't like the answer, genius? The answer was fine, that rude remark at the end is what I didn't like. Work on your reading comprehension, asshole.
>>
>>59963357
2 things:
1:
If the relationship between character and bag is 1:1 then bag doesn't need its own id - it can use character id.

2:
since 1 bag contains many items, item needs a foreign key to bag. bag shouldn't contain a foreign key to item.
>>
File: jp.jpg (71KB, 400x400px) Image search: [Google]
jp.jpg
71KB, 400x400px
>>59964380
>>59964388
>>
File: 1489547706535.png (308KB, 638x721px) Image search: [Google]
1489547706535.png
308KB, 638x721px
>>59964313
Don't ask stupid question then.

>>59964157
Keep it up, anon.
>>
>>59964388
>he doesn't understand paraphrasing
>>
>>59964424
this is what I mean.
>>
>>59964386
>>59963357

Oh, and since item:bag is many-many, you should have an intermediate table that holds a quantity.
>>
>>59962934
underrated
>>
>>59964411
Learn to manage your emotions
>>
>>59964466
>PARAPHRASING
learn 2 reading comprehension
>>
>>59963390

Guess I'll stick to reddit then
>>
>>59964484
Maybe you should if you can't even solve such a simple problem.
>>
>tfw i'm part of the cancer ruining /dpt/
>tfw I don't even know how to program
i'll stop posting now
>>
>>59964484
std::string has a "find" function.Try command.find("help"). look up the exact syntax on cppreference.
Please don't use string.h in C++ for no good reason.
>>
>>59964495
Good job mods
>>
>>59964495
TEN PERCENT
E
N

P
E
R
C
E
N
T
>>
>>59964534
the mods have no power here!
>>
>>59964129

I've had similar looking problems when I'm mutating the same image that I'm looking at to perform the effect.

In a lot of cases that causes weird looking results.
>>
>>59964386
>>59964439
The way I imagined it, I thought items would just be a database of all possible items: apples, pears, bananas so the bag would need the foreign key to item instead of the other way around.
>>
>>59964524
Is binary size a good reason?
>>
>>59964094
kek
>>
File: 1450826579222.jpg (146KB, 589x900px) Image search: [Google]
1450826579222.jpg
146KB, 589x900px
>>59964094
bretty gud, but not enough comments
>>
>Friend knows I know a little bit of programming
>Ask me to look as his assignment
>It is in python
>See * expression
>Ask him why would he put a pointer there
>Whats a pointer
>No it is used to unpack sequences

For
What
Purpose
>>
>>59964867
Fuck off, Maki's a slut.
>>
>>59963390
What you want is
if(!aux.empty()) 


However, you need to change <string.h> to <string>. The .h versions of the standard library are only really there for legacy code.
>>
File: 1446336838569.jpg (64KB, 627x466px) Image search: [Google]
1446336838569.jpg
64KB, 627x466px
>>59964867
Eat shit; she was shilled here by a failed normalfag from /r9k/ who has shit taste. She's no queen of /g/. She's just a dirty slut who acts like retarded child.
>>
>Lain is in her 30s now
>>
I'm getting an error "expression must have class type" in this function definition:

bool linkedListIterator::operator==(const int& right) const
{
return (current == right.current);
}

the int right is giving me the error. What am I fucking up?

Function declaration is this:

bool operator==(const int& right) const;
>>
File: maxresdefault.jpg (95KB, 1920x1080px) Image search: [Google]
maxresdefault.jpg
95KB, 1920x1080px
>>59965491
>C++ was a mistake
- Bald Danish man
>>
>>59965491
Nvm forget this I'm literally a retard, I did it so horribly wrong /g/ but I think I've got it now
>>
File: 1479963255632.jpg (82KB, 408x600px) Image search: [Google]
1479963255632.jpg
82KB, 408x600px
>>59965482
Lain is an immortal qt.
>>
File: inc.jpg (169KB, 591x532px) Image search: [Google]
inc.jpg
169KB, 591x532px
>>59965633
>>59965669
Why don't you go back to your slovenly little home where you can worship your nasty mentally-impaired, and cock-slurping slut you call "Maki."
>>>/r9k/town_bicycle_thread
>>
I have two C programs (let's say A and B) running on a Linux machine. Program A needs to send a command with parameters to program B from time to time and subsequently receive a return value.

What is the best way to achieve this?
I am considering System V message queue but I don't know if there is an easier way.
Using a socket seems like an overkill.
>>
>>59966018
Why not threads?
>>
>>59965491
>const int& right

This isn't right.
>>
>>59966018
Are programs A and B proven to be running at the same time? What if one of them loops or halts unexpectedly?
>>
>>59966018
There are so many ways to do IPC. Using a socket/pipe/whatever would probably be the easiest way.
However, if B doesn't need to be running constantly, you could just have A run B itself every time it needs to, and communicate with it using its arguments and stdin/stdout.
>>
Wrote a rudementary printf in AS3 cause im autistic
Also AS3 is best lang <3
function printf(str:String, ... args):void 
{
var newStr:String = ""; if(str.indexOf("%") == -1) newStr = str;
else {
var indices:int = args.length; var index:int = 0; var arr:Array = str.split("");
for(var i:int = 0; i < arr.length; i++) {
if(arr[i] == "%" && index < indices) arr[i] = (args[index++]).toString();
} for(var p:int = 0; p < arr.length; p++) { newStr += arr[p]; }
} trace(newStr); return;
}
>>
>>59966241
whats the point of making your code totally unreadable for anyone else?
>>
>>59966241
>Multiple statements on one line
Why the hell do your format your code in such a stupid way?
>>
>>59966280
>>59966288
Its the glorious AS3 way <3
>>
I accidentally ran simulations that we all reading the same file. Turns out it causes your programs to run like shit.

Also, thanks mods.
>>
Also, i 100% find this superior
function printf(str:String, ... args):void 
{
var newStr:String = "";
if(str.indexOf("%") == -1)
newStr = str;
else {
var indices:int = args.length; var index:int = 0; var arr:Array = str.split("");
for(var i:int = 0; i < arr.length; i++) {
if(arr[i] == "%" && index < indices)
arr[i] = (args[index++]).toString();
}
for(var p:int = 0; p < arr.length; p++) newStr += arr[p];
}
trace(newStr);
return;
}

<3
>>
I got a quetsion
how to make a program that takes emails from gmail and displays them in webpage?
I tried imap with php but can't make it work
could you point me some general direction?
should I look for email client in php or email crawles?
>>
>>59966190
Both are running constantly (or at least assumed to be).

>>59966197
I cannot use pipe because B has to be running constantly.
I can use a socket but is it more efficient than message queue? The programs are running on an embedded system and I need the CPU usage to be minimal.
>>
>>59966373
/wdg/ is down the road
>>
>>59966373
https://developers.google.com/gmail/api/quickstart/php
>>
Thank you, jannies!

>>59966373
There's an API for gmail.

>>59966336
Why are you using AS3 when Flash is dead?

>>59966400
How much time do you have to spare? You could try implementing both and see which one is more suitable.
>>
File: 1460622337293.png (763KB, 787x830px) Image search: [Google]
1460622337293.png
763KB, 787x830px
What should I work on?
>>
>>59966436
You should make a web browser that's fast, extensible, and free as in freedom.
PLEASE
>>
File: nei.jpg (7KB, 452x25px) Image search: [Google]
nei.jpg
7KB, 452x25px
>>59966433
>Why are you using AS3 when Flash is dead?
Cause the course im taking is outdated as all hell
And who dosen't love Java with hints of Perl and Javascript? ... im gonna kms
>>
>>59966436
An anime language.
>>
File: 1419669638912.png (32KB, 256x256px) Image search: [Google]
1419669638912.png
32KB, 256x256px
>>59966446
I'd like to but from the ground up? Fuck that.

>>59966457
That's called Japanese or 「日本語」.
>>
File: 1491117166998.png (41KB, 185x185px) Image search: [Google]
1491117166998.png
41KB, 185x185px
>>59966447
You poor fuck. Which school is offering this shit course?
>>
File: geometrica.jpg (46KB, 934x176px) Image search: [Google]
geometrica.jpg
46KB, 934x176px
>>59966473
>Which school is offering this shit course?
Pardon me for not sharing informaton with a bunch of fa/g/s but im not gonna do that
I will tell you that its in such a small part of Norway that people would actually recognize me if i told y'all
>>
>>59966470
>That's called Japanese or 「日本語」.
I don't know of a compiler for it, though.
>>
>>59966505
>Pardon me for not sharing informaton with a bunch of fa/g/s but im not gonna do that
You're good; it just takes just one memelord who thinks he's being funny.
At least tell me what the course is about.
>>
>>59966512
It's interpreted.
>>
>>59966559
There is no such thing as an "interpreted" language.
>>
File: 1491840339096.jpg (323KB, 708x769px) Image search: [Google]
1491840339096.jpg
323KB, 708x769px
>first day of work after easter
>>
>>59966597
Who the fuck cares, faggot
>>
>>59962873
>>#define DEV_REG (*(unsigned char *)0x80000000)
But that's fucking beautiful.
>>
>>59963056
Fucking retard. C++ doesn't solve this case.

>>59963094
And it's even uglier in Rust

>>59963167
Holy shit fucking kill yourself you have no idea about anything.
>>
>just programmed and used a tip calculator
This is why I am a Programmer. All of my father's friends were impressed as I stopped all of the discussion as I wrote my calculator and finally told them the precise amount owed from my laptop
>>
>>59964334
No, you fucking idiot.
>>
>>59966910
>tip
Stupid americans.
>>
>>59966910
Why did you capitalize "programmer" you fucking retard?
>>
>>59963124
or you could just do this:

inline volatile unsigned char& dev()
{
return *reinterpret_cast<unsigned char*>(0x80000000);
}
>>
>>59966545
programming and mediadevelopment
>>
>>59962532
suffering from the after-effects of being specifically told by my boss to, under no circumstances, write any unit or integration tests during development of our product. "They are a waste of time" he says.
As he continually adds changes to the code base with a mediocre understanding of the language, breaking it, and then complaining to me when bugs are suddenly appearing.
>>
>>59967079
Everyone in this thread except >>59966910
>>
Whats the general consensus here about Jai?
main := () -> void {
a: int = 2;
b:int = 5;
c:u64 = cast(u64)a/b;
print("c is %", c);
return;
};

Jai Primer:
https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md
>>
Dear /dpt/,

How do I make the USA want me to become an american citizen?

With regards,
Ivan Smirnov
>>
>>59967216
>:=
Pretty good.
>:
I hope you can write it like "a : int". If so, then it's pretty good.
>>
>>59967235
I think you can..
dont think the compiler is out yet, so kinda hard to test
>>
redpill me on doubly linked lists
learning them today on data structures
>>
File: 23904879373.png (18KB, 771x298px) Image search: [Google]
23904879373.png
18KB, 771x298px
Uhhh which version of python do I have?
Trying to install pyperclip, the most recent version is for 3.5. How would it go installing it on 3.6?
>>
>>59967350
What have you tried? There are few backward-incompatible changes between 3.5 and 3.6 so there must be a way. I just installed it with my package manager on ArchLinux and it seems to import fine under 3.6.0....
>>
>>59967298
I'm writing a C library that's basically a big collection of generic data structures (void* data and key types) and I can tell you the only advantage they have is that you can scan the list backwards.

And that's only IF, in your implementation, you store the head and tail pointers. If you manipulate your list just by storing the head pointer, then they are worthless and offer no advantage whatsoever. In fact you waste space by storing a pointer to the previous node.

Circular doubly linked lists though are the fastest to insert/append elements to (these operations are O(1) at worst case), even if you don't store both the head and tail pointers (just with storing the head pointer).
>>
>>59964847
what's the problem
>>
>>59967350
You have both Python2 version 2.7.13 and Python3 version 3.6.1. They are completely distinct languages so it's not unusual to have a 2.x and a 3.x installed side-by-side.
>>
>>59967350
Looks like 2.7 is installed systemwide, while you have the 3.6 as a runtime.
Try this: https://superuser.com/questions/433897/python-in-command-line-runs-the-wrong-version
>>
There is old php site in internal use that uses db2 as database.
Researchers need some kind interface to build custom queries. They weren't too happy when I told them to just learn sql.
So I need to make somekind of graphical interface for them. I could do this myself but there propably exists multiple implementations that try to do this.
Can anybody recommend anything?
>>
>>59967350
>>59967380
Type python3 in cmd and you'll get 3.6.0. (Probably)
>>
File: 93487933.png (8KB, 739x137px) Image search: [Google]
93487933.png
8KB, 739x137px
>>59967395
>>59967390
>>59967380
Fixed it. Both versions installed. Linked python2 to cmd because it was the only one in C:\, python3 was in appdata, linked that instead.
>>
Im second year cs could i find jobs on the internet during the summer
like small ones for a couple sheckles to buy steam games with?
>>
>>59967298
http://bigocheatsheet.com/
>>
File: 1491219003076.jpg (117KB, 1280x720px) Image search: [Google]
1491219003076.jpg
117KB, 1280x720px
You should leave this thread immediately if you don't do most of your computation at compile time.
>>
>>59967485
I spend more than half of my electricity compiling stuff. Does that count?
>>
>>59967485
>doing any IO at all
ok pleb
>>
File: 1479935093015.jpg (8KB, 215x250px) Image search: [Google]
1479935093015.jpg
8KB, 215x250px
>>59967485
>not doing your own computation
>not being your own computer as fast as a i7
i want brainlets to leave
>>
>>59967485
>compile time
what? you dont write in 01s?
report this faggot
>>
>>59967515
Where does that post mention I/O?
>>
>>59967531
Why do you need runtime?
>>
>>59967549
To compute things which can't be computed at compile time.
>>
>>59967559
So, nothing?
>>
Why do you store strings in zero-terminated char arrays, /dpt/?
>>
>>59967591
Because some neckbeard forgot to implement proper string handling.
>>
>>59967569
Depends on the language. Also you might want to compute some things at runtime for efficiency reasons.
>>
whats the point if u cant program a waifu
>>
>>59967604
>for efficiency reasons
There is no reason that should be the case
>>
>>59967636
Why is that?
>>
>>59967640
Why should it be otherwise?
>>
>>59967654
You didn't answer the question.
>>
>>59967614
>your waifu a shit
>>
>>59967671
but youre my waifu
>>
I wish one flow to exist.

The vim/makefile/gcc workflow you can set up in Linux. Bash scripting instead of batch scripting.

But in Windows.
Alas, Windows will never have an easy way for a general development environment like Linux provides, there's just so much setup and breakage it often isn't worth the hassle.

But hey, that's why I have a dedicated work laptop! Oh well.
>>
File: 1484497285541.png (204KB, 744x843px) Image search: [Google]
1484497285541.png
204KB, 744x843px
>>59967666
>>
Is it possible to out dual type parameters in a function for haskell?
How would one go about implementing it?
 examfunct:: Either a b -> Int 
>>
How do I store dates correctly with nodejs? for instance I have a program that is hosted in like switzerland, this program will periodically visit a url of a website hosted in canada, read the day, month, year and time (24h) from a string in that website's page and transform this into a Date object. Problem I'm having is that it does that but with the switzerland (local) timezone, am I doing this right? how do I make it transform it into UTC or specify the canada timezone?
>>
>want to browse /g/ on programming class cause bored
>click /gif/ instead cause shitty school lab mouse with acceleration on
>only girl in class ugly af winks at me
w-wow that was an experience
>>
>>59967678
>Bash scripting instead of batch scripting
But there is Powershell
>>
>>59967715
Man, I don't even know how to launch myself into learning powershell with how easy it is to write simple things in batch - the issue comes when I want to complicate it.

How the fuck do I begin to learn PS?
>>
>>59967559
>>59967569
An example of compile-time computation, although you could hardly call it such, considering this implies you only need to compute something once, is any algorithm which makes use of primes. Prime sieves, hash tables, and cryptographic functions can all be made to run faster by holding a table of pre-computed primes.
>>
>>59967701
>not writing down the full url
>>
>>59967666
checked
>>
>>59967729
it doesnt show up cause i clear history
unless u want me to write it all down
the fuck would i do that for
>>
>>59967688
What do you mean?

examfunc (Left _) = 0
examfunc (Right _) = 1
>>
>>59967724
>How the fuck do I begin to learn PS?
PS comes with a quick refence and a manual.
>>
>>59967688
wat?

examfunct :: Either a b -> int
examfunct _ = 1
[/code
this typechecks but it's also pointless.
>>
>>59967701
if you don't exclusively use the keyboard to browse to websites (i.e. F6, type url, hit enter, use tab [for 4chan at least]) then ur a superskrub
>>
By the way, do we have an IRC for /dpt/?
>>
>>59967736
>the fuck would i do that for
because 4chan.org/g/ takes just three more characters to type, and it takes less time than typing 4chan.org and clicking "/g/ - Anime and Technology" link.
>>
>>59967700
What format is the string? What language? Have you RTFM on your specific language and library and thought about it?

Two possible paths:
- either the string specifies a timezone and you can use that information to pinpoint the instant in UTC, for example
"Wed Apr 19 13:47:38 CEST 2017"
I happen to be in Switzerland and we have Central European Summer Time right now. With the appropriate function you can parse this into a locale independent timestamp.
- or it doesn't and it supposes you know it by context, in which case you have to pass "CEST" or something to some function so it can meaningfully interpret the string.
>>
>>59967778
Strings are in this format: "19/04/2017 08:50" (dd/mm/yy) I just separated month, day etc using regex
I was recommended the "moment" library not long ago, this is how I was using it

let date_new_test = self.moment.utc();
date_new_test.tz('America/Toronto');
date_new_test.date(day);
date_new_test.month((month - 1));
date_new_test.year(year);
date_new_test.hour(hour);
date_new_test.minute(minute);
date_new_test.second(0);
date_new_test.millisecond(0);
date_new_test = Number(post_date_new.format('x'));
>>
>>59967855
what fucking language is that? Does this code do what it's intended to do, and if not, what does it do wrong?
>>
>>59967701
>those 'I just got promoted' stories are real.
I always type 4chan.org/g/dpt
Or let it autocomplete that.
>>
>>59967855
I like this api.
>>
>>59967862
It's nodeJS as I've said, the last bit ".format('x')" just returns the unix time which is what I store. What it does wrong is that it gives different unix times, for instance while I'm testing it locally on my machine it will give number x while in production (hosted in switzerland) it will give number y. Shouldn't it give the same unix numbers on both since I'm already setting the same timezone for both and both will be parsing the same string? it just makes no sense to me
>>
File: literally me.png (64KB, 622x420px) Image search: [Google]
literally me.png
64KB, 622x420px
>>59967876
This makes me curious. What is /dpt/'s average typing speed?

https://typing-speed-test.aoeu.eu

Go for it and post results, lads.
>>
>>59967908
It's not much for normal text. Around 60.
But typing out an URL you've typed a hundred times isn't hard.
>>
File: wew lad.png (59KB, 604x533px) Image search: [Google]
wew lad.png
59KB, 604x533px
>>59967908
>>
>>59967921
Well, that's what I'm curious about - how fast is that anon who uses his mouse to click /g/? I figure he'd have an abysmal speed for typing.
>>
File: speed.png (53KB, 726x438px) Image search: [Google]
speed.png
53KB, 726x438px
>>59967908
>>
>>59967889
Don't use a moment.utc(), you specifically do NOT want UTC.
>>
File: out.webm (687KB, 1086x470px) Image search: [Google]
out.webm
687KB, 1086x470px
>>59967908
>>
>>59968054
id do a recording but my laptop can barely handle rendering webpages lmao
also, i notice the same slowdowns that i get in your typing too, which is fairly interesting. i wonder if that happens with most typists in the same way
>>
File: ss+(2015-07-24+at+04.49.13).png (33KB, 693x547px) Image search: [Google]
ss+(2015-07-24+at+04.49.13).png
33KB, 693x547px
>>59967908
That site refuses to load for me for whatever reason, so have an old screenshot instead. I doubt I've changed much since then anyway. Although in real world scenarios I'm probably a fair bit slower.
>>
>>59968126
typing quotes from a book creates an inflated wpm because you can read the words and jam them out non-realtime (i.e. taking a gander before starting)

having random words pop up at you that are used commonly (the website that you cant load) is a very standard way to measure typing speed with general concise and simple use case scenario
>>
>>59968141
Yeah I've done it on other sites that use random words before and I get closer to 125-135, that's the only screenshot I have on hand though.
>>
>>59967739
I mean this , thanks, I was wondering why the function could'nt read the input, forgot the parenthesis

>>59967745
it's solved, but thanks anyway, heres what i was doing:
leftorr :: (Show a , Show b ) => Either a b  -> String
leftorr (Left x) = "You have entered Left value: " ++ show x
leftorr (Right x) = "You have entered Right value: " ++ show x


i was missing the parenthesis beside leftorr
>>
Should I waste my life on IT and learning how to programm if quantum computers will destroy everything soon? Codemonkeys will lose their jobs, information security and cryptograhy sphere is goint to be destroyed. Scary.
>>
>>59968234
You wouldn't bother to learn how to program even if quantum computers weren't going to be a thing, stop kidding yourself.
>>
>>59967971
You quoted the wrong guy, how should I set it up then?
>>
>>59968234
Excuses anon. It doesn't matter for most of us because we will need to program quantum computers too. Unless they're too unworkable which makes classical computing still relevant.
>>
File: output2.webm (3MB, 1028x574px) Image search: [Google]
output2.webm
3MB, 1028x574px
>>59968141
>>59968152
Took me forever to get this under 3MB, was still using an ancient version of ffmpeg
https://10fastfingers.com/typing-test/english
>>
>>59964186
print(("4+2={}".format(4|2))
print(("8+1={}".format(8|1))
print(("16+32={}".format(16|32))
>>
>>59968496
Trash.
>>
>be me
>at interview
>get asked how to check if a string is an integer or float
>go on whiteboard
>write method that searches for a dot in a string (that way he know it was a float)
>never heard from them again

is there a better way to do this?
>>
>>59968496
Made you a function :^)
def add(a, b):
print((str(a)+"+"+str(b)+"={}".format(int(a)|int(b))))
>>
I'm trying to build an app or a program but I don't know what to do now:
the goal is to build a simple website with dashboard on my localhost (got front-end part down, no problem here)
now I want to write a script (I guess php) that downloads emails from my gmail and shows ones with chosen email subject (i.e. work)
I made google api quickstart, put it on localhost
now what shoud I do?
I want simple script that returns php variable with email with mentioned mail subject. rest I can do on my own
I also tried using imap but it doesn't work
I know some coding, simple programs but never did more complex project than simple php cms
>>
>be me
>at interview
>write a red black tree
>"o-on a whiteboard?"
>"wtf no, you can use this laptop"
wew lads
>>
Can anyone resurrect /wdg/
>>
File: python is stupid.jpg (17KB, 798x91px) Image search: [Google]
python is stupid.jpg
17KB, 798x91px
>>59968624
Cause im cool, pic related to show it works :p
>>
>>59968668
I have to try this, memesnek is unreal
>>
>>59968668
add = lambda a,b: print("%s+%s=%s")%(a,b,int(a)|int(b))
>>
>>59968668
>4|20=20
>>
>>59968687
What's unreal about it? Did you seriously take that bait?
>>
>>59968649
>be black
>write a red black tree
Wow, racist.
>>
>>59968760
>>be black
no thanks
>>
>>59968623
yes, certainly, 2 is an int and not the float of 2

perhaps learn more basic skills in c before trying to advance
or was it python? haha
>>
File: 1459487588767.jpg (78KB, 340x314px) Image search: [Google]
1459487588767.jpg
78KB, 340x314px
>>59968750
Everything about Python is unreal, the fact that this could even work is plausible and therefore innately hilarious.
>>
>>59968623
pssssh, I got methods for this for DAYS

static (int?, float?) IsIntegerOrFloat(string input) => int.TryParse(input, out var intValue) ? (intValue, null) : float.TryParse(input, out var floatValue) ? ((int?)null, (float?)floatValue) : (null, null);
>>
>>59968786
It also works in C :^).
https://ideone.com/8ssAte
>>
>>59967515
The website you're browsing right now is impossible without IO.
>>
>>59968795
i was supposed to do this is C, but thanks anyways
>>
File: anal beads.png (3KB, 189x103px) Image search: [Google]
anal beads.png
3KB, 189x103px
>>59968816
You are responding to a bit of a joke.

I mean, it technically works in a way, but that is NOT the way you'd really go about doing things.
>>
New thread:
>>59968831
>>59968831
>>59968831
>>
>>59968801
Ass ate
Thread posts: 313
Thread images: 40


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.