old thread: >when your program abuses undefined behavior and triggers valgrind warnings up the asshole but your program is correct
What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
eigen.tuxfamily.org
godbolt.org
stackoverflow.com
web.archive.org
api.site.com
api.site.com
api.site.com
api.site.com
api.site.com
api.site.com
youtube.com
twitter.com
too soon, fgt
Productivity tips? Currently:
>Having a sleep schedule (rise at 6 and go to bed at 10)
>Alternating between focused-work and rest (60 min for work, 30 min for rest) sessions
>Using Python and Make (free multithreading) for scripts (level generation from image) and C11 (need performance and too much of a brainlet for C++) for the game engine
>Sometimes using physical work (splitting logs) as rest from programming, but longer (90 min session for a full trailer). I think it's working just as well, maybe just as good as good as just resting, but you get perspired so that sucks.
>Reading random excerpts from C11 standard, OpenGL ES 2.0 guidebook, OpenGL ES 2.0 standard, GLSL 1.0 standard on free time when just can't think about programming anymore (it gets too much, maybe I don't like it as much as I thought I did, but it's too late to "search for myself" now, I'm fucking 20 already)
>Using Code::Blocks svn build (much fewer bugs and much faster) and IDLE as IDEs
>Dropped Lua because Python does its job (except for high-performance embedded game-engine scripting, but my little turd is very far from that) and focusing on Python
>Thinking about starting drinking coffee, maybe it improves focusing on code (or maybe I should look into aderall for a real thing?). So far not having any major bad habits (smoking, drinking, drugs) but this one might actually be beneficial.
>Got ~3.5 years to start my own company because then I get my university degree (software engineer) and if I'm not good enough to sell my own shit by then I'm officially a failure
>So far got some primitive matrix/vector math that I'm really using, nothing else, even algorithms (only BFS, DFS, backtracking and shit I have probably re-invented when I needed) in my head, maybe that's enough. Can't wrap head around physics with angular velocity (haven't really tried yet), for know I'm fine with "minecraft-like bit-array using primitive physics", access is O(1)
report and ignore
Please, vinny did nothing wrong
Here's the real one made after bump limit:
no thank you
>>Got ~3.5 years to start my own company because then I get my university degree (software engineer) and if I'm not good enough to sell my own shit by then I'm officially a failure
kiddo. That's not how life works.
Let him be, life hasn't curbstomped his hopes and dreams yet.
wow I suck
#define TRAPS straight
You do know that /dpt/ used to only use this image, right?
>you will be a loser like me. just wait for it
Soon as it grows beyond a lexer, I probably will. Like I said, it's pretty early on in development at this point. It's just a couple hundred lines for now.
that's a cute girl
Outright lie.
>sure is summer
at least go work on your shit instead of shitposting
If you're trying to make an end product and not teach yourself stuff like math and physics, use libraries like Eigen and Bullet. Making a proper math or physics library is an undertaking that can take years in and of itself.
>sure is summer
>girl
use Sexuality::*;
#[derive(Debug, PartialEq)]
enum Sexuality {
Gay, Bi, Straight
}
trait Are {
fn are(self) -> Sexuality;
}
struct Traps;
impl Are for Traps {
fn are(self) -> Sexuality {
Gay
}
}
fn main() {
assert_eq!(Traps.are(), Gay);
}
What esoteric programming language is this?
TrannyLang
a.k.a. Rust
The death of Cniles
if you haven't already made it, all you have is your lofty dreams, and you're probably deluded about what you can achieve or the timeframe of doing so. reaching massive success in a few years time is something very few people can pull off
if i pull that off, would you die?
I also grabbed my image from wiki.installgentoo.com
>use libraries like Eigen and Bullet
The thing is, as far as I looked at them they're humongous and have a steep learning curve.
If I can limit my game to simple block-like physics without angular momentum, rolling my own 2D/3D bit array is a task I can accomplish myself in a reasonable timeframe, which would probably be less that getting accustomed to a full-blown physics engine and learning C++.
Eigen isn't that hard. I'd say it'd be easier than teaching yourself the underpinnings of the relevant math, and the result will most likely be more efficient than anything you could roll yourself in the short term.
Bullet is the wrong library for a 2D game, true, but you have stuff like Box2D for that. In your specific case it sounds like rolling your own would be more efficient, but for math, I would look before I leap, and look hard.
I'm flying out to LA to interview with Tinder.
Wish me luck /dpt/
Eigen is really intuitive to learn.
eigen.tuxfamily.org
is a good start if you already know matlab or know the math
>>Using IDLE as IDE
Guess dating applications is the best place to be a game developer.
Whoever has the most entertaining dating service wins these days
>impying traps aren't Bi as well
kek
>the gamification of everything means gamedevs are now everywhere
JUST
They pay well too. The position I'm applying for starts at $135k
Nah, it's not that. It's just that successful people are generally those who are resilient from repeated failure and have contingency plans ready to go rather than those who are committed to a very specific fantasy.
>loser
kek. You don't know me, kiddo. I have succeeded past my wildest dreams in a number of arenas and I still ain't dead yet.
I know it's stupid, but, should I buy a Net Yaroze?
It's got 5 days to go and already £155. It'd be like a collector's items.
Where though? Cost of life matters dude, the valley is a shit place for that.
>I have succeeded past my wildest dreams in a number of arenas and I still ain't dead yet.
This is where people are usually retarded. Just don't have wild dreams.
Planning on making homebrew?
Wut?
Yup. It would be good to learn how the developers of old had to deal with stuff.
It would totally be a vanity own project. It's quite an expense.
People usually think that they are hot shit, when most aren't.
The rational course of action if you want to be happy is to not expect much out of life and be happy with what you have. Count your blessings like christians say.
Then if you actually are hot shit, you can be pleasantly suprised, and if you ain't, you can still be happy.
Psychology supports that as well, people are happier when they make achievable goals for themselves. Tons of studies support this.
>no ace definition
I'm not sure what advantage a net yaroze has over a regular modded PS1. Are there special debugging tools?
>ace
?
straight = eg, boy loves girl
gay = boy loves boy
bi = boy loves boy or girl
ace = boy becomes engineer
Well yeah, that's what I did.
Like, I didn't try to have a threesome with supermodels, that would be impossible, but they were still young and cute.
jej
It's in LA. They're in West Hollywood and I've been looking at rent. I found a place for $2k a month. The net gain of expendable income is better than the 70k job I'm doing right now.
People who don't think they're hot shit take anti-depressants.
Studies have been made user.
It's actually the other way around.
Makes sense, but you'll forgive my europeean ass to be weary of huge figures when cost of living in America (and Sanfran even moreso) is high as a kite.
I'm checking a byte array if it matches any particular file signature from a predefined list. The byte array length is not fixed and file signatures can have any length. Is there any common way to do this without using some existing library?
I thought about doing hex string switch case but that would require to convert the byte array for every signature length.
Converting to integer is impossible because a long signature can exceed values provided by uint64.
Is doing byte array comparisons the only way?
use memcmp to write a memmem function
It's official homebrew, rather than nodded homebrew.
My PS1 is already chipped I guess, so you're right, I could just use that, especially as that will allow me to write to CDs. Whereas the net can only have the system ram used. Can't use the cd.
There's the PSIO, which I could use, though I would need to buy a PS1 that has a parallel port, as mine doesn't have one.
The file signatures start at the start of the byte array, I don't need to search the whole array as offset is always the same (0).
Also please explain the method and not throw a vague solution. Are you suggesting doing byte array comparisons?
Unless you write a lot of PS1 homebrew I don't see the point.
In this case, you don't need a memmem function.
Just memcmp the first n bytes of your signature and see if it's a match with your byte array.
Depends on the language
fn matches(bytes: &[u8], signatures: &[&[u8]]) -> bool {
signatures.into_iter().any(|sig| {
bytes.windows(sig.len()).any(|ref slice| slice == sig)
})
}
What's the best way to measure real time in milliseconds C, lads?
I never have before. It'd be fun to learn. And great to keep in a collection. Maybe I'll find one being sold cheap as someone doesn't realise what it is.
static struct timeval tm1;
static inline void start()
{
gettimeofday(&tm1, NULL);
}
static inline void stop()
{
struct timeval tm2;
gettimeofday(&tm2, NULL);
unsigned long long t = 1000 * \
(tm2.tv_sec - tm1.tv_sec) + (tm2.tv_usec - tm1.tv_usec) / 1000;
printf("%llu ms\n", t);
}
I tried making some DS homebrew but all the guides I can find are shit, I spent more time refactoring example code than building my own shit.
There is no way to get a better resolution than 1s in pure C that I recall, but you can use gettimeofday() on Unix.
Is there BASIC dialect with C features?
Go is pretty basic
>using BASIC
Just learn C user.
I guess for all these consoles it's quicker and easier to develop with emulators, rather than real hardware anyway.
DS emulators bite you in the ass with improper cache emulation but yeah. desmume gave me a good excuse to learn gdb.
school me, /dpt/
why does
002002FB 0000 add [eax],al
002002FD 0000 add [eax],al
002002FF 004801 add [eax+0x1],cl
00200302 2000 and [eax],al
00200304 0000 add [eax],al
00200306 0000 add [eax],al
00200308 2500000000 and eax,0x0
0020030D 0000 add [eax],al
0020030F 0000 add [eax],al
;repeat for fucking ever
occur when inside the bin conversion of
int main (){
int i;
i = 0x12345678;
}
godbolt.org
I don't see it.
From where exactly did you get that asm?
from this tut: web.archive.org
I ran ndisasm -b 32 test.bin
test.bin being the conversion of test.c using objcopy
Oh I get it now, so you wouldn't normally write that, that's just disassembled junk. Thanks user
can you do objdump -zd test.bin?
>objdump -zd test.bin
test.bin: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 :
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: c7 45 fc 78 56 34 12 movl $0x12345678,-0x4(%rbp)
b: b8 00 00 00 00 mov $0x0,%eax
10: 5d pop %rbp
11: c3 retq
i assume this is what they call "intel syntax"
no, that's AT&T syntax
>objdump -M intel -zd test.bin
for intel syntax
OK that's your code. It returns 0. And it's 64bits, not 32.
Am I a code rat for having this as my solution to Euler problem 1?
Would people in the workplace laugh at me for writing this way?
#!/usr/bin/env xcrun swift
import Foundation
/*
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
*/
private let VALUE : Int! = 1000
func multiplesOf3And5() -> Int {
var sum : Int = 0
for index in 1..
No, that's "tl;dr" syntax
So it wouldn't really matter which way i choose to write the asm, right?
Ah, thanks. Do you know how i'd run 32bit?
>So it wouldn't really matter which way i choose to write the asm, right?
No, they have slightly different syntax, but as long as your assembler understands the syntax you chose, it doesn't matter.
>Do you know how i'd run 32bit?
compile with "-m32" flag(gcc and clang)
thanks again, user
it runs:
test.bin: file format elf32-i386
Disassembly of section .text:
00000000 :
0: 55 push ebp
1: 89 e5 mov ebp,esp
3: 83 ec 10 sub esp,0x10
6: e8 13 00 00 00 call 1e
b: 05 f5 1f 00 00 add eax,0x1ff5
10: c7 45 fc 78 56 34 12 mov DWORD PTR [ebp-0x4],0x12345678
17: b8 00 00 00 00 mov eax,0x0
1c: c9 leave
1d: c3 ret
0000001e :
1e: 8b 04 24 mov eax,DWORD PTR [esp]
21: c3 ret
At least parametrize your function:
fn sum_multiples(of: &[u64], below: u64) -> u64 {
(1..below)
.filter(|x| of.into_iter().any(|div| x % div == 0))
.sum()
}
fn main() {
assert_eq!(23, sum_multiples(&[3, 5], 10));
println!("{}", sum_multiples(&[3, 5], 1000));
}
I know C, I just was thinking of a language that's as powerful as C and as easy as BASIC.
not in the spec.
fucking wanks prematurely optimizing.
Idea for a project: Lexer/Parser generator that generates Rust code, similar to Flex/Yacc for C.
It's not premature, not optimization, it's just common sense.
It's called Pascal.
isn't OpenEuphoria like that?
That's actually a good one, Rust would be great to implement a compiler-compiler, with the extended enums and all.
> touch CoC.md
Yeah no not right for me old chump
Asking for golang advice here because /wdg/ are literal monkeys.
I need advice for which golang router to pick. Go-programmers shit out a dozen of routers each week, some which suck, and others are even worse. Asking someone will lead to them telling you to "just use net/http". Useless people.
I'm going to have a REST service which may have some complex url patterns. Example:
Here:
GET api.site.com
Lists all files.
GET api.site.com
lists all files in json format.
GET api.site.com
lists all files in json format.
Here:
GET api.site.com
Gets a single file with that ID.
GET api.site.com
Links to a page where one can edit said file.
api.site.com
plus all the PUT, PATCH, DELETE and other things. Question is, what router or net package makes this the easiest? Consider how easy Django REST framework makes it with nesting url patterns.
Any clue for which router offers the best performance/ease of use? httprouter is out of the window because it doesn't support things like this.
Why do you need 32bits?
Thinking of maybe making a Chrome/FF extension that does a price-tracking similar to pic related, but for Steam games (I often find myself jumping through several hoops just to see if a game has ever dropped in price).
How bad of an idea is this?
I-is that you vinny?
youtube.com