Wednesday, June 11, 2008

Vim freezes with Ctrl+S

lol ... now this is a very strange and funny problem. Most of us are used to ctrl+s for saving files, but on vim it just freezes everything. Specially if you are on a ssh session, have just added 100 lines of code to your cool new application, ctrl+s can effectively ruin all the fun all of a sudden. Well the solution to this problem was not very complicated, try pressing ctrl+q ;)

Well, found the solution to this problem somewhere here :: http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#32.1. And this is what it says ::

Many terminal emulators and real terminal drivers use the CTRL-S key to
stop the data from arriving so that you can stop a fast scrolling display
to look at it (also allowed older terminals to slow down the computer so
that it did not get buffer overflows).  You can start the output again by
pressing the CTRL-Q key.

When you press the CTRL-S key, the terminal driver will stop sending the
output data. As a result of this, it will look like Vim is hung. If you
press the CTRL-Q key, then everything will be back to normal.

You can turn of the terminal driver flow control using the 'stty' command:

$ stty -ixon -xoff

or, you can change the keys used for the terminal flow control, using the
following commands:

$ stty stop 
$ stty start 

Saturday, May 31, 2008

AC3 demystified for AppleTV (Fsck You Apple !!)

Anywayz, it just didn't have to be this complicated. "Apple" could easily make this box do a lot more than what it does now without keeping this superb-lame intention of leaving this box half crippled and restricted.

Back to the point ...

[»] AC3 works only through optical output, should also work through hdmi, but I have not tested it myself since I have only 1 hdmi cable at home.

[»] change the following keys in apple.tv by logging in as frontrow :

(1) defaults write com.cod3r.a52codec attemptPassthrough 1

if you have ATV-files installed ::
(2) defaults write net.ericiii.ATVFiles EnableAC3Passthrough 1

if you have nitoTV installed ::
(3)
defaults write com.apple.frontrow.appliance.nitoTV passthru 1


[»] nitoTV automatically installs ffmpeg at this location :: /System/Library/CoreServices/Finder.app/Contents/PlugIns/nitoTV.frappliance/Contents/Resources/ffmpeg

[»] to check if a video has ac3 :: ffmpeg -i video.avi ... it will print the audio/video informations for the input video.

[»] after changing the keys, restart frontrow or reboot appleTV and play the video with AC3, it should give you 5.1 sound output now.

Fsck you Apple, for making it so complicated, if I knew it before, I would have just bought a cheap media-center pc and would happily run mythTV on it. FSCK you again ... Either make a proper iTunes for linux or leave the damn thing out of the way, so that I can store and play my files on the device without any intervention of the fscking itunes ...

[ sorry guys, just couldn't stop myself. I kind of spent the whole last night digging into this ac3 problem, went to bed at 7am in the morning. now you tell me, who would know those correct key names to change, if you dont digg this much ... sorry once again for not being able to control my rage on Apple for making so unnecessarily complicated ]

Fuzzy check if a bash input is string or a number

Couldn't think of anything better. Please leave comments if anything better exists.

#!/bin/bash
read -p "[*] input" in

if [ $((in+1)) -eq 1 ]
then
 echo "input is a STRING"
else
 echo "input is a number"
fi


Friday, May 30, 2008

send sms from shell !!! [pennytel]


source code for my "sms.sh" with some bells and whistles ... ;-)

#!/bin/bash

db='/home/babil/scripts/sms.db'

### input password
echo
read -s -p "[*] enter password: " pass 
echo
###


### input recipient
echo
recp_no=''

while [ -z "$recp_no" ]
do
 read -p "[*] enter recipient: " recp_in
 
 if [ $((recp_in+1)) -eq 1 ]
 then
  s=''
  s=`cat $db | grep -w $recp_in`

  if [ ! -z "$s" ]
  then
   recp_name=`cat $db | grep -w $recp_in | awk '{print $1}'`
   recp_no=`cat $db | grep -w $recp_in | awk '{print $2}'`
   echo "[*] recipient number found : $recp_no"
  else
   recp_no=''
  fi
 else
  
  recp_no=$recp_in

  s=''
  s=`cat $db | grep -w $recp_in`
  if [ -z "$s" ]
  then
   read -p "[*] give recipient a name : " recp_name
   echo "$recp_name $recp_no" >> $db
   
  else
   recp_no=`cat $db | grep -w $recp_in | awk '{print $2}'`
   recp_name=`cat $db | grep -w $recp_in | awk '{print $1}'`
  fi
 fi
done
###



### input sender
echo
sender_in=''
read -p "[*] enter sender: " sender_in

if [ $((sender_in+1)) -eq 1 ]
then
 s=''
 s=`cat $db | grep -w $sender_in 2>/dev/null`

 if [ ! -z "$s" ]
 then
  sender_no=`cat $db | grep -w $sender_in | awk '{print $2}'`
  sender_name=`cat $db | grep -w $sender_in | awk '{print $1}'`
  echo "[*] sender number found : $sender_no"
 else
  sender_no=''
 fi
fi

if [ -z "$sender_no" ]
then
 echo "[*] using default sender : 614XXXXXXXX"
 sender_name='default'
 sender_no='614XXXXXXXX'
fi
###


### input message
rem=0
while [ $rem -le 0 ]
do
 echo
 read -p "[*] enter message: " msg
 msg=`echo $msg | sed -e 's/ /\+/g'`

 len=${#msg}
 rem=$((157-len))
 if [ $len -ge 157 ]
 then
  echo -n "[$len/$rem]"
 fi
done
###



### print info
echo
echo "[>] recipient  : $recp_name $recp_no"
echo "[>] sender     : $sender_name $sender_no"
echo "[>] message    : $msg"
echo "[>] length     : $len / $rem"
echo
###


### confirm with user
read -n1 -p '[?] are you happy with the setting : [y/n]  ' yn
echo

if [ "$yn" != "y" ] || [ ! "$yn" != "Y" ]
then
 exit 1
fi
###


### send message
echo
echo '[*] Trying to send ...'
echo

curl -c cookie.txt -d "username=6128XXXXXXX&password=$pass" "https://www.pennytel.com/m/login.jsp" -L 2>&1 1> /dev/null 
 
m=`curl -b cookie.txt -d "trans=SendSMS&pagecaller=SMS&smstype=Premium&recipient=$recp_no&smscount=1&message=$msg&counter=$rem&mobilenumber=%2B$sender_no&credit=%24+4.31&freesms=0&walalang=FREE" "https://www.pennytel.com/sms_sent.jsp" -L -A='Mozilla/5.0' -e='http://www.pennytel.com/m/index.jsp?error=Invalid%20Entry' -# 2>/dev/null | grep "Please enter your username and password"`
 
echo
if [ -z $m ]
then
 echo '[*] SUCCESS.'
else
 echo '[*] FAILED.'
fi
 
rm cookie.txt 2>/dev/null
echo
###

Wednesday, May 14, 2008

DCCP-CCID4 bug+patch (p1)


if (hctx->p > 0)
// when loss
{
hctx->x = min(((u64)hctx->x_calc) << 6, min_rate);
low_thresh /= TFRC_T_MBI;
ccid4_hc_tx_x_header_penalty(hctx);
}

else if (ktime_us_delta(now, hctx->t_ld) - (s64)hctx->rtt >= 0)
// no-loss
{
hctx->x = min(2 * old_x, min_rate);
low_thresh = scaled_div(low_thresh, hctx->rtt);
hctx->t_ld = now;
/*ccid4_hc_tx_x_header_penalty(hctx);*/

// babil
// header penalty should not be applied if there's no loss yet
// it will effectively stop the X from growing higher in a small packet and
// low data-rate stream, while the available bandwidth is higher on the link.
}