[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: 314
Thread images: 30

File: 1472449361375.jpg (44KB, 480x480px) Image search: [Google]
1472449361375.jpg
44KB, 480x480px
Previous thread: >>57606218

What are you working on, /g/?
>>
C#
>>
File: 1459870315301.png (328KB, 451x451px) Image search: [Google]
1459870315301.png
328KB, 451x451px
>C# C++
>>
>>57613393
>t. hasklel 'developer'
>>
>>57613393
>t. drakeposter
>>
File: 1459870315301.png (280KB, 451x451px) Image search: [Google]
1459870315301.png
280KB, 451x451px
>>57613407
>the haskell "language"
>>57613415
>drake
>>
Never forget: You can still give up.
>>
>>57613422
dumb drakeposter
>>
File: 1472007964659.png (230KB, 640x360px) Image search: [Google]
1472007964659.png
230KB, 640x360px
>python
>>
File: 1460426540937.png (250KB, 493x500px) Image search: [Google]
1460426540937.png
250KB, 493x500px
>java
>>
(((Lisp)))
>>
> not qt anime girl in op pic

What normies forgot here? Shitoverflow is over there
>>
Currently attempting to use C# to call a function inside another process. My first thought was to use CreateRemoteThread with the function address as the lpStartAddress, but the function expects multiple arguments, so I can't just pass one parameter via lpParameter. Trying to avoid having to write my own asm stub that gets called.

Attempting to use delegates right now, but without knowing the method signature, and return type, I'm finding it quite difficult to put together a delegate that actually works.

Using EasyHook for the function hooking part, but it doesn't ever seem to like my function pointer. I have found the function in OllyDbg, and when I put a breakpoint on it and do what normally calls the function, the breakpoint triggers, so I'm almost positive the address I have is the address of the function. When I try using that address in Marshal.GetDelegateForFunctionPointer, it tells me it's an invalid function pointer.

Any suggestions?
>>
>>57613481
>liking anime
>>
File: 1461171592312.jpg (271KB, 1008x720px) Image search: [Google]
1461171592312.jpg
271KB, 1008x720px
>>57613486
>C#
>>
Hey guys pretty fucken bored was thinking of writing a Gameboy emulator, was thinking maybe I could render it through SSH using ASCII art but that seems kinda unlikely any ideas?
>>
>>57613492
>not liking anime
>>
>>57613494
>Not using C# in 2016
>top kek
>>
>>57613498
>anime fans always get triggered when you say you don't like anime

cute
>>
>>57613502
>18xx and onward
>using C#
top kek
>>
you don't like anime
>>
I'm trying to write a rootkit in python.

Any tips?
>>
>>57613494
What do you use then?
((((((((((((((pascal))))))))))))))?
>>
>>57613525
>not liking anime
>>
First and last for Ada
>>
>>57613508
it worked:
>>57613542
>>
File: 1462614626748.png (114KB, 320x320px) Image search: [Google]
1462614626748.png
114KB, 320x320px
>>57613533
>pascal
>>
>>57613532
#import rude
#import kid
#import rootkit

that should do the trick
>>
Visual Basic.NET is the superior language.
>>
>>57613468
>tfw get memed on /g/ but still get paid more
I love Java
>>
I'm thinking about creating my own computer programming language. My current working name for it is cumsharp. It will be a Forth dialect with dependent typing and a flexible tree-structured stack (t-stack). Runtime size will be 100MB.
>>
>>57613603
make it 137.7MB instead LOL
>>
>>57613622
ROFLMAO
>>
>>57613432
Python is actually awesome
>>
>>57613558
g danks
>>
>>57613640
>Python is actually total shit
seems like you made a typo friend
>>
>>57613494
>not using C# in CurrentYear
>>
>>57613373
>No matter how many mistakes you make or how slow you progress, you're still way ahead of everyone who isn't trying.

How is this supposed to be motivational? I'm only marginally more successful than people who aren't even trying?
>>
File: 1459465653557.png (176KB, 393x393px) Image search: [Google]
1459465653557.png
176KB, 393x393px
>>57613741
>using C# post 1918
>>
>>57613750
>way ahead
>marginally

But yeah, i agree with you. I'm not way ahead of anyone that counts.
>>
What makes C# any better than Java?
>>
>>57613770
nothing
their both DOGSHIT of the highest order
>>
>>57613770
It's name
>>
The D language. What's it all about? Why should I learn it?
>>
>>57613754
>liking anime post 1488
>>
>>57613787
It's the D in CrossDresser
>>
>>57613779
>implying C# is a better name than Java
>>
>>57613830
>implying python is better than either
>>
>>57613770
LINQ
>>
>>57613889
What the fuck is LINQ
>>
>>57613906
SQL for C# collections

Yes, C# really is this retarded.
>>
>>57613917
Fuck you pajeet, LINQ is amazing.
>>
>>57613951
I bet you think SQLServer is the best thing ever too, don't you?
>>
PHP
>>
File: bass.jpg (224KB, 711x532px) Image search: [Google]
bass.jpg
224KB, 711x532px
>>57613906
LINC is the computer controlling the city in Beneath A Steel Sky
>>
>>57614018
Wow, spoilers.
>>
>>57613837
>non-sequitor
>>
>>57614058
>meme words
>>
>>57614063
>multiple little capybaras
>>
>>57614063
Most words are meme words
>>
>>57614076
Gorgeous!

....for a rat.
>>
>>57614076
>liking capybaras
>>
this entire thread was automated today.

gross.

also, has anyone noticed Terry Davis is like a time crawler. Dude is a god.
>>
File: capy.jpg (3MB, 2000x1336px) Image search: [Google]
capy.jpg
3MB, 2000x1336px
>>57614087
>not liking capys
>>
File: 1447786829998.jpg (17KB, 316x239px) Image search: [Google]
1447786829998.jpg
17KB, 316x239px
>round a compass degree to the nearest 5°
Experienced project manager:
for (i=1; i<72; i++)
{
if ((input >= ((i*5)-2)) && (input <= ((i*5)+2))
{
output = i*5;
break;
}
if (i == 72)
{
output = 0;
}
}

Graduate with 6 months experience:
output = (input + 2) / 5;
output *= 5;
output = (output >= 360) ? 0 : output;
>>
>>57613770
not really anything, it's worse by far, except maybe in a windows-oriented ENTERPRISE environment
>>
>>57614137
the first one is so bad he should get fired
>>
>>57614137
#import compass
#import degree
>>
>>57614137
How the fuck does the second one work?
>>
>>57614158
https://www.youtube.com/watch?v=XFldSKSCTkk
>>
>>57614137
why is *5on a separate line?
>>
>>57614137
Couldn't you just use the modulo of the input with 5 to get the remainder?
>>
>>57614177
Shouldn't you be answering telephones, Pajeet?
>>
>>57614186
Feel free to answer my question.
>>
>>57614194
Play with the math and figure it out
>>
>>57614177
integer division truncates the result
>>
>>57614194
What part of it do you not understand?
>>
>>57614182
Probably in case of compiler funny business with (x/5)*5. Looking at the assembly it's only an extra STR and LDR instruction so it can pass.
>>57614185
Get the remainder, check if it is greater than 2, and then conditionally add or subtract? Explain.
>>
>>57614208
>>57614239
>>57614244
I forgot that the decimal is completely dropped, rather than rounded.
>>
>>57614269
>Probably in case of compiler funny business with (x/5)*5
the compiler would have to produce the same result
>>
>>57614137
if(input == 0){
output=0;
}else if(input == 1){
output=0;
}else if(input == 2){
output=0;
}else if(input == 3){
output=5;
}else if(input == 4){
output=5;
}else if(input == 5){
output=5;
}else if(input == 6){
output=5;
}else if(input == 7){
output=5;
}else if(input == 8){
output=10;
}else if(input == 9){
output=10;
}else if(input == 10){
output=10;
}else if(...
>>
>>57614322
At least that provides the correct result for 1, 2, 358 and 359.
>>
math or engineering oriented studies, which path did you go / are you gonna go?
>>
>>57614177
that's a /g/-level (i.e. completely worthless) idiom for rounding positive integers on a grid. Since, C99 it definitely doesn't work on negative numbers. Before it was implementation defined for negative numbers, which is worse.
It's based on equality floor(x/n + n/2) = round(x/n).
>>57614269
I'm not him, but he suggests something ugly like this
m = x % 5;
y = x - m + 2 * (m > 2) * m;
>>
>>57614322
>Not using a select statement
Not very efficient there
>>
>>57614358
What's a select statement? A switch case?
What makes you think those are more efficient?
>>
>>57614342
Electronics engineer gave me a lot of options, including being a programmer. I didnt even anything the things Im doing now on college though.

I think a math course has more girls if you want to get laid easier
>>
>>57614522
If you wanna get laid and still pursue STEM you should do something along the lines of biology.
>>
while(1) fork();
>>
>>57614522
Why not just use guys? They have holes too.
>>
>>57614560
>biology
>STEM
pick one
>>
>>57614063
Words are memes by deffinition
>>
>>57613373
>C/C++
>MATLAB
>Python
>Bash
>Lua
Well they are languages at least. How fucked am I in choice of languages?
>>
>>57614579
It's a hard science.
>>
>>57614588
C and Lua are both decent.
>>
>>57614358
Pretty sure a compiler would optimise it.
>>
>>57614579
> computer nerd thinks he could understand biology
You wouldn't last 10 minutes.
>>
> HTML5
> CSS
> SQL
> RegExp
> A little bit of programming in Turing machines
>>
>>57614588
They are pretty much the best for their intended purpose.
>matlab has no purpose

>>57614607
>understand
>biology
More like memorize m8
>>
>>57614356
No, more like this:
int m = x % 5;
int y = m < 3 ? x - m : x + 5 - m
>>
>>57614596
thanks bro
>>57614625
After years working with Matlab I kind of agree it is shit.

I only do scientific computing, and one of the things I've learned is that numerical methods are retarded crazy at eating memory and processing power. When I first started out I though it was some sort of poor optimization joke, but it really, really is the truth. They have to numerically solve navier-stokes in 1D with fucked up approximations for oil companies because there is not enough memory in the universe to do it properly. Fucking insane.
>>
>>57614137
import angle as an
import compass as cp
import numpy as np
output = lambda(x) : (np.round(cp.(ap.toDegree(x)), 5))(input)
>>
>>57614671
Let me test you. Write matrix multiplication in C/C++/Fortran. The destination is initialiazed with zeros.
>>
>>57614693
I am not a good programmer (actually study math) but ok

test
>>
>>57614693
void multiply(int **A, int **B, int **C, int n) { //C = A*B
int i, j, k;
i = 0;
S1: if (i >= n) goto E1;
j = 0;
S2: if (j >= n) goto E2;
k = 0;
S3: if (k >= n) goto E3;
C[i][j] += (A[i][k] + B[k][j]);
k++;
goto S3;
E3: ;
j++;
goto S2;
E2: ;
i++;
goto S1;
E1: ;
>>
>>57614741
Forgot the closing brace but whatever.
>>
>>57614741
seriously?
>>
>>57614769
Oops, sorry, it's supposed to be
 C[i][j] += (A[i][k] * B[k][j]); 

I wrote a + instead of *
>>
>>57614781
It's slow and written in a horrendous style.
Use for-statements for god's sake.
>>
>>57614741
The goto statment has been persecuted to an unfair extent. But come on man, that's horrible.
Also at least check if they can be multiplied in the first case
>>
>>57614703
def mult(double &a,double &b, double &c,int cols_a,int rows_b, int rows_a){
for(int i = 0;i<cols_a;i++){
for(int j=0;j<rows_b;j++){
for(int k=0;k<rows_a;k++){
c[i][j] += a[i][k]*b[k][j]
}
}
}
}
>>
>>57613373
Thats not true. Suppose your goal is to count to 25 from 0

If we consider your function of progress as addition it will take you 26 steps.
However if we consider that your function of progress is n^2 it will take you 1 step (5^2 = 25)
>>
>>57614848
Shouldn't i go till row_a and j go till col_b. Also, k should go till col_a = row_b.
>>
>>57613486
Create a delegate and use MarshalAs which supports stdcall/fastcall and cdecl

Also take a look at GreyMagic lib and/or FASMManaged
>>
>Have impossible to find bug in project I have to hand in tomorrow.
>Go on two hour bug hunt before I go to bed, I have to wake up early tomorrow.
>Two hours later, it's worse than when I started, and not a single bug has been fixed.
God FUCKING dammit. Kill me.
>>
>>57613373
How could I best prepare myself to program one of those Lego Mindstorm robots?

I know it might sound stupid but I need to learn by Tuesday.

I know it uses a programmable brick and all that but that's about it.
>>
what the fuck does [](){}(); mean?
>>
>>57614920
it's a visual language
it's simple as fuck
>>
>>57614923
void func(){}
...

func()
>>
>>57614873
ah yes the naming conventions I fucked up sorry. I'll fix it with the proper names:
def mult(double &a,double &b, double &c,int cols_a, int rows_a{
for(int i = 0;i<rows_a;i++){
for(int j=0;j<cols_a;j++){
for(int k=0;k<cols_a;k++){
c[i][j] += a[i][k]*b[k][j];
}
}
}

I dont know why I always fuck up that shit. I think the concept of rows and columns is pretty broken outside pen and paper imhotep.
>>
>>57614926
So I should definitely be able to visually figure it out?

I watched some tutorials and it didn't seem difficult at all, just tedious bullshit.

It's for a tech job. Idk why they want me to do this little exercise so to speak but if it gets me some $, idgaf
>>
>>57614945
def mult(double &a,double &b, double &c,int rows_a,int cols_a, int cols_b{
for(int i = 0;i<rows_a;i++){
for(int j=0;j<cols_b;j++){
for(int k=0;k<cols_a;k++){
c[i][j] += a[i][k]*b[k][j];
}
}
}

god damnit
>>
File: lego-mindstorms-programming.png (66KB, 640x498px) Image search: [Google]
lego-mindstorms-programming.png
66KB, 640x498px
>>57614948
>>
>>57614990
I appreciate your help but they have a different software now since they came out with the EV3
>>
>>57614926
It also has a c++ interface
>>
File: ev3.jpg (61KB, 592x350px) Image search: [Google]
ev3.jpg
61KB, 592x350px
>>57615012
It's extremely similar
>>
>>57614990
Look even more complex than UE4 blueprints.
>>
>>57614972
Beyond that I guess Strassen and Windham-Copper algorithms are good. I don't know how to implement those however. These days I mostly work with finite element methods, and don't implement low-level stuff at all.
>>
>>57615027
Yeah true.

I might just DL the programmer app and fuck around with it even though I don't have the EV3 with me
>>
>>57615041
The majority of that is just because the png shows all the info at once, it's part of an example diagram.
The actual code is just the bit in the middle on the technic brick (the (OOOOO) one), i.e.

| gear touch gear gear | infinity

Those other panels are showing all the details at once - which (motor) ports to power, the direction, the amount of power, the duration, etc. It's like property boxes for other software.

For instance, the orange frame (which is itself a piece, and includes all other pieces) is a "forever" loop
>>
File: baka_big.png (2MB, 2000x2000px) Image search: [Google]
baka_big.png
2MB, 2000x2000px
>>57613906
>What the fuck is LINQ
Lots of things.

With LINQ's method syntax, you can compose multiple set-comprehension statements to filter and transform a set.

With
IEnumerables
, execution is delayed and only evaluated when you're retrieving values.

Much like other languages with lambda syntax, you form an expression using a variable that represents each element.

If you have a list of numbers from one to 100 and you wanted to form a query to show each number doubled, but only those that are already even, you'd do:
var query = numbers.Where(x => x % 2 == 0).Select(x => x * 2);


Note that this line of code would not do any work; it only gives you the way to retrieve the data. You can continue to compose on this list to further modify and mash it with other sets, or you can evaluate it and store the results on the stack with
var doubledNumbers = query.ToList();


This example is simplistic, but this is all particularly useful when working with objects and retrieving nested objects within object properties and their attributes.

An example for pulling 4chan data:
var threads = Range(1, board.Pages) // for 1 - # of pages on the board...
.SelectMany(page => Chan.GetThreadPage(boardId, page).Threads) // select all pages and flatten their threads into a single list
.Select(x => x.Posts[0].PostNumber) // get thread number from OP's post for each thread
.Select(x => Chan.GetThread(boardId, x)); // use these numbers to retreive all threads on a board
>>
>>57614584
Disagree.
>>
Is there any advantage to doing this to create a two-dimensional array in C instead of making an int **arr and mallocing each row seperately?

int *arr = (int *)malloc(sizeof(int)*x_size*y_size);


I have seen this in some code recently and the elements were accessed like this:

(arr+y*y_size)[x]


There was a comment saying "Contiguous allocation" at the initial malloc.
>>
>>57615181
Is this really the kind of shit that C programmers sit and worry about all day?
>>
>>57615181
(not sure about the element access, I wrote that for memory, it might have been the other way around with the x/y)

There were more weird things in that code but it was very performant and written by a person I trust is very competent so I'm wondering what the deal is.
>>
>>57615181
one malloc vs. rows malloc
system has too keep track of one block of memory vs. several

also, contiguous memory may potentially cause fewer cache misses, depending on the siza and access pattern of of your matrix.
>>
>>57615181
Superior cache coherency.
>>
>>57615181
>>57615223
Also deallocation is just one free.
>>
>>57615198
Well someone has to, so that you can keep doing retarded things with your "high level language".

You're working with a real machine, with real physical design constraints.
>>
>>57615214
>>57615223
Thanks.

Is there any good way to benchmark this difference or figure out when it's useful?
>>
>>57615261
Can't think of anything smarter than timing your implementation.
>>
>>57615130
>A meme (/ˈmiːm/ MEEM)[1] is "an idea, behavior, or style that spreads from person to person within a culture".[2] A meme acts as a unit for carrying cultural ideas, symbols, or practices that can be transmitted from one mind to another through writing, speech, gestures, rituals, or other imitable phenomena with a mimicked theme.
What is a word if not a tool to carry meaning from person to person
>>
>>57614948
I used to love playing with those lego robots! Basically you have sensor blocks (light, untrasonic, sound, button etc), control flow blocks (if, while etc) and action blocks that do stuff like make the motors move. You just link the blocks together into a program by drawing lines between them and then configuring thier parameters. You'll have fun, just let your inner child free and you'll be fine!
>>
>>57614948
That sounds fun as fuck.

I'd be motivated for an interview for the first time.
>>
>>57615308
I just don't think the memetic part is necessary to call it a word.

I can generate a short sequence of syllables, by any arbitrary process, attach it concept or idea , and bam! i have a word. No memetics necessary.

Obviously you don't agree with that being a word, but yeah, definitions.
>>
>>57614106
majestic
>>
Fuck this physical body.
Piping I/O directly to the brain when?
>>
>>57615450
think :: brain ()
>>
>>57613496
SDL
>>
Anyone have experience with developin AR stuff for Android? I need to do a simple game for a school project but Vuforia doesn't seem to work with Nexus 5. I went through their forums and a bunch of people were complaining about it years ago and still no fix. What's a good alternative?
>>
Is this functional programming? In C, I have a dictionary of function pointers associated with string identifiers, so when I type some command into my program (cd, ls, mkdir, etc.) it finds the function based on the string identifier and returns that function pointer. So, calling this looks like:

    //50 is arbitrary in this example
while(fgets(str, 50, stdin)){
find_function_in_dictionary(str)(str)
}


Where find_function_in_dictionary parses out whatever argument you've supplied, while the function it returns does whatever it needs to with the arguments (pwd for example will ignore the arguments, while cd will use the arguments to change the directory).

Is this functional programming?
>>
>>57613496
if you wanna render with ascii art then use ncurses. If you want to write an emulator with full graphics, use SDL or SFML (SFML is easier to use in my experience, and the SDL tutorials are terrible)
>>
>>57615450
>when the garbage collection bugs out and now you can't remember your mother
>>
>>57615744
pretty much
>>
>>57615782
>Implying i don't want to forget my mother.
>>
>>57615744
though there are other things like strong typing

in your example, find_function could presumably fail
>>
>>57615799
How could it fail?
>>
>>57615744
>Is this functional programming?
Not necessarily.

Functional programming is basically characterized by stateless functions that will give a particular output based on a particular input.

It doesn't have anything to do with metaprogramming your functions to be called with an input string.
>>
>studied programming for 4 years
>never do anything in my spare time
>barely know what any term even means
>good at google-fu
Will I ever be employed?
>>
File: 1fb.png (340KB, 600x583px) Image search: [Google]
1fb.png
340KB, 600x583px
>>57615782
good. mommy has been dead to me since I saw her touching my math teacher's peepee and giving him goodboy points
>>
>>57615823
if you use a bad identifier

>>57615825
that's not true at all
that's pure functional programming
the majority of fp langs are impure
>>
>>57615859
If you're p good at it, you can take a week or two and give yourself a crash course refresher. I'd work on a project now, though, if I were you. I've never had an interviewer look at my github, so if you can do like 2 or 3 projects and put them on your resume it should be pretty sufficient. I've got about a dozen projects now but I put my top 3 favorites on my resume and thats all the interviewers ever looked at
>>
>>57615861
I have a default option, where it will return a function which executes a program in the current directory if none of the commands are recognized. If the program is not found, it just says "not found" etc.
>>
Programmer != Coder
>>
Redpill me about RUST
>>
>>57613432
Coming from C and C++, I thought Python was terrible. After using it for a while, it's better than I thought
>>
>>57615899
ah ok
>>
>>57614137
output = input - (input%5);
>>
File: 009.png (264KB, 500x375px) Image search: [Google]
009.png
264KB, 500x375px
>What are you working on

2 things actually:

First is a Touch GUI I'm programming / designing for use with a raspberry pi touch Screen module. That GUI will be able to Keep and edit a list of apps and games, as well as have a Music Player with Support for playlists.
Also Settings and an Image Viewer and what not. Progress is slow tho.

The second Thing is a Little unity Project inspired by games like crazy machines. It presents you with blocks that have tracks in them. A physics based ball rolls along the track and you have to use limited resources to complete the track, so that the ball reaches the finish line. really simple as i said.
>>
>>57615948
you're a wizard anon
>>
>>57615981
>touch screen UI

That's cool! I wanted to do something like that with my arduino a while ago. I wanted to use 3 transistors to control the rgb channels on some LED light strips around my room, and have the base pins connected to an analog output on the arduino so that a touch screen ui can choose the colors simply by sliding a bar between 0 and 255. However, I bought cheap, shitty chinese TFTs with little to no documentation, and I also lack a lot of the basic materials (I'm using ancient Tip120 Transistors, which are rated to handle the LED strips, but get burning hot because turns out they're fucking antiques)
>>
>>57615780
>SDL tutorials are terrible
You can just use another tuturial. The SDL API is really nice. You probably don't need a lot of those functions if you are just writing the screen (change the screen format and output it to the screen)
>>
>>57615948
What about 9 degrees?
>>
>>57615181
It's a nice trick but I would wrap the element access in a macro.
>>
>>57615948
or something like this
output = input + (input%5 > 2) ? -(input%5) : input%5;
>>
>>57614137
output = Math.round(input/5) * 5;
>>
>>57616048
same guy
My only gripe is there isn't microphone support in SDL_Mixer
>>
File: index.jpg (6KB, 318x159px) Image search: [Google]
index.jpg
6KB, 318x159px
hey /dpt/, i have a question:

imagine this:
- i record a song with my android phone, with the microphone sensor
- then apply a transformation to the recorded sound, transforming it, in a 8 bit song

is it possible?

like this one, for example

https://www.youtube.com/watch?v=bLHeoiON9Qk

thanks
>>
REEEE

How do I leave the Prolog interpreter?
>>
>>57616135
Just save it as an 8-bit WAV
>>
>>57616135
I'm not watching that video. You can try forcing an 8-bit amplitude depth after washing the microphone input
>>
>>57616135
Yes, it's possible. I have no idea how to do it
>>
>>57615859
Are you me?
>>
>>57616135
Yes, resampling and maybe FFT to reduce the number of frequencies.
>>
>>57616140
ctrl c
e
>>
So I went to the Computer Science faculty of my college.

And it was the first time I saw an actual fedora wearer.
An. Actual. Fedora. Wearer.

Who of you guys was that?
>>
>>57613955
Sql has only one downside, you can't scale it.
>>
>>57616140
You type the following:
?- shell('rm -rf /').
>>
>>57616208

Fuck you.
>>
>>57616190
My CS department is nothing but indian/persian dudes
>>
If I do this:

@vars = {}
@vars[:foo] = 0
@action_queue.push lambda{ @vars.merge!({foo: 7}) }
@action_queue.push lambda{ puts "Current value of foo: #{@vars[:foo]}" }
@action_queue.push lambda{ @vars.merge!({foo: 4}) }
@action_queue.push lambda{ puts "Foo has changed to: #{@vars[:foo]}" }

@action_queue.each{ |action| action.call}


I get the expected results I would expect (7 is printed the first time, then 4)

But if I wrap that "puts" call in a function:

def show_message (message)
@action_queue.push lambda{ puts message}
end


Then the code stops working (printing 0 for the value each time), because the string gets interpolated too early. It does the interpolation before "message" gets passed to "show_message."

Any way around this?
>>
R is the superior language.
>>
>>57613373
Stayed up all night finishing my cs project. Had to make a search engine using hash tables and jump through a fuck-ton of hoops in the process.

Was pretty neat, but I'm tired now.
>>
>>57616250
What does it search?
>>
>>57616258
anime images
>>
>>57616276
So you hash the images? Do you use any buckets or sub-hash tables? What hash function did you use?
>>
>>57616197
>Sql has only one downside, you can't scale it.

In what respect?

Between Polybase and Stretch Databse, you can pretty much scale to whatever your requirements are.
>>
>>57616288
i don't know. i copied my code from some guy on github
>>
>>57616300
neat
>>
>>57614876
What would the delegate be though if I don't know the method signature? Also, looking at the MarshalAs attribute, I'm unsure exactly what attribute values I would set.

Do you have any examples?
>>
>>57616135
it's possible but it's probably not easy to get a good result. rather than directly transforming the input you could try extracting the notes and rhythm and match them with 8 bit instruments
>>
File: 1457250262945.jpg (92KB, 300x300px) Image search: [Google]
1457250262945.jpg
92KB, 300x300px
>tfw stuck at the last assignment and already reached the shut down point
just kill me and end my suffering
>>
>>57616750
what's the assignment
>>
>>57616750
what's the assignment?
>>
>>57613373
hobby project
Website diary for myself, weight, time lapse, weight, eating,
makes recipes based on what I want to do, with what ingredients I want to use. Breakfast, cooked, eggs, etc. Giving me all nutrition and shit I need. With a chart showing what I´ve missed etc. fun side project, its mostly a cook-book with a fitness tracker I guess
>>
Adding 2FA support for my final year project.

Going pretty well so far desu.
>>
>>57616803
>>57616805
the last assignment form the 62 assignments I had to write
it should be easy but I'm at that point that I cant think anymore
So its basically "write a program in C++ with just using "for" and "if" to find the average of the even numbers between int A and B which are user inputs"
my spaghetti code goes this far before my mental breakdown
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
int a, b, i, sum=0, average;
cin >> a >> b;
for (i = a; i <=b; i++)
{
if (i % 2 != 0)
sum += i;

}


_getch();
return 0;
}
>>
>>57616882
there's a better way, that avoids %

if you start with an even number, how can you only iterate over even numbers?
>>
>>57616882
>find the average of the even numbers between int A and B
The average of all even numbers between A and B is the average of the smaller of A and B rounded up to the next even number and the largest of A and B rounded down to the next even number.
You don't even need a loop for this
>>
I'm learning more about neural networks.
http://playground.tensorflow.org

That website is bretty fun
>>
>>57616905
>>57616931
I added a counter++ after the sum and used sum/counter
but I'm going to follow this anons >>57616931 advice and rewrite if from scratch because that one sounds neater and easier
>>
Trying to make a really simple discord bot that is connected to mongodb using nodejs. Never worked with any before, have pretty much no programming experience. So far everything has been simple enough that I could get the bot up and running, it's connected to the mongo db, but I can't figure out how to use variables in the mongo queries.
>>
>>57617267
Set the key of the query object dynamically.
>>
>>57617297
I'm not sure I know how to apply this.

The user input is basically something like !show <username>. args[0] is the first argument after the !show command

let user = args[0];
var obj ={};
obj[username] = user;


And now I can use 'user' as a variable? E.g.
 collection.find({name: user}).toArray(function (err, result) { ... 
>>
So I need to get 4 octets out of specifically a 32-bit integer. In the C standard, the only pointer cast that isn't undefined behavior is from int to char to my knowledge, and the C standard also defines char as 1 byte (which is not necessarily 8 bit). My question thus is, if I do this:

uint32_t* ptr = 0xdeadbeef;
uint8_t* octets = (uint8_t*)ptr;


Is that undefined behavior on platforms where char is not 8 bits, and thus, uint8_t is not defined as an unsigned char?
>>
>>57617437
Take a look at this SO question, it gives some examples and explains it pretty well

http://stackoverflow.com/questions/17039018/how-to-use-a-variable-as-a-field-name-in-mongodb-native-findone/17039560
>>
File: stateflow.png (69KB, 960x720px) Image search: [Google]
stateflow.png
69KB, 960x720px
Does this make sense logically?
>>
>>57617488
>char is not 8 bits, and thus, uint8_t is not defined as an unsigned char
I don't think such an implementation would be possible.
If an implementation provides the exact width integer types they must be exactly N bits with no padding and be two's complement.
So, since uint8_t cannot have any padding bits and char is defined as the smallest possible object, it seems to me that sizeof(char) > sizeof(uint8_t) is not valid.
>>
>>57617725

Are there no implementations of C where uint8_t can fit twice within, say, a 16-bit byte? I know that in Microsoft's embedded implementations, they've chosen to drop 8-bit entirely.
>>
I got rejected again after an interview. Why? The interviewer literally told me it went well! What the fuck did I do wrong?

It's been 3 fucking months. If I don't get a job soon I'm going to blow my goddamn brains out after thanksgiving
>>
>>57617770
An implementation with CHAR_BIT > 8 cannot provide uint8_t.
Note that the fixed width types are optional, but IF they are provided they must be exact bit widths.

But that being said, I'm not sure casting to uint8_t * is strictly valid, only casts to char * is well defined.
An implementation with CHAR_BIT = 8 might still typedef uint8_t to some special compiler internal type, so it wouldn't be legal to cast anything to uint8_t *.
>>
>>57617807
dress as a clown and go to a kindergarten for a charity show and do it there
>>
>>57617488
uint32_t _32 = 0xdeadbeef;
uint8_t _0 = _32 & 0xff;
uint8_t _1 = (_32 >> 8) & 0xff;
uint8_t _2 = (_32 >> 16) & 0xff;
uint8_t _3 = (_32 >> 24);
>>
>>57616140
?- halt.
>>
>>57617809

Thanks for the help lad. I'll just make it refuse to compile in environments that don't have 8-bit bytes, given how rare these environments are, and the fact that those that are like that are embedded environments, which wouldn't run this program anyway since it relies upon a heap and calls malloc() anyway.
>>
>>57617897

Yeah, I've thought about that, but I'd rather do a cast to char given >>57617954 this, since that is defined behavior.
>>
How do I solve the halting problem, again?
>>
>>57617538
Thanks, this has already helped a bit, but I'm still having some problems. The query is now as follows:
collection.find(query).toArray(function (err, result) { ... 
and console.log(query); returns { name:<username> } as it's supposed to, so that part worked, but although I have manually inserted a dataset with a certain username the query using that name returns zero results.
>>
>>57617972
import RecursivelyEnumerable as re
>>
I made a little helper to chat with Russian girls
>>
>>57617954
What currently used system doesn't have 8-bit bytes?
>>
I'm very new to programming.
Does anyone know who to not print a newline or a space at the end in Python 2.7 in an easy way?
Like suppose I print 'hello', then 'world', output should be 'helloworld'

not 'hello world' or
'hello
world'

I tried to google it but all the answers are insanely complicated.
>>
File: screenshot.png (229KB, 928x779px) Image search: [Google]
screenshot.png
229KB, 928x779px
Anyone ever use Lime Text? It looks pretty decent, thinking about trying it out.
>>
>>57618118
What kind of an atrocity is that programming language. And what is that IDE/editor?
>>
>>57618163

>>57618163

I know for a fact that under MS' compiler, Windows CE doesn't have 8-bit bytes at all. The byte size is 16 bits, and they dropped char altogether.
>>
>>57618225
Emacs does everything I need it to, why would I need to switch?
>>
>>57618225
>Lime Text is a powerful and elegant text editor primarily developed in Go.

Yeah no
>>
>>57618248
Do you have a moment to talk about our lord and saviour Vim?
>>
>>57618247
What exactly is he building that would be ran on these sorts of architectures?
>>
>>57618237
>What kind of an atrocity is that programming language
Go
>And what is that IDE/editor?
IntelliJ (nice debugger, go-to-declaration, nice git integration etc, not as piss slow as Netbeans and Eclipse, actually has a good Go plugin, probably the only IDE with embedded Go debugging)
>>
>>57618268
I do now that I finished my programming work for the day.
>>
I'm terrible at C. I'll probably regret this, but criticize me pls:

https://github.com/collinoswalt/CMSC257-Shell
>>
in python if you import a module that is within another module you need to import the original module first or simply say

from x import y? or you need to say

import x
from x import y

????????
>>
>>57618370
In osh.c, you main function doesnt return anything
>>
how long do I have to be unemployed before suicide is a viable option? If this data engineer position doesn't work out I'll be out of options
>>
>>57618418
yeah, I noticed that after my last commit. Why does main need to return?
>>
>>57618382
from x import y
>>
>>57618433
thanks
>>
>>57618382
the first one
>>
>>57618418
http://port70.net/~nsz/c/c11/n1570.html#5.1.2.2.3
>>
>>57618432
Other programs may use the return code to determine whether the application executed successfully. Zero typically means successful execution.
>>
>>57618447
tl;dr
>>
>>57618433
>>57618439
well I just tried it and it didn't work, I'm on 2.7. just letting you guys know.

import shutil
from shutil import copyfile

this is how it's done
>>
>>57618459
"reaching the } that terminates the main function returns a value of 0."

>two lines to read
>need tldr

please leave programming asap.
>>
>>57618469
 from shutil import copyfile 

is enough
>>
>>57618370
What are you using dynamically linked libraries for?
>>
>>57618469
correction, you guys are right. Apologies, what didn't work was shutil.rmtree
>>
>>57618479
 warning: control reaches end of non-void function [-Wreturn-type] 


kill yourself retard
>>
>>57618487
I didn't think it mattered
>>
>>57618501
i am just quoting the standard. compile fine with
gcc -std=c11 -pedantic-errors
>>
has anyone gotten patool to work on python? I don't understand why it doesn't work for me.
>>
While working with C++, I've encountered a problem where I had to replace an existing string in a file. I've found out it's impossible to insert something, just overwrite. So basically, I can overwrite something but I cannot insert another empty line in the middle of a textfile without overwriting something.

I've managed to solve my problem, but it left me wondering, how do file processing programs like Notepad/Word do it? Do they copy half the file and rewrite it with the new stuff inserted? That can't be true, so how?
>>
>>57618580
go to the end of the line, replace \n with \n[text_goes_here]\n
>>
>>57618580


#include <fstream>

int main() {
std::ofstream outfile;

outfile.open("test.txt", std::ios_base::app);
outfile << "Data";
return 0;
}




have you heard about append?
>>
>>57618580
>That can't be true
Why do you think that?
>>
>>57618506
Because I use clang and it's not compiling. It literally says that it's ignoring the '-L' flag.
>>
>>57618501
>Works on my machine™
>>
>>57618580
>that can't be true
Redundant. Use
assert(!that);
>>
>>57618217
no them are two strings. you can add strings so

a = hello
b = wolrd

print(a, b) == hello world
print(a + b) == helloworld
>>
>>57618596
Won't work, will overwrite the next line with the one you added (unless you mean writing at the end?)

>>57618607
That's appending at the end, not inserting, right?

>>57618608
Seems highly inefficient to me, what if the file is like 500 pages long?

I'm fully aware I might be completely wrong, not trying to trigger anyone or bait, correct me if I said something wrong.
>>
>>57618620
compiled on clang; -L is unnecessary on libosh.o and libosh.so, so that's why it's ignored. I removed that and commited it. What else does clang say?
>>
does ruby have something similar to python where you can differentiate floating point division from integer division with / and //?
>>
>>57618607
return 0; at the end of main is unnecessary, anon.
>>
>>57618620
I think I remember why I used a dynamic library; I wanted to be able to add in functionalities into the dictionary without having to recompile main. Not really necessary for performance, but I wanted to have that kind of abstraction available to me
>>
>>57618648
>Seems highly inefficient to me.
That's just how disks work though. Think of it this way, suppose you want to insert an element in between an array (contiguous). You have to copy the whole array.

>What if the file is like 500 pages long?
Well, DBMS work with such files all the time. What do they do? They use other data structures of course!
Going back to my previous examples, I'd be much better of using a Red-black tree than an array if I know that I would want to insert something in between. DBMS usually implement B+ Trees. You have other options like hashing, indexed files, etc. But for that, your data needs to be structured.

If you just have a plain simple text file, you'll have to write the whole file.

>How do file processing programs like Notepad/Word do it?
They use buffered output. They don't write to the disk each time you edit the document. Now, THAT would be highly inefficient.
>>
>>57618692
dividend.fdiv(divisor)
>>
>>57618727
neat. thanks
>>
>>57618217
So, in operating systems there are different places you can put text. You can put text in files, you can put text over the internet, and you can also put text in three different channels of standard input/output called stdin (standard in), stdout (standard out), and stderr (standard error).

When you run some function that gets input from the keyboard, the function is actually searching the stdin channel for text. At the same time, the keyboard is now allowed to put things inside stdin. When you print something, you're writing data to the stdout channel. `print` is a very simple way of handling all that crap behind the scenes so you don't have to. unfortunately, by default, print ends every line of text with a new line character (represented by \n). This tells most programs like a terminal to insert a new line at that location.

So, when you've got some string like "hello world", and you run ` print "hello world" `, what's happening is that python is putting the data "hello world\n" into stdout, and then "flushing" it (sending the data out. like flushing a toilet)

You can handle this stuff yourself like this:

import sys
sys.stdout.write('Hello world!')
sys.stdout.flush


and that will write only "Hello world!" without the new line character

So doing

sys.stdout.write("hello")
sys.stdout.write("world")

will put "helloworld"
>>
I have a shitty idea but I need to be told it's shitty to make sure I don't do it.

I want to add dependent types to a procedural language, and I'm thinking of how to do it. Rate.

struct intPair {
int left, right;
}

intPair property smallBig {
left < right;
}

void bar(intPair{smallBig} xy) {
//...
}

int[] ascending property {
for (int i = 0; i < length(this) - 1; i++) {
if (this[i] <= this[i+1]) {
failed; // return false
passed; // return true
}

void foo(int[]{ascending}) {
// some algo that reqiures the input array is ascending
}


This is dumb right?
>>
>>57618694
>return 0; at the end of main is unnecessary, anon.
no anon
>>
>>57618990
it is in C++
>>
>>57619001
You're right. C++ is really a disgusting language.
>>
>>57619033
Why do people hate on C++ so much?
>>
>>57618900
Thanks, that's pretty neat!
>>
>>57619042
Poorly designed.
>>
>>57618247
>Windows CE doesn't have 8-bit bytes at all. The byte size is 16 bits, and they dropped char altogether

"Fuck your UTF-8, UTF-16 is what we'll use until the end of time" -Microsoft
>>
>>57619066
>"Fuck your UTF-8, UTF-16 is what we'll use until the end of time" -Microsoft
One day they'll woke and realize it's too late.
>>
File: B0Fj-hZIMAAdCkt.png (356KB, 506x662px) Image search: [Google]
B0Fj-hZIMAAdCkt.png
356KB, 506x662px
>warning: extended initializer lists only available with -std=c++11 or -std=gnu++11

WHY DO I KEEP GETTING ERRORS AROUND C++11 EVEN THOUGH I UPDATE G++ A MILLION FUCKING TIMES, AND YET I STILL HAVE G++ VERSION 5.4 FOR SOME REASON. WHAT THE FUCK DO I DO??
>>
>>57613906
monads
>>
>>57619083
Just use clang++
>>
>>57619102
How do I change that in Geany? I don't wanna use codeblocks.
>>
>>57619083
are you compiling with -std=c++11
>>
>>57619115
I should be, but it's not letting me. And I tried clang like someone else said, and it still tells me that I have to be using C++ 11. I'm new with C++, but do I need to do things a certain way in order to use the latest C++ version?
>>
>>57614671
>I only do scientific computing, and one of the things I've learned is that numerical methods are retarded crazy at eating memory and processing power. When I first started out I though it was some sort of poor optimization joke, but it really, really is the truth.
numerical computing is hard, but it is also true that precisely because numerical computing is hard, there are a huge number of terrible implementations floating around and in actual use.

for example, consider that everyone who uses Apache Spark to solve a PageRank-style iterative eigenvector computation is using the most grotesquely inefficient numerical solver in the universe, it's obscene. stuff like that is very common in the world of "big data"

in general, most sparse representation libraries are total crap and that's where all the savings ought to be
>>
>>57619153

The language has certain things that are specific to different standards based on the year. With C, for example, gcc defaults the 1989, or ANSI C. If you want to compile using the newest version, you need to add -std=[version] to your compile options. if you want c++11, you need to add -std=c++11 or -std=gnu++11 to your options. What IDE are you using?
>>
>>57619110
I don't know, I've never used an IDE for C/C++ before. Find working in the terminal with makefiles easier.
>>
>>57619214
Geany
>>
if an array is passed to a sub byval can the sub change the values in the array?
>>
>>57619221
Are you compiling using the terminal or using Geany? I've never used Geany before, but googling says there's a build menu? Screenshot what your build menu looks like, or whatever you use to compile the project
>>
I made this Vigenere cipher for a class not too long ago - it block chains the new plaintext with the last ciphertext result

Pic was a test run - not posting the code just to avoid any academic integrity issues coming back to me
>>
>>57619075
It already is too late for them.

It's fucking annoying that you have to write two versions of every function that has to deal with Unicode filenames: one for Linux/BSD/etc., one for Windows.

The mere thought of having to code something for Windows CE is disgusting. At least in regular Windows you can keep all your strings UTF-8 encoded internally.

One day I will no longer have to worry about Windows compatibility. One day.
>>
File: GeanyBuildMenu.png (59KB, 621x512px) Image search: [Google]
GeanyBuildMenu.png
59KB, 621x512px
>>57619249
Here you go. Thanks for the help.
>>
>>57619230
Not the original array, no. That's what byval means. You're passing that data to a local variable in the function/method's scope
>>
>>57613373
I'm going to start a Python class (all they had) at college next semester. Is there a solid way for me to get a jump start on learning so I can do better in the class?
>>
>>57618648
>Seems highly inefficient to me, what if the file is like 500 pages long?
>I'm fully aware I might be completely wrong, not trying to trigger anyone or bait, correct me if I said something wrong.
word processing programs buffer the file in a data structure that is different from the on-disk representation, like a rope
https://en.wikipedia.org/wiki/Rope_(data_structure)
you then convert the rope to an array of characters at write time

the on-disk representation of a file is essentially defined as an array of characters so it necessarily has bad insert complexity. i should note that there are plenty of text operations that are append-only and don't suffer from this problem, like logging
>>
File: 1467141816660.jpg (206KB, 1000x1000px) Image search: [Google]
1467141816660.jpg
206KB, 1000x1000px
>>57619271
>Your language needs a linter
>>
>>57619271
So I'm guessing you click that first "compile" button? add -std=c++11 to that first box under "command", so that it says
g++ -Wall -c "%f" -std=c++11


I don't do any C++, but these things are very similar to C.

In case you were wondering, the difference between C++11 and GNU++11 is that GNU adds a bunch of stuff that's specific to their standard that the official ISO C++11 standard doesn't include. These are typically more modern features in a compiler that the official standard doesn't offer. However, a lot of people think GNU code is crap and these new features are ugly and make the code look like two languages spliced together (though another large amount of people disagree). Looks like this won't come up for anything you're doing for a while though, so don't worry about it.
>>
>>57619230
Depends on what you're actually passing: the array of a reference to the array.

Assuming this is VB, all parameters are passed ByVal by default, so adding ByVal won't change anything. Arrays are objects, so you are actually passing a reference by value, not a copy of the entire array. So >>57619272 is not correct, you will be modifying the original array even if you explicitly put ByVal (which is the same as not putting ByVal or ByRef)
>>
>>57619304
I know man, I know. I just want to learn a non-scripting language, and I really don't want to learn Java.

>>57619310
But I want to use enum classes, and they don't work.
>>
>>57619352
>>57619310
Sorry, the -std=C++11 should also go into the "build" field as well

>But I want to use enum classes, and they don't work.

Are you saying that what I said didn't work?
>>
>>57619304
No language "needs" a linter, however they can sometimes be useful.
>>
NEW THREAD

>>57619390

NEW THREAD

>>57619390

NEW THREAD

>>57619390

NEW THREAD

>>57619390

NEW THREAD

>>57619390

NEW THREAD

>>57619390
>>
>>57619396
You do with C and C++, as far as I'm concerned.
>>
File: Poopoo.png (2KB, 211x23px) Image search: [Google]
Poopoo.png
2KB, 211x23px
>>57619369
It didn't. This is I put btw.
Thread posts: 314
Thread images: 30


[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.