« first day (1558 days earlier)      last day (3393 days later) » 

10:01 PM
lololol
 
I wish there was a *simple*, built-in "Select random results" in MySQL, order by rand() is not scalable in the least and most other methods are

things I don't understand
 
@AustinBurk "most other methods" do not return evenly distributed results
 
Finally, I am using native machine instructions for the shift left overflow check! github.com/TazeTSchnitzel/php-src/commit/…
 
order by dart(on_map)
 
and ORDER BY RAND() is good enough for 99% of cases
 
10:04 PM
Compare http://www.sudomemo.net/browse/?random
and http://www.sudomemo.net/browse/?featured
 
@AustinBurk and?
 
that's around three seconds extra execution time - too much
 
ThW
@AustinBurk do the records have an autoincrement id?
 
@zerkms I don't think 99% (I'll take that as "Most") of cases is a good measure; unless you mean that most cases requiring random selection aren't on big db tables.
@ThW yeah but it's messed up
 
That's correct
 
10:07 PM
@AustinBurk This one is simple but not truly random:
// SELECT name FROM holes
//  JOIN (SELECT r1.random_id
//         FROM holes_map AS r1
//         JOIN (SELECT (RAND() *
//                       (SELECT MAX(row_id)
//                         FROM holes_map)) AS row_id)
//               AS r2
//        WHERE r1.row_id >= r2.row_id
//        ORDER BY r1.row_id ASC
//        LIMIT 1) as rows ON (id = random_id);
 
generate N numbers and select with offset
 
For tables that are full, it will be random. It's just not evenly distributed if there are gaps in the data.
 
ThW
get 10 numbers between 1 and the max autoincrement id, fetch records with limit 1, repeat until you have a record
 
"repeat", f no.
 
f yes
UNION ALL
 
ThW
10:08 PM
in this case yes
 
The autoincrement value is messed up, it's throwing multiple numbers in between records
 
"generate N numbers and select with offset"
 
ThW
the chance for a repeat is low, if it high increase the count of generated random ids
 
| 28134 |
| 28135 |
| 28136 |
| 28137 |
| 28138 |
| 28139 |
| 28141 |
| 28142 |
| 28143 |
| 28144 |
| 28145 |
+------------+
It's mostly sequential but there are just...random gaps in there. Rows aren't usually ever deleted
 
if(is_int($count)){
    $this->count = (int) $count;
}
lol
strict type checks (or any other kind) can't help that person.
 
10:14 PM
@AustinBurk Then the method I linked above will probably be 'random' enough for you, though some entries will have a higher chance of being selected. If you want truly random selection you would need to make a 'holes map':
create table holes_map ( row_id int not NULL primary key, random_id int not null);
SET @id = 0;
INSERT INTO holes_map SELECT @id := @id + 1, id FROM holes;
select * from holes_map;
And do the random select from it.
 
not NULL primary key -- that is funny
 
/copying from notes, not from code.
 
fix your notes :-)
 
holes_map would need to be repopulated as holes has rows added to it, right?
 
oh... generate random in programming language and use offsets
 
10:16 PM
forgive my cluelessness, for I am but a novice programmer...

.<.
 
@AustinBurk Yes. You'd either have to setup a trigger to do it, or if you didn't mind a little latency, have a background job to sync the tables.
 
I don't know what a trigger is but I'm sure it's something amazingly simple and easy to learn, right?

Right?

guys?

.......
 
pinging gets really annoying.
 
oops
was just going for the effect
 
They're really simple - but I don't like them: dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html
 
10:20 PM
gonna eat
 
Debugging one php-uv bug… found bugs in:
- aerys (no response generated)
- amp (uv_run may block indefinitely)
- php-src (zend_mm_heap corrupted)
- not yet found the source of the php-uv bug :-(
 
@AustinBurk I think this is almost exactly what you want:
create trigger comments_after_ins_trig after insert on comments
for each row
begin
  insert into activities (comment_id, user_id) values (new.comment_id, new.user_id);
end#
However I suspect just setting up a background task to sync the tables would be needed anyway to do the initial creation of the table. And running that sync task every ten seconds would be fast enough for now, until you're comfortable to deploy a trigger.
 
@Danack oh wow, thanks!
maybe triggers could solve that shameful minutelyTasks.php script of mine that I run every ten seconds
<?php
include '/var/www/lib/db/dbconn.php';
$db->query("update stars set yellowStars = 10 where (yellowStars>10)");

*winces* yes it's a kludge
 
Syncing tables can actually be really efficient with low load on a database, if the amount of 'stuff' to be copied is set low e.g. 50 rows to be copied at once, then having a separate sync script can be lower load than triggers.
But yeah.....that case you have above is definitely something for a trigger to do.
Although you might still need a data integrity check to be run every 20 minutes to catch any items where the trigger failed to trigger due to 'reasons'.
 
Thank you! @Danack
 
10:34 PM
the error_get_last() gave me this beauty: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 7479","file":"\/Applications\/MAMP\/htdocs\/tirumsTrav\/httpdocs\/booking\/phpQu‌​ery\/phpQuery\/DOMDocumentWrapper.php","line":199
Im sure it must be known... so is php query buggy ?
Ive written some massive pages and i can't figure out where to put those htmlentities()!
Maybe advise how to backtrace this error? It's late and no manual in english makes sense any more to me
 
massive pages?

probably irrelevant, but I keep the bulk of my pages in a class file and then just call
$myPageClass->displaySomePageElementHere($args);
 
@animaacija "expecting ';'"
Look for something missing a ';'
 
So phpQuery has bug ?
 
19 secs ago, by Danack
Look for something missing a ';'
btw @AustinBurk that sync query might be better (not guaranteed) written as:
$batchSize = 5000;
// $total =  select count(*) from stars
$offset = 0;
while ($offset < $total) {
	$db->query("update stars set yellowStars = 10
		where stars_id >= $offset and stars_id < ".($offset + $batchSize)."
		and (yellowStars>10)
		order by stars_id");

	$offset += $batchSize;
}
Currently you're (effectively) locking the whole table while the whole thing is updated, which makes every other query block until it's done. You don't need that. By breaking the query up and running it against the index, other queries can run, unless they are interested in those rows - and as the individual queries will complete faster, the wait time will be lower even if they are blocked.
 
yeah, across 20 times 100 lines ^^ umh .. how to backtrace? because error_reporting(E_ALL);
ini_set("display_errors", 1); gave me nothing all this time.. And user doesn't get all the progress messages, thus process still completes.. But not neat UI.
 
10:40 PM
btw the 'order by' is required replication to work reliably....which you might not be using yet, but is worth thinking about.
@animaacija How about looking at "line: 7479" of the file you're trying to parse?
 
efree()'ing from the arena sounds like a great idea…
 
can't be, the html file I'm pulling has only 7306 lines.
 
@Danack Aah... trying to understand how what you're talking about works - I do understand partially. Thank you, I'll be working on educating myself on this. :)
@animaacija Which editor are you using btw?
 
phpQuery::debug("Full markup load (HTML), documentCreate('$charset')");
$this->documentCreate($charset);
$return = phpQuery::$debug === 2
? $this->document->loadHTML($markup)
: @$this->document->loadHTML($markup); //the line 199 is here
if ($return)
$this->root = $this->document;
@AustinBurk the best one, we all know which currently it is
 
10:55 PM
@animaacija I like Notepad++, and otherwise, nano through SSH on my phone
 
If a had a pocket pc i would make use of it too... But can you create custom snippet shortcuts in notepad++ i think not. As well as if it has linters and all toolsets in one place ?
 
@animaacija addictivetips.com/windows-tips/… There's a plugin for that
How do you set the display text for a link here?
 
well, a subset of that...look here
 
@AustinBurk [Really cool thing](https://www.youtube.com/watch?v=kfVsfOSbJY0)
/ticking on and on.
 
There is no enter key tho!
 
11:09 PM
@ircmaxell is it touchscreen ?
 
Yes
 
if double tap does not work, you must tweak kernel for that...
 
@ircmaxell have you tired using the 3 keys below
 
Yes
 
does it have USB
 
11:13 PM
"Loading Fonts please wait"
Weird.
 
@ircmaxell how can i backtrace the error_get_last() ? This drives me crazy - product is finished but this thing shows up ;(
 
"This thing"
 
woo
@ircmaxell Hello Anthony, can I ask you few questions about your article?
 
Wheels up, later
 
woo
ok
 
11:18 PM
@animaacija ffs "expecting ';' in Entity, line: 7479"".....
 
(About to take off, literally) post your question and I will get back to it tomorrow
 
@Danack yes but which file ?
 
user895378
@bwoebi lol. Productive. Not fun, but productive.
 
@animaacija Presumably line 7479 of $markup
 
arrgh... goodnight tomorrow
 
11:23 PM
Hi
 
@ircmaxell Thanks
Oh gah I'm using a Mac
I want to backup my server, and I've been asking around to see if Lansing Community College has any Linux computers; eventually I just hoped that a Mac would do (rsync, ssh, all that stuff)
All is good except for the fact that it won't mount my ext3 (or 4, can't recall) filesystem on this thing
 
user895378
Hi :)
 
user895378
afk, dinner, bbl
 
this mouse is sticking and it only has one button
the control key doesn't do what I expect
all the menu bars are up top, this is too close to ubuntu's unity

;0;
 
@AustinBurk not natively, but there are drivers out there…
 
11:29 PM
@bwoebi Heh, I could be out of luck in that case
 
@AustinBurk well, for ext3 and 4 there exist some…
 
@bwoebi I don't have root permissions on this thing so installing drivers is out
 
oh okay, then…
 
The scroll wheel on this mouse doesn't work at all
No wait, it works in tiny tiny little bits
I think I'm out of luck - maybe I can run, say, portable virtualbox on one of the Windows computers in the library and go that route
 
11:49 PM
Maybe I'm silly but
What if we had set literals?
set[ 1, 2, 3 ] which would be equivalent to array( 1 => NULL, 2 => NULL, 3 => NULL )
Serious idea
Writing those NULLs is a pain
 
Hi guys - any idea how to loop through this php array? pastebin.com/taHNm7kN (want to access creators four times)
 
I'm unfamiliar with Python, explain?
 
@AustinBurk ?
 
I googled 'set literals' and found python stuff
Apologies
 
Oh, Python happens to have a syntax that produces a set
Most languages just have some constructor
In Python, {1, 2, 3} is the same as set([1, 2, 3])
PHP doesn't have a native set type, but it does have associative arrays
 
11:52 PM
@AndreaFaulds I love PHP arrays, so nice and easy to use and no typecasting to screw up, <3
 
To use one as a set, you just ignore the values
but writing out [1 => NULL, 2 => NULL, ...] is a pain... on the other hand, if it's not a constant, array_flip would work
 
@AndreaFaulds aha, okay
@mboeckle Won't a foreach loop work? php.net/manual/en/control-structures.foreach.php
foreach($theArrayWithAuthorsInIt as &$itemWithinThatArray) {
print_r($itemWithinThatArray["author"]);
}
since author is a sub-array you do the whole $item["author"] thing
 

« first day (1558 days earlier)      last day (3393 days later) »