Jump to content



Member Since 24 Mar 2010
Offline Last Active Feb 18 2017 04:32 AM

#146571 randomuser.me is taking off!

Posted by solewolf on 08 April 2016 - 04:16 PM

Why does the API sometimes return entirely arabic names when getting multiple results? I would have thought it would be be better to return some arabic names mixed with names from other places every single time instead of returning an array of 100 arabic names!


Good news everyone!


Randomuser.me is now version 1.0 running on Node.js!


You can view the full changelog and documentation if you'd like, but here are the main updates:

• Generate up to 5,000 users per request

• Users that are returned in a request for multiple users are now all randomized instead of 1 nat.

• Multiple nats can be requested in a comma delimited list

• Added inc and exc parameters for including and excluding fields

• Added pagination

• Added back CSV, YAML, and XML formats

• Added DK and TR nats

#146065 Code Wars!

Posted by solewolf on 27 May 2015 - 06:43 AM



It's a pretty fun website where you can practice your programming skills to come up with the most efficient solutions to problems.


Complete different challenges in the language of your choice to earn honor (points) and level up.



#145080 Just got card at Target! WTF???

Posted by solewolf on 12 February 2015 - 10:37 AM

Also if you turn the air duster upside down, it can be used to super cool locks and break into them.


Thank you Burn Notice.


#144888 Reading input without interruptions

Posted by solewolf on 04 January 2015 - 02:21 AM

Node has readline built in, does it not do what you want? http://nodejs.org/ap...xample_tiny_cli

That reads the input like I want, but it isn't able to handle console.log interrupting a command that is being typed.


I ended up using the keypress module and ANSI control sequences to do it all manually.


Basically I had this listen and store every key typed into a buffer:

var keypress = require("keypress");


// listen for the "keypress" event
process.stdin.on("keypress", function (ch, key) {
    // Add to buffer
    buffer += char;

    // Output character

And then if there was an attempt to console.log, this would run:

// Moves cursor to beginning of line
echo("\033[1G", true);
// Clear from cursor to end of line
echo("\033[0K", true);
// console.log data
// Put buffer back
echo(buffer, true);

#143883 DB Structure for collecting data on views, points, etc.

Posted by solewolf on 29 August 2014 - 09:27 PM

Wow, this sounds a lot like wdr Contribution (source) TheMaster and I worked on.


The way we set it up was a new record for each member for every day and then we run a cron job at midnight to update the totals.

#143765 view / edit data ...

Posted by solewolf on 21 August 2014 - 03:09 AM

Here is a pure PHP solution that is probably not as efficient as it could be.


I am not sure how you'd do it solely with SQL, but this gives you the output that I think you are looking for.

$db = new PDO("mysql:host=localhost;port=3306;dbname=", "", "");

$statement = $db->query("SELECT * FROM `btExtendedFormAnswers` GROUP BY `asID`");
while ($info = $statement->fetchObject()) {
    $asID = $info->asID;
    $data[$asID]["aID"]        = $info->aID;
    $data[$asID]["msqID"]      = $info->msqID;
    $data[$asID]["answer"]     = $info->answer;
    $data[$asID]["answerLong"] = $info->answerLong;

foreach ($data as $key => $row) {
    $statement = $db->prepare("SELECT * FROM `btExtendedFormAnswers` WHERE `asID` = ?");
    while ($info = $statement->fetchObject()) {
        $answer[$key][] = $info->answer;

echo "<pre>aID\tasID\tmsqlD\tanswer\tanswerLong\n";
foreach ($data as $key => $result) {
    echo $result["aID"] . "\t" . $key . "\t" . $result["msqID"] . "\t" . arrayToSTring($answer[$key]) . "\n";
echo "</pre>";

function arrayToString($array) {
    $return = "(";
    foreach ($array as $val) {
        if ($val == null) {
            $val = "''";
        $return .= $val . ", ";
    return substr($return, 0, -2) . ")";

And the output looks like this: http://keitharmstron...h/wdr/13631.php

#143568 var timer system (help please)

Posted by solewolf on 11 July 2014 - 11:12 PM

Next time, please use code tags when sharing your code.


PHP is a server side language. So each of those echos in that loop that counts down from 60 to 0 will result in a blank loading page for 60 seconds (while the script is running on your server) and then at 60 seconds, it'll spit out the numbers from the countdown all at once when the page loads.


I believe this actually would be impossible to do with PHP, you'd probably want to do something like this with Javascript which is client side.

#142920 How can I display tables on a webpage?

Posted by solewolf on 13 May 2014 - 11:44 PM

You don't necessarily have to use PHP; you just need to use a language that is capable of querying your database and displaying the data.


Anyways, here is the basic checklist that you'd have to go through to retrieve your table data.


  1. Connect to the database (I am assuming it is a MySQL database)
  2. Write up your query
  3. Process the results that are returned from your query and display them


To connect to your database, we are going to use PDO vs the deprecated mysql_query functions.


Remember to replace DBNAME, USERNAME, and PASSWORD with your actual connection values.

// Connect to MySQL database saving PDO object into $db.
$db = new PDO("mysql:host=localhost;port=3306;dbname=DBNAME, USERNAME, PASSWORD);

Next, we are going to write up the SQL query.

// Replace table with your table name
$sql = "SELECT * FROM `table`";

And now, we query the database and display the data.

foreach ($db->query($sql) as $row) {
    // To display the column value of a record, access it with $row['COLUMN']
    echo $row['id'] . "\n";
    echo $row['username'] . "\n";
    echo $row['email'] . "\n";

Hope that helps.

#142518 [C/C++] Use system() and return result over socket to another server

Posted by solewolf on 26 March 2014 - 07:07 PM

What I am trying to do is emulate an ssh connection basically.


So, let's say that there is a client computer that has a program that will attempt to create

a socket and connect to a server listening on a specific port.


Once the listening server receives a connection, it'll wait for a command from the user.

That command is then sent to the client and is executed via the system function.


How can I return the result (if any) of that command as if the input typed on the server

was via ssh and the result of the command immediately appears on the next line.


How could I get tricky things like top/htop to work where it repeatedly sends an update every 2 seconds or so?


The end result of this little project would be to have the client send it's hostname and the username of the user that ran the script

so that I can make a bash prompt looking thing as well.

And then it'll try to emulate an ssh connection as much as it possibly can.

#142364 I present myself

Posted by solewolf on 16 March 2014 - 08:15 PM

Welcome to wdR!

#142350 looking for advice :)

Posted by solewolf on 15 March 2014 - 06:50 PM

The problem with learning web design in school is that curriculums can't possibly keep up with the speed at which the web changes.

This is very true, especially when I took web tech in high school 2 years ago.


The images and resources that we were using for our labs had a last modified date of 2003!

#142347 looking for advice :)

Posted by solewolf on 15 March 2014 - 06:33 PM

When I first started with HTML, I found this book to be entertaining and helpful.




It was very easy to follow along and it was also entertaining (to my 6th grade self at least).

#142124 Programmer Jokes

Posted by solewolf on 06 March 2014 - 06:53 PM


A guy is standing on the corner of the street smoking one cigarette after another. A lady walking by notices him and says
"Hey, don't you know that those things can kill you? I mean, didn't you see the giant warning on the box?!"
"That's OK" says the guy, puffing casually "I'm a computer programmer"
"So? What's that got to do with anything?"
"We don't care about warnings. We only care about errors."

#142101 Github Atom Download

Posted by solewolf on 06 March 2014 - 01:34 AM

So apparently you can download atom without an invite by exploiting a flaw in the update check that it makes.


By faking your user agent as Atom itself, you can download the app pretty easily.

curl -L https://www.atom.io/api/updates/download -A "Atom/0.1 CFNetwork/1.5" > Atom.zip

Source: Reddit


EDIT: Here's a mirror since the exploit doesn't work anymore.

#141989 Programmer Jokes

Posted by solewolf on 28 February 2014 - 11:26 AM

In the 1960's the KGB was very interested in learning everything possible about the American space program, sending all sorts of spies to find every possible piece of information.


One afternoon, a breathless spy returned to headquarters with a page of paper in his hand, excitedly shouting to his superior, "Comrade! Comrade! The Americans are using Lisp to write their rocket launching software!"


The commander was skeptical. "How do you know?"


"I broke into their research lab and stole a page from the teletype machine! It's not the whole program, but it's the final page and contains the concluding logic of the program! See for yourself!!!!"


The commander looked at the page and smiled: