dev notes thread

by Melancholy

Melancholy
すけべ
Admin
Posts: 3,987
Threads: 219
Joined: Jul 2014
Reputation: 60
10-19-2016, 01:33 AM
#61747 (1)
post dev notes below. you can use this thread for your own future reference or to share cool/useful findings.

i figured this kind of thread would be interesting, as i learn something new every day; and it'd be cool to learn stuff from everyone's experience.



while trying to fix some mobile inconsistencies on ios safari, I found out that iti doesn't like:
Code:
min-height: auto;

to fix, i had to do:
Code:
min-height: 0;

Backlash
TAIWAN NUMBAH ONE!
Nephilim
Posts: 1,331
Threads: 41
Joined: Oct 2015
Reputation: 21
10-19-2016, 09:51 PM
#61780 (2)
Little somethin' for Android devs embarking on their first real project: If your application crashes and you can't seem to figure out why, start by ensuring that every statement (save the ones that import libraries) are in methods.

When I was building my first Android app, I spent an entire week trying to switch Activities without crashing; even enlisting the help of a friend. What he failed to notice was that the statements that collected data from the previous Activity were outside of a method, which led to a fatal error. I'd imagine this is much less of a problem in Java programs with a dedicated main method.

[+] 1 user loves Backlash's post
KuroAku
lainchan
lainchan
Posts: 47
Threads: 1
Joined: Jul 2016
Reputation: 0
10-22-2016, 01:40 PM (This post was last modified: 10-22-2016, 01:41 PM by KuroAku.)
#61930 (3)
I'm monitoring this thread.

Quick contribution with a C hack

Code:
//Given an array
int a[5];

// This line is correct
int b = a[1];

// And this line is correct too
int c = 1[a];

This is because of how the compiler transforms `a[1]` to `*(a + 1)` and `*(a + 1)` is equivalent to `*(1 + a)`
RX14
Chibi Hentai Master
Optimist
Posts: 663
Threads: 8
Joined: Nov 2015
Reputation: 4
10-22-2016, 02:08 PM
#61933 (4)
(10-22-2016, 01:40 PM)KuroAku Wrote:
Code:
//Given an array
int a[5];

// This line is correct
int b = a[1];

// And this line is correct too
int c = 1[a];

This is because of how the compiler transforms `a[1]` to `*(a + 1)` and `*(a + 1)` is equivalent to `*(1 + a)`

Thats interesting as fuck but holy shit never do that in serious code. (I wouldn't use C in serious code anyway...)

[Image: 68747470733a2f2f6177772e6d6f652f683731666e372e706e67]
English animemester
malmon
nya?
Torrents
Posts: 1,734
Threads: 31
Joined: Nov 2015
Reputation: 17
10-22-2016, 06:20 PM
#61942 (5)
(10-22-2016, 02:08 PM)RX14 Wrote: (I wouldn't use C in serious code anyway...)

I am hurt

[Image: 68747470733a2f2f752e6e79612e69732f77757466626d2e6a7067]
„こころゆらゆらゆれてる”
RX14
Chibi Hentai Master
Optimist
Posts: 663
Threads: 8
Joined: Nov 2015
Reputation: 4
10-23-2016, 04:07 AM
#61958 (6)
(10-22-2016, 06:20 PM)malmon Wrote:
(10-22-2016, 02:08 PM)RX14 Wrote: (I wouldn't use C in serious code anyway...)

I am hurt

It's too easy to make mistakes in C when languages like Rust exist. If what you're doing isn't systems programming, languages like Crystal shine.

[Image: 68747470733a2f2f6177772e6d6f652f683731666e372e706e67]
English animemester
malmon
nya?
Torrents
Posts: 1,734
Threads: 31
Joined: Nov 2015
Reputation: 17
10-23-2016, 08:39 AM
#61964 (7)
(10-23-2016, 04:07 AM)RX14 Wrote:
(10-22-2016, 06:20 PM)malmon Wrote:
(10-22-2016, 02:08 PM)RX14 Wrote: (I wouldn't use C in serious code anyway...)

I am hurt

It's too easy to make mistakes in C when languages like Rust exist. If what you're doing isn't systems programming, languages like Crystal shine.

Aren't most hardware drivers and firmware written in C? Seems pretty serious to me :P

[Image: 68747470733a2f2f752e6e79612e69732f77757466626d2e6a7067]
„こころゆらゆらゆれてる”
KuroAku
lainchan
lainchan
Posts: 47
Threads: 1
Joined: Jul 2016
Reputation: 0
10-23-2016, 10:25 AM
#61968 (8)
(10-23-2016, 08:39 AM)malmon Wrote:
(10-23-2016, 04:07 AM)RX14 Wrote:
(10-22-2016, 06:20 PM)malmon Wrote:
(10-22-2016, 02:08 PM)RX14 Wrote: (I wouldn't use C in serious code anyway...)

I am hurt

It's too easy to make mistakes in C when languages like Rust exist. If what you're doing isn't systems programming, languages like Crystal shine.

Aren't most hardware drivers and firmware written in C? Seems pretty serious to me :P

You can write a firmware or a driver in any language that let's you use the same ABI as the platform. You can write a Linux kernel driver in Rust if you like. Or even in Go I think it will be possible too.
malmon
nya?
Torrents
Posts: 1,734
Threads: 31
Joined: Nov 2015
Reputation: 17
10-23-2016, 11:34 AM
#61971 (9)
(10-23-2016, 10:25 AM)KuroAku Wrote:
(10-23-2016, 08:39 AM)malmon Wrote:
(10-23-2016, 04:07 AM)RX14 Wrote:
(10-22-2016, 06:20 PM)malmon Wrote: I am hurt

It's too easy to make mistakes in C when languages like Rust exist. If what you're doing isn't systems programming, languages like Crystal shine.

Aren't most hardware drivers and firmware written in C? Seems pretty serious to me :P

You can write a firmware or a driver in any language that let's you use the same ABI as the platform. You can write a Linux kernel driver in Rust if you like. Or even in Go I think it will be possible too.

Though C does have the advantage of having a compiler on virtually any platform anyone might find themselves working on

[Image: 68747470733a2f2f752e6e79612e69732f77757466626d2e6a7067]
„こころゆらゆらゆれてる”
KuroAku
lainchan
lainchan
Posts: 47
Threads: 1
Joined: Jul 2016
Reputation: 0
10-23-2016, 06:28 PM
#61986 (10)
(10-23-2016, 11:34 AM)malmon Wrote:
(10-23-2016, 10:25 AM)KuroAku Wrote:
(10-23-2016, 08:39 AM)malmon Wrote:
(10-23-2016, 04:07 AM)RX14 Wrote: It's too easy to make mistakes in C when languages like Rust exist. If what you're doing isn't systems programming, languages like Crystal shine.

Aren't most hardware drivers and firmware written in C? Seems pretty serious to me :P

You can write a firmware or a driver in any language that let's you use the same ABI as the platform. You can write a Linux kernel driver in Rust if you like. Or even in Go I think it will be possible too.

Though C does have the advantage of having a compiler on virtually any platform anyone might find themselves working on

That's why C is still the king on systems programming
RX14
Chibi Hentai Master
Optimist
Posts: 663
Threads: 8
Joined: Nov 2015
Reputation: 4
10-24-2016, 04:38 AM
#61998 (11)
(10-23-2016, 08:39 AM)malmon Wrote:
(10-23-2016, 04:07 AM)RX14 Wrote:
(10-22-2016, 06:20 PM)malmon Wrote:
(10-22-2016, 02:08 PM)RX14 Wrote: (I wouldn't use C in serious code anyway...)

I am hurt

It's too easy to make mistakes in C when languages like Rust exist. If what you're doing isn't systems programming, languages like Crystal shine.

Aren't most hardware drivers and firmware written in C? Seems pretty serious to me :P

Just because C is a serious language, or that others use it for serious code doesn't mean i would use it for serious code (unless I have to) now that rust is mostly stable.

[Image: 68747470733a2f2f6177772e6d6f652f683731666e372e706e67]
English animemester
malmon
nya?
Torrents
Posts: 1,734
Threads: 31
Joined: Nov 2015
Reputation: 17
03-03-2017, 05:15 PM
#66851 (12)
If you're getting a load of garbage between lines on a serial connection, check to see exactly how much of the string you're sending.

i.e., If you tell it to send 32 bytes, but there are only 16 characters in the string, garbage will await you on the other side.

[Image: 68747470733a2f2f752e6e79612e69732f77757466626d2e6a7067]
„こころゆらゆらゆれてる”
malmon
nya?
Torrents
Posts: 1,734
Threads: 31
Joined: Nov 2015
Reputation: 17
03-13-2017, 03:57 PM (This post was last modified: 03-13-2017, 04:01 PM by malmon.)
#67174 (13)
Code:
char rawdata = {0x12, 0x4E, 0x92};
int16_t tempData = (rawdata[1] << 8) | (rawdata[2]);

rawdata[1] and rawdata[2] are cast as int16_t before the bitwise operations are carried out!

Should be:
Code:
int16_t tempData = (rawdata[1] << 8) | (rawdata[2] & 0xFF);

[Image: 68747470733a2f2f752e6e79612e69732f77757466626d2e6a7067]
„こころゆらゆらゆれてる”