/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 69831040_p0.png (1088x978, 591K)

Other urls found in this thread:

github.com/rootcoma/narf
dpaste.com/3YC7QAK
medium.com/@authmane512/how-to-build-an-apk-from-command-line-without-ide-7260e1e22676
medium.com/@authmane512/how-to-do-android-development-faster-without-gradle-9046b8c1cf68
hanshq.net/command-line-android.html
ntu.edu.sg/home/ehchua/programming/android/android_ndk.html
software.intel.com/en-us/articles/building-an-android-command-line-application-using-the-ndk-build-tools
nickdesaulniers.github.io/blog/2016/07/01/android-cli/
mywiki.wooledge.org/BashPitfalls
pastebin.com/Fvwyaegn
twitter.com/SFWRedditVideos

What are YOU working on, OP? Nothing I assume
Bring back /prog/

I'm working on my wayland compositor. I'm specifically doing a fuckload of refactoring to get wp_linux_explicit_synchronization working.
I wouldn't normally talk about it unless I had something new to say, but you asked.

Attached: 1557279904231.jpg (900x882, 217K)

o-ok
im not working on anything, as usual, except looking for a job
keep up the good work and cute images

What are the most important data structures to know very very good?

>inb4 all of them

There is like 5000 bazillion binary tree kinds you have AVL Red/Black Heaps and other shit which one is the most used in the "real world"?

Attached: 1550148930246.jpg (240x334, 16K)

Got my programming socks on. Now it's time to write JavaScript!

Attached: 22dacbff8020c9b36da45fd9cd2cf008.jpg (453x680, 50K)

so long as you know at least one binary search tree, heap, etc

>What are you working on, Jow Forums?

I'm making a video game!

list is the most important by far.

lists are wack

list[], dictionary{}, tuple(), set Set()

Linked list
Priority queue
Double ended queue (dequeue)
Heap (goes hand-in-hand with priority queue)
Binary search tree
Trie (Not even that important, it's just my favourite data structure)
Hashmap

I need to learn C++ for Uni. I only have experience with C#, Python and some Java. I run Linux btw.

What would you recccomend for an IDE?

Also, can someone post that image of Jow Forums's programming challenges? It was basically just a list of simple challenges to get started in any language.

>dictionary{}, tuple(), set Set()
all implementable with list/pair.

what's the benefit of using/having types?

Attached: 999999999.png (124x91, 319)

>What would you recccomend for an IDE?
a text editor

Better performance.
Interfaces which are harder to misuse.
Maintainability.

To abstract bits into logical units.

Attached: 1504991125537.png (900x900, 1.15M)

lowers likelyhood of errors
allows for more readable and explicit code

Attached: lispbest.jpg (840x412, 253K)

>Better performance.
Eh nu-javascript is faster than most non low-level languages

I got a "DevOps" graduate job after finishing my cs degree, and basically I have no responsibility and do no development.

I've fucked up big time I think. Never work for a BigCorp.

Is this true?

>I have no responsibility and do no development.
so what do you do all day? do you need to show up?

Lisps are an aberration. In my opinion they're the best form a dynamic language can take.

not at all

I used a text editor until my makefile got too confusing.

Then I used CLion. See what works for you is the only real answer.

Yes, JS is the fastest general purpose scripting language.

Right now I'm waiting for someone to give me a set of certificates. I turn up out of fear / guilt / obligation. I would even go back to my webshit job with my tyrant boss.

good luck everybody

Im refactoring backend for work, whatever idiot made this snit should be shot. Server started going out of memory few days ago.Old shit was O(N^3) with at least N db queries. After i managed to figure out what for fuck sake was going on i managed to reduce complexity to O(N*log(N)) and 2 db queries. And no more memory problems and its much faster now... fuck web developers

OK so not "non low-level" languages then you fucking spaghetti

>Old shit was O(N^3) with at least N db queries.
> i managed to reduce complexity to O(N*log(N)) and 2 db queries

you managed to reduce 100 queries to 2 queries how?

If its anything like my webshit job its probably replacing a foreach -> query to a query with some kind of aggregate function.

I'm guilty of writing shitty php but in my defense my boss was always on my ass.

I am making a program which is supposed to store an array in SQLite in C.
I heard that storing as BLOB would work fine, considering how pointers work in C

This is the code for storing

rc = sqlite3_bind_blob(stmt, index, obj->array, sizeof(obj->array), NULL); //index is the position of the parameter in the SQL statement
If you ignore the opening, preparing and stepping of sqlite...please note that it works fine binding variables like integers and chars and is displayed in the table when using
echo .schema | sqlite3 table.db
However, the column that is supposed to store the array is just displayed as 0
When I try to retrieve it using this code....

if (sqlite3_step(stmt) == SQLITE_ROW)
unsigned int *array_new= (unsigned int*)sqlite3_column_blob(stmt, index); //index is the position of the column of the table
...and tries to iterate through it and print its length(sizeof(array_new)/sizeof(array_new[0])) it prints nothing and just says the length is 2.

what am I doing wrong? Everything else works fine

Attached: 1546814469733.jpg (640x550, 53K)

fucked up the code at the end lmao

smfh famalam

Attached: dumass.png (794x458, 56K)

How long have you been working on this blob query? Post the statement and everything.

I am making a program which is supposed to store an array in SQLite in C.
I heard that storing as BLOB would work fine, considering how pointers work in C

This is the code for storing

rc = sqlite3_bind_blob(
stmt, index, obj->array, sizeof(obj->array), NULL
); //index is the position of the parameter in the SQL statement


If you ignore the opening, preparing and stepping of sqlite...please note that it works fine binding variables like integers and chars and is displayed in the table when using
echo .schema | sqlite3 table.db

However, the column that is supposed to store the array is just displayed as 0
When I try to retrieve it using this code....
if (sqlite3_step(stmt) == SQLITE_ROW)
//index is the position of the column of the table
unsigned int *array_new = (unsigned int*)\
sqlite3_column_blob(stmt, index);


...and tries to iterate through it and print its length(sizeof(array_new)/sizeof(array_new[0])) it prints nothing and just says the length is 2.

what am I doing wrong? Everything else works fine

Not with me being smart but with old developer being retarded.. turns out data had to be collated from 4 tables and packed oddly.Why? No idea but our front end and other stuff require it. So all i did is write 2 big sql queries with bunch of joins etc... old developer knew only where clause and nothing else. Turns out 3 inner joins are much faster than triple nested for loop that does same shit and since i already had all data from 2 queries all i had to go is loop it once and a bit more...

good for you but nobody really cares

goodnight dpt i love you

it's 1 PM here

Eh i wanted to rant... and if it helps demonstrate web dev stupidity and keep few anons from making my mistake in going web dev im happy

Trying not to have an aneurysm while reading threads about the new side channel attacks.

/dpt/ loves you too

I’m making an operating system

i meant that if the end result is the same your boss is not going to notice but good for you pal

The edges do have points defining them, but the visibility check I'm implementing has the ray only from the center of each element to the center of each other. Since the elements will be pretty tiny, that's an acceptable approximation to me.

>If you're feeling adventurous maybe create some sort of implicit shape from each connected set of edges. You see how the inner portion of the outer circle covers the entirety of the outer edges, maybe you could create an implicit shape that is that inner edge and goes off into infinity. It would isolate the inner portion entirely and you'd just have to check if you're inside or outside that implicit shape.
You are completely overestimating my ability to write code. I understand how that would work in mathematics, but translating that into coding would be way beyond my level, never mind my time to implement it. Very elegant solution, though.

I'll try that, thanks. I've seen some other resources on the matter (mostly application in games too), but they were poorly explained for the most part.

>dropped out from computer engineering
>now can't prove that I can program in my resume because no degree

Nice, you can clone this and save yourself the time of copying from osdevwiki github.com/rootcoma/narf

do a project, put it on github or something

>What are you working on?
A bash script that makes data hoarding easier.

I'm having some problems with it though.
dpaste.com/3YC7QAK

When I try to run it from the terminal, it doen't do anything.

You will either find a way, or an excuse.

I don't care what time it is, go to bed.

>general purpose scripting language.
that doesn't make sense. and v8 is slower than both luajit and hotspot.

>data hoarding easier.
?

"Serious" open-source contributions look very good on a CV.
I've been told by people at my last 2 jobs that my open-source shit is why I was hired.

Attached: 1555786551660.jpg (1039x1329, 820K)

it wasn't because of the anime picture?

Nice memory management!

Attached: wtf.png (1054x541, 22K)

wtf /dpt/ lied to me

My github profile pic is literally a cute anime girl. It was back then, and still is now.

But I should also note that I do have a CS degree.

That's because your program has no side effects. It all got optimized to a no-op.

Good taste.

It's supposed to download code repositories from git, subversion, mercurial addresses.

if [[ ! -z "$2" && ! -z "$3" && ! -z "$4" && ! -z "$5" && ! -z "$6" && ! -z "$7" ]]; then

if [ verify_add $1 $3 $6 $7 ]; then
if [ verify_backup $2 $6 ]; then
if [ verify_repository $3 $7 ]; then
if [ clone_repository $3 $7 $6 $2 ]; then
compress $4 $6+=$2 $5
fi
fi
fi


if (( $# > 7 )) && verify_add "$1" "$3" "$6" "$7" && ...

Yeah, I've heard about them but find it very difficult to find something to do. Other than having something to show, it would probably be a good way to experience programming in the real world rather than just school stuff.
How did you find the things you could contribute to?

Is there any good way to generate fresh Android project boilerplate shit without using the IDE?

Qt Creator

Not sure but the google results for searching for that are hilarious. I thought I remembered the google android docs having command like instructions.

Attached: AndroidDevelopmentGoogleSearch.png (1515x796, 85K)

that is almost all there is to it.
Inserting
char *sql = "INSERT INTO Indexer (indexOne, indexTwo, id, idTwo, list) VALUES(?, ?, ?, ?, ?);";
rc = sqlite3_prepare_v2(db, sql, strlen(sql) + 1, &stmt, NULL);

rc = sqlite3_bind_int(stmt, 1, obj->indexOne);

//indexTwo, id, idTwo...

rc = sqlite3_bind_blob(stmt, 12, obj->list, sizeof(obj->list), NULL);


Selection
char *sql = "SELECT indexOne, indexTwo, id, idTwo FROM Indexer WHERE id=(SELECT MAX(id) FROM Indexer);";
rc = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);

if (sqlite3_step(stmt) == SQLITE_ROW)
{
obj->index_one = sqlite3_column_int(stmt, 0);
obj->index_two = sqlite3_column_int(stmt, 1);
obj->id = sqlite3_column_int(stmt, 2);
obj->id_two=sqlite3_column_int(stmt, 3);
unsigned int *temp = (unsigned int*)sqlite3_column_blob(stmt, 11);
//memcpy(temp, obj->list, sizeof(temp));

printf("List: \n Length: %lu \n", sizeof(temp)/sizeof(temp[0]));
for(int i=0;i

rc = sqlite3_bind_blob(stmt, 5, obj->list, sizeof(obj->list), NULL);
Oversight...there are 12 variables but it would be too much code so I just took the most important ones

select FIELD.FIELDNUM, FIELD.TITLE, count(*)
as "NO. ACADEMICS INTERESTED"
from FIELD
inner join INTEREST
on FIELD.FIELDNUM = INTEREST.FIELDNUM
group by FIELD.FIELDNUM, FIELD.TITLE
order by FIELD.FIELDNUM ASC

anyone have any suggestions how I can apply a where to this to restrict the out put as where there is more then 10 academics interested?

Thanks

It depends on what you're interested in, I guess.
The type of stuff I generally work on is something that I personally want or is solving an issue that affects me. You'd probably lose motivation if you aimlessly try to write some random program that you don't have a personal investment in.

I'm , and I only really started working on a Wayland compositor because I personally wanted to use it, and the rest of the ones at the time were pretty shit. It looks more impressive to people since everything I did was specialised as fuck, so nobody outside of a very small group of people know what the hell I'm talking about, but a few thousand lines of code contributed somewhere would be all you need to show some general programming skill.

Attached: 72491702_p0.jpg (2185x1553, 1.45M)

Why are you inserting 5 values buy binding a blob to the 12th index?

>
char *sql = "INSERT INTO Indexer (indexOne, indexTwo, id, idTwo, list) VALUES(?, ?, ?, ?, ?);";
rc = sqlite3_prepare_v2(db, sql, strlen(sql) + 1, &stmt, NULL);

rc = sqlite3_bind_int(stmt, 1, obj->indexOne);

//indexTwo, id, idTwo...

rc = sqlite3_bind_blob(stmt, 12, obj->list, sizeof(obj->list), NULL);

I'm not sure, but you could try this
FIELD.FIELDNUM = INTEREST.FIELDNUM
AND (SELECT (NO.ACADEMICS INTERESTED FROM FIELD FROM FIELD) > 10)

see
There are 12 but if I posted them all it would reach the character limit. Besides it works just fine with those 5. The other 7 variables are kinda useless

That's what it feels like at times, I don't like having to boot up Android studio to generate a project and then strip the bloat from it

>sizeof(obj->list)
I am also fairly sure this will give you the size of a pointer.

Messed up. Here:
AND (SELECT NO.ACADEMICS INTERESTED FROM FIELD) > 10

We should be able to just compile for arm and run elf binaries. I hope GNU makes some progress with Replicant

Also yeah, you could generate projects with the android tool in the past back when it used ANT, but they made no such tool for gradle. Fucking lunatics.

ah that could be true. As the struct is passed by reference(if that's the correct term) as in function(&obj);
In this case, what should be done then?

it says invalid column :/

size_t s = sizeof() *

There you have it.

medium.com/@authmane512/how-to-build-an-apk-from-command-line-without-ide-7260e1e22676
medium.com/@authmane512/how-to-do-android-development-faster-without-gradle-9046b8c1cf68
hanshq.net/command-line-android.html
ntu.edu.sg/home/ehchua/programming/android/android_ndk.html
software.intel.com/en-us/articles/building-an-android-command-line-application-using-the-ndk-build-tools
nickdesaulniers.github.io/blog/2016/07/01/android-cli/

I just found out French had recursive functionality in the standard.
>portmanteau()
Worst English influencer to be honest.

learning microservice architectures and implementing one in ASP.NET Core

>When I try to run it from the terminal, it doen't do anything.
Not surprising, your script is broken everywhere. This should help a bit.
mywiki.wooledge.org/BashPitfalls
pastebin.com/Fvwyaegn

I implemented a C++ custom class the other day overloading the bracket [] assignment with help from the kind anons in /dpt/.
It's working fine, but I have a problem. The [] operator returns a value, and when I try to do an assignment like class[a] = T, the compiler complains about having a value on the left side of the assignment, which is absolutely right.
The naive way of solving this is just making the [] operator return a pointer I guess, but then I'd lose the capacity to return a value, which makes things like T a = class[b] not possible.
What is the clever way to fix this and have the best of both worlds?

Don't you use the reference character '&'? Something like this?

public:
int& operator[] (const int index);
};

int& IntList::operator[] (const int index)
{
return m_list[index];
}

I will try that, thanks

I enjoy programming while studying it but I don't know of any open source projects that I'm interested in. I barely even know about any since I'm not already active in that stuff.

Trying to make a mod for Terraria. Only problem is I'm coming from knowing Java so I've gotta learn C# and will need to get a thorough reading done of the tmodloader documentation

Attached: tuba tyrant.jpg (403x631, 67K)

New to Java, trying to use Math.pow(4, 1/2)

Can somebody explain why the output is 1.0 instead of 2.0?

No, right now it looks kinda like
class {
object mat;
struct Proxy {
object& m;
size_t x;
T operator [] (size_t y) { return m.get(x,y) }
}
Proxy operator[] (size_t x){ return Proxy(*this, x)}

1/2 are integers, so you're doing integer division, which means that the result is 0.
Anything to the power of 0 is 1.

So change it to 1.0/2.0 to use floating point numbers.

Thanks. Why doesn't the 4 need to be made to 4.0?

There are automatic conversions for integers to floats, but that happens AFTER the division happens.

method signature must be:

T &operator [] (size_t y)
T operator [] (size_t y) const

Wanting to #learntocode, not here to ask what language I should learn first like a plebiscite, am looking for a decent learning tool. If anyone has any suggestions?