/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

github.com/enfiskutensykkel/ssd-gpu-dma/tree/api-rewrite
hackmd.io/s/ByA-x21Hf
soulecule.com
github.com/python/cpython/blob/9b6c60cbce4ac45e8ccd7934babff465e9769509/Objects/floatobject.c#L1535
twitter.com/SFWRedditImages

First for women in tech.

Changing examples to use the new API. I will hopefully start working on the benchmarks over the weekend.

github.com/enfiskutensykkel/ssd-gpu-dma/tree/api-rewrite

c++ is the greatest language of all time

what did he mean by this?

I got a problem with a simple request :
select fields
from table_A
left join table_B on a.smth = b.smth

is executed in less than a second
while
select field
from table_B
left join table_A on a.smth = b.smth

takes forever.

Why is it happening ?

One table has an index or key on smth, the other does not.

Both tables have an index on it

Then one of the indexes involve more fields? It's been a long (looong) time since I optimized queries.

Or, alternatively, one table has a lot more records than the other.

I am learning Racket at the moment, and I am having a lot of fun. I do have a question though. Do functional languages have a professional market? As in, can you get hired to program on a functional language. Can you guys give me examples of things that were created through functional languages?

how do i get more stupid stars for my awsome github repo

Post it here.

I don't think it would be the problem. One have 90k liens of data the other one 200k only.

I'll try a few things. related to but damn it's annoying.

Well, good luck anyway. When you find out why, feel free to post it here (or next /dpt/), I'm interested in what you find out :)

the class is more real than the instance

So I have a simple question.

If I want someone to write some text into a .txt file, is there a way they can make line breaks in the file?

I don't want to make a variable for every line (line1, line2, line3) and then use .writelines()

I would just like to make line breaks using one input variable.

>pic is the basic code I want to use.

>This branch is 4 commits ahead of XXX:master
how to 'downgrade' to upstream?

damn right

git checkout
if those commits need be discarded, perform a git reset.

I'm fairly sure the character '\n' will work as intended here.

or if you simply want to go back to the master branch, do 'git checkout master'

Holy shit. Found the issue : encoding.
Both table didn't had the same encoding and one was fucking with the other one. Both queries run as fast now.

Thx anyway man.

\n

So... why did it die?

I wouldn't have thought of that
good to know, thanks

hackmd.io/s/ByA-x21Hf

it tried to be everything

That is pretty cool. From that group of languages. Which one do you recommend me to learn?(After I learn scheme, of course)

depends what your goals are.

Well, my long term goals is to work on AI(including machine learning, deep learning, etc). Other than that, I wouldn't know. I would still like to learn a multi-use functional language, just to add more tools to my tool kit.

I have a dream.

A dream that I one day will create my own computing stack.
My own ISA (probably shitty RISC-V clone), my own CPU design (probably not even pipelined), my own compiler (probably only the backend for LLVM), my own kernel, my own OS.

None of them would actually be any good or worthwhile or used by anyone than me, but they would be mine and I would know them from top to bottom.

I know that this dream will probably never come to fruition, but it's a dream, damn it! (but it would be that much more realistic if one of you nerds built an actually fast circuit simulator, because FPGAs/Verilators feel too synthetic)

user, share a similarly ambitious dream if you have one.

Catgirl gf

What? I use it everyday at work.

Okay, so... I know about \n.

The point is I have a database with info on a lot of animals (hunting license related), and whenever I want to add a new animal, I just open the program and and enter the new data.
Problem is, I want it to look like this:

Hunting season: 1/10 - 31/1

Species: (whatever)

Age of maturity: (whatever)

And so on. The problems seems to be whenever I use \n in the input to variable Fill, it just gets printed as a string, and doesn't make a line break.

Does that clarify?

>What? I use it everyday at work.
for simple scripts?

what's your job?

I've developed a blogging platform where anybody can post whatever bullshit info they want.

I've recently created an 'advertising' banner spot where I can get people to advertise with me and hopefully start making dosh off of my site. All of this was coded with PHP and SQL. The database stores my adverts and the locations, the PHP pulls the files to be rendered a single random ad out of the pool of ads.

Oh and I designed it so it does not get blocked by adblock plus.
shuffle($adoutput);

$r = 0;
while($r < 1){
$sqlqueriedads = "SELECT * FROM ADVERTISEMENT WHERE ID='$adoutput[$r]'";
$resultqueriedads = $conn->query($sqlqueriedads);
if ($resultqueriedads->num_rows > 0) {
// output data of each row
$rowqueriedads = $resultqueriedads->fetch_assoc();
$adid2=$rowqueriedads['ID'];
$adurlimage2=$rowqueriedads['URLIMAGE'];
$addateadded2=$rowqueriedads['DATEADDED'];
$adurllink2=$rowqueriedads['URLLINK'];
$adtags2=$rowqueriedads['TAGS'];
$adtagjustthestring2 = $rowqueriedads['TAGS'];
$adarticletype2=$rowqueriedads['ARTICLETYPE'];
$adcodeoutput.='';
}
$r++;
}

>I've developed a blogging platform where anybody can post whatever bullshit info they want.
>I've recently created an 'advertising' banner spot where I can get people to advertise with me and hopefully start making dosh off of my site

so Sup Forums?
>Oh and I designed it so it does not get blocked by adblock plus
but gets blocked by ublock origin

Backend dev. We use Mojolicious mostly.

Are you me?

I need a rough estimation
Should I use a physics engine for the particles? or should quadtrees speed up the collision calcs a bit faster?

here's the particles in action
soulecule.com

Well, now that there's officially public interest, we need to team up and follow the standard /dpt/ development protocol:
1) Pick the name,
2) Design the logo,
3) ??? (Here be dragons),
4) Fame and glory.

sumarray(long[] array) {
long[] sumarray;
sumarray = new long[array.length];
.
.
.
}

long sum(int l, int r) {

}
}


how do I access the array I created in summarray in my sum method?

>make it global
>pass as parameter
>return array from sumarray and use this value

Hmmm no. Sup Forums has moderators and don't allow certain content. If someone wanted to advertise/peddle or just talk about what they want they can. There are minimal rules and also does not store IP addresses.

>ublock origin
See pic related. it did not block my ad.

>See pic related. it did not block my ad.
because it's not an ad.

that's probably a simple image

aha its not. It's definitely an ad.

1stamender.com/article.php?articlenumber=352

With that being said... What these adblockers do is they check non-serverside coding for anything referencing 'ad' or 'advertisement'. By labelling everything in a way that doesn't reference common naming conventions for ads causes this to work. You can try it yourself with notepad using div tags or image tags that reference a folder like 'advertisement'.

long[] sumarray;
sumarray = new long[array.length];
Looks like you fell for the arrays are pointers meme

so when you click on the image, where does it go to?

do you make money when a user clicks on it?

Poof, no ad anymore.
Nothing is stopping me from adding your website to a couple of common ad block lists so that no ad will show up no matter what pointless trickery you decide to waste your time on.
But I won't do that, because I'm not a bad guy, but it's a possibility :^)

>not anime thread
shit bread

Which one is better? MIT's SICP lectures or UC Berkeley's CS61A SICP lectures?

Should I use github even if it's only for myself? I am the guy that wants to practice programming and make the app for a friend.
I've complied some of my ideas that I will show him and ask him how he would want it to look like, but if I actually work on it I will probably needs some place to have multiple version stored in case a change is bad or something, I guess?

>class="ad1-container"
>adblock proof
top jej

Why are you this way?

berkeley

>I've complied some of my ideas that I will show him and ask him how he would want it to look like, but if I actually work on it I will probably needs some place to have multiple version stored in case a change is bad or something, I guess?
so pure, holy shit

hey it worked. Don't knock what actually fucking works.

works until it doesn't

...

>$r = 0;
while ($r < 1) {
$r++;
}
Use a for loop

/dpt/ is absolute shit today

what's going on?

>Mojolicious
WHY

How can I abuse templates to determine if a particular type is callable with a certain argument list?
In other words:
struct Functor
{
void operator()();
void operator()(int);
};

isCallable // true
isCallable // true
isCallable // false

Shitty languages are the future of quitting programming

/dpt/ is always absolute shit

the results for advertisements are not a quantifiable amoutn as it can grow. So this required a 'while' loop also in the future there is a possibility I may put in multiple ads.

Why exactly can't you use a for loop there? Give me an example

What's wrong with it?

So I guess you could use a for loop. I didn't use a for loop because I don't know what is the max amount of advertisements initial number.
for($i=0; $i

yes, for data preservation. for private repos, bitbucket is more interesting.

I'm having trouble understanding how to calculate the Big-O of programs. Can someone help me out here? ELI5

template
struct IsCallable {
using Result = decltype(std::declval()(std::declval()...));
}

example?

Measure execution time at eg. problem sizes 5, 10 and 20 entries or whatever it depends on.
Plot the execution time vs. the problem size
It should now be obvious whether it is O(n) or O(n^2) etc

Can 2 foreign keys be a primary key

Working on it right now. A bit alien as far as ISAs go, though.

Why is this giving me segfault?
#include

int main() {
int * a; *a = 22;
int b = *a;
printf("b = %d\n", b);
*a = 30;
printf("*a = %d, b = %d\n", *a, b);
}

a points to some random adress you don't own. Use malloc

>int * a; *a = 22;

You didn't allocate 'a'.

{
=(::()(::()...));
}
literally nightmare fuel

#include
#include // Malloc

int main(int argc, char **argv)
{
int *a, b;

a = malloc(sizeof(int));
if (!a)
return 1;

*a = 22;
b = *a;

printf("b is %d\n", b);
*a = 30;
printf("*a is %d, b is %d\n", *a, b);

free(a);

return 0;
}

Thanks, midgets.

>midgets
That really rustles my jimmies

Sorry for being a noob, ill get the hang of it I promise

Ill give both a look, thanks a lot

>if (!a) ..
>free(a)
why?

Thanks

Allocations can fail

Best C++ resource for learning by practice problems? I bought C++ Primer (Lippman) but it goes into great detail about the technicals, but the problem sets are lacking

YOU SHUT YOUR WHORE MOUTH WHEN GARY KILDALL IS TALKING

main = alloca (\a -> do
poke @Int a 22
b

fn main() {
let mut a = Box::new(22);
let b = *a;
println!("b is {}", b);
*a = 30;
println!("*a is {}, b is {}", a, b);
}

>::
oh shit i thought it was rust for a sec

really rust-les my jimmmies

>write a function that recieves a floating point number and sends back the integer and fraction parts
>i have to do this in C
hello darkness my old friend, i want to do this in scheme or lisp
it would be as simple as a #'ROUND 'ing that numba ....

man modf

Steal github.com/python/cpython/blob/9b6c60cbce4ac45e8ccd7934babff465e9769509/Objects/floatobject.c#L1535

No actually this implementation is very shitty. Go for

ok so basically \n is being literally interpeted as two chars rather than a single one
Coding from the hip you can try to instead define some char like ";" or "," to designate where the data should be separated, if you really want to insert it all on one line (separate vars are much better my man).

...
data = fill.split(";")
for dataline in data:
dataline = dataline.strip()
test.write(dataline + "\n")

test.close()

>ok so basically \n is being literally interpeted as two chars rather than a single one
What? Your computer is haunted.