Sunday, November 06, 2011

IRC - Get the user count of a channel in plain text with Denora/PHPDenora/

You need to have Denora and PHPDenora installed and running on your IRCd for this to work.

<?php
define("_VALID_PARENT", 1);
require ("libs/phpdenora/init.php");  //You have to provide the proper path to the file here
$link = sql_db_connect();
$channelcount = sql_fetch_array(sql_query("SELECT currentusers FROM ".$denora_chan_db." WHERE channel LIKE \"".mysql_real_escape_string(trim($_GET["channel"], '"'))."\";"));
if ($channelcount[0] == "") {
    $channelcount[0] = 0;
}
header("Content-type: text/plain");
echo $channelcount[0];
sql_db_close($link);
?>

It works like this : http://stats.yournetwork.net/usercount.php?channel=%23youchannel

In PHP, you will probably want to use something like this :
$usercount = file_get_contents("http://stats.yournetwork.net/usercount.php?channel=%23yourchannel");

The great thing with this is that you can now use some PHP to serve your users a user count badge for their channel.

See also : http://whatnwhat.blogspot.com/2011/11/irc-get-user-list-of-channel-in-json.html

IRC - Get the user list of a channel in JSON with Denora/PHPDenora

You need to have Denora and PHPDenora installed and running on your IRCd for this to work.

<?php
define("_VALID_PARENT", 1);
require ("libs/phpdenora/init.php");  //You have to provide the proper path to the file here
$link = sql_db_connect();
echo json_encode(denora_who_in_channel(mysql_real_escape_string(trim($_GET["channel"], '"'))));
sql_db_close($link);
?>

It works like this : http://stats.yournetwork.net/userlist.php?channel=%23yourchannel

In PHP, to get the file content and parse it into an array, you will need to do something like this :
$userlist = json_decode(file_get_contents("http://stats.yournetwork.net/userlist.php?channel=%23yourchannel"), true);

To loop through the array, you will need to follow this logic :
foreach ($userlist as $userinfo) {
       foreach ($userinfo as $infokey => $infovalue) {
                //echo $infokey . " : " . $infovalue . ", ";
       }
       //echo "\n";
}

If you want to access only a single attribute per user, like for example, if you only want to list the nicknames, you can access the attribute directly by its name by doing something like this :
foreach ($userlist as $userinfo) {
       echo $userinfo["nick"];
}


See also : http://whatnwhat.blogspot.com/2011/11/irc-get-user-count-of-channel-in-plain.html

Wednesday, October 26, 2011

How to copy the real URL of pages listed in google search results

Okay. Google's practice of using long ass unsharable redirect links instead of direct links to websites in their search results is a fucking pain in the ass. It's impossible to right click and copy a link to a page right from the google search result page, which makes it impossible to get an appropriate link to something that cannot be viewed in the browser and can only me downloaded, like a pdf, a word document, or something similar.

I have a solution.

Notice that on a fresh search, if you hover a link, what will first show in the status bar is the direct URL to the page it links to. However, as soon as you click or right click the link, the URL is replaced with that ugly google URL.

The solution is to use FireBug, right click and inspect the [pdf] or [doc] element that is just before the link. It's then easy to locate the actual link of search result and possible to get the direct URL. You have to do it on a fresh search and you must not click the link.

Friday, October 21, 2011

The good ones go first

You know how they say that the good ones go first and then people say "God needed them"... well maybe god is actually like "Fuck you, you're too happy, so I'm going to kill you and put you in a shittier life."

Wednesday, October 19, 2011

Quickly save and reinstall a list of packages on Ubuntu

Credit this guy : http://ubuntuforums.org/showthread.php?t=261366

I found out how to do this recently and thought it might be helpful to some people. To output this information to a file in your home directory you would use,
dpkg --get-selections > installed-software
And if you wanted to use the list to reinstall this software on a fresh ubuntu setup,

dpkg --set-selections < installed-software
followed by

dselect