« first day (1767 days earlier)      last day (3197 days later) » 

Abe
12:02 AM
Mar 12 at 12:02, by Danack
>
There are known knowns.
These are things we know that we know.
There are known unknowns.
That is to say,
there are things that we know we don't know.
But there are also unknown unknowns.
There are things
we don't know
we don't know.
took me a while to find it
 
hmm @Fedora is back but for how long?
 
12:31 AM
@benlevywebdesign till they find out 1 rep users can't talk?
 
A mod took...... action.
 
Abe
also known as hammer
 
12:53 AM
gosh, i can't find a good authentication pattern for my project and i don't want to rebuild it with laravel or symfony
 
1:25 AM
wtf is log_errors_max_len ini setting truncating my exception backtraces? :-( … What is that option good for except annoying users?!?
^ \cc @NikiC ?
 
1:50 AM
At least, I'd be in favor of making the default in php-src being 0 (aka unlimited)
 
Take a look at this page. You can see that at the top I just put a print$sql and you can see there is nothing in the results but below in the form you will see what should be there...
 
@Abe I was getting expectations and dbc mixed up. i would be happy if the checks worked like outlined in the accepted expectation rfc but would not be disabled in production like assertions.
 
2:05 AM
OK, so who's interested in this. I've located the main areas where PHP does overflow checks and replaced them with inline x86 assembly to use the check overflow bit instead of casting and shifting and was able to prove a 15% performance gain in some cases.
3
Of course the crappy part is this only works on x86 architecture, but I'm sure someone more crafty than I could make the assembler more portable.
Or we could just fall back to the C overflow checks and say screw you to ARM and AMD :/
 
This is just so irritating...it is probably something stupid
 
Abe
@Orangepill both are useful, checks you only need in development (mostly private stuff calls checks) and checks that must always be performed. pre and post conditions checks (in terms of assertions) are rare (or rarely useful) because a language supporting types covers 95% of cases already
 
No one? Alright...
 
Abe
@Sherif too late maybe? :P
starred, so others can read tomorrow
 
@Abe Maybe.
Then again, we do inline assembler in zend_operators so not sure if going back and changing a ton of code now even makes sense.
I wonder why we don't just rely on the API calls internally when doing math then? hmmm...
I mean, I was able to identify at least 80 integer overflow bugs in php-src since 1999. This approach is a lot safer.
Also, there's a lot of undefined behavior in weird places like printf("%d", PHP_INT_MAX / -1); ... you would think that should do the right thing by converting the float back, but instead it just totally craps out and returns PHP_INT_MIN.
There's some retarded overflow crap going in PHP I tell ya
Sorry I meant printf("%d", PHP_INT_MIN / -1); there obviously.
 
2:23 AM
@Sherif uh, because float representation is the same, obviously?
 
@bwoebi PHP_INT_MIN / -1? PHP_INT_MAX was a typo.
int min / -1 is an overflow so it should cast to float, but printf won't format it correctly as decimal.
 
@Sherif yes. because ((float)PHP_INT_MAX) === PHP_INT_MAX + 1 === PHP_INT_MIN / -1
 
huh?
 
oh
 
@bwoebi PHP_INT_MIN / -1 == -9223372036854775808 / -1 == 9223372036854775808, but PHP gives you -9223372036854775808
well, 64 bit anyway
 
2:26 AM
printf, wtf
 
yea, that's what I thought
I found a lot of other interesting places where casting to float creates a WTF too
 
@abe dbc is intended to be a design time construct as well?
 
Which is why I'm now wondering if just relying on the CPU's overflow check is better and safer.
Reason I bring this up is because I was researching a white paper on type safety in different languages and was curious to find that not even PHP gets type safety right at all.
 
Abe
@Orangepill yes (?)
 
So I hypothesized that it could be better solved to rely on your ISA's overflow checks in the ALU to enforce better type safety in languages like C/C++ where it's not always well-defined behavior.
 
Abe
but as it's proposed, it seems it wants to cover only development stage @Orangepill which is meh... i'd just use assertions for that
 
@bwoebi Wait a minute, that just casts to double. How did it get NaN?
 
@Sherif that casts from double to long…
 
Wait you mean printf is casting it back to long?
argh
So the only way to get the correct value is to always use printf(".0f", PHP_INT_MIN / -1)
 
sure. You're specifying %d
yes
 
2:35 AM
That's stupid, it's not like PHP actually has strict typing.
I could understand that in a language like C or C++, but here PHP did the cast to float for me.
I'm just a stupid guy who knows nothing.
It should still try to represent it as a decimal since we're back to strings here. Which brings me back to my theory that perhaps instead of casting to float we should just use gmp for arbitrary precision and to have a real BIGNUM type once we go out of bounds. Because now we have overloaded operators for gmp anyway.
But then again you can throw performance out the window at that point :)
 
@abe yeah ... it seems redundant ... I would prefer something that mirrored the assert syntax but didn't get switched on in production.
 
No wonder javascript just used floats everywhere! Screw overflow checks!
 
something like
public function setAge(int $years){
    expect($years > 0, new Exception("Age must be a positive integer"));
}
vs
public function setAge(int $years){
    if ($years <= 0) throw new Exception("Age must be a positive integer");
}
 
@Sherif hehe
 
Abe
but that's not declarative @Orangepill as opposed to dbc whose assertions become part of the signature
 
2:40 AM
The insanity of creating a typesafe language I tell ya!
 
Abe
class A{ public function setAge(int{NonNegative} $years){} }
class B extends A{ public function setAge(int $years){} } // incompatible signature
 
@Abe part of the signature would be better ...
 
Abe
same if it uses expressions
class A{ public function setAge(int{$years > 0} $years){} }
class B extends A{ public function setAge(int $years){} } // incompatible signature
@Orangepill that's the whole point :P dbc introduces imperative rules in the "abstractness" of interfaces
 
@Sherif can you explain me what the fucking hell it's doing in that if branch… lxr.php.net/xref/PHP_TRUNK/Zend/zend_operators.c#2974
 
I would like a syntax where I could control the behavior if the expectation was not met at runtime.
 
Abe
2:43 AM
means that you can't implement an interface by faking it or being sloppy. you are forced to follow such rules
 
I guess what I am wanting is not dbc ... although I can see the benifits
 
Abe
@Orangepill yes that's what i'm proposing, rather than having just assertions, introduce generic validators
 
I just want short hand for precondition checks I guess.
 
@bwoebi Not sure. But I noticed we do a lot of casting :)
 
While signature assertions would be nice, I'd be okay with throw being a truthy expression, so you could $age > 30 or throw ...;
 
2:45 AM
@Sherif I thought this work was already done by @Andrea?
 
@LeviMorrison Was it?
 
Abe
@DanLugg there are a bunch of use cases
 
@abe okay ... just reread you post ... I could get on board with that
 
Abe
i would love having that
 
Likewise
 
@Sherif I do have a bad memory, so perhaps not ^^
I was thinking it was done as part of the overflow semantics changes.
 
@LeviMorrison The only places where I see carry bit check being used is in the engine itself like lxr.php.net/xref/PHP_TRUNK/Zend/zend_multiply.h#27
 
@Danlugg that would work for me
 
But there's still lots of places in other extensions where overflow checks are done poorly.
 
By the way, in general I would say inline asm is acceptable in this situation.
 
2:49 AM
Or maybe I'm just looking at an outdated master. I haven't pulled from origin in a while.
 
I think we have platform specific asm already, so it is just a matter of some ifdefs yeah?
 
Yep @Orangepill, short circuit ftw
 
@LeviMorrison Yes, in /Zend it's already there :)
#if (defined(__i386__) || defined(__x86_64__)) && defined(__GNUC__)
/* ... */
#elif defined(__arm__) && defined(__GNUC__)
/* ... */
#elif defined(__aarch64__) && defined(__GNUC__)
 
Abe
there was a guy recently in here that said that sometimes you can't keep instances always in a valid state, so he suggested to have an isValid() method. remember? now that guy could have signatures like this:

function Valid($something){
    if(!$something->isValid())
        throw new TypeError('You can only pass valid Something instances');
}

public function setSomething(Something{Valid} $something){
    $this->something = $something;
}
was he @tereško?
 
bob-weinands-imac:php5 Bob$ php -r 'var_dump((int)(PHP_INT_MAX * 2));'
int(0)
bob-weinands-imac:php5 Bob$ php -r 'var_dump((int)(PHP_INT_MAX + 1));'
int(-9223372036854775808)
@Sherif looks to me like PHP wants to preserve overflow semantics ??!?
 
2:53 AM
@bwoebi Yay! It's broken!
It definitely shouldn't be doing that.
 
test whether double cast to long preserves least significant bits
I'm not sure whether I should love or hate that o_O
 
Abe
public function checkIn(Person{CanCheckin} $person){
    // ...
}
 
@bwoebi You realize that has undefined behavior, right?
I mean, not specifically in that expression, but the casting is not well defined in general.
 
Abe
that would be incredibly useful for DDD @Orangepill
 
@Sherif no, not as long as we assume IEEE 754 doubles… point is rather the lost accuracy
which makes it weird
@Sherif strictly seen maybe, but it's doing what it should…
 
2:56 AM
for now
 
@Abe yes it would...
 
but I'm seriously wtf'ing that this is implemented intentionally that way O_O
 
I guess... I mean if you think about it, how is it going to cast it to an int anyway.
it can't
 
@Sherif note that we're doing a value cast, not casting a pointer… (int64_t)some_double isn't UB, *(int64_t*)&some_double is.
 
Yea, so it wraps
 
2:59 AM
@abe what would be cooler is if instead of it just being a validator it could be a converter as well :)
 
php -r 'var_dump((int)(PHP_INT_MAX * 1.5));' // int(-4611686018427387904)
 
@Sherif truncate. (to PHP_INT_MIN/MAX) … that's what I'd expect
@Sherif yep
 
PHP is weird
Because it won't actually let you do that if you assigned it to a variable first and then did the cast.
or wait a minute.
I put my foot in my mouth it does.
heh
 
but yeah… excellent quiz question… what's does var_dump((int)(PHP_INT_MAX + 1)); return -.-
 
Abe
@Orangepill i guess there are some use cases for that but i would never use it :P the type is like a religion
 
3:02 AM
@Sherif well, that'd be buggy then^^
 
@bwoebi You mean useless trivia question that you can only get right if you know the exact version of PHP and architecture it's built on? :p
 
@Sherif eih, that one should always be equal to PHP_INT_MIN
 
why is half my page not working and the other half working...ugh fsdfafsgdfads
 
@bwoebi Yea, you're probably right. I doubt anyone changed that any time in the last decade or so.
 
private function convertDate($date){
    return new \DateTimeImmutable($date);
}

public function setPickupDate(\DateTimeInterface{[$this,"convertDate"]} $date)


$obj->setPickupDate("2015-08-29");
 
3:04 AM
I am so close, I can just feel it...
 
Damn, all these years I never knew PHP actually allowed integers to overflow like that.
 
@benlevywebdesign believe your sql should be SELECT destaddress, destiname, arrivaltime, priority FROM ontheway_destinations WHERE id=71
 
printf("%u", PHP_INT_MAX * 1.5); heh
It wraps and everything
 
Abe
i don't like that for some reason :P i mean, i would just have:
function setDate(DateTime|string $date){}
 
w00t! Way to go PHP. You are now officially just a bastardized C!
 
3:07 AM
@Orangepill is it not? I thought it was...
 
@Sherif the issue is the lost precision
 
helloo
 
@bwoebi You mean because it casts to double and back again?
 
@abe union types like that would be useful but I wanted to be able to allow for the transition of one type to another.
 
3:09 AM
yea
 
@Sherif yes
so, totally useless that way
 
So not only is it not type safe, it's even added a compounded precision error on top of it!
awesome
Now I know what my next blog post is going to be about :)
 
@benlevywebdesign are you getting a single record filled with 0's
 
@Sherif seriously? :-D
 
@anaslmt hello
 
3:12 AM
@bwoebi Yes, I've been meaning to write a nice post about solving the type safety problem by demonstrating all the security problems it creates in every-day code like openssh, firefox, and PHP :D
 
@Orangepill no...
 
o/
 
@benlevywebdesign what are you getting as your query result then?
 
I have so many examples of how overflow checks done poorly create disasters.
 
@Sherif solving?
 
3:13 AM
Well, by solving I mean making it safer.
 
you want to solve that?
 
Abe
conversion from one type to another has to stay in one place only, a constructor, say:
class DateTime{
function __construct(DateTime|string|int $dt){}
}
or factories... if you start converting stuff everywhere you know how it would end up: BAD
 
As in relying on the ISA's carry/overflow bit checks instead of writing really bad and sometimes slow code that tries to do that.
Which is obviously not always an option unless you're already at the systems level programming language.
 
$id = $_GET['id']; // ?id=#

$sql = "SELECT destaddress='$destaddress', destiname='$destiname', arrivaltime='$arrivaltime', priority='$priority'
FROM ontheway_destinations
WHERE id='$id'";
$results = mysql_query( $sql );

$results 	    = mysql_query( "SELECT * FROM ontheway_destinations WHERE id='$id' LIMIT 1" );
$myrow 			= mysql_fetch_array( $results );
$id 			= $myrow['id'];
$destaddress	= $myrow['destaddress'];
$destiname		= $myrow['destiname'];
$arrivaltime	= $myrow['arrivaltime'];
$priority		= $myrow['priority'];
ops
 
@benlevywebdesign what is the first query supposed to be doing for you
@benlevywebdesign plus i'm sure you have heard this before but your query is being constructed wrong your parameters are not being escaped properly.
 
3:17 AM
 
fetching the results
 
don't mean to interrupt, just why wouldnt this work $curUser = new self($user['login'], $user['passe'], $user['prenom'], $user['nom']); in a class method?
 
@benlevywebdesign is the SELECT destaddress='$destaddress'... you are not assigning the value of the record to $destaddress you are actually assigning the result of the comparison of the record's destaddress field to the current value of destaddress (which I assume is undefined at this point)
 
@Sherif also for llvm (only the non-generic version): llvm.org/releases/3.5.0/tools/clang/docs/…
 
3:22 AM
@bwoebi That's provably slower than relying on the ISA from what I gathered.
 
..I need to assign them
 
Because you still have to cast, i.e. more cycles to swap registers and more addition
 
Abe
@AnasLmt define "work"? as in "logically"? or "functionally"?
 
@Sherif can you please show me your asm (for e.g. add)?
 
@benlevywebdesign then take the ='$...' off of the end of everything before the from clause... you should just have a comma separated list of field names
 
3:24 AM
ok
 
the after the mysql_query statement you should do a $record = mysql_fetch_assoc($results); this will get your results as an associative array. then you should be able to use them by saying $record["destaddress"];
 
@Abe don't get neither. it seems logically possible, doesn't it?
 
Abe
i'm not understanding. are you asking if it's reasonable code or the reason you are getting a fatal error or something?
 
@benlevywebdesign now assuming that there is a record with an id of 71 you should be able to do print_r(mysql_fetch_assoc($result)); and see the contents of the record.
 
3:28 AM
@bwoebi Here's an example I tried gist.github.com/srgoogleguy/6fc65988aedcd8fed3d7 I also tried setc which is supposedly even faster
For carry bit I mean
 
yes that's it @Abe
there is no error of any sort
 
Abe
Me: A or B?
Interlocutor: Yes
always happens
 
@benlevywebdesign another good idea for you would be to enable error reporting just throw the following at the top of your script
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
 
lol, sorry, it's A. i'm asking if it is reasonable code
 
Abe
@AnasLmt it doesn't look fine, but i can't actually tell without reading more of it
 
3:31 AM
because i don't get any errors or anything. just blank spaces where the attributes should show
 
Abe
new self makes me think you are using static methods, which you shouldn't use
 
The jump overflow/no-overflow is probably going to be a tad bit slower, but it's hard to benchmark accurately here since I'm testing on a VM.
 
Abe
need painkillers
 
noo, this is the function: `public function fetchUserInfo() {
        $db = Db::getInstance();

        $req = $db->query("SELECT * FROM perso WHERE login = '".$_SESSION['name']."'");
        $user = $req->fetch();

        $curUser = new self($user['login'], $user['passe'], $user['prenom'], $user['nom']);

        $db = null;
        return $curUser;
    }`
 
my eyes
 
Abe
3:34 AM
so you have:
(new User())->fetchUserInfo()->fetchUserInfo()->fetchUserInfo()->fetchUserInfo()->fetchUserInfo()->fetchUserInfo()->fetchUserInfo()->fetchUserInfo()->fetchUserInfo()
 
no i'm trying to pass those attributes to the class instance $curUser
 
Abe
which is self
#inception
 
@benlevywebdesign looks like you are getting the data out that you wanted.
 
this is the constructor:
 
3:36 AM
@Orangepill yes but is it being duplicated?
 
public function __construct( $data = array() ) {
        if( isset( $data['username'] ) ) $this->username = stripslashes( strip_tags( $data['username'] ) );
        if( isset( $data['password'] ) ) $this->password = stripslashes( strip_tags( $data['password'] ) );

        if( isset( $data['first_name'] ) ) $this->first_name = $data['first_name'];
        if( isset( $data['last_name'] ) ) $this->$last_name = $data['last_name'];

    }
 
Abe
public function __construct( $data = array() ) <- you are asking for 1 array, but instead you pass 4 arguments
 
@benlevywebdesign it looks like you are fetching and echoing the data first with mysql_fetch_array then again with mysql_fetch_assoc .... mysql_fetch_array gets the results both indexed by offset and keyed with the field name
mysql_fetch_assoc just gets the results as a fieldname keyed array.
 
@Orangepill well at the top of the page where its just printed out...
 
   100000e14:	48 01 f7             	add    rdi,rsi
   100000e17:	0f 90 c0             	seto   al
   100000e1a:	48 89 3a             	mov    QWORD PTR [rdx],rdi
   100000e1d:	0f b6 c0             	movzx  eax,al
^ @Sherif that's asm from the builtin
 
3:39 AM
so i'm supposed to put array('arrayname' => [arg1, arg2..]) as an attr?
or as an argument
 
Array ( [0] => 2020 Market St, San Francisco, CA 94114, United States [destaddress] => 2020 Market St, San Francisco, CA 94114, United States [1] => Safeway Supermarket [destiname] => Safeway Supermarket [2] => 10:00:00 [arrivaltime] => 10:00:00 [3] => Medium [priority] => Medium )
 
@bwoebi ahhmmm... interesting. I had read something earlier that suggested the built in relied on casting. Good to know :)
 
@benlevywebdesign that is the results from mysql_fetch_array not mysql_fetch_assoc
 
Abe
function a($one){}
a($one);
function a($one, $two){}
a($one, $two);
function a($one, $two, $three){}
a($one, $two, $three);
@AnasLmt you should read a basic php tutorial before attempting doing more imho
 
lol got it!
 
Abe
3:41 AM
that is both functionally and logically wrong
no offense clearly
 
Oh ok I see. but why is _assoc only show each part once and _array shows it twice?
 
it's just the stress
 
   100000e0b:	48 01 f7             	add    rdi,rsi
   100000e0e:	48 89 7d f0          	mov    QWORD PTR [rbp-0x10],rdi
   100000e12:	71 07                	jno    100000e1b <_add_i64+0x1b>
   100000e14:	c7 45 fc 00 00 00 00 	mov    DWORD PTR [rbp-0x4],0x0
   100000e1b:	48 85 d2             	test   rdx,rdx
   100000e1e:	74 07                	je     100000e27 <_add_i64+0x27>
   100000e20:	48 8b 45 f0          	mov    rax,QWORD PTR [rbp-0x10]
   100000e24:	48 89 02             	mov    QWORD PTR [rdx],rax
@Sherif at least compared to your suboptimal asm…
(I used -O2 for the asm)
 
@benlevywebdesign read the docs and examples for both mysql_fetch_array and mysql_fetch_assoc ... and pay special attention to the red box labeled "Warning"
 
thank you Abe
 
3:43 AM
@bwoebi Well, yea, that code was by no means optimized. I'm not an asm guy really. But it was still way faster than doing the overflow check in C ^^
 
@Sherif yeah, definitely.
just saying, if you want a real boost, use the builtins. They're even portable…
 
Abe
new self doesn't make sense though @AnasLmt
 
My point still stands. Overflow bugs are hard and probably a better way to avoid them is to rely on the ISA.
@bwoebi Yea, now that I double checked the literature, it looks like they do mention in the foot note that GCC has since fixed the bug they mentioned.
 
I had an assembler book once... borland turbo assembler... I would read it everytime I couldn't get to sleep... it always worked in less then a page :)
 
yeah? should I just pass the values one by one? $this->attr = value ..
curUser->attr*
 
3:46 AM
@Orangepill I know, I know its deprecated. I am not trying to worry about that right now. this is just an old project and I don't really care that much i just want it work enough
 
@Sherif well, I'd rather prefer relying on the compiler. Sure, relying ISA is probably a tad bit safer, but not portable. Hence…
Anyway… time to go to bed (5:48 here)
 
@benlevywebdesign also the parameters are not being properly escapsed... aside from that being a huge sql injection possibility it is wrong in that if a user has an address on King's Cross Road you query will break.
 
I mean the compiler is just doing the inlining for you with macros based on the ISA, so same concept is applied really. I just wasn't aware GCC supported all of it until now.
 
@Sherif I wasn't either… but they have builtins for every shit… so I just checked…
 
it's not just insecure ... it is wrong
 
3:50 AM
Yea, good to know definitely :)
But that still begs the question why aren't more people relying on it?!
heh
So much bad overflow check code out there in C.
 
@Sherif probably a) not many people knowing about it, b) the builtins being rather new and c) when you need to support MSVC targets, older gcc versions etc.
 
@Abe any suggestion?
 
@Orangepill I'll get to that. Now I just want to know why the form fields don't seem to be connected to the db on update...
 
Abe
@AnasLmt read about the data mapper pattern
 
But mostly a) I guess and c) when in open-source
 
3:53 AM
@bwoebi Well, you can still do the asm for MSVC, albiet I discovered the 64bit can't be inlined for some strange reason, but yea.
Wait did you mean MS Visual Studio?
blah
I read that wrong
 
yes?
 
okay thanks bud
 
@Sherif the problem is that Windows runs on many architectures… so we would still need asm for every architecture^^
 
@Orangepill It looks like it updates but doesn't
 
and that's ultimately why we don't use inline asm… because there's always some arch we don't cover.
 
3:56 AM
@bwoebi Yea, but that's not hard to get. I found asm that works for x86 architecture and x64, but yeah.
@bwoebi We cover intel, ARM, and AMD in PHP
 
@Sherif yeah, not a problem for the standard archs, but when you get more exotic.
 
@benlevywebdesign i don't see where you are handling a post an attempting to perform an update.
 
And we didn't always used to cover ARM or AMD either.
I remember a few years back when someone complained after trying to compile PHP on ARM.
 
when you click the text at the bottom of the page
 
Then they contributed the ARM asm.
We have lots of inline asm all over /Zend
 
3:57 AM
@Sherif point is, we need always a C variant.
 
@Orangepill the "Save & Update" text
 
@bwoebi Sure you can still fall back to C with some #ifdefs ;)
 
@Sherif sure. And there we're back to the problem with "bad overflow checks"
 
oh well, you have to make a compromise somewhere. Either you want to support a wider array of archs or you want stable code.
 
@benlevywebdesign based on the query UPDATE ontheway_destinations SET destaddress='2020 Market St, San Francisco, CA 94114, United States', destiname='Safeway Supermarket', arrivaltime='10:00:00', priority='Low' WHERE id='' LIMIT 1 you aren't passing in a id
 
3:59 AM
@Sherif ;-D
anyway… 6 a.m. here… I really should get some sleep.
 
g'night :)
 
@benlevywebdesign <form id="editform" method="post" action="destination_update.php?id=<?= intval($_GET["id"]) ?>">
do that on your input form head and you should be able to get at the id as $_GET["id"] in your update code
 
<input type="hidden" name="tripinfoid" value="<?php echo $tripinfoid ?>" /> </input>
^ I thought that is why I did that line...ugh this
 
that should work assuming you are using $_POST["tripinfoid"] in your update
 
I am using $_POST["tripinfoid"] ...let me check something
 
4:07 AM
@Orangepill Wait, why intval? It's going to be a string regardless.
 
@sherif because he refuses to use a sane db api
 
Oh, you mean you're just trying to avoid SQLi?
heh, at that point you might be too late if they already did something with $_GET['id'] anyway.
 
@sherif yeah
part of me wants to truncate his table just to prove a point
 
I remember when php.net was still vulnerable to SQLi and we were using md5 password then so someone showed Zeev his password to make a statement :)
 
<input type="hidden" name="tripinfoid" value="<?php echo $tripinfoid ?>" /> </input> and $id = escape_data ( $_POST['tripinfoid'] );
 
4:12 AM
@benlevywebdesign You forgot to escape in value as well ;)
No idea what escape_data does, but it had better be htmlspecialchars equivalent or you're still vulnerable to XSS.
 
ok I just did something good!
Its now updating but I have to fix another thing :)
 
Where would we be without sites like w3schools teaching people bad code :)
 
good old w3schools
 
"w3schools giving consultants work since 1998!"
"consultants" being a euphemism for people that are overpaid for fixing your crappy code, of course!
i.e. replacing it with slightly less crappy code
 
ha ... just peeked at there php database section... they don't endorse the use of mysql_* function either
 
4:20 AM
No, they updated their site about a year ago or something. It only took them a good 9 years to catch up, too :)
 
I just fixed two of the pages
once I fix most of the problems I will go back and update the php
I just didn't want to do that when things were still borked.
@Orangepill Is that understandable?...
 
You know testing code can only prove that defects could not be found, not that it is void of defects. So really, your code is always broken in theory. You just haven't managed to prove how. Which is to say that broken code is no reason not to change your way of thinking about a problem.
 
Understandable
 
I guess it sounds better the way Dijkstra puts it. "Testing shows the presence, not the absence of bugs" - Dijkstra
 
@sherif so philosophical.
 
4:28 AM
This project was a mess from the beginning...I guess
 
@benlevywebdesign not the way I would have gone about it but I understand.
 
I defiantly don't have years of experience
 
@Orangepill Well, that part isn't philosophy. It's science.
Although I guess you could say that philosophy is a social science.
 
both aim to find truth
 
At the time I took my university class where we learned about php that is the way we learned which sucks because a lot of it is deprecated
 
4:31 AM
Sure, but I was actually opting for the computer science wisdom there rather than the social science wisdom :)
 
that's just packaging ... wisdom is wisdom.... if it's not universally true it isn't true at all.
 
Universal truths. That's an ironic choice of words.
 
why the irony
 
@abe sweet... is the blink tag still in the spec?
 
4:36 AM
@Abe Remind me to send a case of single malt to the person who wrote that.
 
Abe
nope, lol
@Sherif thank you :D i wrote that
i neez a coffee
 
no... the blink attribute is now listed as a "non-conforming feature"
 
hmmm, amazon don't let you ship alcohol
Damn you Bezos!
 
@Sherif Maybe they will domestically...I'm available for a test :)
 
Well, good thing I'm still on the AWS Free Tier! AWS Service Charges $0.00
@Orangepill I couldn't even find alcohol on amazon
 
4:44 AM
damn... my jug of cheap whiskey is getting a little light...
 
...or are you just getting stronger?
wink wink
 
great another unexplainable issue on my end...well at least I can't explain it.
 
@benlevywebdesign We can't explain things we don't understand, but we can understand things that haven't been explained. So it's possible you mean to say that you don't understand it :p
 
benlevywebdesign.com/ontheway/destinations_list.php?id=15 and clicking on "Rimi" to edit it. That works but then It goes to tell me that it is from "Stackoverflow PHP Chat Test Trip" but it clearly came from "Madis Goes Shopin'!"
 
5:01 AM
Look at your database table. You screwed up the ids.
 
oh
at which stage, if I may ask
 
Who knows. I'm guessing from the lack of code you've shown me.
 
@sherif you might know of a better way to approach this ... I need to validate a parity bit for a 7 bit input in php... this is where I'm at now 3v4l.org/oZ8kB
is there a better way to go about this... I haven't done any bit twiddling like this in about 15 years
 
@Orangepill if ($num & 1) ?
 
@sherif isolating out the least significate bit
like I said there is probably a much better way
isolating the lsb as the parity bit then shifting it off then anding powers of 2 masks to isolate out the remaining bits to get a count of "1"'s
 
5:13 AM
mornin'
 
@teresko mornin'
 
I can't remember if PHP already had a function for this, but yea, just shift and AND it
That's the way to do it
 
Abe
morning
 
I might have found my issue!
 
@Orangepill my only question would be why use a loop at all? 3v4l.org/RZIDI it's much faster to just unroll the loop. You only have 7 bits.
 
5:33 AM
I don't think I'm getting the trip info id # right
 
5:43 AM
morning.
 
morning
 
6:03 AM
@sherif simple enough to manage that with only 7 bits
 
@Orangepill Well, if you were looking for a more clever way to do it $bitsOn = !!($num & 1) + !!($num & 2) + !!($num & 4) + !!($num & 8) + !!($num & 16) + !!($num & 32) + !!($num & 64); $parity = $num & 1; seems far more clever and concise to me.
2 lines of code vs. 13. That's 11 less opportunities for bugs to creep in :D
blah, as long as we're code gulfing lemme make it 1 line
$bitsOn = ($parity = !!($num & 1) ? 1 : 0) + !!($num & 2) + !!($num & 4) + !!($num & 8) + !!($num & 16) + !!($num & 32) + !!($num & 64);
 
I think I like the clarity of the unwound loop .
 
I don't. I find explicit code clearer to read since there's no question about state.
But that's just me.
You only have 1 variable affecting state in the above line. Your loop brings into question many more states.
 
@sherif my preference was for your first suggestion... not my original.. the loop was ugly as sin
 
Anyone around to answer a few questions about a cron job setup?
 
6:17 AM
@Orangepill oh sorry misread that
$bitsOn = ($parity = $num & 1) + !!($num & 2) + !!($num & 4) + !!($num & 8) + !!($num & 16) + !!($num & 32) + !!($num & 64); There we go... I had more time to write less code
3921 μs vs. 5 μs
^^
Nothing like a nice 784 fold performance boost
 
I'm going to sleep. I'll have to keep working on my problem tomorrow
 
okay ... I can swallow the cognitive overhead for that sort of performance gain. well placed comment should bridge the gap
 
I love that in PHP that's actually a valid expression. heh
No other language would let you get away with rhs assignment.
 
6:41 AM
Mornin
 
morning
 

« first day (1767 days earlier)      last day (3197 days later) »