Jump to content


Popular Content

Showing content with the highest reputation since 09/15/2018 in Posts

  1. 2 points
    class whatever { function func1 { do stuff } function func2 { do stuff } } object = new whatever(blah,blah2); object->funct1(); object->funct2();
  2. 2 points
    Gosh! you and rizwansyed must be working with identical school exercise book, both working with a circuit board, communicating with server and file on sd card, and now same identical form inputs requiring the SAME effect on selection, must be biggest coincidence in the whole milky way galaxy. hmmm Also you could use required attribute that will give a warning that selection is required if first option has empty value.
  3. 1 point
    All phones have a device-independent resolution smaller than 768 pixels, even if their physical resolution is much higher. You must use a meta viewport tag in order to get the phone to use its device-independent resolution.
  4. 1 point
    Well, what do you mean by "non-volatile." If that is data that will never ever change, even across servers, which is actually non-volatile, then you can just make it a property in the class. Otherwise, it's volatile, and the common way for reusability and extensibility is to pass it as parameters, awkward or not. If you want other methods, then you could hard-code calls to your config class inside the other classes, but now you've introduced a requirement that your new class relies on another class being defined and implemented. Maybe that's a fine tradeoff though. So, inside the constructor of one class, you could make calls to something like a static config class, e.g. config::get_value('smtp_host'). But, like I said, that's going to make things less reusable. The better way is to pass those values as parameters. There are other ways though... PHP is a single-inheritance language, but you can use something like a trait. http://php.net/manual/en/language.oop5.traits.php You could make a ConfigTrait trait, and your ConfigTrait would read your config values from wherever they're stored and set up a data structure. Then, you could make a config class which uses the config trait, and you can use that config class to access config settings in any arbitrary piece of code. Maybe your ConfigTrait has a method called getConfigValue, so when you make a config class that uses the ConfigTrait, the config class would also be able to use the same getConfigValue method. If you then make your mailer, or any other, class use the same ConfigTrait, then those classes will also have a getConfigValue method that you can use to get the config values inside your constructor or any other method. Traits are how PHP deals with being a single-inheritance language. A class can use multiple traits. In our application, for example, we have a userAwareTrait. For any class which needs to access the logged-in user, they just use the userAwareTrait and then they can use something like $this->getUser() to access the logged-in user. Those classes don't need any other code other than the line to use the userAwareTrait, and they have all of the properties and methods which that trait defines. Just be aware of naming conflicts. If you have a config trait, call your method getConfigValue, not just getValue.
  5. 1 point
    Its still part of the menu, its just all but itself, is hidden .topnav a:not(:first-child), .dropdown .dropbtn { display: none; } Home anchor is first child, and it instructs that it should NOT be included when applying display: none;
  6. 1 point
    Go to the first link code and just adjust y position value and add text-anchor="middle" <text x="50%" y="60%" fill="white" font-size="45" font-family="Verdana" text-anchor="middle">THE NY TRIBUNE</text>
  7. 1 point
    JSON is used to transfer data, so you are continuously requesting the data from Matomo every time it is required, even though it will be likely same each time you do so. instead you can use JSON just once within a time limit, to retrieve the data and store, you can then filter what is wanted, from unwanted. Database OR XML they are both forms of storage of data, depending on the data amount depends on which to use, large capacity data, use database, small capacity use XML. The database is much quicker, easier to read large amounts of stored data, but! You could split larger data into smaller XML files that relates to a specific type of data related to a specific page.
  8. 1 point
    The most information you'll be able to gather from my page, is that it updates every 5 minutes, is slow to load the first time, and works nearly instantly from thereafter until the next 5 minute rotation. Here's the link: https://www.championfreight.co.nz/currency (It has a note on when it was last updated) The slow loads are updating the Database with the API, then displaying the data. The fast page loads are loading from the Database without updating, as the Data hasn't aged enough for me to need to update from the API. A very high level overview: RAM vs Disk. Disk is slow, and updates the RAM. The RAM is fast, and can respond to multiple commands quickly, as it can access its own data very quickly, but would need to update from the Disk if it gets a request it isn't expecting, and lacks the data required. In this scenario: Your Matomo would be the Disk, with the absolute values required at any time. The RAM would be a database you create and host on your own server. Its super fast, due to it being hosted in the same place, but periodically needs to get the up to date values from Matomo. I store a timestamp with the values I retrieve, so I check the timestamp, and if its too old, I get new values. In your case: AJAX asks for Data from PHP PHP gets Data from Database and checks when it was received If its recent enough, PHP returns the data back to AJAX, If its not, PHP asks Matomo for the Data Matomo reports and returns the Data to PHP PHP updates Database with Data, and a timestamp for checking later PHP then returns the Data back to AJAX If you don't like the idea of a slow load, if your hosting provider allows scheduled tasks, just run the page on the scheduler. The page load from the Scheduler will pull all the Data required, and none of your users will experience any slowdown of experience.
  9. 1 point
    Unfortunately, after removing PDO and its prepared statements, and using addslashes of all things, you're back to code that is thirteen years out of date. I don't know what issues you were having with the other code, but I guarantee it wasn't PDO and using prepared statements to protect your database. It's difficult for me to continue trying to help you. It seems like things keep regressing, you run into a minor problem like a missing character and throw everything out and come back with something worse with an entirely new set of problems. The unfortunate thing is that I doubt that you understand this code any better than the code you threw out. Maybe I'm wrong, but when it's telling you which line the error is on and you can't spot things like a missing semicolon or hanging comma it seems like you're not understanding what you're doing. Tossing out newer code and trying to go back to something that people stopped using a decade ago isn't helping.
  10. 1 point
    A lot of these things that you've asked about will be unique to you unless you're working with enforced styling such a development team. Code wise, a lot of it looks good. Only things that I'll pick out it: Try throwing your CSS into a separate file. It will unclutter the main HTML code, and you'll be able to reuse it for other pages. In my opinion <br /> tags are kind of a crutch? They have their place but, most of the time, you'll be able to do better with CSS And on the note of the <br /> tags, one of them doesn't have an ending slash. This just looks like its been forgotten and it isn't make or break, however something that's really important is to be consistent across your tags. Your <a> tags inside the <footer> have spaces in between the href and = whereas the ones on your <aside> do not. Just the main thing is to be consistent. Have a look into the DRY principle. "Don't repeat yourself"
  11. 1 point
    Both of them are equally efficient, they reserve the same amount of memory and they take the same amount of processing time. The only difference between them is the context in which the memory is reserved. I would recommend with putting the entry variable inside the each() callback only because you don't need it anymore after the process has ended.
  12. 1 point
    The last example I wrote is a bit more complicated at the processor level, I was just showing an alternative way to do things. It is probably best to have the declaration inside the each() callback as I said initially. You're mostly correct, with a couple of differences due to the way scope and references work. 2) If the space does not have an object yet, it behaves as you said and puts the object in that space. If there was already an object in that space, the variable entry is changed to point to a new space in memory and the new object is placed there instead. The old object remains exactly where it was as long as there is a pointer to it from somewhere, like the entryArr array. 3) The value is not retrieved from the storage space, instead the array just contains a reference to that space in memory telling it that the object is there. This distinction is important, because the error you had initially occurs because all of the array elements had pointers to the same piece of memory meaning that changing one of them would change all of them. I've attached a short diagram explaining basically how the memory works in this situation. It's not 100% accurate, but it would take at least a semester course to teach the details.
  13. 1 point
    No, it is the same function. Every time the program enters a function, new memory is allocated for it. When the program leaves the function all of the memory used by the function is freed unless there are pointers to it from another part of the program, such as the array that was declared outside.
  14. 1 point
    The problem before is that you created only one object and on each iteration you changed the properties of that object and added a new pointer to it from the array. What you really need to do is to create a new object on each iteration. You can recreate the variable every time because it is inside its own function. Another option would be to declare the object outside and initialize it inside the loop: var entry; // Reserve memory for storing objects $.each(inputArr, function(key, object) { entry = {}; // Create a new instance of an object and place it in the reserved memory for(var property in propertyArr) { var prop = propertyArr[property]; entry[prop] = object.prop; // Set the properties of the object } entryArr.push(entry); // Add a pointer to the new object at the end of the array }); return entryArr; They both do the same thing but for different reasons.
  15. 1 point
  16. 1 point
    (1) As far as I can make out, that screenshot contradicts location path for image and html file, from one image to the next? Get the image to show using file:/// as you did in accessing html file in bowser address bar. Also with windows you can right click->open with-> then select browser, this will open the image in browser, not a a html web page, use the Linux alternative to get the same result. You can get the url required to use in image src attribute.
  17. 1 point
    I'm hoping this is a snippet, I couldn't get this to run originally, but you said you could so no matter. Try adding a value to the Select Option, and then check if that is the option currently selected. <select id='opt2' name='USUnits' onchange="showForm1()"> <option value="">Select Option</option> <option value="0">Lbs/Sec</option> <option value="1">Lbs/min</option> </select> Then it would be as simple as var v = document.forms["myForm"]["USUnits"].value; if (v == "") { alert("SMass flow unit selection must be selected"); return false; } I highly recommend you use more descriptive variable and field names. It was a little hard impossible to follow the jq, jjq, jqq, ojq, and what they meant without checking the definitions of them.
  18. 1 point
    The only way to show or remove using == or != is to place those values in an array ShowRemoveArray=[3,6,9,12] (use current for loop to push these values into this array), then use jQuerys, $.inArray() to identify if $(this).parent("td").attr("class") value that exists, is equal '==' array or not equal '!=' to -1 (not found returned value)
  19. 1 point
    I read what you posted, but I don't know which columns are in that screenshot, there are no headers. I don't know which tables they are either. I don't know what values are in items, transport, projects, and nerms. You're selecting data from multiple tables and using math operations on them, addition and multiplication. What I am saying if that if any of those values you use in addition or multiplication are null, the answer is null. This is what I mean: 1 + 2 + null + 5 + 9 = null 2 * 5 * null * 3 = null
  20. 1 point
    The client only runs on a event, with button it would be .onclick, a form .onsubmit, with none of these you are left with event .onload which it usually attached to window. that only runs when the document has fully rendered. https://www.w3schools.com/jsref/event_onload.asp
  21. 1 point
    Because whoever wrote the sequence solver didn't do a good job. You might also notice that exact sequence is listed on that solver as a divergent sequence. If you want to know what that means, look it up.
  22. 1 point
    Internet service. Network appliances like routers know how much traffic is being delivered to which IP address. "Internet" is not a thing that is sent. You have an account with an ISP. The ISP knows about your account. When your computer uses the USB device, or modem, or whatever, to contact the ISP to get an IP address, it tells the ISP which account you are (if you want to know how, look up MAC address - the ISP knows which device you have to connect). If you have a valid account, the ISP assigns an IP address to you and lets you on its network. If you want to know what happens after that, look up internet backbones and gateways.
  23. 1 point
    Again, npm is just a package manager, it is not a build tool. We use webpack, for example, to build the actual file we deploy. npm does not do that, it just gathers the required packages and handles dependencies. Actually building the project to deploy is another process. If you open your Chart.js file and look at it, what do you see? Does it define a Chart object? Yes, all of our servers use that environment. We have 7 servers online right now, as the CTO part of my job is running them. Our servers don't crash, but occasionally one fills up its hard drive or something else fun happens. Why not download and save a copy of the file that you then serve locally?
  24. 1 point
    Is it not possible to just include the Javascript file with a <script> tag?
  25. 0 points
    You won't be able to do that with just Javascript, you'll need a server-side language to read the directory contents and print the filenames into an array that you can use.