nedjelja, 10. srpnja 2011.

Intuitive way to insert data into mysql

So instead of standard:

INSERT INTO sometable
     ( field1, field2, field3 )
VALUES
     ( 'value1', 'value2', 'value3' )

you can do this:

INSERT INTO sometable
   SET field1 = 'value1',
       field2 = 'value2',
       field3 = 'value3'

Securing your mysql queries from $_POST or $_GET injections

Easiest way is to do this:


foreach ($_POST as $k=>$v) {
    $_POST[$k] = mysql_real_escape_string($v);
}

ponedjeljak, 4. srpnja 2011.

Best linux distribution for Asus EEE PC (900)

I had my Asus EEE pc 900 lying around and almost never used it, because it was slow while running Windows XP. So I decided to try some linux distribution. I found #! ( http://crunchbanglinux.org/ )and I was a bit sceptical at first. I installed it on my 4 GB SD card. I installed it from USB stick which I created with unetbootin ( http://unetbootin.sourceforge.net/ ).
Installation passed without a problem and all hardware was detected (Wow!!! :)
Because it is based on debian, apt-get work also.
I used liquorix kernel that setup offers to install.
My web n walk stick for broadband internet works out of the box :)
Wine works perfectly ( I needed for Mikrotik managing program winbox.exe , even mac detect devices (wow) )
Only little problem I found that default speaker volume was muted, so you have to bring up the volume in mixer.
CRUNCHBANG comes with Chromium browser, and flash player. Youtbe videos are working without a glitch on my 900 mhz Asus EEE 900.
All in all, if you need a distribution for your asus eee, go with CRUNCHBANG :)

Debian: How to send and read SMS with your web n walk stick

If you have T-mobile web n walk stick, witch is Qualcomm 3g CDMA model GIO255 and you want to send sms this is the way:

first check is the device detected:
:~$ dmesg
....
usb 3-1: new full speed USB device using uhci_hcd and address 6
usb 3-1: New USB device found, idVendor=0af0, idProduct=6971
usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-1: Product: Globetrotter HSDPA Modem
usb 3-1: Manufacturer: Option N.V.
usb 3-1: SerialNumber: Serial Number
usb-storage: probe of 3-1:1.0 failed with error -5
hso 3-1:1.0: Not our interface
usb 3-1: USB disconnect, address 6
usb 3-1: new full speed USB device using uhci_hcd and address 7
usb 3-1: New USB device found, idVendor=0af0, idProduct=6971
usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=4
usb 3-1: Product: Globetrotter HSDPA Modem
usb 3-1: Manufacturer: Option N.V.
usb 3-1: SerialNumber: Serial Number
hso0: Disabled Privacy Extensions



then you should look in /dev/ for device ttyHS*

:~$ ls /dev/ttyHS*
/dev/ttyHS0  /dev/ttyHS1  /dev/ttyHS2

For sending sms you will be using /dev/ttyHS0.
Now you can install and run gammu or wammu

apt-get install gammu

or

apt-get install wammu

You can reconfigure gammu with sudo gammu-config

So as port you should use /dev/ttyHS0 , then save and that is it.
You can test it with 

sudo gammu getallsms


petak, 29. travnja 2011.

Connecting to your virt-viewer from Windows

First, you have to install Xming, you can dowload it from here.
After install start it with:


>"C:\Program Files\Xming\Xming.exe" -ac -multiwindow -clipboard    or on a 64-bit system...
>"C:\Program Files (x86)\Xming\Xming.exe" -ac -multiwindow -clipboard
  Notes: using -ac is TOTALLY UNSAFE
now, connect to your linux(ubuntu, debian...) machine with ssh.
After that in shell enter:

DISPLAY=your.windows.ip.address:0.0

export DISPLAY

Dont forget to change your.windows.ip.address to your your windows ip address :)


after that you can start any Xwindow application, and for your virtual viewer you can write:


virt-viewer -c qemu:///system your_virtual_machine &

Linux software raid and S.M.A.R.T monitoring

If you want to monitor SMART settings on your debian/ubuntu system you will have to install

apt-get install smartmontools

If your SMART is disabled, use this command to test them

smartctl -s on -t short -d ata /dev/sda
after that you can check status with

smartctl --all /dev/sdb


To check status of your raid you can do

mdadm --detail /dev/md0