User ID encoding on the URL? - screen-scraping

I would like to get some information from the user profiles of a certain domain.
www.domain.com/profiles/[userID]
The main problem is that the user ID is like:
4fc34f1ad3d85a000300b5a4
4fc34f1ad3d85a000300b5a4
4f4bdd96848740000300026a
4f09884f9cc1590001019c98
4f1bcd5f33aa850001011811
4faa2801c619ad0003011c7e
4e4f506ac9d69600010010ca
so if I wnat the user profile of a certain user I have to put
www.domain.com/profiles/4fc34f1ad3d85a000300b5a4
www.domain.com/profiles/4f4bdd96848740000300026a
www.domain.com/profiles/4f09884f9cc1590001019c98
www.domain.com/profiles/4f1bcd5f33aa850001011811
www.domain.com/profiles/4faa2801c619ad0003011c7e
www.domain.com/profiles/4e4f506ac9d69600010010ca
What kind of ID is that? How I know the subjacent canonical order?
Other times was a lot easier because the user ID only was integers.
www.domain.com/profiles/1
www.domain.com/profiles/2
www.domain.com/profiles/3
www.domain.com/profiles/4
www.domain.com/profiles/5
I would like to know if this is some kind of encoding or what.
What kind of ID on the URL is that?
Thank you in advance.

Looks like an MD5 hash. So either it's a random hash, or it might a hash of the previously used ID, or something completely different. Either way apart from brute force guessing, there's no simple way to decode them.
http://en.wikipedia.org/wiki/MD5

These ID's use hexadecimal - notice there are no letters above 'f'.
The similarities between ID's are interesting - could you provide the ID's of some consecutively created pages, to check if there is a pattern to how the ID changes.
Or the website may just generate a random number between certain limits and convert to hex.

Related

Show UniData SELECT results that are not record keys

I'm looking over some UniData fields for distinct values but I'm hoping to find a simpler way of doing it. The values aren't keys to anything so right now I'm selecting the records I'm interested in and selecting the data I need with SAVING UNIQUE. The problem is, in order to see what I have all I know to do is save it out to a savedlist and then read through the savedlist file I created.
Is there a way to see the contents of a select without running it against a file?
If you are just wanted to visually look over the data, use LIST instead of SELECT.
The general syntax of the command is something like:
LIST filename WITH [criteria] [sort] [attributes | ALL]
So let's say you have a table called questions and want to look over all the author for questions that used the tag unidata. Your query might look something like:
LIST questions WITH tag = "unidata" BY author author
Note: The second author isn't a mistake, it's the start of the list of attributes you want displayed - in this case just author, but you might want the record id as well, so you could do #ID author instead. Or just do ALL to display everything in each record.
I did BY author here as it will make spotting uniques easier, but you can also use other query features like BREAK.ON to help here as well.
I don't know why I didn't think of it at the time but I basically needed something like SQL's DISTINCT statement since I just needed to view the unique values. Replicating DISTINCT in UniData is explained here, https://forum.precisonline.com/index.php?topic=318.0.
The trick is to sort on the values using BY, get a single unique value of each using BREAK-ON, and then suppress everything except those unique values using DET-SUP.
LIST BUILDINGS BY CITY BREAK-ON CITY DET-SUP
CITY.............
Albuquerque
Arlington
Ashland
Clinton
Franklin
Greenville
Madison
Milton
Springfield
Washington

Laravel show records as flat array or single record

I have 2 column in my table setting
with the following values
KEY VALUE
company ABC
phone 14344
address Somerset City
I need to display this like a single record or a flatten
array in the view/blade page
something like
{{$sett->company}}
{{$sett->phone}}
or an array with lookup
{{$myarray('company')}}
{{$myarray('phone')}}
The idea is if I add another settings like contact us email address
for my website I don't want to add another column.
I know this is achievable in controller by creating different variable
and executing different query but I'm kind of looking for some options here.
Thanks for the help really appreciated.
You can use $settings->pluck('value', 'key') to get your result. Read more here: https://laravel.com/docs/5.4/collections#method-pluck

How to assign unique names to images?

I'm writing a web application where users can upload images. I wonder what's the best practice of assigning unique names to images ? I thought MD5 can ben useful and enough, but since each image has an owner, do I have to use MD5 ? I mean it could be enough to rename with Userid + imagename + creationdate ?
Your database gives you a unique ID for each record. Though there are many different ways to do what you want, it is usually best to use this ID as a prefix/suffix to the name of the image. So, for these records:
ID | name
15 image.png
23 image.png
you could display something like: 15_image.png, 23_image.png
No, it would not be enough as the user might want to upload several images with the same name.
The easiest solution is to use a sequence number with the image name. You can be certain that there is no other image with the same name and there will never be one. With a hash function there is always an ever so slight chance of collision.

Store user name as separate first/last name, or as a single full name String?

I have a web app, I'd like the user to supply their real name, for friend searches. I'm not sure whether to store this as two separate fields in my user class, or as a single field:
class User {
#Persistent
private String mFirstName;
#Persistent
private String mLastName;
}
.. or ..
class User {
#Persistent
private String mFullName;
}
I'm only going to use it to let users search for people. For example, they might search for "John", or "John Doe", or "Doe". I'm not sure what the app engine query engine allows us to do here, in terms of partial matches and such - has anyone gone through this and can recommend a good solution? I'm leaning towards just storing the full name to make searches easier,
Thanks
It's not just a question of how you end up storing names, it also matters how you ask for names on your web form.
If you prompt with a first and last field, the vast majority of inputs will probably conform, but you'll still have many exceptions (prefixes, middle names, suffixes, punctuation, etc).
If you clearly prompt with separate prefix, first name, middle name, last name, suffix fields, there'll be even fewer exceptions, but users might get peeved or confused.
You might even offer both: an easy one-field input or preparsed multifield input. Explore what other web sites do and see if you find them appealing/confusing/whatever.
Also keep in mind that if you input separate fields you can always easily join them later, but if you input only a single field you won't have the typist's help if you need to parse it later.
Short answer: store a full name.
Long answer here (Falsehoods programmers believe about names, by Patrick McKenzie).
I’m going to list assumptions your systems probably make about names. All of these assumptions are wrong.
(#1) People have exactly one canonical full name.
(#20) People have last names, family names, or anything else which is shared by folks recognized as their relatives.

Autocomplete Dropdown - too much data, timing out

So, I have an autocomplete dropdown with a list of townships. Initially I just had the 20 or so that we had in the database... but recently, we have noticed that some of our data lies in other counties... even other states. So, the answer to that was buy one of those databases with all towns in the US (yes, I know, geocoding is the answer but due to time constraints we are doing this until we have time for that feature).
So, when we had 20-25 towns the autocomplete worked stellarly... now that there are 80,000 it's not as easy.
As I type I am thinking that the best way to do this is default to this state, then there will be much less. I will add a state selector to the page that defaults to NJ then you can pick another state if need be, this will narrow down the list to < 1000. Though, I may have the same issue? Does anyone know of a work around for an autocomplete with a lot of data?
should I post teh codez of my webservice?
Are you trying to autocomplete after only 1 character is typed? Maybe wait until 2 or more...?
Also, can you just return the top 10 rows, or something?
Sounds like your application is suffocating on the amount of data being returned, and then attempted to be rendered by the browser.
I assume that your database has the proper indexes, and you don't have a performance problem there.
I would limit the results of your service to no more than say 100 results. Users will not look at any more than that any how.
I would also only being retrieving the data from the service once 2 or 3 characters are entered which will further reduce the scope of the query.
Good Luck!
Stupid question maybe, but... have you checked to make sure you have an index on the town name column? I wouldn't think 80K names should be stressing your database...
I think you're on the right track. Use a series of cascading inputs, State -> County -> Township where each succeeding one grabs the potential population based on the value of the preceding one. Each input would validate against its potential population to avoid spurious inputs. I would suggest caching the intermediate results and querying against them for the autocomplete instead of going all the way back to the database each time.
If you have control of the underlying SQL, you may want to try several "UNION" queries instead of one query with several "OR like" lines in its where clause.
Check out this article on optimizing SQL.
I'd just limit the SQL query with a TOP clause. I also like using a "less than" instead of a like:
select top 10 name from cities where #partialname < name order by name;
that "Ce" will give you "Cedar Grove" and "Cedar Knolls" but also "Chatham" & "Cherry Hill" so you always get ten.
In LINQ:
var q = (from c in db.Cities
where partialname < c.Name
orderby c.Name
select c.Name).Take(10);

Resources