/dpt/ - Daily Programming Thread

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

Attached: 1543221423073.jpg (720x960, 254K)

Other urls found in this thread:

godoc.org/encoding/json
twitter.com/SFWRedditVideos

Trying to set up a load screen on android so my app doesn't just go black for several seconds when switching to an activity with a big front load of computing demands.

wtf is this???

What do you mean, its just functional java

>fissbuss

oh come on, I just do that stuff so I can keep track of what is becoming what. Its close enough.

import android.support.v7.app.AppCompatActivity;
import android.support.annotation.RequiresApi;
import java.util.function.IntUnaryOperator;
import java.util.Random;


@RequiresApi(api = Build.VERSION_CODES.N)
public class FunctionPassingExample extends AppCompatActivity {

IntUnaryOperator fiss = (a) -> a%3;
IntUnaryOperator buss = (a) -> a%5;
IntUnaryOperator fissbuss = (a) -> a%15;
int Input = new Random().nextInt(100)+1;


@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Fissbuss(Input, fiss, buss, fissbuss);

}

public String Fissbuss(int input, IntUnaryOperator Fizz, IntUnaryOperator Buzz, IntUnaryOperator FizzBuzz){
String notfissorbuss = "%s";
notfissorbuss = String.format(notfissorbuss, input);

if(Fizz.applyAsInt(input) == 0){
notfissorbuss = "Fizz";
}
if(Buzz.applyAsInt(input) == 0){
notfissorbuss = "Buzz";
}
if(FizzBuzz.applyAsInt(input) == 0){
notfissorbuss = "FizzBuzz";
}
return notfissorbuss;
}
}

Your blog, your rules
Nodoby gonna judge you over what's you write. Poorly written posts are always better than no blog post.

If you work on a project, you may want to write about the progression of this one.
For each new features you could do a new post: what result you wanted to get ? What attempts have you done ? What's worked and what didn't ?

When you feel you've completely understood a concept, you could try to summarize it in a blog post.

your problem is you're thinking in terms of C/C++

Lisp is the most powerful programming language.

I want it to be more project-oriented but I believe it doesn't hurt if sometimes I talk about specific things, "neat tricks" as you put it

> Try writing a couple, ask for feedback, and try adapting your style to something that works best for the ideas you're trying to convey. Best of luck mate!
great tips, I truly appreciate it! thanks, user

that's kinda how I illustrate it in my mind. thank you for replying!

ah shit i see what you mean
just reduced around 30 lines of redundant code, cheers mate

JavaScript rocks!

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

I need some help with golang guys. Why wont it make an array of my Trades struct?
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)

type Trades struct {

time string `json:"time"`
trade_id int `json:"trade_id"`
price string `json:"price"`
size string `json:"size"`
side string `json:"side"`
}

type Trade struct {
a []map[string]string //that works
//a []Trades //this does not
}

func Getcandels(){
resp , err := http.Get("api.pro.coinbase.com/products/BTC-USD/trades")
z := Trade{}
if err != nil{
//pass
}
defer resp.Body.Close()
jsn , _ := ioutil.ReadAll(resp.Body)
err = json.Unmarshal([]byte(jsn) , &z.a)
if err != nil{
//pass
}
fmt.Println(z)
}

func main(){
Getcandels()
}

h-hello

fuck you

Post some really terrible code by you or others so I can laugh at it.

Attached: 1531526562170.jpg (1431x899, 452K)

>*posts wojak
> i love pepe the frog
>how do you do fellow anons?

Since Java 8 which was years ago.

based and redpilled

no, fuck you leatherman

Is this Android studio programming?

Thank you for using an anime image.

Golang person still here.

The fields on Trades have to be public.

Attached: Lisp NPC.png (944x539, 57K)

Literally puking, is that SEPPLES?

>installed Arch
>installed i3 with bitmap fonts
>bought a 40% keyboard
>learned Haskell
Where is my $300k job?
Don't tell me to wear stockins

Attached: 1420224787743.png (900x900, 281K)

You have to take s.oy and estrogen and make a twitter account and wear long rainbow socks and shave your legs too

dumb frogposter

> String notfissorbuss = "%s";
> notfissorbuss = String.format(notfissorbuss, input);
Why is this two steps?

It's more efficient.

I could you please tell me more about that?

Anyone else getting this issue? In android studio, if you have too many words in the text box for multi line, all your widgets on your screen disappears. Anyone has a fix for this? Here's a screencap of what I'm seeing.

Attached: Error.png (1631x558, 42K)

Ever heard of Integer.toString(...)?

No it's orange crab (ish)

hi

Attached: car.gif (600x308, 68K)

whats a project to prove my full stack developerness

nvm, i figured it out

Why are so many anime fags into programming? One of my lab TAs drew a sketch of an anime girl with huge breasts on the whiteboard. That was probably the cringiest thing I've ever seen

Attached: k.jpg (236x208, 9K)

>unironically uses integer divison more than once for fizzbuzz
Never gonna make it

Kill yourself frogposter.

what does the @ mean? Is it a decorator?

dumb frogposter

Create a game of reversi in Haskell ;-)

Programmers are mostly "losers" of the world like most of tech. These people attract to anime/japan/weeb culture for some reason.

Not to mention mental illness is a big thing now in tech in the US with traps and trannies and SJW movement and LGBT promotion. All the politicians constantly telling people like this to go into tech because its high paying and they know the more they push in the further wages will be driven down.

I'm working on a game with my friend using Godot. I'm basically making a clone of "Enter The Gungeon" just to prove that we could actually finish something playable. I'm only using the 2D part of Godot because it's comfy as fuck and I hope GDScript become faster as time goes. Does anyone has any experience with 2D gamedev and its shittyness?

Programming is actually a subset of anime.

Attached: 1544074982024.png (139x129, 23K)

pedophile

Give me a sample of your input JSON data.

>Does anyone has any experience with 2D gamedev and its shittyness?
I do but i don't know why you're calling it shitty
2D game development is so easy these days

it's called annotation in Java. I have no idea how it works and you could basically put an annotation to almost anything, variable, function, class, interface, you name it. I've only used it for Springboot and it's pretty comfy once you've got the hang of it.

dumb frogposter

Attached: 0ec42a6b5937fb75879d369bb2fd0b85e1bf34b9.jpg (1003x1339, 739K)

>All the politicians constantly telling people like this to go into tech
Seriously?

maybe crutches, words of wisdom or something like that. I've made my proof of concept and basically as soon as the date of the exam has passed, I'll start making it for a month.

pajkat v ramzes
who wins

[{"time":"2018-12-13T14:59:18.387Z","trade_id":55865937,"price":"3384.10000000","size":"0.02852379","side":"sell"}]

Just imagine lots of maps in the array.

That's not very nice.

Attached: gg3.jpg (658x374, 45K)

Yes. Also every major company pushes for it too. The more people of lesser quality they can throw into the mix the lower they can pay them.

>trannies
>real competent programmer
pic related to my point
I'm also including sjw and woman that thinks man are bad because they're man. I mean, they're not wrong, but there's no reason to be rude about it.

Attached: 1544467837660.png (1600x6283, 1.72M)

I don't know if there are any general words of wisdom, 2D gamedev is so well established now that anyone can do it
Just don't expect to have a decent game in a month
Try six months

If i have a char array in c++ like

char *poop = "bla bla 12 3";
how do i replace the spaces with the number (character) 0?

>6 months
give me an example, i've seen games made in a day like in those gamejams and it has better quality than most phone games on playstore. Not trying to disapprove your point, just wanna know what a professional gamedev could make in 6 months. I'm new to this.

first of all, it's char*
secondly
for i in poop
if poop[i] == ' '
poop[i] = '0'

>webdev

isn't char* became immutable sometime ago? Or am I thinking of other languages?

Well it depends how high your quality standards are. Gamejam games are prototypes, nobody would buy them. I don't know what you're aiming for.
A professional team, like a programmer and two artists, could make Enter the Gungeon in a year
I don't know how low the standards are for phone games, I dont even have a phone

nah it's not immutabe, just loop over it (hopefully you know the length of your poop) and replace whatever

strings in python are immutable, and im pretty sure java strings are immutable

fuck off with this meme, webdev are quite hard if you're trying to make a good website

To be fair here that picture is pretty accurate of why job descriptions suck. They don't pretend to be a good "programmer". He admits he's a UX designer at best and not into the programming/engineering aspect and that's what he wanted for in a job. He makes good points at why web dev titles are shit, why job descriptions suck, and how HR doesn't know what they are doing on job advertisments.

char poop[] = "bla bla 12 3";
char *ptr = strchr(poop, ' ');

for (; ptr != NULL; ptr = strchr(ptr + 1, ' '))
*ptr = '0';

You need the char[], you can't modify a string literal.

>i dont have a phone
redpilled as fuck. Even I only use it as an over glorified mp3 player. And thank you for the time reference, I need that.

image poster here, holy fuck you've actually read the post. Guess my bait don't have any effect on someone with reading comprehension.

>redpilled as fuck
no i just dont have any friends

it can be hard, but it's artificial difficulty.

This. Webdevs use retarded frameworks for everything and throw in 100+ packages of dependencies and wonder why their shit is slow and broken.

Try to make it scale to 1,000,000,000 users.

you can modify a char*
is just an array of chars bro

package main

import (
"encoding/json"
"fmt"
"log"
"net/http"
)

type Trade struct {
// Have to be public for the json package to access them
Time string `json:"time"`
TradeID int `json:"trade_id"`
Price string `json:"price"`
Size string `json:"size"`
Side string `json:"side"`
}

func Getcandels() (err error) {
resp, err := http.Get("api.pro.coinbase.com/products/BTC-USD/trades")
if err != nil {
// Handle your errors, you damn slut
return
}
defer resp.Body.Close()

// Declare array for decoder to write to
var z []Trade
// A streaming decoder is more efficient than capturing and decoding with a
// buffer
err = json.NewDecoder(resp.Body).Decode(&z)
if err != nil {
return
}

fmt.Println(z)
return
}

func main() {
err := Getcandels()
if err != nil {
log.Fatal(err)
}
}

// RTFM: godoc.org/encoding/json

just buy more servers

hope you do well in life user

>artificial difficulty
so human communication is the artificial difficulty?

Only if it points to something you can write to, you can modify a string literal. This will segfault on most systems.

char *ptr = "string literal";
*ptr = 'S';

im in the middle of making a Chip 8 emulator and im a bit stumped on how to make a display window with the output of my program drawn to it.
anyone know a good way to do this?

>can
*can't

i see what your saying, i was wrong
for example if you have
void function(char* string){
}

if you try to modify string in function it's an error

im assuming cuz the compiler puts it in the static part of memory, .bss or whatever that's called

you're right

Thank you so much and I know this might sound like Im asking a lot but imagine this , a different api has different json keys but the data is pretty much the same. Do you have to make a whole new struct or is there a way to reuse this somehow?

Google struct embedding.

thanks f4m

didn't know using capital letter as the first letter of a variable is basically the keyword of "public" in go.

but why?

Stop using node.js and it's not an issue.

GLFW or SDL

Because Rob Pike is retarded. Go has its faults too.

thank you user looks good

Attached: f5ed8b61442b291ce583d3c44bb9a4c7.jpg (500x398, 40K)

how about rust?

>run c program
>Segmentation fault (core dumped)
oof

It's working as intended.

my favorite is when i fuck up so bad that i don't notice how it just uses up all my memory and my computer crashes and i have to reboot

>be a retard
>pay the price for it
Checks out.

please do not bully !

Attached: 1517689595831.gif (512x512, 639K)

imagine believing we should stick with a language from the 70s that was haphazardly designed to write kernels for 16-bit machines.