2010-02-27

Making Verizon's website go

You need the following in your /etc/sysctl.conf:

net.ipv4.tcp_wmem = 4096 16384 131072
net.ipv4.tcp_rmem = 4096 87380 174760
Disclaimer: I have no idea what this does, so use at your own risk... like I am.

ffmpeg on Ubuntu

For extra ffmpeg codecs:

sudo apt-get install sudo apt-get install libavcodec-extra-52
To convert from wav to mp3,
ffmpeg -i song.wav -acodec libmp3lame -ab 192k song.mp3

2010-02-10

Shell tidbits

Found reminders of a couple useful scripting tidbits today.

Check the number of commandline arguments in a bash script with $#. Check for a commandline argument containing only alphanumeric values with if test "`echo $1 | egrep -v '\W'`x" != "x".

This stuff is relevant for my edit-in-gui-editor script, which basically lets you edit the clipboard in a text editor like vim. I use it to write e-mails, blog posts, whatever. Here's the whole script.


#!/bin/bash
# open a temporary file in a gui editor with the contents of the clipboard
# you can set the editor to use by setting GUI_EDITOR in ~/.bashrc

# if you specify a commandline argument, it becomes the temp file's
# extension, e.g. 'edit-in-gui-editor html'
if test "$#" = "1"
then
 if test "`echo $1 | egrep -v '\W'`x" != "x"
 then
  EXTENSION=$1
 else
  EXTENSION=".txt"
 fi
else
 EXTENSION=".txt"
fi

# pick the editor to use.
DEFAULT_GUI_EDITOR="gvim -f"
if test "`which ${GUI_EDITOR%% *}`x" != "x"
then
 GUI_EDITOR="$GUI_EDITOR"
else
 GUI_EDITOR="$DEFAULT_GUI_EDITOR"
fi

# make the tempfile
TMPFILE_ORIGINAL=`mktemp`
TMPFILE="$TMPFILE_ORIGINAL.$EXTENSION"
mv $TMPFILE_ORIGINAL $TMPFILE

# do the editing
xclip -selection clipboard -o > $TMPFILE
$GUI_EDITOR $TMPFILE
xclip -selection clipboard -i $TMPFILE

# done!
exit 0

2010-02-02

First Post

Howdy. If you're reading this, then it means you've found my new blog. I guess I just want (need?) a place to post all the random little things I learn at times.

Today's find: in the sudoers file (edited with visudo), NOPASSWD entries must be last. The form of the entry I needed was:

%admin    ALL = (ALL) NOPASSWD: [commands]