/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Touch_typing
github.com/ValveSoftware/steamlink-sdk
tour.golang.org
golang-book.com
android.googlesource.com/platform/frameworks/av/ /android-5.1.1_r8/media/libmedia/IMediaPlayer.cpp
android.googlesource.com/platform/frameworks/base/ /donut-release/include/media/IMediaPlayer.h
stackoverflow.com/questions/15520098/implementation-of-remote#15523124
github.com/AnthonyBloomer/ezflix
twitter.com/NSFWRedditVideo

Idris is a reasonable language

fuck opengl though

OP is an unreasonable faggot

any programming language with more than three letters is automatically trash

Learn to touch type and you won't have trouble with longer names.

>touch type
Is that just a fancy name for typing? How do you type without touching your keyboard? Psychic powers?

en.wikipedia.org/wiki/Touch_typing

>steam link is $15
>Armv7 with neon and opengl ES,sdl,etc
>Official SDK: github.com/ValveSoftware/steamlink-sdk

>cheaper than a raspberry pi and can make for some cute programming ARM projects

Sounds comfy. How open is it?

Thinking about starting a cloud service for paranoid autists with a specialization for shitty connection speeds. What meme language and libraries do i use to get started?

Python with Django for the service
Pascal for the infrastructure background

>Pascal
some memes are too deep

what is the best configuration file format?

Seems totally open but not a lot of projects being made for it. I just wanna get some arm experience

//You should be able to solve this:

#include
#include
#include
#include

using namespace std;

int main()
{
ostringstream oss;
oss

I once colorized a drawing of that room.

tour.golang.org
golang-book.com

So I could do weird things..

nogenerics.info

An overly complex dice roller.

..like this.

>nogenerics.info
such a nice language, thanks for posting this!

You should eat a serrano pepper NOW /dpt/.

If I'm going to use SDL and GL3 + gles2.
What's the best way to load the GL stuff and does there exists some decent library that does that?

>Overly complex
Explain yourself, shit seems trivial to implement

he's talking about the human that rolls the dice

i don't understand

Overly complex in the expressions it recognizes - it's based on a proper context-free grammar, it's dice all the way down.
In a typical dice roller you can roll expressions like XdY, where X and Y are numbers. I allow X and Y to be dice. Numbers are just dice that roll their value every time. So 1d6 rolls a single 6-sided die, (1d6)d(1d6) will roll X Y-sided dice, where X is the result of rolling one d6, and Y is the result of rolling another.
There's also a bunch of other modifiers (exploding dice, keeping the highest/lowest, etc.), and standard arithmetic, all of it composable.

Doesn't seem overly complex to me. Just complex enough to be really useful.

Is this an efficient way to determine if a number is a prime or not?
int n, remainder;
remainder = 1;
for (n=2; remainder != 0 ; ++n){
remainder = num % n;
}
if (num == n - 1)
return (1);
else
return (0);

im trying to understand some low level android source code, specifically the audio playback. every function in the class ends with a call like:
remote()->transact(SET_DATA_SOURCE_STREAM, data, &reply);

or
remote()->transact(START, data, &reply);

does anyone know where the function pointer remote() is defined? its not in any of the headers from the file.
file and header for reference
android.googlesource.com/platform/frameworks/av/ /android-5.1.1_r8/media/libmedia/IMediaPlayer.cpp
android.googlesource.com/platform/frameworks/base/ /donut-release/include/media/IMediaPlayer.h

What's the big deal about closures? Why does every javascript book highlight them like one the most important features of the language?

Closures are anonymous functions with variable capture (also known as lambdas). Anonymous functions without variable capture are not particularly useful compared to free functions besides not needing a name.

>Is this an efficient way to determine if a number is a prime or not?
No. You would become extremely famous if you found one.

stackoverflow.com/questions/15520098/implementation-of-remote#15523124

lurk moar bitch

Yeah, I'm having fun with it. Most of the functionality would never be used in a real game, but I like the fact that the system does support this generalized notion of dice.
The idea is to give basic rolls simple, intuitive representations (if you type in XdY + Z it just werks), support extra mechanics from popular game systems (1K2d20 is 5E's advantage, 8T10A5d10 is a Storytelling System roll, 4d3-2 is a FUDGE dice roll), while allowing advanced users to do crazy things.

lambda expression is the base concept of many abstraction techniques.

Your medal's in the post.

int human() {
return 3;
}

int human(void) you mean

No, I mean int human()

fellow pajeets, can i get a quick refresher on what is extends and implements

same thing

>implements
class inheriting interface
>extends
all other inheritance

Can anyone recommend a good youtube channel(s) to learn c++ concepts? I'm taking a class on it and the textbook is really unintuitive, so if anyone knows of someone who is good at explaining these things, I'd be grateful

>implements
basically like header file in cpp right? but in java its for the programmer not the compiler or whatever
>extends
the children will have everything the parent have

I already know how to program somewhat and I want to study through this book

any objections?

it's nothing like a header file, they both inherit.

read SICP and do the tasks

how do i get started with something basic

have a high pH value

Pour acid on it to neutralize.

why does this work

def foo(a):
def bar():
print(type(a))
return a
return bar()
print(foo(1))


but this doesnt

def foo(a):
def bar():
a += 1
return a
return bar()
print(foo(1))


python 3.6 btw

import primes
if a is primes:
return 1
else:
return 0

That's a caustic reply.

what kind of a brainlet language is this ?

it's called fermats little theorem with the addition of i forgot what algorithm
an efficient algorithm for determining primeness exists
it's actually in SICP

it's probabilistic, but you can get 99.9999 certainty so who cares
there's also a polynomial algorithm to determine (or find a large prime for example) if a number is prime

you are thinking of factoring products of primes

Passing by reference vs. passing by value. Setting something else to a inside foo doesn't change the value of a outside foo.

>so who cares
Mathematicians care.

you do realize that a probablistic alogirthm where it is YOU who determines what the certainty is in the answer is literally A WIN right

at that point it's over, problem is solved

fourchan

Doesn't matter because such an "outside foo" is never referenced.

>Made sure I know something before moving onto the next chapter
>Few chapters later I forgot what I learned 3 chapters ago
Man, this is a bit demotivating. Always unsure if I should go back to review the whole shit again or to keep going. Slow progress...

def foo(a):
def bar():
nonlocal a # a is from an outer scope
a += 1
return a
return bar()
print(foo(1))

It's not about the value not changing, it throws UnboundLocalError: local variable 'a' referenced before assignment.

def foo(a):
def bar():
a = 3
return a
return [a, bar(), a]

works and returns [1, 3, 1].

Why do you need nonlocal on the second one and not on the first one?

Don't give up

Spent some time updating this thing. There was a lot of spaghetti from 2014; cut code in half and made it better.

Yes, it's just a glorified scrot + tesseract process invoker. The idea was to get it to automatically recognise text from around your mouse cursor so you can just mouse over something in manga or whatever and get the characters but I don't have enough time for that right now.

i not gonna explain what scopes are, please read a basic programming tutorial.

Gonna try to squeeze in as many programming books as possible in the next couple of weeks.

Currently finished with "The Little Lisper" and I have no fucking clue what the last couple of pages on Ch. 9 (the one that mentions currying and the Y-combinator) , but I'm just gonna move on to learning other stuff

Such a shame....

You seemed an honest man

Because Python is shit.

Command line utility that allows you to search for TV and movie torrents and stream using Peerflix automatically.

Been adding a lot more features to this over the past few weekends like advanced filtering and ability to download subtitles automatically.

github.com/AnthonyBloomer/ezflix

Hey, here. I use closures in my dice roller.
Say you want a function d(d1, d2) that takes two dice and returns a new die that rolls (d1)d(d2). We can represent dice as functions that, when called, return a random value from a specific distribution. We can implement d like so:
const d = (d1, d2) => {
return () => {
const number = d1()
const faces = d2()
let rolled = 0
for (let i = 0; i < number; i++) {
rolled += Math.floor(Math.random() * faces) + 1
}
return rolled
}
}

If we then also define
const constant = n => () => n

then d6 = d(constant(1), constant(6)) is a six-sided die, and d(d6, d6) is the (1d6)d(1d6) I mentioned here: . No messy objects with getters/setters/etc., just compact and composable functional programming.

>You seemed an honest man
what a whiny song

fuck anime and people who watch anime nowadays
literally normalidiots

...

ugly af

Employed Haskell programmer reporting in

Post feet

...

why are these threads so dead in american hours

Holiday weekend. Everyone is too type to drunk.

Is there any good low level opengl C library? All of them seem to be in sepples.

is this a legal signature?
can a non-brailet explain what it means?

With clang, is it possible to export visible symbols automatically at compile time?
I know about __attribute__ ((visibility ("default"))), but is it possible to export these visible symbols automatically into a consolidated header file so it can be included in other projects?

Anyone worked in the field of Io T (internet of things) programming something ?

GLEW

What do you mean? OpenGL *is* a low level C library.

Returns the maximum of an array of Es, where E must be comparable with itself.

something wraps the differences between gles and gl and lets you build cross gl shaders?

C/C++ query for you style nazis

#ifndef FILE_H
#define FILE_H
// code
#endif


or

pragma once;


or

#ifndef __542E2D93_2169_4149_A38C_C45EE4036B6B__
#define __542E2D93_2169_4149_A38C_C45EE4036B6B__
//code
#endif

the fuck is the third one

first

GUID

Using a GUID instead of a normal header guard.

why cant i fucking do the collatz sequence i thought this level of programming was easy
def collatz(number):
if number%2==0:
number=number/2
print(number)
elif number%2==1:
number=number*3+1
print (number)
elif number==1:
print(number)
print("Input a number.")
number=int(input(""))
while number !=1:
number=collatz(number)

Input a number.
7
22
Traceback (most recent call last):
File "collatz.py", line 13, in
number=collatz(number)
File "collatz.py", line 2, in collatz
if number%2==0:
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

Why would you use a double underscore though? isn't that reserved for the implementation?

Why don't you just use OpenGL ES?

how would you even write such a function?
I assume there is a standard compare function or something in which I can just reduce (or fold) the array with

>first
Why? Seems a chore if several projects have the same header an/or you need to rename the file.

not portable