/dpt/ - Daily Programming Thread

>What are you working on?
>Previous:

Attached: programmer.jpg (604x340, 24K)

Other urls found in this thread:

imagefap.com/profile/Recursive/galleries
pastebin.com/PMh76eVu
youtube.com/watch?v=pMYZm3A9Sjs
racket-lang.org/
portacle.github.io/
twitter.com/SFWRedditImages

lads, gimme some lesser know programming anime to watch or manga to read.

how can i write an ai to teach me how beautiful the world is?
should i just have it give me wikipedia files that fit a certain filter?
or is there more?

let randoNum0 = Math.random();
console.log ('randoNum0 = ' + randoNum0);

let randoNum1 = randoNum0 * 120
console.log ('randoNum1 = ' + randoNum1);

let randoNum2 = randoNum1 / 20
console.log ('randoNum2 = ' + randoNum2);

let diceRoll = Math.ceil(randoNum2)
console.log ('diceRoll = ' + diceRoll);


so, i just started playing with JS. i THINK i made a 6-sided die.

(i'm sure there's a more elegant way to do this)

is my logic right though? is there truly a equally random chance of getting 1, 2, 3, 4, 5 or 6?

Attached: 2018-04-23 - Copy.png (900x1560, 105K)

>How do I teach an AI something that is false
Just give it enough false information

no, i want it to teach me

That's basically circular reasoning

nowhere did i specify that the ai must be taught

I'm working on a personal project that uses

* Elixir/Phoenix backend
* Postgres database
* React.js front-end with React-Bootstrap
* Using a genserver like a cron job to regularly fetch and store data from an API into my database for my application
* Running it using docker (pulling an ubuntu image) on a Linode instance running ubuntu

>MFW Elixir is the best language ever

Attached: 54HkHcR.jpg (1366x768, 118K)

>the term "artificial intelligence" is applied when a machine mimics "cognitive" functions that humans associate with other human minds, such as "learning" and "problem solving".

If it's not learning nor solving problems independent of your input, it's not AI

>the term is applied when
>thus the term is appled only when
nice

How would I go about designing a dictionary trie for LZW? Apparently hashmaps are not good enough. Is it just a tree where every node is a linked list?

>I unironically love templeOS and HolyC

Is there a way to learn or use HolyC outside of TempleOS?
I'd love to see what additions were made to it

pastebin.com/8b1ts5kS
How do I change font size in Tkinter (for this script, not labels)?
Trying to make a console with it, but the text size's too small, also am a pythonlet.

When im coding my mouse hand gets so cold i lose partially feeling in it. How do i deal with this?

Turn on a heater or something.

>coding
>mouse hand
?
and is our room just cold? get some gloves silly

>he doesnt code on an on-screen keyboard
kek

>what are capacitive gloves

quick give me an idea for an android app

does anyone have a good way of hiding the scroll bars on the new firefox?

Fart app.

local small transactions
e.g. put up an offer to buy a condom within a 500m radius, or a couple eggs

>capacitive gloves when using a mouse
triple kek

>Any math major can do this in his sleep even if he never seen merge sort before.

Why is /sci/ so delusional?

made me gig there

Elsa & spiderman abortion game where each time you lose you get a 3min ad.

I wrote a python script to download galleries from ImageFap.

I never used the site before and just wanted to download a bunch of galleries from one specific user.

imagefap.com/profile/Recursive/galleries

I wanted all these images, so I just created folders for each of those categories, created a text file called "list" inside each of them, which contained a list of links to each gallery, and then ran this.

while read link; do imagefap-get $link; done < list

imagefap-get is the python script I wrote, pic related.

I use a similar skeleton as a base for scraping many websites, I created the skeleton myself though. It is extremely useful and simple.

pastebin.com/PMh76eVu

Attached: 2018-04-23-034120_746x755_scrot.png (746x755, 40K)

Elixir is maybe the only language better than Ruby/Smalltalk/Lisp.

haha yeah or a game adaptation of "Batman Eat Shit ! Shit Sticky face Elsa and mouth Anna"

The only fault with elixir is it can get a bit ugly sometimes.

I can't find my confidence back. Simply unmatching color of parenthesis gets me worried.

Attached: Screenshot from 2018-04-23 18-03-43.png (1480x1880, 234K)

Why not just pick a number between 1 and 6 inclusive to begin with?

That's just your editor being std::shit

Does paredit get better if you get used to it?
It's cool if thongs go smoothly, but once I need to restructure some expressions all hell breaks loose, amd usually I just disable it while I do the fix

God I hate fucking timezones. Covnerting between them is a fucking nightmare. Why cant humans just all use UTC everywhere?

Rust doesn't have this problem

>Learn Android app development
>I’ve come really far
>Know all about how to do it
>When I sit down to make the app I want, I get overwhelmed and feel helpless

Maybe I’m just not cut out for this

In my experience, whenever Elixir was getting ugly, it's because I was doing something really weird or using a library in a stupid way.
There was never a time I couldn't refactor my solution into something more elegant, and the refactors were always obvious in hindsight.
It resulted in a very exploratory process of writing code -- do a first write to discover the appropriate dataflow, then once how the code is supposed to work, refactor it to make that process plain.
Elixir always seemed to support this workflow, letting me approach this discover-dataflow->optimize-code in bite-sized chunks.

My problem with Elixir was I often found myself having to reverse engineer how libraries work -- even if a library was documented well, you often had to dig in and discover how it was treating the dataflow to know how a higher level would work.

It means it takes a long time to start becoming productive when you're using a library you haven't used before. I kind of prefer Ruby for that reason -- it's very easy to just start hacking your solution.

Don't worry. This is how every programmer feels.
I feel like this *every fucking time*. What I always do, is just pick one feature that seems relatively simple and with fewer dependencies (rather, one which will be a dependency), and start chipping away.

I want to add -- if you don't feel this way, you're probably doing something wrong or are way overconfident and writing dumb dumb code.
That you're unconfident means you're concerned about the overall design of your code. You're waiting for your mind to understand everything before you start putting code down.
The problem is -- that understanding isn't going to come unless you're working for NASA or some shit.
Coding is an exploratory process. Just start hacking.

My little pet project is getting better every day. With a few months of work and better hardware I think it could handle decent players with ease in competitive. Might work better in games where opponent is more visible but I'll look into it later.

youtube.com/watch?v=pMYZm3A9Sjs

still way too slow.

Appreciate the advice user. It is very overwhelming but it’s nice to know that the feeling is common. I’ll start with authentication and the login screen and see where it goes from there. Thanks.

i've been toying around with python for a while now, doing some of the easier stuff on pro/g/ramming challenges
i want to try my hand at a small game, like a very basic rpg or literally just snake, i don't know where to start or what to use though, any suggestions?

Decide whether it's going to be graphical, TUI based (ncurses), or text based.
From there, you can start looking at things to start implementing it with.

Merge sort is my favorite sort desu
its elegant and seems so obvious once you learn it

Nah, heapsort is the best.
Graphically, it looks like a clusterfuck, but once you actually know what it's doing, it's so elegant.

Attached: 1524375342479.jpg (492x438, 62K)

>tfw boss didnt came in today so if i stayed home and did nothing he would never know
fuck i wish i could know these things beforehand, i could just work on my android apps instead

That's a cute cat.

Attached: sneaky cat.jpg (712x987, 368K)

Re-heaping everything doesn't feel as clean. Q sorts are usually the most disgusting though

Trying to program in a C idiom with a C++ compiler.
Would it be deeply wrong to mix in a few unique_ptrs? It gets really annoying making sure every init function is matched with a close function.

Attached: 1523323107170.jpg (417x452, 14K)

template
constexpr void heap_sort(Container& list, Compare comp=nullptr){
if constexpr (std::is_same_v){
std::make_heap(std::begin(list), std::end(list), comp);
std::sort_heap(std::begin(list), std::end(list), comp);
}
else{
std::make_heap(std::begin(list), std::end(list));
std::sort_heap(std::begin(list), std::end(list));
}
}


Behold the power of C++

Do you mean you're writing C++ in a C style? If so not using unique_ptr is just bad and autistic

Yeah. RAII is only worth it if you're writing in the "modern" C++ discipline because of exceptions and shit.

Stop being a crap eater and just write C.

Why [math] tag is far more customizeable and complex than code tag?

Math uses shitloads of glyphs

It works about 35% faster on optimized settings sacrificing some detection accuracy for speed and capturing small area around crosshair. It's still many orders of magnitude slower and inaccurate than reading positions from memory.

Gotta work on dataset generation and finish all shit so it's ready for a time when I can just throw a lot of power to it and it works

Because it's LaTeX

Attached: d4a4cefd8a5f230bd90acbefa373b282.png (343x43, 2K)

this is what happens when the timeline splits away from lisp and goes full retard in the opposite direction

Unrelated but why not just defined a void function called debug or something that prints a debug message inside of ifndef ndebug check then just calling it everywhere instead of having to clutter everything with these checks throughout the code.

didn't you get it backwards?

d'oh

>This spaghetti code

What in concatenation

That's not even close to being spaghetti. Do you even know what spaghetti code is?

Math.random() returns a number from 0 inclusive to 1 exclusive, so there's a possibility that randoNum0 = 0, so diceRoll will also be 0

Math.floor(Math.random() * 6) + 1

Hey man chill, no need to get defensive over your spaghetti code. I’m just calling a spade a spade, you can improve it through more practice

I'm not the guy who originally posted the code, but I do write enterprise grade saghetti for a living.
It's not saghetti unless you have at least a couple of goto's break's continues's (with bonus points if they're hidden in a macro.

I want to learn lisp. Which dialect should I choose?

Attached: sicp.jpg (600x338, 100K)

does not matter, in the end lisp is lisp - useless

>so there's a possibility that randoNum0 = 0
what is this probability?
I know it is not 0 since floating point is not real numbers, but it can not be very high can it?

the same probability of any other number

You a a reddit cyber"punk" who fell for nu male movies and shows. Sorry to shit on your cake but AI isn't what you think it is. I suggest refraining from spouting shit you don't know anything about, had I seen your rampant faggotry in real life I'd have had you lynched.

Not true with floats. There's less precision around .5 than at 0.

scheme

I'm pretty sure that Math.random() uses the entire float's mantissa to generate a random number and doesn't care about the exponent, so there's a 2^(-23) chance that it will be any number. The precision should always be the same.

[spoiler]I'm talking out of my ass[/spoiler]

you should use separate constructors here. branching behavior based on the size of the provided initializer_list:
(1) creates inconsistent/unpredictable semantics. there's a clear difference between "Ring(5)" and "Ring({5})", but with this code, the (important) difference between "Ring({1})" and "Ring({1, 2})" is semantically invisible at the call site.
(2) arbitrarily assumes/requires the "length to reserve" value to be of the same type as the container elements in the 1-argument case, effectively disabling use of this functionality for non-numeric types. how do you reserve 5 elements for a Ring?
(3) unnecessarily branches at runtime. with separate constructors, overload resolution would determine the path of execution at compile time.
(4) repeats work already done in std::vector, which has distinct constructors defined that yield the functionality you're looking for (which you can most likely get using constructor overloads and initialization lists alone, without the need for any constructor body code at all).

also, you should take initializer_list arguments by value (copying them does not copy the underlying values). this is the standard behavior; they already naturally have reference semantics, so taking them by reference is redundant. also, your code takes it exclusively by rvalue reference, which arbitrarily disables functionality that ought to work (in >1-argument cases of deducible/uniform type, "auto list = { ... };" deduces an initializer_list from the arguments, which can then of course be passed to functions - but your constructor would not accept such a list, due to it being an lvalue reference)

Literal C# beginner here, I tried making a simple script that would sort a bunch of files into different directories.
Well as it turns out, File.Move can't be used to move files into already existing directories. Is there any workaround for this? Copying and then deleting the original isn't viable since I'm moving gigabytes of data.

Hey there, I want to write a simple program which involves these 5 variables-
u (initial velocity), v (final velocity), a (acceleration), s (distance) and t (time).
The users chooses to enter values (doubles) for any three variables and the program calculates the other two variables.
I first thought of creating 20 functions, like
Four to find u, four to find v, etc (4c3 = 4).
Tried to simplify it with 4 for u, and after u value is confirmed, 3 for v, 2 for s. By now, 3 values are confirmed so just 1 function for a and 1 for t, so a total of 11 functions. But doesn't look elegant at all, what's the correct way to approach this?

optional arguments with default value?

You should use MATH and ALGORITHMS

File.Copy) has an overwrite overload and then File.Delete()
You can also use filestream to overwrite the existing destination file.

Is that Python? So does it rearrange equations itself?

P(f == 0.f) = 2^(-151)
P(f == .5f) = 2^(-24)

The exponent is generated geometrically from -1 to -128

As I said, I'm moving a lot of data. If I copy it and then delete the original it'll take minutes, at that point I might as well do it by hand.

>(1) creates inconsistent/unpredictable semantics. there's a clear difference between "Ring(5)" and "Ring({5})", but with this code, the (important) difference between "Ring({1})" and "Ring({1, 2})" is semantically invisible at the call site.
Point taken.
>(2) arbitrarily assumes/requires the "length to reserve" value to be of the same type as the container elements in the 1-argument case, effectively disabling use of this functionality for non-numeric types. how do you reserve 5 elements for a Ring?
Not sure what you are trying to say, but the underlying structure is vector. I'd simply use vector.reserve(5), as suggested in the code.
>(3) unnecessarily branches at runtime. with separate constructors, overload resolution would determine the path of execution at compile time.
Point taken.
>(4) repeats work already done in std::vector, which has distinct constructors defined that yield the functionality you're looking for (which you can most likely get using constructor overloads and initialization lists alone, without the need for any constructor body code at all).
Point taken.
>also, you should take initializer_list arguments by value
>exclusively r-value ref
I thought T&& is the universal reference?


Also, thanks for the useful feedback, senpai.

Attached: 1517698309948.jpg (1053x1063, 332K)

Akarinposter used C, not C++

racket or common lisp.

racket-lang.org/
portacle.github.io/

Wrong. There is at least one akari poster for each of C (microsounds), C++(me) and Rust(Ruby Sempai)

Attached: 1520047614749.jpg (643x720, 154K)

if you know/want to learn Emacs: clisp

Microsounds is the only real akariposter you fraud

Attached: 1523932796297.png (373x346, 105K)

I'm tired of working with Java, what language should I play with over the summer? I've never had to manage my own memory since Java does garbage collection it's has always been handled for me. I was thinking of maybe but playing with C or C++. I just want to make a few small desktop apps and play around with dynamic arrays.

Attached: litedog.jpg (500x493, 22K)

I know on old hardware from like the 80s and earlier, any data that was copied or moved had to go through the CPU unless there was hardware support for DMA. How is it on modern PCs? If I copy a file from one HDD to another, is all the load on the CPU or does it just get directly copied from one location to another?

I just went through the V8 engine source

// Static and exposed for external use.
static inline double ToDouble(uint64_t state0, uint64_t state1) {
// Exponent for double values for [1.0 .. 2.0)
static const uint64_t kExponentBits = uint64_t{0x3FF0000000000000};
static const uint64_t kMantissaMask = uint64_t{0x000FFFFFFFFFFFFF};
uint64_t random = ((state0 + state1) & kMantissaMask) | kExponentBits;
return bit_cast(random) - 1;
}

It only sets a random mantissa. The exponent is always 0 (1023 - 1023), so the precision is from 1.0 to 2.0. Then it subtracts 1, which doesn't cause information loss, so the probability of any number being generated is 2^(-52) (double instead of float)

>Static and exposed for external use.
> static inline
dafuq am I even reading

>literally just solving a system of equations/basic algebra and physics 101 kinematic equations

I'd do something like:
def Solve(a=None, v=None, s=None, t=None, u=None)
Solve(v=10, u=20, t=30):
if not a and not s:
a = accel(v, u, t)
s = displace(v, a, t)
# do stuff with a and s here, maybe return a tuple or print something
elif etc...

where accel and displace are also functions
basically the kinematic equations rewritten for their respective variable
>v = u+at
becomes
def accel(v, u, t)
return (v-u)/t

btw I hate python lately
sick of it to be honest

dma is still the way to go

Ooh, that's a clever way of doing it.