/dpt/ - Daily Programming Thread

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

Attached: 1543319269793.jpg (906x1280, 153K)

Other urls found in this thread:

docs.microsoft.com/en-gb/windows/desktop/CoreAudio/core-audio-apis-in-windows-vista
docs.microsoft.com/en-gb/windows/desktop/learnwin32/learn-to-program-for-windows
twitter.com/AnonBabble

first for Java

What should I work on tonight?
Alternative site for Tumblr NSFW content
Or a DNS admin panel?

>What are you working on, Jow Forums?
a dumb video game
the only things I try to make are dumb video games, I want to make something cool but nothing comes in mind besides dumb video games

How do I decrease the font weight in android studio?

Attached: font problem.jpg (917x803, 214K)

For me, it's Malbolge.

settings

I don't know, I only write industry level code with Eclipse and the Spring framework.

This is my favorite hot new meme

well I have been fucking around in there and I can't find it

Try to get first place in tonights advent of code problem

How far have you gotten? I've only recently heard about it.

I really like programming in c but it bothers me how there isn't a single good ide for it.

vim

Thank you for posting Sachiko

Attached: 1532293351595.jpg (1280x1480, 527K)

No

nano

I've tried. Hours of setup and it ended up being worse than notepad

>Hours of setup
lolwut

About to start making a standalone 4channel client for AmigaOS with it.

it helps if you weren't a retard

Do you expect me to use vim without any plugin? I'm not autistic

preferences

it takes way less than an hour to get plugins

I use plugins too, but it's literally copy and paste from github.

kek

And all those plugins are shit, then you keep looking for better plugins and there is none

I don't even see a preferences, and the in settings search doesn't bring it up for me. I'm so close to just dumping the font into illustrator and manually decreasing the character weight of every letter.

try borlands then, faggot

What does /dpt/ think about vscode? I'm use vim now, but I'm check out vscode now, and I have to say I could get used to this.

Attached: 1537744899159.gif (250x140, 2.76M)

what do I program my website on?
how do I use Json to get my java code to work in my website?

What do functional programmers call a function that operates on each element in vector?

GNU style is best, don't @ me

Performance issues make it unpleasant to work with, in my experience.

Map

You sound like a troll.

map is just an example of that, I mean what about reduce

as far as I know, json is just data
use a java library that converts data into json and use js to use the data from the json

Working through Brent Yorgey's course. I am on the third part of assignment 4. Can someone give me pointers on where my bug is? Is there a way to not have use the @ syntax if I want to access things within a parameter?
Data Tree a = Leaf | Node Integer (Tree a) a (Tree a)
deriving (Show, Eq)

foldTree :: [a] -> Tree a
foldTree xs = foldlr f xs Leaf
where
f x tree = insert x tree
insert :: a -> Tree a -> Tree a
insert x Leaf = Node 0 Leaf x Leaf
insert x tree@(n left val right)
| (height left) < (height right) = Node n (insert x left) val right
| otherwise = Node (n + 1) left val (insert x right)

height :: Tree a -> Int
height Leaf = 0
height tree@(_ left _ right) = max (1 + (height left)) (1 + height right)

what's some cool/useful math or forumlae i should learn?

learned about polar co-ordinates and arithmetic progressions today,
I got a D at A-level for maths so now i have free time to learn whatever the fuck i want on the side of my [spoiler]frontend webdev[/spoiler] job and find it way more interesting but don't want to go back and relearn stuff from scratch with things like khanacademy

Oh, right. That makes sense because no side effects.

Unfortunately that doesn't work well for me, because of performance concerns I need to modify the vector in place.

Thanks anyway.

>tfw you finish a project

Attached: 1498564882917.png (1001x823, 806K)

*bug

I see I forgot to put "Node" after "tree@(" and have an 'l' in foldr

Linear algebra.

Also, since you've learned about arithmetic progressions, why not continue with geometric progressions, and telescoping sums.

I don't know that feel.

learn calculus first. it opens the door to a lot of the more interesting math. i’d recommend the book by spivak although it’s pretty rigorous. if you want something easier i’ve heard stewart is alright

A mans work is never done user.

i already know some calculus from high school and sixth form

you're talking about integration and differentiation right? not sure what I would do next or how it works implementing code

Can sachiko say niggy?

hash learning retard here again
what is the advantage at ALL of any open addressing scheme?
let's say you use chaining, your search function search(key) will iterate through the list at table index h(key) until finding the proper item for key. and so search time complexity is O(1+ load factor), i.e constant time plus whatever we would expect the length of a chain to be.
in open addressing say with linear probing, it's the same complexity. instead of iterating through a list you iterate through the table itself. the search complexity is till O(1+ load factor). but in open addressing, you're fucked if you run out of table elements. meaning the amount items you want to store can be no larger than your table size. what the fuck? why would anyone do that?

heres a graph from wikipedia that i'm sure is related but I don't know what a "cache miss" is and the article never mentions it before this pic

Attached: 362px-Hash_table_average_insertion_time.png (362x235, 14K)

def sachiko():
return True

Okay, not sure if this belongs in /sqt/ or /qtddtot/ but you guys may give me more relevant answers:
What do I do if my programming knowledge is good enough that all the beginner tutorials are trivial but I'm not good enough to understand more complex projects/do my own projects?
I learned python in school (and java basics for 1 semester in uni) and both where basically the same but whenever I try an actual project there's too much I don't know, evenn when I look into example code. I wanted to control the windows sound mixer in a project and failed miserably (no idea how to interface with it).

So how do I make that next step? I just want to be able to badly code so I can get better. Instead I know a stupid amount of sorting algorithms etc.

Book recommendations are appreciated as well.

import winsound

start a project and actually do it
>control the windows sound mixer
windows is notorious for being terrible to deal with, so don't feel about that
a good project can be one from that roll chart people post here sometimes

JavaScript rocks!

Attached: js-rocks.png (1000x494, 369K)

why lemon?

When the processor wants to operate on a variable in memory it reads that variable from ram and stores it in the processor cache memory. Actually it reads a chunk of ram and stores it in the cache. If the next piece of memory the processor wants to operate on happens to be in that chunk, the processor can access it directly from cache and does not need to read ram again. Reading from cache memory is faster than reading from ram. If the next piece of memory the processor wants to operate on is not cached, the processor neads to read that from ram again. This is called a cache miss.

Optimising your program to minimise cache misses can tremendously speed up the execution of your program.

Trying to carry out the next challenge in adventofcode.com

I'm trying to utilise fscanf to read in the data which is in the following format:
#[ID] @ [top],[left]: [width]x[height]


As an example:
#1388 @ 448,853: 18x15


I've attempted to read them off using this:
fscanf(fabric_list, "%1c %d %1c %d %1c %d %1c %d %1c %d",discard,&id,discard,&top,discard,&left,discard,&width,discard,&height


I'm doing this in a while loop, to just pull all the data into a struct. To test, I've got the while loop just printing it out. Curiously though, I'm getting it printing out each line twice. Any ideas why?

...

But you guys are more fun.

>discard
Add a * to the format specifier. %*c will read a character and discard it. No argument required.
>Any ideas why?
You're going to need to post more of the code.

post the loop

Thanks for the tip on the %*c. Here's the code:

while(fscanf(fabric_list, "%*c %d %*c %d %*c %d %*c %d %*c %d",&id,&top,&left,&width,&height) != EOF)
{
printf("%d: %d,%d, %dx%d\n",id,top,left,width,height);
}

>I wanted to control the windows sound mixer in a project and failed miserably (no idea how to interface with it).
You basically have to get good enough to be able to understand Microsofts API documentation.

why don't you print it in the same format as the input?
also I have no clue what's wrong

My full code:
FILE *fabric_list;
fabric_list = fopen("fabric_cuts_input.txt", "r");
if(fabric_list == NULL)
{
printf("File not found\n");
return;
}
char discard[1];
int id, left, top, width, height;

printf("Hello\n");
while(fscanf(fabric_list, "%*c %d %*c %d %*c %d %*c %d %*c %d",&id,&top,&left,&width,&height) != EOF)
{
printf("%d: %d,%d, %dx%d\n",id,top,left,width,height);
}
printf("Goodbye\n");

The hello and goodbye just proving to myself it's not being called twice.

*scanf returns the number of format modifiers read (in your case, 5). You should check that you're actually reading 5 things.
I would guess the %*c ends up reading the newline character still in the stream, and that just ends up throwing off the rest of the format. Add an explicit space at the start of the format and see if that fixes it.

That's where I failed, to be more precicely I failed to even find anything worthwhile. They name some, but not all functions and even then in barely any detail. Because of that I searched for others doing something similar but I really didn't understand their code. I get that the microsoft API is too much but I also don't know what is within my scope. Thanks for answering though.

Correct-o-mundo. Adding in a space and it's only printing what it is meant to.

I get that it would offset it, but I don't understand why it would then read that whole line again?

>using fopen
>not if (!ptr)
>not if (cond) or while (cond)

Attached: eww.png (451x451, 328K)

tic tac toe with ncurses

It's not reading the whole line again, it's just that scanf is exiting early after a matching failure, and then you just print out what was in the variables before.

I don't know ncurses, but Tic tac toe was rather easy. You see I get the basics, I just miserably fail when I take that next step. Maybe I'm just not patient enough.

Slow as fuck. I don't even type quickly but I can feel the input lag.

Ah! I understand. Thank you for your help.

>pic is you

Attached: UnripePleasedAlbacoretuna-small.gif (250x250, 1.03M)

space invaders with ncurses, learn ncurses

>Not using Atom

>has clunky code and bad style
>no u
You best be trollin'.

Well I'll look into it, thanks.

because my gpa is 2 and i'm a junior and might fail some of this semesters classes im considering dropping out and working 12 hour days in the local amazon fulfillment center for 4 days a week so i can have a 3 day weekend and just spend my time then doing hobby programming.
thoughts?
killing myself after my mom dies btw but that's gonna be a while.

for the record, you're much better off writing some utility functions for string parsing because you'll be doing this literally a million times
write a function StringSplit that takes a string and a character (or another string) and returns an array, so StringSplit("ab1cd1ef1", "1") returns ["ab", "cd", "ef"]
write another function StringScrape that takes a string and two parameters and returns the value in between, so StringScrape("ab1234cd", "ab", "cd") returns "1234"

with these two you can do all the string parsing you need
so to get top,left out of your input you could do StringSplit(StringScrape(input, "@ ", ":"), ",") and you'd get back [top, left]

>thoughts?
quit the job

Thanks, will implement that soon!

How do I contact someone on github?

Email them.

How do I get good at writing clean code when using a functional language or library? I have so many ugly nested folds and maps and once I get something the looks okay I realize I've massively reduced clarity

Is right in a way. It sounds to me like you need practice reading documentation. That's a skill in itself.

You could also try to learn and do something in OpenGL. That's also very educational, in my experience.

Well if it's a skill then I'm sure I'm bad at it, so you may be right. I'll think about OpenGL, thanks very much.

>OpenGL

Is that not going to be a dead thing soon? Like, surely learn Vulkan as that will stay on, OpenGL will start to die off.

Anyone got any interesting transposition &/or substitution cipher ideas. Would like to implement some but I can't think of anything.

I imagine that OpenGL is still going to stick around for quite a while.
It has a lot of momentum, and is much easier to use for projects that have simpler requirements.

Also, learning Vulkan without some OpenGL background is going to be a lot more difficult.

docs.microsoft.com/en-gb/windows/desktop/CoreAudio/core-audio-apis-in-windows-vista

I don't mean to be discouraging. I meant that it's a skill that you can and will learn with practice and experience.

Lol no. Vulkan is way too low level to be usefull for most developers. You need to have some serious skills and time on your hands to do anything usefull with vulkan, and some specialised performance needs for it to be worth it. For the rest of us we will at best use some some higher abstraction wrappers, which OpenGL practically already is.

But I only mentioned OpenGL because that's what I learned a lot of my API reading skills from.

>I don't mean to be discouraging. I meant that it's a skill that you can and will learn with practice and experience.
You weren't, don't worry. In fact this is more incouraging. Thanks for
>docs.microsoft.com/en-gb/windows/desktop/CoreAudio/core-audio-apis-in-windows-vista
I think I looked through that code in the past, but it's been some time with the specific sound mixer project, I'll have another look. Thanks again. You actually motivated me to go back and try again at some point.

OpenGL has been deprecated for over a decade now and nothing can replace it.

Am i in a parallel world where vulkan doesn't exist?

Vulkan will never replace it until it becomes easier. It's like telling Java programmers to rewrite everything in C.

"no"
Vulkan's power and control will force brainlets to git gud

"no"
OpenGL is good enough for most applications. The only people who will switch over ultimately are tech demos trying to show off next gen shit or gaymening.

docs.microsoft.com/en-gb/windows/desktop/learnwin32/learn-to-program-for-windows

This might also be good practice for you. Learn to program Windows applications from scratch. At least, I found it rewarding when I did it.

>good enough
>nearly every emulator, SFML/GLFW
>as well as many finished AAA games
>tech demos
wew lad