/dpt/ - Daily Programming Thread

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

Attached: 1564536803174.png (1000x1000, 483K)

Other urls found in this thread:

github.com/Cxbx-Reloaded/Cxbx-Reloaded
pastebin.com/vaKxJz7L
twitter.com/NSFWRedditGif

Some scripts to generate random (S)FTP traffic. Thought about doing it in Python but I've really enjoyed doing it in shell. If anyone has any suggestions on how to properly put endless amounts of data

such a shitty thread

You're late.

Oi, Anone! Your JavaScript project looks sweet! Good job! (`・ω・´)b

Attached: 1f1bbbc4828b0aea17159ddfc1203f93.jpg (600x901, 56K)

shill your obscure lang, i need more to procrastinate with.

covering all my bases here >>

Thanks! Although it's written in C++20 not Javascript.

>programming thread
>posts 3d artist

Attached: 1550168563812.png (1000x1155, 314K)

But the artist herself is 2D

nene is a miracle of the universe.
>learn programming and make a game just to get a job at a game company to be with your friend

>shift it right by 5, we get 11111110
no, also order of operations. your thing is equivalent to
(0xd0 >> 5) & (7

why do all programming books have the same type of humor?

ATS
It's the one true lang

for what purpose

>Why do books written by programmers for programmers have programmer humor?
gee I wonder

I don't mean that jokes are related to programming, but rather thall all jokes are whacky childish ones.

I've looked at ATS a few times actually.
Seems to be the only actual lang with full linear types so i may finally give it a go.

What's an easy way to round up a given number to the nearest given multiple?
e.g.
x = 81.123
y = 2.5
f 81.123 = 82.5

liftM6

ah, the true elegance of haskal

Programming on laptops is really annoying. After half an hour i catch myself slouching and my wrists hurt like hell.
Fuck my life.

laptops are only good for using in bed.

They overheat in bed.

imagine getting out of bed

buy a metal lap stand with a mesh for ventilation.
The amazon basics one gets the job done for me

ceil(x / y) * y

const roundToMultiple = (number, multiple) => {
const divided = number / multiple;
const integer = Math.trunc(divided);
const decimal = divided - integer;
return multiple * (integer + Math.round(decimal));
};
If you want to to always round away from zero then in the return just to (integer + (decimal === 0 ? 0 : Math.sign(number)))

State is basically a way of taking and returning an extra parameter but with the functor/applicative/monad interfaces

The virgin The chad

int z = (int)(x/y);
return z*y
//This is Java coz I'm a n00b

If you don't want to use built-in functions you can just cast to integer.

Is the lowest incline comfortable when used in bed? Is it on your lap or are you doing a handstand or...?

This is for C++ and QT. I'm trying to learn QT. I used QT Designer to get a .ui file. I know how to use uic.exe to get the .h file, but I want to get a .cpp file too. All methods I can find to do this via uic.exe have me doing things that do not work; uic.exe tells me that whatever I try is an unknown option. I can only assume it's because those functions are now deprecated. Could someone help me here?

I understand that there are better ways of doing this by having QTCreator just do this for you automatically from the .ui file, but I want to see and play with this.

>.exe

Look user, I'm not a smart man, but I'm trying here.

Yeah, it's on my lap, legs are usually a quarter/half wayup and i have a bunch of pillows behind me to avoid neck strain. All the levels except the very highest are usable depending on how you lie. Build quality is just okay though, you're pretty much getting what you pay for, but as long as you don't throw it around, you'll be fine.

Thanks mr. amazon shill, i am buying one right away. I hope Jeff uses my $20 to snort heroin.

no problem m8.
>tfw haven't sold enough laptop stands this week so rajesh is docking my pay again

IDK how to post code but im working with linked lists in c++ and im apparently de-referencing a null pointer. how do I i make it go away. also what is it?
void reverselist(list* n, int x) {

list *head=NULL;//starts as a
list *last=NULL;

last = new list();
head = new list();
last->p = NULL;

head = n;
//set the head to a->b

while (n!=NULL) {//loops to and sets n to the last item in list (n->null)
last = n;
n = n->p;
}
//set n to point to head->p
n = last;//n = d
n->p = head;
//set head to point to null
head->p = NULL;
//repeat for x # of items in list
return;
}

head->p = NULL is where its happening.
ayyy i guessed the code thingy right!
heres my list struct
struct list {
int val;
//points to the next list object
list* p;
};

Im not gonna bother reading your question. Use nullptr and stop using new.

>Type theory!!

Attached: 1565538363940.gif (326x192, 41K)

I like a strong type system.

>design patterns!! monads!! i love my job!!

Attached: onions.png (644x800, 15K)

Go back to Java and stay there.

Simple type theory (HOL) > dependent type theory (MLTT)

Dynamic typing is better than all of those

A good static type system can subsume """dynamic""" typing

>uni type values with runtime checking
>brainlet.jpg

>Dynamic typing! JavaScript and Python! I don't need my hand held by a type checker!

Attached: soy.jpg (1024x617, 123K)

run with ASAN, if that doesn't clear it up get out gdb.

based and redpilled
there are so many retards who know nothing but pi types

tell me about pi types, why do they have superiority?

they don't, pi types are just dependent function types and absolute brainlets think that everything is about dependent types

Is there any tutorial to learn C for an ASM perspective?

like comparing the diferences?

Attached: Tusky Uncensored_1565539686112_MF09UHKXCF.jpg (1200x1063, 167K)

just..
coding..

I looked through some old code I wrote when all this was still new to me ...

Attached: 9u.png (83x652, 8K)

I figured it out myself. I didnt realize head was literally n.
head = n
head->p=n->p is correct

Attached: pinguclap.gif (250x200, 458K)

Working on writing my own Jow Forums-x in Elm.

is writing functions and code in C in a non POO way, just like outside the main loop all the functions are global and there's global variables, and you can make your game using only those global functions combined without a class?

trying to clean my mind of POO brain root.

>Elm
sugoi user, have a public repo?

Is it safe to say that any language that compiles to x86 native binaries can be used to program for a proprietary game console, as long as you have the SDK?

Or is there something that makes c++ the only option for such things?

t. interested in writing something for an old console

As long as you can compile object files that can be linked with the SDK you should be fine.
But C or C++ are the gotos. What console?

If it has inline asm or c ffi, you can probably use it for emu/retro dev.
Which console though?

drop C++, use C

Original xbox. It has a pretty interesting hacking scene, and it's pretty close to PC, so I thought I'd give it a try.

Actually, I was thinking of using something a bit more esoteric like pascal or even ada, that's why I'm asking if C/C++ are the only options.

>C/C++
Never heard of that language.
Did you mean C?
Did you mean C++?

"C or C++".
Hence the "are".
Stop being an autistic pedant.

I'd give Zig a look since it can be used as a c compiler.
pascal is pretty ded these days, Ada might be too cumbersome, but who knows.
CXBXC is mostly C++ and C though.
github.com/Cxbx-Reloaded/Cxbx-Reloaded

If you do Ada you'll need to use the FSF GNAT compiler as the Adacore one will likely not comes with the tools needed to cross compiler or compile directly to x86.

The main issue is that you'll need to use highly C++-focused system libraries like DirectX.

>he doesn't use the pedantic flag
>-pedantic

>Is it safe to say that any language that compiles to x86 native binaries can be used to program for a proprietary game console, as long as you have the SDK?
that's the opposite of true
maybe for modern consoles, definitely not older ones

It depends on what you mean by "having the SDK." Embedded and console development usually requires some assembly to set control registers, etc., so whatever language you're using would need to support inline assembly.

If you're intent on using a high-level language, it might be easiest to write a small "firmware" layer in C and then call into that from the other language.

SEPPLES can inline asm

In my experience recent consoles rarely require you to do that kind of thing with assembly. Anything newer than the 6th generation just lets you do it all with C bindings.

Attached: govnocode.webm (640x360, 2.35M)

i missed you user
there's been this awful js poster lately

Doll poster is CUTE

what the fuck is govnocode?

govno = shit

oh

Attached: a9c[1].jpg (2560x1920, 895K)

How can I fix the following warning:
Library.hs:121:29: warning: [-Wtype-defaults]
• Defaulting the following constraint to type ‘Integer’
Integral a0 arising from a use of ‘fromIntegral’
• In the first argument of ‘(.)’, namely ‘fromIntegral’
In the expression: fromIntegral . ceiling
In the second argument of ‘(*)’, namely
‘(fromIntegral . ceiling $ x / minPlates)’
|
121 | ceilWeight x = minPlates * (fromIntegral . ceiling $ x / minPlates)

For code:
ceilWeight :: Float -> Float
ceilWeight x = minPlates * (fromIntegral . ceiling $ x / minPlates)
where minPlates = minPlate * 2

So I made something to help with actually using imagepack to Starsector
number = 0
while number < 100:
number = number + 1
print(f' "graphics/portraits/e{number}.png",')
Is it any good for like two hours of learning Python?

there's an ambiguous type in (fromIntegral . ceiling)
basically you want to specify what the intermediate type should be
for example
ceilF :: RealFrac a => a -> a
ceilF = fromIntegral . (id :: Integer -> Integer) . ceiling

here i'm composing id in the middle, specialised to Integer, to specify that's what I want
you can also use TypeApplications in a recent GHC version so it'd be
fromIntegral @Integer . ceiling

where is the fucking bug in my code?
Pressing buttons A ON/OFF works, but group B doesnt. What did I do wrong? I can't find it.
#include
#include
#include
#include
#include "rc.h"

#define F_CPU 9600000

#define A_ON PB2
#define A_OFF PB3
#define B_ON PB1
#define B_OFF PB4

enum switches {
SW_A,
SW_B
};

ISR(PCINT0_vect)
{
cli();
uint8_t btn = PINB & ((1

>rc_set(SW_B, 1);
Also this call works. I testet it without the press of a button.
case (1

it's good for a beginner. it isn't long so there isn't much to go on otherwise.
you could also use a for loop
for number in range(1, 100):
print(f' "graphics/portraits/e{number}.png",')

that should probably be range(1, 101) because i don't think it includes the last one (i don't really know python)
in C you would basically have the same logic
for (int number = 1; number < 101; number++)
printf("graphics/portraits/e%d", number);

but the for loop here (different to python for loop) does the increment (number++ is mostly the same as number = number + 1) at the end, not the beginning

>TypeApplications
Cool, I didn't know about this feature.

I got the program to work, but it needs cleaning up. Especially the code duplication.
pastebin.com/vaKxJz7L

I don't understand how it would work at all, wouldn't PINB always have 2 bits set? (since either button will be either on or off)

No, those are four buttons basically (for a rc remote). Group A and B. One Button for on/off each.

Should I check out Go or Rust today?

the two things I notice is that almost everything is
ceilWeight (partOfInput * (1 - (interval / 100) * k))
you can abstract over this
calc interval partOfInput k = ceilWeight (partOfInput * (1 - (interval / 100) * k))
mondaySquat = [ ceilWeight $ inputSquat input * (1 - (interval / 100) * 4)
, ceilWeight $ inputSquat input * (1 - (interval / 100) * 3)
, ceilWeight $ inputSquat input * (1 - (interval / 100) * 2)
, ceilWeight $ inputSquat input * (1 - (interval / 100))
, ceilWeight $ inputSquat input
]
--
mondaySquat = [ calc interval (inputSquat input) 4
, calc interval (inputSquat input) 3
, calc interval (inputSquat input) 2
, calc interval (inputSquat input) 1
, calc interval (inputSquat input) 0
]
--
mondaySquat = map (calc interval (inputSquat input)) [4,3..0]

some of them have + minPlate * 2 so the last step wouldn't be possible for those

alright I think I get the button organisation. Does the ISR not run at all when you press the B buttons or does it run but doesn't select the right case?

High IQ individuals tend to have child-like features and thoughts. My dad is above 140 IQ and look like he's 20 and acts like a veggie tales character.

It does select the right case.
When i put rc_set(SW_A, 1) into the B case then it works.
If I put rc_set(SW_B, 1) into the main, then it works too. Just not SW_B inside the ISR. I don't fucking get it at all.
>tfw no programmer that would let me debug that shit

Prolly gotta get my logic analyzer out, but too lazy right now

Anybody who has worked with Python multiprocessing and Queues. Is there any way (via Queue or not) to pass large dataframes (possibly even several GBs) from child process to the main process?

now that's weird
what does rc_set do?