Category: Computers

Simple PHP script to display user’s IP address

By , 2012-06-13 13:22
< ?php
// Stolen from: http://www.cyberciti.biz/faq/php-howto-read-ip-address-of-remote-computerbrowser/
// and http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html
// with CSS from http://www.w3schools.com/css/css_examples.asp
 
function getRealIpAddr()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}
 
$adresseip = getRealIpAddr();
?>
<html><head>
<title>Adresse IP: < ?php echo $adresseip; ?></title>
<style type="text/css">
div { font-family:"Segoe UI","Lucida Grande","Calibri","Tahoma","Sans"; }
div.ip { font-size:250%; }
div.desc { font-size:200%; }
</style>
</head>
<body>
<div><img src="csdccs-blanc.png" alt="logo CSDCCS" /></div>
<p><div>Votre adresse IP: </div>
<div>< ?php echo $adresseip;?></div>
</p>   
</body>
</html>

The secret nightlife of status LEDs

By , 2012-06-03 01:59

Pretty rad.

Canon Rebel XSi, Canon EF 24mm f2.8 prime.

1/15, f2.8, ISO 800

5" f3.2 ISO 200

30" f6.3 ISO 200

30" f2.8 ISO 400

30" f2.8 ISO 1600

 

 

Character encoding

By , 2012-03-29 11:41

ISO-8859-1

UTF-8

I run my site on Linux, using UTF-8 encoding soooo I can do this:

ééééààààççççëëëüôùòîîîïëë

without getting a bunch of this:

��������

Important note that nano on Linux always works in UTF-8 as far as I can tell, so to get a js file or what have you to display proper characters you’ll need to use iconv to convert the final file to ISO-8859-1/Latin-1 or whatever encoding you happen to be using.

iconv -c -f UTF-8 -t ISO-8859-1 someCamelCaseScriptFilename.js  -o someOtherCamelCaseScriptFilename.js

Web server fingerprints

By , 2012-03-23 23:34

Running Apache 2 (Debian) on Windows 2008, and Microsoft IIS on Linux. Like a boss.

via http://uptime.netcraft.com/up/graph?site=www.csdccs.edu.on.ca

Enabling “swap” in an OpenVZ container

By , 2012-03-23 19:28

Oracle client for Linux for some reason requires 1GB of swap space, and will refuse to install, even if you have 9999999999TB of RAM, but 0 swap. Go figure.

Anyway, an OpenVZ container created with Proxmox will by default have 0 swap allocated, despite the Web UI allowing you to specify swap space.

In order to add swap to the container, from a shell prompt, run

On a somewhat related note, here’s how to install oracle client on Debian:

http://randrianiriana.wordpress.com/2010/08/25/debian-php5-oracle-oci8/

vzctl set 213 –swappages 262144 –save

 

Where 213 is your CTID, and 262144 is the amount of swappages you want. 1 page=4096 bytes , so 262144 = rougly 1024MB.

Also, Oracle installer detects 262144 swappages as 1023MB and change, so you will have to put something like 262200 instead.

 

Windows XP driver to force CF as fixed disk (XPfildrvr1224.zip)

By , 2012-03-16 10:39

Some CF cards identify themselves as removable disks as opposed to fixed disks.

This poses a problem when using a CF card as the primary install drive for Windows, which will not enable DMA or pagefile on “removable” disks.

The solution is to force the driver for a Hitachi MicroDrive on the CF card. (Not the IDE controller)

xpfildrvr1224_320.zip

(File source: http://wayback.archive.org/web/*/http://home.graffiti.net/jaclaz:graffiti.net/Projects/USBXP/xpfildrvr1224_320.zip)
(Ref: http://www.thinkwiki.org/wiki/CompactFlash_boot_drive)

Farewell, Desktop Metaphor

By , 2012-03-04 16:20

We’re living the end of an era. I’m sad to say that as tech journalists have been proclaiming for a little while now, it seems “the desktop is dead” or at least on its last legs. (I would have liked to provide some data to support that but unfortunately big G has killed off their search timeline feature as of a few months ago.)

The original Macintosh Desktop

Now, when I say desktop, I don’t mean the desktop PC. I mean the traditional personal computer desktop metaphor introduced on the original Macintosh in 1984 (- yes, I know Xerox was first). Since then, most personal computers have used some variation of a desktop as their primary UI. Windows, icons, folders, documents, trash/recycle bins have become familiar and nearly universal. The desktop metaphor also includes some important elements that were not really part of a traditional physical desktop, such as menu, status and task bars.

Why do I concur that the desktop is dying? Well, there are a few reasons.

Mobile device sales

Smartphones and tablet sales surpassed PC sales this past year. In Q4 of 2011, vendors shipped just over 100 million smartphones, while PC sales were numbered at 92.1 million. It’s not a huge relative difference, but the trend shows no sign of stopping for now since many consumers are still using feature phones but already own a PC. Tablets are also poised to take a bite out of PC sales, especially with ever-faster processors and slimmer packages. New releases of tablet OS in 2011 should also contribute, with Apple iOS 5 no longer requiring activation using iTunes on a traditional PC and Android 4 (“Ice Cream Sandwich”) replacing the rather underwhelming Android 3 “Honeycomb”.

Web apps

Web Apps running in Firefox

There’s no denying that the Web has come a long way from its beginnings on Tim Berners-Lee‘s NeXT cube at CERN. Web sites have evolved from being essentially online news or encyclopedia articles to being hubs for dynamic multimedia content and information sharing. Take a look at your taskbar/dock/other app switcher (if you’re viewing this from a desktop!). There’s a very good chance a Web browser is running. Even if there isn’t one running, chances are you have already used the Web more than once today. More and more of our daily computing activities are performed using a Web-based tool. Sharing. Word processing. Blogging. Watching videos. Listening to music. Instant messaging. Photo editing. E-mail. CLI shell access. Hell, why not any GTK application. True, there are some things that can only be done using a desktop application. Like OS virtualization. Oh, wait – never mind.  There are probably quite a few computer users who never open a desktop app at all. Even as a network admin, most of my work is done using Web-based administration tools.

Single-purpose, full-screen apps

The new Metro UI in Windows 8

With the new breed of smartphones and tablets that started with the iPhone, single-purpose, full-screen apps have become mainstream. Game consoles and PCs had full-screen apps before, but now, more than ever, “there’s an app for that”. With limited screen real estate, these apps are supposed to be fast, intuitive and immersive. Desktop PCs have hopped on the bandwagon too. During the netbook era, “mainstream” Linux distro Ubuntu launchedUbuntu Netbook Remix“, a special version of their OS optimized for small (typically 1024×640) netbook screens featuring large buttons, automatically maximized apps and minimal user distractions. Ubuntu’s new interface, Unity, is based on UNR. Following the immense popularity of their iOS mobile devices, and the successful launch of the iPad, Apple released Mac OS X Lion with support for full-screen apps and many other features and UI elements pulled from iOS. Over in Redmond, Microsoft is bringing their “Metro” interface from Windows Phone 7 and XBOX 360 to the Windows desktop.

The future

It could be argued that some of these new interfaces are an evolution of the desktop metaphor. I would agree, however, the traditional desktop seems to have its days numbered. The future seems to be a future of full-screen apps, custom web/HTML-driven interfaces and maybe widgets. Windows 8 still has what they call a traditional desktop, however the Start button has been unceremoniously killed off. The next version of Apple’s OS is not Mac OS X Mountain Lion, but simply OS X Mountain Lion, a clear sign that the Macintosh and its once-revolutionary desktop is now a part of the past.

For my part, I feel saddened and almost homeless with the prospect that my beloved desktop belongs to the confines of history. True, I could just continue using Gnome 2, or Mac OS X 10.6, or Windows 7, but that means missing out on the latest and greatest. I don’t like where this is going. Change is not always good. I must be getting old.

On a more optimistic note, I know that there are teams of brilliant designers, engineers and programmers also living through this change. And I know I’m not the only person to feel less than satisfied with current desktop environments. Nothing to do but wait to see what the future brings! (Or become a programming pro and write a new Linux DE from scratch/help out with MATE or Cinnamon.)

ALSA: cannot find card ‘0’ when using USB sound card

By , 2012-02-24 10:16

I was trying to get my Alix board to properly output audio. It has no VGA and no onboard sound card, so I’m using a USB to audio adapater. The card was detected, all appropriate snd- modules loaded according to lsmod, and it showed up in /proc/asound/cards. Problem is it was card1, and alsamixer and most programs use card0 by default.

It seems that Debian configures snd-usb-audio in /etc/modprobe.d/alsa-base.conf with the index=2 option to prevent it from being the primary card. To disable this behaviour, simply comment out the line.

 

Original answer:

So are you using a USB sound card as your audio device?It looks like you might have removed some audio device from your computer, that is why card0 is missing, where as usb card is configured as card1.

Edit /etc/modprobe.d/alsa-base.conf, include/modify the line for snd-usb-audio

snd-usb-audio index=0

This would update snd-usb-audio to card0, in case you want that as the first card.

via Debian User Forums • View topic – ALSA: cannot find card ‘0’.

UxStyle – mirror

By , 2012-02-16 17:03

It seems like the ‘net is becoming less and less reliable for keeping old content online. With all the DMCA takedowns, geocities going offline the whole megaupload fiasco and even large companies like Intel taking down or hiding their own software (see previous post).

Anyway today I wanted to enable third-party theme support on a new Windows 7 install. Headed over to http://uxstyle.com to get the tool only to find a 404. Thanks to The Wayback Machine (web.archive.org) I was able to get a copy of uxstyle and hosting a copy here:

UxStyle_Core_jul13_bits.zip

Intel AHCI drivers for Windows

By , 2012-02-12 18:56

If you have a “legacy” Intel chipset (and apparently legacy means anything not from the Core i era), the new AHCI/ATA driver Intel lists on their site (“Intel Rapid Storage Technology” ) isn’t compatible with older chipsets.

I have a few ICH7, ICH8 (also used for VirtualBox’s AHCI controller), ICH9, ICH10 and ESB2 southbridge chipsets and have found that the Intel Matrix Storage Manager 8.9 works.

I’ve attached the Windows installer, as well as the 64 and 32-bit “F6” floppy driver packages, because it seems Intel can’t be trusted to keep old versions of their drivers easily available.

 

Custom theme by me. Based on Panorama by Themocracy