/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

cs.uoregon.edu/research/summerschool/summer16/curriculum.php
youtube.com/playlist?list=PLiHLLF-foEez5Dis-VqoGcg3WepdMh4XT
cs.cmu.edu/~rwh/pfpl.html
people.vcu.edu/~rhammack/BookOfProof/
en.wikipedia.org/wiki/Quicksort
twitter.com/SFWRedditGifs

post more cats programming please

Hello /r/eddit please use an anime image next time.

Which utility library to use for files+directory handling, allocators, data structures and threads when there's so many of them like qlibc, tbox, pjlib, glib?

looks like my cat but with blue eyes

>doing the same thing
Excuse me?

...

I wanna program something but I don't know what, give me some ideas

waifuAI

something that will make money!

A complex AI

Program me a program that does all the "classic" first year UNI programming problems for me.

Make an application that takes every frame in an anime episode and apply waifu2x to it.

what would be the purpose of such a thing?

learn Java

to upscale anime duh

Still looking for help, since my code throws me an out of range error.

Console.WriteLine("Enter a string: ");
string kodString = Console.ReadLine();
string pos = "";
string nums = "";
string comString = "";

for (i = 0; i < kodString.Length; i++)
{
if(Char.IsNumber(kodString[i]))
{
nums= nums+ kodString[i] + " ";
pos= pos+ i + " ";

}
else
comString = comString + kodString.Substring(i, 1);
}

This is for getting numbers and their positions from the string.

for (i = 0; i < pos.Length; i++)
{
if(Char.IsNumber(pos[i]))
{
comString = comString.Insert(pos[i], Convert.ToString(nums[i]));
}

}

This is supposedly to put numbers back in their correct location. It's giving me an out of range exception on pos[i] in the .Insert part and I don't know why. Can someone help?

Remaster episodes of old anime like Aria. The BD upscales are fucking shit and I've found that applying waifu2x to every frame of the show actually unironically makes it more watchable.

>cat
Neko wa kawaii desu

How often do you guys write things down on paper?

-Update/rewrite my old scripts
-Add logging to my old scripts
-Making a custom logging module for fun

It's been a comfy weekend

user:
"
Be honest, /dpt/
Programming is almost all about knowing your libraries.
For the 90% of the time, you are not required to implement a brand new algorithm, there are tons of libraries that does the job better than your algorithm.

Instead of teaching sorting algorithm the books should introduce people to some known libraries. This is much more productive. Of course, there can always be a new innovation but that's only for research.
"

Sup Forums in 2017:
>le fuk off pajeet XD

Learning cmake/make
Unproductive weekend

a lot

Pretty often.

Almost never

...

When I'm not behind a computer.

>learning make
Iktfb

If libraries are so important, can you write a library that selects the library function that fulfills your need the best?

Oh wait, that's a framework... Good luck!

Your argument is like claiming architecture is the science of swinging hammers.

It's insulting.

How do I learn a new thing in programming?

>learning something you can just man

>>le fuk off pajeet XD
Just because you point it out, it doesn't mean that you're not a filthy pajeet code monkey.

my name is Singh get it right

merge sort first attempt
public static void merge(int[] A, int[] B, int[] iArray) {
int a = A.length;
int b = B.length;

int i = 0; int j = 0; int k = 0;

while(i < a && j < b) {
if(A[i]

Tackle new problems.

You must be a pretty shit programmer if you believe that.
Programming isn't only about knowing your tools.

>2016
>Not using the standard Java built in mergesort library

fuck off pajeet

>I'm unable to understand anything about computer science
>therefore everyone does
What kind of reasoning is this? Your lack of creativity is obvious.

>Just because you point it out, it doesn't mean that you're not a filthy pajeet code monkey.
Just because you point it out, it doesn't mean that you're not a filthy pajeet code monkey.

Yes and No.

True that when you get out of school the first thing they do is tell you to learn frameworks and tools like RabbitMQ, Postegres and libraries like React for almost any job. Even if you are doing kernel development there will be an in house gigantic library for handing almost all of the development, in fact I've never worked anywhere that didn't have it's own internal libraries and you just string them together but it's important to still know how said libraries work because you need to optimize them from time to time or know what sorting algorithm is best for the task.

>use only the libraries you were told to use
>wonder why your program is so inefficient because you never learned the nuances of certain algorithms

Wow, great comeback.
Are you fucking 4 years old?

Could you answer my question here please? Can you tell me why "combining two libraries" means "the libraries do the same thing" somehow to you?

Please help.

Well technically your first post doesn't have any value since it discredits its own argument. I'm not the original pajeet though.

Sup Forums is too edgy to do anything else than memeing. What a waste.

>Be filthy pajeet
>Need to sort 30GB of data in a file
>Use built-in quicksort
>Performance is absolutely terrible on the Java® Virtual Machine™
Why is this, my friend?
I thought quicksort was the perfect sorting algorithm that should always be used, and there is no point in understanding anything about the algorithms I use, because they just werk.

does anyone here actually post their progress or work on their projects or just meme endlessly?

What happened to the old /dpt/ where everyone would post their cool projects and what new cool features they added that day

Simple my friend Quicksort is not good for large amounts of data

>What happened to the old /dpt/ where everyone would post their cool projects and what new cool features they added that day
/dpt/ was never like that.
I don't want to shit up this thread with pointless blogposting about the most minor shit I did today.

I'm a beginner. Why is the class name not valid?

Not allowed to start with a number, probably

OOP killed programming. Most learning resources and universities teach you every memes that kill every bit of creativity in your brain. The adult world was a big fucking mistake.

I tried writing different names and found that exact pattern. Is there some obvious reason I can't start a class name with a number?

Anybody interested in programming language theory there's an undergrad seminar posted here: cs.uoregon.edu/research/summerschool/summer16/curriculum.php (or on jewtube here: youtube.com/playlist?list=PLiHLLF-foEez5Dis-VqoGcg3WepdMh4XT ) which uses this book, also avail for free as a draft cs.cmu.edu/~rwh/pfpl.html

If you know any elementary set theory you can figure all the above out people.vcu.edu/~rhammack/BookOfProof/

Thing about learning language theory is that once you learn abstract syntax trees and their graph abstractions plus other theory you can essentially pick up any other language by just looking over the spec, and immediately know what future problems you will likely come across if using it for some project. You can also then contribute to language spec development in whatever language you like, like say C standards or Rust or Haskell and know what you're talking about.

Simplifies parsing for the compiler

Hard to understand for humans and for parsers

But how is my non-CS pajeet brain supposed to know that?
According to , all I need to know are libraries.

Allowing names with numbers at the start introduce ambiguity for the parser, and are just inconsistent overall.
Just name it ex_1_04 or something.

I made a tictactoe

can gib job

in what language?

Alright, thanks

In java, numbers (or maybe only ints, idk) can have underscores in them, so 1_04 is a valid literal. You can imagine it would be hard for java to differentiate the identifier (class, in your case) named 1_04 and a literal with the value 1_04

I'm trying to find the cause of dropped/uncommitted messages in a network stream. Nothing interesting.

c# lmao

first time I'm enjoying programming

I actually got one showing a tic tac game I made with an enterprise database and networking version of tic tac toe connecting to a server which the large software development firm boss was impressed I wrote it all by myself

>Quicksort is not good for large amounts of data
Explain.

en.wikipedia.org/wiki/Quicksort

As the user who originally posted the "question", I'll give an explanation.
I know the answer, I was just trying to poke fun at the stupid "only learn libraries" idiot.

Quicksort has a lot of random data movement. E.g., in the step where you move the data below and above the pivot.
With large amounts of data, you won't be able to fit all of it into memory at once, so your operating system is going to have to page that shit, and when you're randomly swapping shit, your OS is going to constantly pull pages into RAM and push other pages out to RAM.
This is absolutely terrible for performance, and even with an efficient (average case O(n log n)) sorting algorithm, it's going to take forever.

When writing sorting algorithms for large amounts of data, you need to keep this page swapping and random access in mind.
There are a class of sorting algorithms called "external sorting", where you use other files to sort large files, keeping the amount of memory needed to sort a large file low, and not thrashing the pages.

Please, this is really annoying me for the last day or so.

can you guys help me out? i'm trying to rewrite a program i wrote in c# in c++ for performance reasons. for some reason however, it appears as though the program i wrote in c++ is only using 600kb of memory whereas the c# version uses 17mb.

how can i tell my c++ program to use more memory?

>push other pages out to RAM
out to disk*

You didn't even say what the issue is

wat

what are you replying to me for

void * useMoreMemory = malloc(1024*1024*1024);

should make it use 1GB

Sure. Use some alias and Ill make real posts, if you really want to hear about real development.

I'm trying to make a CRM and workflow manager in PHP. Haven't dug into PHP in awhile and Im having a hard time conceptualizing how the workflow manager would do a Post to MySQL, then reassign the top task in the workflow without fucking the table ID's or without doing a mass rework of all scored entries in the MySQL table.
Going to dig into other peoples projects. My apprentice made the base HTML as a good first project so just working the back end code today.

I'm having an issue with adding the numbers back into the correct position in the string, how do I do that with the replace method?

Sorry, quoted the wrong code.

(void *) malloc(17408)

How do I write a program that stops this snowstorm outside?

>Casting to (void *)
>Casting at all.

Glad to hear someone is enjoying programming today. Never dug into C# but saw it had some leverage with Sharepoint servers. Have you found it fairly easy to pickup?

An aside, does anyone have python or C++ source code that can analyze an image's metadata? I feel like with the recent injects into pictures and chrome side channel attacks merit viewing pictures metadata before passing it into chrome or local machine programs.

nvm that's totally not why it's so slow. i actually have no idea how c++ works. any ideas why a pretty straight forward algorithm would be 18 times slower in c++ than in c#?

why the fuck do you want the snow to go away? snow is the greatest thing to happen to this planet, it makes everything so comfy

I want to move to a place that gets a lot of snow after I graduate just because I love it so much

You wrote it poorly.
You didn't compile with optimisations turned on.
You didn't write it in C instead.

Maybe you used std::list where you used List in C#. std::list is linked, List is array-based.

you are probably running in debug mode

idk ask bill gates, weather manipulation is being worked on by those whacky futurists

that seems to be it, now it's ~40% faster. thanks friend.

what are you even measuring?

Compile times.

(ns dijkstra.core
(:gen-class)
(:require [clojure.string :as str]))

(defn parse-graph-file [filename]
(with-open [rdr (clojure.java.io/reader filename)]
(->> (line-seq rdr)
(reduce (fn [g line]
(let [[u & vs] (str/split line #"\s+")
u' (Integer/parseInt u)
vs' (->> vs
(map #(str/split % #","))
(map (fn [[e l]] [(Integer/parseInt e) (Integer/parseInt l)])))]
(assoc g u' vs')))
{}))))

(defn dijkstra [graph start]
(letfn [(inner [visited edgelist]
(letfn [(update-edges [u edgelist]
(->> (into edgelist (map (fn [[v l]] [u v l]) (graph u)))
(filter (fn [[u* v* _]] (not (contains? visited v*))))))
(compfn [[_ minscore :as old] [v* w* nextlen]]
(let [d* (+ (visited v*) nextlen)]
(if (< d* minscore)
[w* d*]
old)))]
(if (= (count visited) (count graph))
visited
(let [[newnode newdijk] (reduce compfn
[nil Integer/MAX_VALUE]
edgelist)]
(println (str "Added " newnode ", distance: " newdijk))
(recur (assoc visited newnode newdijk) (update-edges newnode edgelist))))))]
(inner {start 0} (map (fn [[v l]] [start v l]) (graph start)))))


(defn dijkstra-file [filename start]
(dijkstra (parse-graph-file filename) start))

(defn solution []
(let [results (dijkstra-file "input.txt" 1)
ends [7 37 59 82 99 115 133 165 188 197]]
(map #(results %) ends)))

Coursera programming exercises

Quantum computation will be able to accomplish total weather control

Best resources for learning node.js?

The first weather machine will run on python

>node.js

By Pythons are coldblooded

So, can you help me with it?

>have a file main.c
>have another file tfuncs.c and tfuncs.h
>have a function in tfuncs.c that returns void and isn't defined in tfuncs.h
>I can still call that undefined function from main.c but it returns int instead of void
Why is this allowed? Why doesn't the compiler stop me from doing this shittery?