pty 882 Posting Pro

The two methods are to store the image directly in the table as a blob or to store it on disk (or in the cloud) and store the location/path in your table.

I'd favour the latter approach simply because it's simpler, keeps your database size manageable, doesn't require you to serialise and deseriealise every time you need to read or write it.

pty 882 Posting Pro

gtfo.

rproffitt commented: GIGO? +15
pty 882 Posting Pro

I'll help you out by telling you that you need to format your code properly. I'm not surprised you can't find the error in that wall of text.

Lastly, dynamic SQL like this is what we'd call a 'code smell'. It's an indication that some other part of your design is bad, and by coming up with a harebrained and fragile mess like this is a symptom.

pty 882 Posting Pro

Also, once Python is installed, you can use Python's package manager (pip) to download and install other packages. Django comes with a built in web server and there's even a very simple one that comes with Python itself.

pty 882 Posting Pro

choco install python

(See other thread)

pty 882 Posting Pro

To anyone other than Davy, you're best using Chocolatey. It's a sane apt/brew like package manager for Windows and does all the hard work for you.

Of course, using a Unix like OS makes it even easier.

rproffitt commented: Thanks for this. Something new to me. +15
pty 882 Posting Pro

The pdf files that i am dealing are very complex, containing tables, checkboxes , radio buttons images etc

I wouldn't do this. Whoever came up with this was a masochist. Replace it and don't waste any more time trying to modify PDFs. That's not what they're for.

Trust me, I used to work in the translation industry. We had an entire department who did this kind of thing on an ad hoc basis (customer wants this PDF in French, Bulgarian and Mandarin by Tuesday). The process took about fifteen times longer than working with a text or Word file and was priced accordingly. The results were never perfect, especially for non-standard layouts. Text didn't reflow properly, things didn't always line up.

tl,dr; you're doing it wrong. Start again now you know why.

rproffitt commented: +1 for YDIW. Sometimes that's it, plain and simple. +0
pty 882 Posting Pro

That's not how PDF files work. All of the calculations that take place in the layout stage are done and finalised (this sets PDF apart from Postscript).

You need to treat PDF files as if they are paper. If there's an update, reprint it from the new source. It's digital and free, much easier than printing out some words and try to glue them in the right place.

rproffitt commented: And that's how it is. +15
pty 882 Posting Pro

I'm not sure what you mean by "I am wanting to select an access database table after gaining the ID for the table."

To find a record with a matching first and last name using SQL you'd do something like

select * from patients where firstname = 'Joe' and lastname = 'Shabadoo';

Nobody in the real world would actually create separate variables for a single record's attributes and populate them manually like that. In Rails, for example, using ActiveRecord to find and modify a record we'd do something like this:

p = Patient.find_by(firstname: 'Joe', lastname: 'Shabadoo')
p.firstname = 'Joseph'
p.save

Simple, elegant and pretty self-explanatory.

vb.net probably has something similar. If it doesn't I'd suggest learning something that does instead.

pty 882 Posting Pro

Yes sure. Step one, learn SQL. Try CodeAcademy's SQL course, it's very good.

pty 882 Posting Pro

You need to union the two similar tables together then query the resulting set using group by with max to get the latest information.

I'd do this in two stages using views, otherwise your query will be complex and ugly.

I think you should also question your database design, needing to do stuff like this is usually a hint of a smell.

pty 882 Posting Pro

Yeah, I said Stack Overflow and actually meant the Pro Webmasters section of Stack Exchange.

I was referring to the quality of the question more than the topic. It's a terribly low standard, pretty much at the "how is babby formed?" level.

And the suggestions. Ugh. People just posting stuff without any indication of how it might actually help the OP. And Squidoo hasn't existed for fucking years. Nor has Technorati. And what Travel_3 posted is beyond comprehension.

I've all but lost patience here. The core members try to help people and some threads are constructive but the vast majority are low effort questions with low effort replies.

In this thread poor GentleMedia is wading upstream in a raging torrent of shite. And Gliffer, the latest post, they spell their address wrong on their actual website.

As the scholar and gentleman Duncan Bannatyne repeatedly said, "I'm oot".

pty 882 Posting Pro

It's easy

  • Add a new checkbox
  • Create an associated label with text "Select All"
  • Write some code that when the new checkbox is checked checks the other boxes, and vice versa.

Done.

Here are some ways not to do it

  • Ask a vague question on a forum without giving any information on the context and what libraries are available
  • Copy and pasting random code from the internet until it works
  • Wasting peoples time by asking the same question over and over, each time (when pressed) yielding slightly more information
rproffitt commented: +1 easy. +0
pty 882 Posting Pro

Another thread full of useless information. How long would this have lasted on Stack Overflow? Not long. And that is why people go there.

This is why forums fell behind. This right here.

rproffitt commented: Sort of like opening the black sarcophagus found in Alexandria but worse. +15
pty 882 Posting Pro

I use Skype daily and prefer web.skype.com. It runs perfectly in the browser and means I don't have to install anything or touch the client which, to be honest, could suck golf balls through a hosepipe.

rproffitt commented: Something that could suck balls through that sounds very powerful? +15
pty 882 Posting Pro

Not at all. The algorithm he has used copies whatever is in the boolean position in the input: and, or, xor(?) etc (with maybe a conversion to upper case

Yes I see that but once you start adding or statements to a query you have to take precedence and additional brackets into account. It can get very difficult very fast.

Source, I wrote a query builder a few years ago, thought it'd take a couple of days but ended up being more than a week. Should have just taught the users SQL!

pty 882 Posting Pro

Like I said in my post, this is deceptively easy. We're assuming they're all and, and under that assumption you may as well just join.

Once you start adding or into the query, the whole thing becomes much more difficult.

pty 882 Posting Pro

I quite enjoy puzzles like this. Of course, I suspect that your problem will get much harder once you start adding stuff like (Banana, fruits, or) to the equation, as then you'll need to worry about brackets and presedence.

However, for this simple version here's how I tackled it in Ruby. You can pretty much translate this to PHP but it won't be as succinct or elegant.

puts "(Mango, fruits, and), (Maize, cereals, and), (Mango juice, beverages, and)"
  .scan(/\((.*?)\)/)                                                    # grab all the text that appears inside brackets
  .flatten                                                              # scan yields an array of arrays, flatten it
  .map{|chunk| chunk.split(",")}                                        # split each trio into a word array
  .map{|fruit, category, operation| "(#{fruit}[#{category.strip}])" }   # build the keywords into strings in the desired format
  .join(" AND ")                                                        # join the built strigns with 'AND'

(Mango[fruits]) AND (Maize[cereals]) AND (Mango juice[beverages])

pty 882 Posting Pro

Python is clean, expressive and has a great standard library. It's not just a web development language, it can be used for most tasks.

Where it really pulls ahead of PHP from a development perspective is its general consistency and availability of scientific libraries.

pty 882 Posting Pro

This is exactly the sort of post that shouldn't exist. It's just shit in every way.

rproffitt commented: I agree. Low quality and keeps getting low quality answers. +15
pty 882 Posting Pro
rproffitt commented: And there it is. (answer!) +0
pty 882 Posting Pro

I think you need to spend a little time learning git before you dive in and start using it. Git can be a cruel mistress.

To stash your work run git stash. It says that in the doc you "read".

In short, don't pull when your repo has uncommitted changes.

pty 882 Posting Pro

The difference between hardware and software is that you can touch hardware.

And yes, this is a hijacked thread.

dream11indian commented: Nice post +0
pty 882 Posting Pro

Reverend Jim is correct. It may help if you say the relationship out loud; if it's a 'has many' or 'belongs to' relationship (with a foreign key) you'd typically use a join:

  • A person has zero, one or many credit cards
  • A credit card belongs to a person

If it's a 'is very much like a' or a 'is a kind of' relationship, you probably want a set operation, like union, intersect or minus (aka except)

  • A debit card is very much like a credit card (ie. they both have numbers, expiry dates and security numbers)
  • A Visa is a kind of credit card

These aren't hard rules but a useful guideline.

pty 882 Posting Pro

Where are you? In the UK we have markets like Music Magpie that will give you quotes for items in your collection. Failing that, you can always sell through eBay or Amazon but if you have lots of CDs, creating lots of ads might be a tedius prospect.

pty 882 Posting Pro

Why are you using PHP for this? Can't you just use anupdate statement with a where clause?

pty 882 Posting Pro

Replace sum with avg. But average (mean) is meaningless without standard deviation, so you'd better work that out too.

pty 882 Posting Pro

Essentially what you need is something that sits between the web page and the database. We'd often refer to this layer as an API, but just think of it as a simple program that receives HTTP requests and responds with some data.

Here's a really simple example written in Ruby with Sinatra.

require "sinatra"
require "json"

before do
  content_type :json
end

get "/" do
  [1,2,3,4,5].to_json
end

Now, when I run this program and make a request, we can see exactly what happens. By default, Sinatra listens on port 4567

$ http get localhost:4567

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 11
Content-Type: application/json
Server: thin 1.5.1 codename Straight Razor
X-Content-Type-Options: nosniff

[
    1,
    2,
    3,
    4,
    5
]

Once you have this working you should be able to create a method in JavaScript that makes AJAX requests to your API. The easiest way to do this is to use the new standard Fetch API or something like Axios.

Here's me making the request using fetch in Chrome against the API I just wrote

Screen_Shot_2018-07-09_at_15_24_26.png

Simple, eh? The next step would be to enhance this program (or a similar one written in the language of your choice) and connect it to a database. But, one step at a time.

pty 882 Posting Pro
pty 882 Posting Pro
rproffitt commented: +1 for the enjoining. +0
pty 882 Posting Pro

but searching for "dog mouse cat" will return no results

This is what your query is specifying. To make it match a jumble of words you need to can split up the string and group your criteria with and. This will soon get messy, especially if your searching across multiple columns. Depending on the database you're using I would change the query to use a full text search (available in most RDBMS in one form or another, including PostgreSQL and MySQL).

rproffitt commented: And +1 +0
pty 882 Posting Pro

There's an implementation of SQLRand
available on GitHub and you can read the original paper that proposed the idea here.

Personally I think the approach is over complicated and would instead opt for a sane ORM and coding standards that eliminate the angles of attack.

rproffitt commented: Anti-pattern. Thanks for this. +15
pty 882 Posting Pro

If you have a problem like this you're probably better just starting again. This is a bad idea that will generate useless data. Burn it with fire.

rproffitt commented: Good advice for spider filled homes. +15
pty 882 Posting Pro

I love how there's a discussion in one thread about how to save the platform/community and then there's this crap.

People left because the signal:noise is better on SO and Reddit.

This is clearly noise. Nobody will get anything useful from this and the thousand other threads like it.

pty 882 Posting Pro

Do you want to get sued? Because this is how you get sued.

What value is there in an app that redirects me to a website? What value to me, them (the brands), and you?

As far as I can see, there's none.

rproffitt commented: "Do you want ants? Because that's how you get ants" - Malory Archer +15
pty 882 Posting Pro

Like doesn't support multiple conditions, you need to use or.

pty 882 Posting Pro

This is why mixing code and markup makes things more difficult.

If this was in a Rails controller using an ORM it's simple and, more importantly, debuggable.

PER_PAGE = 20 # should be in a config file, here for clarity

def search
    @results = Video
        .where(active: true) # plus whatever other critera you like
        .limit(20)
        .offset(params[:page_num])

    # now calculate how many pages we'd need to display in the
    # pagination links. In rails we'd do this in a helper, but let's
    # keep it simple
    @pages =  ((@results.length + PER_PAGE) - 1) / PER_PAGE

    # all our info is visible, we can break at this point and inspect
    # the results manually or just dump it out to the log. And we've 
    # not even written any HTML yet! In fact, I could have done all this
    # directly in the console.
    logger.debug("#{@results.length} records retrieved, that's #{@pages} pages!")
end

This clean approach will work just as well in PHP with Laravel or Symfony, or Python and Django, etc.

pty 882 Posting Pro

The short answer is that it depends who I'm talking to. With other people who are interested in technology I use hacker in the traditional sense (white hat).

With muggles (many of my clients), it's easier to use the word to describe the black hat variety. It just means I don't have to explain the term to people who don't really care.

rproffitt commented: Ha ha, muggles. +15
pty 882 Posting Pro

I'm more of an editor than IDE kind of guy but VSCode might fit the bill. It has a built in package manager so you can install PHP (or any other language, technology etc) specific functionally. I use it for Go, JavaScript, CSS and HTML/Vue templates and it works just fine.

pty 882 Posting Pro

I think that spatial functionality probably isn't really required for this, you only need to store coordinates for points (of interest) and a city key in that table, unless you want really fancy functionality like clicking a city will automatically query for any POI within 20km. To start with, an X and Y numeric field is enough.

For displaying maps on the page you're probably best looking into LeafletJS.

I wouldn't worry too much about backend databases to start with, I'd begin by hardcoding a JSON file with the data you need in it, and when you're ready and happy with the structure, content and sections of the app, you can replace it with an API.

pty 882 Posting Pro

Having an off day pty?

It's a solid idea. The users don't need to be adult workers, it could just as easily apply to counsellors or support staff. If you want to make money then adult services are the obvious answer though.

pty 882 Posting Pro

WebRTC video chat with integrated payments for adult performers and smut peddlers, perhaps?

rproffitt commented: Brill. May as well get in on what the internet is all about. +15
pty 882 Posting Pro

You need to provide more info. Is this a form you're submitting to the server to calculate or do you want all this to happen in the browser? Have you tried anything yourself?

pty 882 Posting Pro

I think you're approaching this from the wrong direction. You should be storing the start date and calculating the increment using datediff in a computed column.

If you need more complicated logic (like zero days being displayed as one day), take care of that in the application and just store the start date in the database.

pty 882 Posting Pro

If you really care about image quality (say if you're printing fine art photos), Inkjet is better. For almost all office environments where most printing is black text with the odd image that's not going to be hung on a gallery wall, Laser is more convenient and faster.

rproffitt commented: Fire lasers, spread ink. +15
pty 882 Posting Pro

I don't know much PHP, but if you simply want a list of function names with a count of how frequently they occur, you can do the heavy lifting in grep. Note, I used GNU Grep which I had to install on my mac with brew install grep. The one that comes bundled on the mac is BSD Grep which has fewer options and doesn't support Perl-style regular expressions.

Here it is displaying the top twenty function names in Laravel.

grep -hroP '(?<=function )(\w+)' | sort | uniq -c | sort -r | head -n20
 311  __construct
  93  handle
  49  get
  40  register
  39  __call
  35  getFacadeAccessor
  27  delete
  25  send
  25  getOptions
  25  flush
  24  make
  24  forget
  22  put
  22  getStub
  21  resolve
  20  create
  19  getDefaultNamespace
  18  increment
  18  has
  18  exists

Alternatively, using The Silver Searcher (aka ag) instead of grep.

ag --only-matching --no-heading --no-filename '(?<=function )(\w+)'| sed '/^$/d' | sort | uniq -c | sort --reverse | head -n20

Obviously, run this from the root of your project. Or, after the regex supply a list of filenames to whichever ag or grep and it'll just search them.

pty 882 Posting Pro

Also it's a ton of moderator work.

I know it's a lot of moderator work, but I don't think there's a way out that won't require it.

I wonder, over the last week, how many

  • threads with leigitimate questions asked by real people were created?
  • how many spam posts were there?

Once people have been deemed non-spammers, one would hope that as a cohort, their posts need less moderation in the future. So in theory, acting as a quality gatekeeper keeps the forums clean in the present (iffy posts will never be visible to normal punters) and in the future (the dross has been skimmed and what remains are, hopefully, non-spammers).

pty 882 Posting Pro

What's the advantage of this over drop schema myschema?

pty 882 Posting Pro

Perhaps there is another solution.

When new members make posts, hide them by default until admins have marked them as being a non-spammer. Once they've been greenlit, show them.

Pros:
  • Most spammers will fall into the trap and their spammers and their posts will vanish without the average user (me included!) being aware
  • The new user/spammer will think everything's normal
  • It's probably not hugely complicated to write and there are plenty of prior examples of this kind of functionality
  • If their post looks kind of ok but has some slightly-worrying signs, this would provide an opportunity for an admin to tidy the post/remove spammy links before it is made

    Cons:
  • New code would have to be written and tested
  • Another field (probably boolean) would be required on the user table
  • Extra work is required from admins in greenlighting new users
rproffitt commented: All good ideas. The ideas of gaining points to post is out there but pain point? Will this bring you back? Mods feel the spam pain for now. +0
ernie.cordell commented: I like the idea, but fear what I hope would be insignificant: Normal users falling into the trap somehow. Also it's a ton of moderator work. +0
pty 882 Posting Pro

There most definitely is a one-query solution. You'd effectively have to do both stages of the route I suggested in one go, using subqueries and a union.

Using views to simplify the process is not really a compromise, that's what they are there for. If you don't want them to be mixed in with your everyday database objects, use a separate schema (again, that's what they are there for!)

The good thing about doing it in stages is that it makes debugging much easier. If your results look a bit iffy or don't perform well and you need to start deconstructing a huge query with subqueries in order to begin working out what's wrong, the additional complexity becomes a burden. If your final query is simple and the views that it relies on are simple it's easier to find the problem. Better still, when you fix or optimise it, all the things that rely on it will automatically improve.

rproffitt commented: "I wrote in just one line, then I went mad." +15