[QUOTE=Philly c;33516237]Isn't it a lookup table?[/QUOTE]
Ah yes, that's what it is. I wasn't aware of the distinction :downs:
Yeah, it doesn't map multiple keys to the same value and it replaces a computation so it's more like a lookup table. My bad
[QUOTE=synthiac;33516077]what the fuck[/QUOTE]
[i]That's [/i]the part you're confused by?
[code]C:\Users\Andrew\Documents\Facepunch Lua API>lua main.lua
/174990-supersnail
/196199-Octave
/112075-Jookia
/102668-synthiac
/83719-Yogurt
/141106-Philly
/7258-ROBO
[/code]
[lua]local error = error
local gmatch = string.gmatch
local insert = table.insert
local pairs = pairs
local request = require( "socket.http" ).request
module( "facepunch.thread" )
lastRetrievedThread = ""
lastReturnCode = -1
function findMembersInThread( threadURL )
lastRetrievedThread, lastReturnCode = request( threadURL )
if ( lastReturnCode == 200 ) then
local t = {}
local matched = false
for member in gmatch( lastRetrievedThread, "%/%d+%-%a+" ) do
for _, v in pairs( t ) do
if ( v == member ) then
matched = true
end
end
if ( not matched ) then
insert( t, member )
end
matched = false
end
return t
else
error( "Could not retrieve thread!" )
end
end
[/lua]
[lua]local thread = require( "facepunch.thread" )
for _, member in pairs( thread.findMembersInThread( "http://www.facepunch.com/threads/1137375/86" ) ) do
print( member )
end
[/lua]
:/ idk, just trying to learn Lua patterns, since I suck at all things even remotely regex-like.
[QUOTE=amcfaggot;33516432][code]C:\Users\Andrew\Documents\Facepunch Lua API>lua main.lua
/174990-supersnail
/196199-Octave
/112075-Jookia
/102668-synthiac
/83719-Yogurt
/141106-Philly
/7258-ROBO
[/code]
[lua]local error = error
local gmatch = string.gmatch
local insert = table.insert
local pairs = pairs
local request = require( "socket.http" ).request
module( "facepunch.thread" )
lastRetrievedThread = ""
lastReturnCode = -1
function findMembersInThread( threadURL )
lastRetrievedThread, lastReturnCode = request( threadURL )
if ( lastReturnCode == 200 ) then
local t = {}
local matched = false
for member in gmatch( lastRetrievedThread, "%/%d+%-%a+" ) do
for _, v in pairs( t ) do
if ( v == member ) then
matched = true
end
end
if ( not matched ) then
insert( t, member )
end
matched = false
end
return t
else
error( "Could not retrieve thread!" )
end
end
[/lua]
[lua]local thread = require( "facepunch.thread" )
for _, member in pairs( thread.findMembersInThread( "http://www.facepunch.com/threads/1137375/86" ) ) do
print( member )
end
[/lua]
:/ idk, just trying to learn Lua patterns, since I suck at all things even remotely regex-like.[/QUOTE]
Parsing HTML with regex...
[QUOTE=Yogurt;33516444]Parsing HTML with regex...[/QUOTE]
I know, I know. But it's a quick-and-dirty so I can get a hang of regex, doesn't mean I approve of it, but I'd like to not suck ass at Lua patterns. It'll help me with moving on to regex in the future, I'm guessing.
[QUOTE=synthiac;33516445]i'm not confused by it. it just seems to be very unnecessary and naive.[/QUOTE]
How would you have done it, O wizard of WAYWO?
I somehow fixed my extreme lag bug
I don't even fully understand what was causing it or how I fixed it
[QUOTE=synthiac;33516541]using bitwise operations like anyone else would[/QUOTE]
Using |= 1 for modulo 2? Other than looking "cleaner" there is no advantage, you're doing unnecessary computation when there are a small number of possible results.
[QUOTE=synthiac;33516541]using bitwise operations like anyone else would
or by representing 24-bit values in base-64[/QUOTE]
That's stupid. A lookup table fetch is a hell of a lot faster than going through bit-by-bit and constructing the string one character at a time. Memory is cheap, CPU cycles aren't.
I'm actually unbelievably frustrated. You're criticizing what is possibly the ideal solution to this particular problem and advocating what is probably the worst.
[QUOTE=synthiac;33516653]wow. just wow.[/QUOTE]
Care showing how exactly you would do it? Can you even program from so far up on your high horse?
Synthiac, nobody is appreciative of your berating someone with less skill/someone who does something differently. Your smug attitude is not wanted here.
Found these in the graphics folder, what the fuck?
[t]http://dl.dropbox.com/u/23280705/cakelink/team1.jpg[/t]
[t]http://dl.dropbox.com/u/23280705/cakelink/team2.jpg[/t]
[t]http://dl.dropbox.com/u/23280705/cakelink/team3.jpg[/t]
[t]http://dl.dropbox.com/u/23280705/cakelink/team4.jpg[/t]
[QUOTE=Yogurt;33516684]Synthiac, nobody is appreciative of your berating someone with less skill/someone who does something differently. Your smug attitude is not wanted here.[/QUOTE]
Less skill?
[QUOTE=ROBO_DONUT;33516704]Less skill?[/QUOTE]
I should say less apparent skill.
Perhaps instead of bashing people for their methods of tackling a problem or accomplishing something, we can discuss better approaches and be nice about criticism.
I know that my previous few instances of criticizing design elements have not been the nicest bits of feedback, so I'm trying to be less of a douchebag in that department.
Shane, you're clearly a good developer, perhaps you can explain why bitops are better than storing references in an array for comparison instead of taking my ill approach to feedback.
[editline]30th November 2011[/editline]
[code]C:\Users\Andrew\Documents\Facepunch Lua API>lua main.lua
/174990-supersnail11
/196199-Octave
/112075-Jookia
/102668-synthiac
/83719-Yogurt
/141106-Philly
/7258-ROBO
/397849-amcfaggot
/174990-supersnail
/199765-ZenX2
[/code]
Improving my pattern to find members in a thread! c: I really only want the names though, but I can't think of how I'm suppose to do that. Is anyone else here good with Lua patterns?
Also why is supersnail coming up twice, but later with no numbers at the end of his alias?
Pattern being used: "%/%d+%-%w*"
[QUOTE=synthiac;33516828]if it's "a hell of a lot faster" then why does almost every single implementaion use bitwise operations over this "ideal solution"?[/QUOTE]
Why did everybody think the world was flat before people proved them wrong?
ad populum is a bad fallacy to use. Stop it.
[code]C:\Users\Andrew\Documents\Facepunch Lua API>lua main.lua
octave
jookia
supersnail11
synthiac
yogurt
supersnail
zenx2
amcfaggot
robo
philly
Octave
Jookia
Yogurt
Philly
ROBO
ZenX2
[/code]
More duplicated usernames, woo? Well that's not good. Anyway, I guess I can't retrieve just the plain usernames with patterns alone, so after I get the href parameter, I'm stripping away what I don't need.
[editline]30th November 2011[/editline]
[code]C:\Users\Andrew\Documents\Facepunch Lua API>lua main.lua
supersnail11
Octave
Jookia
synthiac
Yogurt
Philly
ROBO
amcfaggot
ZenX2
[/code]
That's better! I think. Right?
[QUOTE=synthiac;33516828]if it's "a hell of a lot faster" then why does almost every single implementaion use bitwise operations over this "ideal solution"?[/QUOTE]
You've looked at 'every single implementation'?
I doubt you've even looked at more than one.
[editline]giant phalluses[/editline]
Parsing page king!
*Whistle whistle*
~Content instead of fighting~
[code]C:\Users\Andrew\Documents\Facepunch Lua API>lua main.lua
supersnail11
Octave
Jookia
synthiac
Yogurt
Philly-c
ROBO_DONUT
amcfaggot
ZenX2
[/code]
Fixed Philly c's and ROBO_DONUT's name, sorta. But since I'm grabbing the href values and not the actual displayed username I'm gonna have to rewrite my pattern. :( Learning though!
Current pattern: "members%/%d+%-[%w%_-]+"
Instead of complaining like a bunch of babies, why don't your back up your fallacies with some good ol' benchmarks.
[QUOTE=amcfaggot;33517115][editline]giant phalluses[/editline]
Parsing page king!
*Whistle whistle*
~Content instead of fighting~
[code]C:\Users\Andrew\Documents\Facepunch Lua API>lua main.lua
supersnail11
Octave
Jookia
synthiac
Yogurt
Philly-c
ROBO_DONUT
amcfaggot
ZenX2
[/code]
Fixed Philly c's and ROBO_DONUT's name, sorta. But since I'm grabbing the href values and not the actual displayed username I'm gonna have to rewrite my pattern. :( Learning though!
Current pattern: "members%/%d+%-[%w%_-]+"[/QUOTE]
You should make it show the peoples usergroups too!
[QUOTE=Titz;33517200]You should make it show the peoples usergroups too![/QUOTE]
facepunch.user.getUsergroup( username or member object ) and member:getUsergroup() is planned, or something of the sort.
I eventually want to be able to parse entire threads and enumerate ratings and all that fun stuff! :) Then I'll release it as a native module for anyone to use or port.
[editline]30th November 2011[/editline]
[QUOTE=synthiac;33517248]converting a 8-bit number to a binary string representation via a lookup table then extracting 6-bits/converting it back into a number using some ungodly 6-comparison macro
vs
(n & 0xfc) >> 2
lol okay lets benchmark[/QUOTE]
Just remember that some things like this may not be entirely obvious to the rest of us, whilst you may see these things as clear as day.
I didn't choose a side. I'm simply saying, provide some proof so that everyone will stop arguing.
[img]http://i.imgur.com/gUFqI.png[/img]
Yes, that is the Ubuntu font.
If I don't finish this project, I can atleast make a bitchin' skin.
[img]http://dl.dropbox.com/u/23280705/cakelink/buttons/analyser.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/email.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/exitgame.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/finance.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/gameoptions.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/graphicsoptions.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/hardware.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/loadgame.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/memory.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/mission.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/networkoptions.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/newgame.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/newmail.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/optionno.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/options.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/optionyes.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/software.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/soundoptions.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/speed0.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/speed1.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/speed2.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/speed3.jpg[/img][img]http://dl.dropbox.com/u/23280705/cakelink/buttons/status.jpg[/img]
I shrunk the start menu button (the one that says "prog") because it fits better in a desktop layout.
[QUOTE=synthiac;33517248]converting a 8-bit number to a binary string representation via a lookup table then extracting 6-bits/converting it back into a number using some ungodly 6-comparison macro
vs
(n & 0xfc) >> 2
lol okay lets benchmark[/QUOTE]
You're really bad at constructive criticism.
[QUOTE=synthiac;33517248]converting a 8-bit number to a binary string representation via a lookup table then extracting 6-bits/converting it back into a number using some ungodly 6-comparison macro
vs
(n & 0xfc) >> 2
lol okay lets benchmark[/QUOTE]
Care to elaborate on what exactly "n & 0xfc" does?
Sorry, you need to Log In to post a reply to this thread.