Davidt's Posts
Nairaland Forum › Davidt's Profile › Davidt's Posts
When do we get to the "To God Be the Glory" part ? |
Wande Coal is a really talented artist and the only real vocalist in the Mo Hits Crew. It would be really unfortunate if it is actually true that Don Jazzy refused to honour the terms of whatever contract Mo Hits and WC signed. It is a well known fact that record labels exploit their artistes. I just hope WC has a real good backup plan if he is forced to leave Mo Hits because this row would definitely affect his relationship with the record label. He should calm down for some time till he has a real good backup plan. |
@*dhtml A service that is set to automatic and runs under the Network Service or Local Service account should run even when no one is logged in. @candylips This whole thing is part of a product and is for the next version of the product in question. And of course, this application suite currently has customers. |
Nice ideas guys. This is the scenario. This task must be easy to carry out by an average (ordinary) computer user. @javabeasns In the process of trying to achieve this, I have created windows services in a couple of languages. But let's talk about the Windows Service I created in VS2005. Now, this was what I did. I created a windows service and of course, ran it under the NetworkService account, made it . When the service is starting, it launches the necessary batch file. The issue here is that in a Windows service, user interaction is not typical. Therefore, my desire to enable the user select the location of the batch file or executable to run at boot-up (independent of user log-in), is made far-fetched. I was even thinking of using an xml file to set these parameters and then read this file before starting the service, but this voids the ease of use (for the average user) goal I'm trying to achieve. Therefore, I've kinda put the VS2005 service application approach on hold since user interaction cannot be achieved. Thanks javabeasns @*dhtml I've been considering registry hacks too. That is, I've been thinking about automating some registry entries (programmatically) for ease of use (even creating a registry script thingy would violate my ease of use goals). A quick question (sir)? Does making these registry entries enable the batch file execute itself even when a user is not logged-in yet? @femu Thanks for taking the time to respond and thanks for your idea. You guys have always been helpful and that's just great. |
Hey programmers on nairaland! I developed a chat application with an attendant chat server. Everything is working fine. The issue now is the fact that whenever the chat server goes down (for instance, the server system shuts down as a result of power failure or some other problem), by the time the server system come back on, the chat server would have to be restarted manually. I believe (and I know) it is more appropriate for the chat server application to restart itself when the computer comes back on (and of course regardless of who is logged in and of course, even before anyone logs in). I have a batch file that executes the chat server. My attempt was to create a windows service that start automatically and runs this batch file using a Network Service account on the server system. Although, I'm having a hard time with this (temporarily), I would love to ask if there are any alternatives to using a windows service. Suggestions are highly appreciated. |
Thanks scartag. I have already checked it out. The fact that it requires the server to have Zend Optimizer is a phenomenal drawback in my case. Nevertheless, it's a really wonderful tool. Thanks a lot for your contribution, man! |
@Z1mbabwean Thanks for your suggestion. Getting the user's IP and/or MAC address and restricting the application to this info would do a good job of limiting the application to one computer. It's just that IP addresses and MAC ADDRESSES CAN BE CHANGED. The success of this endeavour would greatly depend on preventing the user from knowing that MAC addresses and/or IP addresses are the limiting factor. Thanks again, @lojik I like your idea and I'm impressed with your work, I visited your site and I like what you've done. Please keep it up. I like knowing hardworking people like you exist in this dreary country. I would like to stay in touch with you and probably share a few ideas. @wizziweb Thanks More suggestions are definitely welcome. Thanks everyone. |
I have been developing PHP applications for quite some time. I have always wondered if there was any easy way of hiding your PHP source code such that anyone who has access to the server on which the application is hosted on, would not be able to see the raw PHP code. Furthermore, I am looking for ideas on how to prevent a PHP application from being used on more than one host computer i.e. locking the PHP application to a specific computer. I came across someone who wants me to build a particular PHP application but wants to have access to the source code so that he would be able to edit the source code if he finds any problem, or so he claims. The issue here now is how to deploy the application is such a way that the server admin is able to edit the source code if he wants but is not able to 'steal' the application and use it on another computer, and this may mean obscuring the source code or some other form of security, does anyone have any ideas on how to do this, on how to allow a person edit source code if he wants but not 'steal' the application and use it on another computer. I am trying to do some research on this and would post any ideas I find here. I would appreciate all the help I can get from nairaland software developers. |
oludashmi: 2tait:@poster What oludashmi posits is actually a possibility. It happens a lot, you know. Is there actually a relationship here? This is someone you have never met (I'm probably saying this because I don't believe in such relationships). If the effects of sponsoring this lady are telling on you, you've got to cut it off and find a way to tell her without offending her. Personally, I do not think telling here that you can no longer afford it would offend here. Find a way to explain your situation to her in a way that makes sense. |
I do not see anything wrong with it. I'm curious though. Why do you want to build a house? If you are looking for things to spend money on, why don't you invest your money most likely in shares. |
I did some research and I found this on http://www.greggdev.com/web/articles.php?id=6 As of this writing, there is no automatic way for MySQL to select a random row from a database table. Extracting a random row from a table can be useful for many reasons. It can pull up random products, random advertisments, or any other random thing that you have stored in your database table. For most purposes on smaller database tables, the following will work fine: $random_row = mysql_fetch_row(mysql_query("select * from YOUR_TABLE order by rand() limit 1" );$random_row will be an array containing the data extracted from the random row. However, when the table is large (over about 10,000 rows) this method of selecting a random row becomes increasingly slow with the size of the table and can create a great load on the server. I tested this on a table I was working that contained 2,394,968 rows. It took 717 seconds (12 minutes!) to return a random row. I wrote the script below as a workaround for a random row with a large database table. This will return a random row in about 0.05 seconds, regardless of the size of the table. If the max_id of the table is not dynamically changing, the function can be rewritten to only execute one database query instead of two. I am using this script for a new search engine spidering project I am working on. With this, it is useful to have an tinyint(1) column in the table that is updated as the row is selected so that it will not be chosen again. Since the function uses greater than and less than, it would not return an empty result unless all rows had been updated at which point the script could be ended. For such a script this also allows many updaters to be running at once selecting random rows that will not be selected again because the tinyint will be changed upon selection. <?php //CODE FROM WWW.GREGGDEV.COM function random_row($table, $column) { $max_sql = "SELECT max(" . $column . " AS max_id FROM " . $table; $max_row = mysql_fetch_array(mysql_query($max_sql)); $random_number = mt_rand(1, $max_row['max_id']); $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " >= " . $random_number . " ORDER BY " . $column . " ASC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); if (!is_array($random_row)) { $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " < " . $random_number . " ORDER BY " . $column . " DESC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); } return $random_row; } //USAGE echo '<pre>'; print_r(random_row('YOUR_TABLE', 'YOUR_COLUMN')); echo '</pre>'; ?> ThAs of this writing, there is no automatic way for MySQL to select a random row from a database table. Extracting a random row from a table can be useful for many reasons. It can pull up random products, random advertisments, or any other random thing that you have stored in your database table. For most purposes on smaller database tables, the following will work fine: $random_row = mysql_fetch_row(mysql_query("select * from YOUR_TABLE order by rand() limit 1" );$random_row will be an array containing the data extracted from the random row. However, when the table is large (over about 10,000 rows) this method of selecting a random row becomes increasingly slow with the size of the table and can create a great load on the server. I tested this on a table I was working that contained 2,394,968 rows. It took 717 seconds (12 minutes!) to return a random row. I wrote the script below as a workaround for a random row with a large database table. This will return a random row in about 0.05 seconds, regardless of the size of the table. If the max_id of the table is not dynamically changing, the function can be rewritten to only execute one database query instead of two. I am using this script for a new search engine spidering project I am working on. With this, it is useful to have an tinyint(1) column in the table that is updated as the row is selected so that it will not be chosen again. Since the function uses greater than and less than, it would not return an empty result unless all rows had been updated at which point the script could be ended. For such a script this also allows many updaters to be running at once selecting random rows that will not be selected again because the tinyint will be changed upon selection. <?php //CODE FROM WWW.GREGGDEV.COM function random_row($table, $column) { $max_sql = "SELECT max(" . $column . " AS max_id FROM " . $table; $max_row = mysql_fetch_array(mysql_query($max_sql)); $random_number = mt_rand(1, $max_row['max_id']); $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " >= " . $random_number . " ORDER BY " . $column . " ASC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); if (!is_array($random_row)) { $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " < " . $random_number . " ORDER BY " . $column . " DESC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); } return $random_row; } //USAGE echo '<pre>'; print_r(random_row('YOUR_TABLE', 'YOUR_COLUMN')); echo '</pre>'; ?> As of this writing, there is no automatic way for MySQL to select a random row from a database table. Extracting a random row from a table can be useful for many reasons. It can pull up random products, random advertisments, or any other random thing that you have stored in your database table. For most purposes on smaller database tables, the following will work fine: $random_row = mysql_fetch_row(mysql_query("select * from YOUR_TABLE order by rand() limit 1" );$random_row will be an array containing the data extracted from the random row. However, when the table is large (over about 10,000 rows) this method of selecting a random row becomes increasingly slow with the size of the table and can create a great load on the server. I tested this on a table I was working that contained 2,394,968 rows. It took 717 seconds (12 minutes!) to return a random row. I wrote the script below as a workaround for a random row with a large database table. This will return a random row in about 0.05 seconds, regardless of the size of the table. If the max_id of the table is not dynamically changing, the function can be rewritten to only execute one database query instead of two. I am using this script for a new search engine spidering project I am working on. With this, it is useful to have an tinyint(1) column in the table that is updated as the row is selected so that it will not be chosen again. Since the function uses greater than and less than, it would not return an empty result unless all rows had been updated at which point the script could be ended. For such a script this also allows many updaters to be running at once selecting random rows that will not be selected again because the tinyint will be changed upon selection. <?php //CODE FROM WWW.GREGGDEV.COM function random_row($table, $column) { $max_sql = "SELECT max(" . $column . " AS max_id FROM " . $table; $max_row = mysql_fetch_array(mysql_query($max_sql)); $random_number = mt_rand(1, $max_row['max_id']); $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " >= " . $random_number . " ORDER BY " . $column . " ASC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); if (!is_array($random_row)) { $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " < " . $random_number . " ORDER BY " . $column . " DESC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); } return $random_row; } //USAGE echo '<pre>'; print_r(random_row('YOUR_TABLE', 'YOUR_COLUMN')); echo '</pre>'; ?> Thanks to everyone for responding. The article above gives a solution from a PHP viewpoint (which is perfect since I am working with PHP) though the script above may be complex. |
I was about to point out the same thing Godman_n pointed out. Finding out what happens when rand() generates a number greater than the number of fields would be interesting, I'm yet to try out this stuff but when I do, I'll keep everyone posted, |
Thanks y'all. You've helped a lot. |
I got some stuff online. This was gotten from http://www.petefreitag.com/item/466.cfm There are lots of ways to select a random record or row from a database table. Here are some example SQL statements that don't require additional application logic, but each database server requires different SQL syntax. Select a random row with MySQL: SELECT column FROM table ORDER BY RAND() LIMIT 1 Select a random row with PostgreSQL: SELECT column FROM table ORDER BY RANDOM() LIMIT 1 Select a random row with Microsoft SQL Server: SELECT TOP 1 column FROM table ORDER BY NEWID() Select a random row with IBM DB2 SELECT column, RAND() as IDX FROM table ORDER BY IDX FETCH FIRST 1 ROWS ONLY Select a random record with Oracle: SELECT column FROM ( SELECT column FROM table ORDER BY dbms_random.value ) WHERE rownum = 1 I am working with MySQL and the query for MySQL given at this site concurs with the ideas of kobojunkie and ade2kay. |
Hey Programmers on nairaland, I'm working on a particular project and there is an SQL query I have been trying to put together. This particular task involves a situation in which I have to randomly select, say 50 rows from a particular MySQL database table. The thing is that the 50 rows selected at any point must be random and no row must be selected twice. Therefore, each time the select query is executed, it always returns 50 different rows. (This is of course assuming that the database table has over 50 rows, maybe like 200). What kind of SQL query can I use to achieve this result? Is there some kind of SQL function I can use? I would really appreciate some help. |
And yeah, I'll consider using AJAX, although sometimes that gets a little bit complex. |
Hey guys, this has been some really interesting reading. @yawa-ti-de I appreciate the fact that you keep on reminding everyone to stick to the topic and avoid "chest-thumping". You guys have really helped a lot (I knew you would) and I understand everything you guys are trying to say. The original solution I came up with extensively used session variables and it is due to my doubts concerning performance I created the topic and it turns out I am not the only one concerned about performance problems. I am glad many people would inevitably learn a lot by reading the responses to my question. You guys have been great. |
How about dynamically populating select form elements with options based on the selection in a previous select element? Still curious about that. Have a funny solution to it, but I believe there is a better way to do it. |
@yawa-ti-de Nice one, thanx |
Yeah, that AJAX application was built by the poster. Soft and Smart Inc At least, it's an effort. |
Well, most big companies outsource their programming jobs to companies abroad for the same reasons we would rather buy a product manufactured abroad rather than buy a locally manufactured product. |
ok |
Good thinking, lordbenax. |
Hey Nairaland programmers, this is directed at PHP/MySQL programmers. I started out programming in PHP/MySQL some time ago and I need a little help on something. I have seen web sites that have forms in which for instance: A website for student registration in a school: In the student registration form, there is a select form element where the user is required to select his/her faculty. When the student selects the faculty, the page gets reloaded to indicate only departments within the selected faculty in the next select element which is for selecting department (and of course, after the page reloads, the data the user had already entered previously remains there). What is the typical way of implementing this sort of functionality? I have some ideas which may work but I'll like to know how the pros do it. Please can anyone explain how this is implemented. Actually, in my own case, what I wish to do is that: I have a form in which the user is required to select the number of text inputs he wishes to have and when the page gets reloaded, the user is presented with the number of text inputs he entered previously while the earlier information that the user entered in the form still remains there. I would appreciate some help. |
Basically, right now, Rap music is kind of messed up and has deviated from what it originally was. Originally, rap music was about lyrical versatility and skill but now that aspect has been lost. That's one of the reasons I listen to UK Grime. A good example is the UK Grime rapper 'Kano', also 'Dizee Rascal'. UK Grime music originally came from rap battles in which one person raps and the other replies and all that stuff. So UK Grime is not all about the beats but about the lyrical and vocal skill of the rapper and I really love that sort of music. But upon observation, one would notice that such artists are heavily underrated probably because they do not produce the so-called 'club bangers'. I think the whole rap business is messed up. But what can one do, nothing. |
I'm really impressed with Brandy's album. In fact, I love almost all the tracks on the album. Her voice is celestial. Long Distance Piano Man Human Shattered Heart etc. In fact, I might be in love with Brandy ![]() |
I was pretty disgusted the first time I heard some of the tracks on the album. I first heard Kanye West using autotune in Lil' Wayne's Lollipop Remix. Then I heard it in Young Jeezy's Put On. In both these tracks, it really sounded cool (he was rapping and not singing). The autotune also sounded nice in Go Hard with T-Pain. Then came 808's and Heartbreak. When I first heard Love Lockdown, I could not believe it was Kanye West. I showed the track to a couple of people and they could swear it was not Kanye. Nobody even paid attention to the track. After about 2 weeks, I started hearing Love Lockdown all over the place. As time passed by, I began to like some of the tracks especially Heartless and Welcome to Heartbreak. Most of the others are wack. I heard the album was as a result of his recent loss of his mother and his recent breakup with his fiance. The track Welcome to Heartbreak really has some touching lyrics (if you actually listen to it). I love the video of Heartless. Anywayz, I wish Kanye goes back to rapping and shelves singing although I respect his boldness to explore other forms of music. |
Just be yourself. |
Pretty gross |
I think it depends on the circumstances. |
Take him back! But make sure you buy a helmet and some body armour. And yes! take some self defense classes, probably Kung Fu, Tae Kwon Do and the like. |
Akon is still one of the da best in the business, |
?
);