Ive gotten mixed reports as to how to handle this question while reviewing the web so I thought I should ask you all. I am not sure if its possible to even do with JavaScript, PHP, and MySql, but here is what I wanna do.
Im a manager at a small retailer where I have to schedule 20 people each week. Each day we have different hours, some people are part time, others full time, etc.
Can I create a webpage that can handle this? I was thinking of making a employee database with their status as FT or PT etc but did not know what language would be best to use for a full out functioning scheduler. Also, Id like to eventually add the option to enter day off requests into the form so that the scheduler would not allow them to work on those requested days.
The scheduler would have to be automated and of course may require some user tweaking after it generates.
I AM NOT LOOKING for the code for this.... just suggestions and thoughts as to where you would start (what language, format, etc)
Like #gilly3 said, the language you use is really up to your personal preference and what knowledge you already have. Here are some overviews of the ones I think would be acceptable:
Python is probably one of the easier languages to learn, mostly because of the way it's so easy to read.
There are many great ways to learn it. I like this nettuts+ series. The series is about creating dynamic websites with Django, but before it gets to that, it goes through the python language quite thoroughly. There are also may other sites you can go to to learn about python, such as python.org and others.
Python works best with creating local applications, not online ones. However, there are ways to use python in web development.
You would most likely record peoples stats (part-time, full-time...etc.) in a file, either a python file or another file that could be parsed by python (eg. XML or JSON).
For the results, you could have it print something out to the command line/teminal or use the tkinter library. to open a window and display the schedule visually.
PHP would be your best choice if you plan to record peoples stats in a MySQL database, maybe with phpMyAdmin or something like it.
PHP would need to be hosted on a server (Apache, IIS...etc.), but that shouldn't be a problem.
That too is an extremely easy language to learn, due to the vast amount of resources available, php.net is one of the best places I think, but you may find another that you like better.
If you like HTML, CSS and JavaScript, then you could simply create a webpage and have the user open it in their browser.
If you used this option, you would write out the people's stats in a file (probably JSON if you're working with JavaScript or it could be just plain JavaScript), and simply reference it with a <script> tag or and Ajax call.
There are so may resources out there for learning these that I can't even remember my favorites.
JavaScript is probably the best if you want the user to be able to edit the schedule right in the program.
If you like HTML, CSS and JavaScript, but want a desktop application, check out TideSDK
Keep in mind that if you use PHP and MySQL, you will also have the full power of HTML, CSS and JavaScript in your hands. For that reason, I would recommend PHP. It's only drawback is needing a server, but there are many ways to get around that (XAMPP (windows/linux), WAMP (windows), MAMP (mac) and probably others, but those are the most famous.
Sorry if I've left anything out, feel free to edit.
Related
I need to create a webpage that will generate demo similar to https://django-cms.org/en/demo/.
To generate demo, just click Get your demo!
I dont mind about the language, PHP or anything, as long as free and open source.
When the button clicked, it will run /var/testing/makesite.sh
Inside makesite.sh, it has code urlnya="$thegeneratedurl".
If we run echo http://$urlnya/, it will show the full URL like http://site1045.demosite.com/.
After demo website has been generated, I need it display link
There are some PHP example to achieve this by shell_exec, but I scared if its not really safe, and I dont know how to show progress and return the demo URL just like in the Django CMS site.
Well in python you have subprocess and envoy to execute GNU/Linux commands. You can also use fabric to do this.
In order to acheive this you might need to learn how to use virtualenv and unique port no has to created for each application.
This deserves a separate wrong write up. I cannot write whole source code though it is interesting.
For url part, recommend you to use random subdomain or different idea. You might need to store list of all previously generated values in DB or check currently running demo sites to avoid clash.
References
http://docs.python.org/library/subprocess.html
https://github.com/kennethreitz/envoy
http://pypi.python.org/pypi/virtualenv
http://docs.fabfile.org/en/1.4.2/index.html
The possible issue with shell_exec() has nothing to do with just using it. The scary risky thing is letting your user specify the string that's input to it - the string could very occasionally include all manner of weird attempts to "fool" your system and hack into it. But you don't need to do that. So long as you construct the string that's input to it in your own code, there should be no issue.
The string should be exactly the same thing you'd type at a Linux shell prompt. Depending on the details of what the script wants, the string that starts the script might simply be something like "/usr/local/bin/makesite.sh". Or it might also contain some parameters, like "/usr/local/bin/makesite.sh --ownername clientsname". If there are parameters, substitute them in yourself in the code you write, rather than asking the user to substitute them in for you - that way the security risk is minimal.
The result of the "echo $urlnya" in makesite.sh {and all the other output of the shell_exec() command too} will be handed to you by shell_exec() as a chunk of text to do whatever you wish with. Your code can parse it, use bits of it in your own web page, track bits of it internally, extract some sort of unique ID, and so forth. You may for example wish to place a hyperlink to that URL on the web page you're producing behind a button labelled something like {See Created Web Page}.
For the progress bar, get a widget or library that provides the functionality (but see a couple paragraphs further on:-). The ways to do it are a little weird, and cross-browser issues can be substantial, so a progress bar is one of the things where making use of somebody else's encapsulation and testing of the functionality is a really good idea. I believe a library is available from Yahoo!, and I believe JQuery includes the functionality.
The local browser/client will over and over manipulate the progress bar however it chooses for a few seconds, then "re-sync" with the server so it's displaying accurate information. One sometimes sees for example moving stripes; that movement is probably purely local and purely a "guess". But since the page will "re-sync" with the server in a few seconds to readjust its length (or even stop the stripes altogether if something has gone wrong), that should be sufficient.
Displaying a progress bar is only part of the problem though. The bigger part of the problem is what to display. Something on the system needs to be able to say things like "I'm 55% done". But how (or even if) makesite.sh does that I don't know. I don't know of any capabilities built in to Linux to help produce such information. You may need to run the command several times yourself to see how long it takes and what the milestones are, then create some tracker program of your own that checks for those milestones yourself. It may be more trouble than it's worth. You may wish to instead create something much simpler, say for example just some nearly-brain-dead text like "roughly estimated time to setup completion 2 more minutes" or "setup failed, please try again".
I have a WordPress plugin, which checks for an updated version of itself every hour with my website. On my website, I have a script running which listens for such update requests and responds with data.
What I want to implement is some basic analytics for this script, which can give me information like no of requests per day, no of unique requests per day/week/month etc.
What is the best way to go about this?
Use some existing analytics script which can do the job for me
Log this information in a file on the server and process that file on my computer to get the information out
Log this information in a database on the server and use queries to fetch the information
Also there will be about 4000 to 5000 requests every hour, so whatever approach I take should not be too heavy on the server.
I know this is a very open ended question, but I couldn't find anything useful that can get me started in a particular direction.
Wow. I'm surprised this doesn't have any answers yet. Anyways, here goes:
1. Using an existing script / framework
Obviously, Google analytics won't work for you since it is javascript based. I'm sure there exists PHP analytical frameworks out there. Whether you use them or not is really a matter of your personal choice. Do these existing frameworks record everything you need? If not, do they lend themselves to be easily modified? You could use a good existing framework and choose not to reinvent the wheel. Personally, I would write my own just for the learning experience.
I don't know any such frameworks off the top of my head because I've never needed one. I could do a Google search and paste the first few results here, but then so could you.
2. Log in a file or MySQL
There is absolutely NO GOOD REASON to log to a file. You'd first log it to a file. Then write a script to parse this file.Tomorrow you decide you want to capture some additional information. You now need to modify your parsing script. This will get messy. What I'm getting at is - you do not need to use a file as an intermediate store before the database. 4-5k write requests an hour (I don't think there will be a lot of read requests apart from when you query the DB) is a breeze for MySQL. Furthermore, since this DB won't be used to serve up data to users, you don't care if it is slightly un-optimized. As I see it, you're the only one who'll be querying the database.
EDIT:
When you talked about using a file, I assumed you meant to use it as a temporary store only until you process the file and transfer the contents to a DB. If you did not mean that, and instead meant to store the information permanently in files - that would be a nightmare. Imagine trying to query for certain information that is scattered across files. Not only would you have to write a script that can parse the files, you'd have to right a non-trivial script that can query them without loading all the contents into memory. That would get nasty very, very fast and tremendously impair your abilities to spot trends in data etc.
Once again - 4-5K might seem like a lot of requests, but a well optimized DB can handle it. Querying a reasonably optimized DB will be magnitudes upon magnitudes of orders faster than parsing and querying numerous files.
I would recommend to use an existing script or framework. It is always a good idea to use a specialized tool in which people invested a lot of time and ideas. Since you are using a php Piwik seems to be one way to go. From the webpage:
Piwik is a downloadable, Free/Libre (GPLv3 licensed) real time web analytics software program. It provides you with detailed reports on your website visitors: the search engines and keywords they used, the language they speak, your popular pages…
Piwik provides a Tracking API and you can track custom Variables. The DB schema seems highly optimized, have a look on their testimonials page.
PHP - Apache with Codeigniter
JS - typical with jQuery and in house lib
The Problem: Determining (without forcing a download) a user's PC ability &/or virus issue
The Why: We put out a software that is mostly used in clinics, but can be used from home, however, we need to know, before they go to our mainsite, if their pc can handle the enormities of our web-based, browser-served software.
Progress: So far, we've come up with a decent way to test dl speed, but that's about it.
What we've done: In php we create about a 2.5Gb array of data to send to the user in a view, from there the view calculates the time it took to get the data and then subtracts the php benchmark from this time in order to get a point of reference of upload/download time. This is not enough.
Some of our (local) users have been found to have "crappy" pc's or are virus infected and this can lead to 2 problems. (1)They crash in the middle of preforming task in our program, or (2) their virus' could be trying to inject into our js thus creating a bad experience that may make us look bad to the average (uneducated on how this stuff works) user, thus hurting "our" integrity.
I've done some googling around, but most plug-ins or advice forums/blogs i've found simply give ways to benchmark the speed of your JS and that is simply not enough. I need a simple bit of code (no visual interface included, another problem i found with one nice piece of js lib that did this, but would take days to remove all of the authors personal visual code) that will allow me to test the following 3 things:
The user's data transfer rate (i think we have this covered, but if better method presented i won't rule it out)
The user's processing speed, how fast is the computer in general
possible test for infection via malware, adware, whatever maybe harmful to the user's experience
What we are not looking to do: repair their pc! We don't care if they have problems, we just don't want to lead them into our site if they have too many problems. If they can't do it from home, then they will be recommended to go to their nearest local office to use this software "in house" so to speak.
Further Explanation
We know your can't test the user-side stuff with PHP, we're not that stupid, PHP is mentioned because it can still be useful in either determining connection speed or in delivering a script that may do what we want. Also, this is not a software for just anyone on the net to go sign up and use, if you find it online, unless you are affiliated with a specific clinic and have a login name and what not, your not ment to use the sight, and if you get in otherwise, it's illegal. I can't really reveal a whole lot of information yet as the sight is not live yet. What I can say, is it mostly used by clinics/offices for customers to preform a certain task. If they don't have time/transport/or otherwise and need to do it from home, then the option is available. However, if their home PC is not "up to snuff" it will be nothing but a problem for them and make the 2 hours task they are meant to preform become a 4-6hour nightmare. Thus the reason, i'm at one of my fav quest sights asking if anyone may have had experience with this before and may know a good way to test the user's PC so they can have the best possible resolution, either do it from home (as their PC is suitable) or be told they need to go to their local office. Hopefully this clears things up enough we can refrain from the "sillier" answers. I need a REAL viable solution and/or suggestions, please.
PHP has (virtually) no access to information about the client's computer. Data transfer can just as easily be limited by network speed as computer speed. Though if you don't care which is the limiter, it might work.
JavaScript can reliably check how quickly a set of operations are run, and send them back to the server... but that's about it. It has no access to the file system, for security reasons.
EDIT: Okay, with that revision, I think I can offer a real suggestion - basically, compromise. You are not going to be able to gather enough information to absolutely guarantee one way or another that the user's computer and connection are adequate, but you can get a general idea.
As someone suggested, use a 10MB-20MB file and several smaller ones to test actual transfer rate; this will give you a reasonable estimate. Then, use JavaScript to test their system speed. But don't just stick with one test, because that can be heavily dependent on browser. Do the research on what tests will best give an accurate representation of capability across browsers; things like looping over arrays, manipulating (invisible) elements, and complex math. If there is a significant discrepancy between browsers, then use different thresholds; PHP does know what browser they're using, so you can give the system different "good enough" ratings depending on that. Limiting by version (like, completely rejecting IE6) may help in that.
Finally... inform the user. Gently. First let them know, "Hey, this is going to run a test to see if your network connection and computer are fast enough to use our system." And if it fails, tell them which part, and give them a warning. "Hey, this really isn't as fast as we recommend. You really ought to go down to the local clinic to perform this task; if you choose to proceed, it may take a lot longer than intended." Hopefully, at that point, the user will realize that any issues are on them, not on you.
What you've heard is correct, there's no way to effectively benchmark a machine based on Javascript - especially because the javascript engine mostly depends on the actual browser the user is using, amongst numerous other variables - no file system permissions etc. A computer is hardly going to let a browsers sub-process stress itself anyway, the browser would simply crash first. PHP is obviously out as it's server-side.
Sites like System Requirements Lab have the user download a java applet to run in it's own scope.
I want to develop an application that does a bunch of cool stuff. The first thing that I need in it is to get information about the page a person is browsing.
With that said, I need for example to know how long a user stayed in a page and where was the scrollbar. While getting that data, It's all saved to a database.
The thing is, I prefer doing that in Flash [although I have no experience in it] over Ajax since I want to hide the code - which as far as I know not possible in Javascript/Ajax.
So, can I do all that in Flash? - Read the content of the page, get the status of the scroll bar..
Plus, I then need to go threw the gathered information that is saved in the database. Since there could be many calculations i thought C++ .Net is better than PHP [which I know better].
Is that all possible or am I just crazy? :)
Thanks ahead.
Server side
I think it doesn't matter whether you'll use PHP/C++/Java/Ruby/Python/whatever... each of these is fast enough to do complex calculations, especially if we talk about pure math.
So if PHP is what you know the best, then it's obvious to use it.
Client side
Flash is pretty cool for animations and others visual effects, but for things like scroll position, time spend on website JavaScript is just better. It doesn't require third-parties plugins, it's integrated with DOM. Personally I just thing JavaScript is the most proper tool for this task.
I vote for JavaScript, you can do in JS all that you mention, using the DOM, and it has not a proprietary license.
Although you cannot compile JS code, obfuscation tools offers a decent level of protection. Closure is worth of mention too, YUY minifier etc.
Also check this ready made JS heatmap.
I advise against using C++ for server side programming. You'll be better off with Ruby/PHP etc.
This is a general programming question.
What is the best way to make a light blogging system that can handle images, bbcode-ish styling and text without a database back end? Light means not more than 50 to 100 posts in extreme cases.
What language(s) should be used? Is there any preferred data format for the information? How does security play out?
EDIT: Client has no database, is on a shared server. Can't change that. Therefore, no DB.
EDIT2:
Someone mentioned SQL Compact - does that require anything more than copying files to the server? The key here is again that things shouldn't require any more permissions than FTP Acess.
If you're looking to do it yourself; store each post as a file in a directory. Then to sort and limit the posts you rely partially on the file names to order and limit them, and potentially (in the case of a search) on reading every last file. Don't go letting users make 10,000 posts though. But yeah, the above is considered a flat file data format. You can get fancy by using a standard format like JSON, Yaml, or XML within each post file, and even fancier by requesting these with Ajax calls in mostly client side code.
Now if the reason you want to work with flat files is that you just don't want to install a database server, there's nothing stopping you from reading a local (to the server) file as a berkley DB, a Lucene Index, or an SQLite DB from within your webapp using the appropriate client library. You'll find any of these approaches a little more sane (a bit faster, a bit more readable in code) than the afore-mentioned with all the same requirements for installing on the server (read-write file permissions). Many web frameworks or languages (like php) come with the option of an API to these client libraries; SQLite, and Lucy (C Lucene) particularly.
If you're just looking for examples of it being done, I first (I think 1999 or 2000) came across blosxom which is a perl script that either runs as a cgi script per request or as a cron job. It builds a dated index of "posts" based on whatever you throw into the directory it's meant to scan. It also builds an RSS feed.
Jekyll or Blogofile are my favorite kind of solution for that, "compiling pages before upload".
I'm going to go out on a limb here and say that it's not always the destination, but the Journey.
If you're going to set out to do this, I recommend using a language you are comfortable. Personally, this would be C#/.net for me, but from your tagging, I'll assume PHP would be the Serverside scripting language you would choose.
I would layout how I wanted my application to behave. If there is going to be a lot of data, you should consider (as dlamblin mentioned) an DB of some sort for lookup and retrieval. (Light Blog, not so much data... 1000 users can edit? maybe you should consider a DB.) Once you've decided how to store the data, decide how to present it.
Write some proof of concept code for each of the features you want to implement (blog templating, bbcode, user authentication, text searching...) and start to work them all together.
search for flat-file cms-es on google, for example:
http://www.flatcms.org/
this has been already done, so there is no need to create such CMS again. there are plenty of them.
I concur with dusoft that this has already been done.
DotNetBlogEngine.net is an ASP.NET (C#) based blogging system that has a nice XML back-end as an option.
Doesn't answer your question directly but check Unify.
If you do not want to write a new one or want to get some inspiration:
Flatpress
Simple PHP Blog
Ninja Designs are working on a db-free wordpress clone
You could either use XML, or use SQL compact (which allows for handling things just like SQL Server, but instead of a database you utilize flat files).