Tuesday, December 14, 2010

How to convert an m2ts video to an avi

1. install missing libraries:
sudo apt-get install libavcodec-unstripped-51

2. convert:
ffmpeg -i vacation.m2ts -vcodec libxvid -b 11182k -acodec libmp3lame -ac 2 -ab 640k -deinterlace -s 1440x1080 vacation.avi

3. example:

$ nohup ffmpeg -i vacation.m2ts -vcodec libxvid -b 11182k -acodec libmp3lame -ac 2 -ab 640k -deinterlace -s 1440x1080 vacation.avi >> processing.txt &

$ tail -f processing.txt

Thursday, October 7, 2010

How to list all the jar contents in one line and redirect the output to a text file for easy searching

1. place all the jar files in a directory on a linux server

2.
$ cd jardirectory

3. list the files
$ for file in `ls | grep ".jar"`; do `unzip -l $file >> jarcontents.txt` ; done

4. use vi and search for entries
vi jarcontents.txt
In vi, type forward slash, and your search string.

Monday, October 4, 2010

On the Android phone: how to disable the annoying Verizon VCAST messages that autoplay when you plug your phone into the USB connector

dial ##7764726
Hit Call (you will not hear a ring tone)
Type Password 000000 (that's 6 zeros)
Hit Feature Settings
Choose CD ROM
Click Disable
Hit menu, commit modifications (it will say "No item changed")
Done.
----------------------------

Credits: http://community.vzw.com/t5/DROID-Incredible-by-HTC/Disable-V-CAST-Media-Manager-Web-Pop-Up/m-p/275464

Friday, October 1, 2010

How to delete a fail2ban IP from the iptables chain of rules

################################################
root@myserver:~# nano /usr/local/sbin/deleteipfromfail2ban.sh
#!/bin/bash

IP=$1

if [ "$IP" = "" ] ; then
echo "Syntax: deleteipfromfail2ban.sh "
RETURNSTATUS=1
exit $RETURNSTATUS
fi

iptables -D fail2ban-ssh -s $IP -j DROP

################################################

Example of usage:
deleteipfromfail2ban.sh 10.1.1.25

Thursday, September 30, 2010

How to change the Ubuntu message of the day (MOTD)

Source:
http://www.newbtopro.com/guide/change_message_day_ubuntudebian

Basically, you remove the symbolic link /etc/motd and re-link to a static file:

sudo touch /etc/motd.static
sudo cat /etc/motd.tail > /etc/motd.static
sudo rm /etc/motd
sudo ln -s /etc/motd.static /etc/motd
sudo vi /etc/motd.static
Edit the file to your liking! Done.

Wednesday, September 22, 2010

Nu ratati o vacanta de vis la:

Nu ratati o vacanta de vis la: ... :)

Getting banned from Facebook by Eric Hancock

Thank you, Facebook, for being unjust.

My "friend" Eric Hancock emailed Facebook and lied to them, saying that I'm abusive. Facebook simply closed my account and deleted everything I had, 4 years worth of pictures and contacts.

Thank you, Eric, thank you Facebook.

------------------


from The Facebook Team info+rxnvms@support.facebook.com
reply-to The Facebook Team info+rxnvms@support.facebook.com
to facebook@alanlupsha.com
date Wed, Sep 22, 2010 at 1:43 AM
subject Re: My Personal Profile was Disabled
mailed-by bounce.secureserver.net
signed-by support.facebook.com


Hi,

Your account was disabled because your behavior on the site was identified as harassing or threatening to other people on Facebook. Prohibited behavior includes, but is not limited to:

• Sending friend requests to people you don't know
• Regularly contacting strangers through unsolicited Inbox messages
• Soliciting others for dating or business purposes

After reviewing your situation, we have determined that your behavior violated Facebook's Statement of Rights and Responsibilities. You will no longer be able to use Facebook. This decision is final and cannot be appealed.

Please note that for technical and security reasons, we will not provide you with any further details about this decision.

Thanks,
The Facebook Team



---------------

Monday, August 23, 2010

TECHNOLOGY ENTREPRENEURSHIP AND COMMERCIALIZATION - FALL SEMESTER 2010

Grading:
• Final Commercialization Plan Report (Team): 35%
• Final Commercialization Plan Presentation (Indiv): 35%
• Class participation (Indiv): 10%
• Team evaluation of your contribution (Indiv): 20%


Final Report and Presentation: A Product Commercialization Plan
Assume you are making a pitch for a $150k state technology commercialization grant

Content Outline

1. What’s Your Idea & Technology Overview

2. What Problem is it Solving & How Big is the Problem?
3. What is the market for your idea? How would you categorize competing technologies in the market? And, where does your idea fit?
4. Who are your target customers? (i.e. target market) How will you get your product to them?

5. Who are your competitors in this category? What are their strengths & weaknesses?

6. What are your competitive advantages? Why should you be selected instead of the competition?

7. What is your product development plan? From concept, to prototype, to market? What are the steps & what is the time frame? How will you protect your invention & when will you initiate the protection in your product plan?

8. What are your commercialization alternatives? Licensing to a company in this category? Starting a company? Risks vs. Rewards.

9. Conclusion.

Thursday, July 29, 2010

Startup scripts

Sample startup file, place in /etc/init.d:

cat /etc/init.d/archiva
#! /bin/sh
# chkconfig: 345 90 10
# description: Archiva server

# uncoment to set JAVA_HOME as the value present when Continuum installed
export JAVA_HOME=/opt/SDK/jdk
export ARCHIVA=/opt/archiva/current/bin/archiva

case "$1" in

'start')
su - archiva -c "$ARCHIVA start"

;;

'stop')
su - archiva -c "$ARCHIVA stop"

;;

'restart')
su - archiva -c "$ARCHIVA stop"
sleep 20
su - archiva -c "$ARCHIVA start"

;;

*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac

exit 0


To add it to startup, execute as root:
chkconfig --add archiva


Done.




Another example, using Geronimo:

[geronimo@mypc bin]$ ./geronimo.sh --help
Using GERONIMO_HOME: /home/geronimo/geronimo-tomcat6-javaee5-2.1.6
Using GERONIMO_TMPDIR: var/temp
Using JRE_HOME: /opt/SDK/jdk/jre
Usage: geronimo.sh command [geronimo_args]
commands:
debug Debug Geronimo in jdb debugger
jpda run Start Geronimo in foreground under JPDA debugger
jpda start Start Geronimo in background under JPDA debugger
run Start Geronimo in the foreground
start Start Geronimo in the background
stop Stop Geronimo
stop --force Stop Geronimo (followed by kill -KILL)




Create /etc/init.d/geronimo as follows:

#! /bin/sh
# chkconfig: 345 90 10
# description: geronimo server

# uncoment to set JAVA_HOME as the value present when Continuum installed
export JAVA_HOME=/opt/SDK/jdk
export GERONIMO=/opt/geronimo/current/bin/geronimo.sh

case "$1" in

'start')
su - geronimo -c "$GERONIMO start"

;;

'stop')
su - geronimo -c "$GERONIMO stop"

;;

'restart')
su - geronimo -c "$GERONIMO stop"
sleep 20
su - geronimo -c "$GERONIMO start"

;;

'debug')
su - geronimo -c "$GERONIMO debug"

;;

'jpdarun')
su - geronimo -c "$GERONIMO jpda run"

;;

'jpdastart')
su - geronimo -c "$GERONIMO jpda start"

;;

'jpdastop')
su - geronimo -c "$GERONIMO stop"

;;



*)
echo "Usage: $0 { start | stop | restart | debug | jpdarun | jpdastart | jpdastop }"
exit 1
;;

esac

exit 0



Test each entry:

/etc/init.d/geronimo
Usage: /etc/init.d/geronimo { start | stop | restart | debug | jpdarun | jpdastart | jpdastop }

/etc/init.d/geronimo start

/etc/init.d/geronimo stop
(login/pass = system / manager)

/etc/init.d/geronimo debug


# add to startup
chkconfig --add geronimo

# check that the file exists in the startup location, ex:
ls -la /etc/rc.d/init.d/geronimo

Friday, July 16, 2010

How to load properties files in Oracle's Weblogic 11G

PropertiesLoader propertiesLoader = new PropertiesLoader(propertiesFileName);
if (propertiesLoader.thePropertiesFileExists()) {
System.out.println("Properties file exists: " + propertiesFileName);
} else { ... }


String serverName = propertiesLoader.getProperty("serverName");


...


And the properties loader class:




package alan.lupsha.properties;

import org.apache.log4j.Logger;
import java.util.Properties;
import java.io.InputStream;

public class PropertiesLoader {
    private static final Logger logger = Logger.getLogger(PropertiesLoader.class);

    private Properties props = null;
    private String propertiesFileName = null;
    private boolean propertiesFileExists = false;

    public PropertiesLoader(String propertiesFileName) {
        this.propertiesFileName = propertiesFileName;
        try {
            props = new Properties();
            ClassLoader cl = this.getClass().getClassLoader();
            // does not work in 11G: java.net.URL url = cl.getResource(propertiesFileName);

            InputStream in = cl.getResourceAsStream( propertiesFileName );
            if( in != null )
            {
                props.load(in);
                setPropertiesFileExists(true);
            }
            else
            {
                logger.warn("InputStream is null while trying to load properties file: " + propertiesFileName );
            }
        } catch (Exception e) {
            logger.error("Error while loading properties from file "
                    + propertiesFileName + ". Error is: " + e.toString());
            System.out.println("Error while loading properties from file "
                    + propertiesFileName + ". Error is: " + e.toString());
        }
    }

    public String getProperty(String propertyName) {
        String returnStr = "";
        if (props == null) {
            logger.error("Sorry, your props file couldn't be loaded: " + propertiesFileName);
        } else {
            returnStr = props.getProperty(propertyName);
            if (returnStr == null) {
                returnStr = "";
            }
        }
        return returnStr;
    }

    public void setPropertiesFileExists(boolean propertiesFileExists) {
        this.propertiesFileExists = propertiesFileExists;
    }

    public boolean thePropertiesFileExists() {
        return propertiesFileExists;
    }
}


Tuesday, May 4, 2010

How to set up ProxyPass and ProxyPassReverse in Apache

How to set up ProxyPass and ProxyPassReverse in Apache to allow access to Continuum (which runs on port 8080) and to Archiva (which runs on port 8082):

As root, edit: /etc/httpd/conf/httpd.conf

Enable:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so


At the bottom of the config file, add:

# ***********************************************************
ProxyRequests On
ProxyPreserveHost On
ProxyVia full


Order deny,allow
Allow from all


ProxyPass /archiva http://myserver.my.domain.com:8082/archiva
ProxyPassReverse /archiva http://myserver.my.domain.com:8082/archiva

ProxyPass /continuum http://myserver.my.domain.com:8080/continuum
ProxyPassReverse /continuum http://myserver.my.domain.com:8080/continuum
# ***********************************************************


Restart Apache: /etc/init.d/httpd restart

Friday, March 26, 2010

How to scan using the Epson Perfection 3490 Photo scanner

Source: https://bugs.launchpad.net/ubuntu/+source/sane-backends/+bug/311191

Binary package hint: libsane

Epson 3490 wont run without the following modification
The following steps did it for me (running 8.04 Hardy, 8.10, 9.04):-

1) sudo apt-get install sane-utils

2) Go to the Users and Groups screen and add yourself (and other
scanner users) to the "scanner" group.

3) Log off and on (or reboot) to make 2) effective.

4) sudo mkdir /usr/share/sane/snapscan

5) sudo cp Esfw52.bin /usr/share/sane/snapscan

6) sudo chmod 644 /usr/share/sane/snapscan/Esfw52.bin

7) sudo gedit /etc/sane.d/snapscan.conf

Change firmware entry to say:-
firmware /usr/share/sane/snapscan/Esfw52.bin

Please note point 6 as the file was initially created with insufficient access.

Firmware .bin is attacted

http://ubuntuforums.org/showthread.php?t=108256&page=6 - is the scanner being discussed

=================
# How to scan from the shell:

scanimage --device-name snapscan:libusb:002:006 --resolution 200 --high-quality=no --mode Color --format=pnm > lastscan.pnm

# Convert the file to jpg:
convert lastscan.pnm 01.jpg

# To convert all the pnm files to jpg files, type this command on one line:
for i in `ls *.pnm`; do convert $i $i.jpg; done

=================

Wednesday, March 3, 2010

Ubuntu - how to fix the annoying error "resolvconf: Error: /etc/resolv.conf must be a symlink"

How to fix the error: "resolvconf: Error: /etc/resolv.conf must be a symlink"

1. Kill the NetworkManager process:

sudo kill -9 `ps aux | grep sbin/NetworkManager | grep -v grep | awk '{print $2}'`

2. Run the resolvconf reconfiguration tool:

sudo dpkg-reconfigure resolvconf

(select YES, OK )

3. Verify that the resolv.conf file is ok:

ls -la /etc/resolv.conf

It should look very close to this:

lrwxrwxrwx 1 root root 31 2010-03-03 19:53 /etc/resolv.conf -> /etc/resolvconf/run/resolv.conf


4. Check the contents, it should have your name server(s) listed. The following shows an example using Comcast nameservers, and includes a router with address 192.168.0.1:

cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 68.87.74.162
nameserver 68.87.68.162
nameserver 192.168.0.1
search wp.comcast.net


5. Verify that it all works, try a restart of your system, and start with:
ping google.com
If you get a reply, your network works.


Share

Monday, February 8, 2010

How to install the command line transmissioncli bittorrent client in Ubuntu

mkdir ~/downloads
cd ~/downloads

# get the latest stable version from http://www.transmissionbt.com/download.php
wget http://mirrors.m0k.org/transmission/files/transmission-1.83.tar.bz2

bunzip2 transmission-1.83.tar.bz2
tar -xvf transmission-1.83.tar
cd transmission-1.83/
cat README | more

sudo apt-get install intltool
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install openssl

./configure
make
sudo make install

# verify that the install worked
ls -la /usr/local/bin/transmissioncli

------

Share

Saturday, February 6, 2010

How to set up Apache with groups of users and basic HTTP authentication

1. Do this as user root:

sudo su -

and find the path to the config files for Apache, ex: ls -la /etc/apache2/

2. create users, and use the htpasswd tool to encrypt their passwords
and store them in the password file:

htpasswd /etc/apache2/passwords john

and

htpasswd /etc/apache2/passwords mary


3. add your users to a groups file

nano /etc/apache2/groups

Create a group called "trusted" followed by ":" followed by
the user names who are in that group, space delimited:

trusted:john mary


and set permissions so that user apache (who is in group "www-data")
can actually see the "passwords" and "groups" files.

chown root:www-data /etc/apache2/groups
chown root:www-data /etc/apache2/passwords


4. edit the apache config file to set up the directory which you are serving

nano /etc/apache2/apache2.conf

At the end of the Apache config file, add the following alias,
assuming that you keep all your files in /home/john/coolfiles/


alias /john "/home/john/coolfiles"

Options Indexes +MultiViews
AllowOverride None
Order allow,deny
Allow from all

AuthType Basic
AuthName "Password Required"
AuthUserFile /etc/apache2/passwords
AuthGroupFile /etc/apache2/groups
Require Group trusted




5. restart apache, as user root

sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start



6. test with a browser

http://localhost/john/

or

http://yourdomain.com/john/



Share

How to use wget to download recursively, using HTTP basic authentication

wget --http-user=john --http-password=smith -e robots=off
--recursive --level=1 --no-directories --no-host-directories
http://myhost.mydomain.com/path/to/files/


Share

Friday, January 15, 2010

Chapter 1 summary

Life is getting better:
- life expectancy
- health
- income
- education
- entertainment

Economics: the study of how we make a CHOICE (selections amongst alternatives) under SCARCITY (concepts that there is less available form nature than one desires)

1. Scarcity does not equal poverty
2. Scarcity necessitates RATIONING (allocating scarce goods to those who want them)
3. Scarcity leads to competitive behavior

Resources: human, physical, natural

Capital: human made resources, used to produce other goods/services

Guideposts to economic thinking:
1. opportunity cost (highest valued alternative which you sacrifice when making your choice)
2. individuals are rational (try to get more value at less cost)
3. incentives matter (change incentives, change behavior)
4. individuals make decisions at the margin, using a cost-benefit analysis
5. information helps us make better choices
6. beware of secondary effects (intentions may not equal the result)
7. the value of goods/services is subjective
8. to test a theory = to be able to predict real world events

POSITIVE economics vs. NORMATIVE economics

Pitfalls to avoid economic thinking:
1. ceteris paribus (other things constant)
2. good intentions don't guarantee desirable outcomes
3. association is NOT causation
4. fallacy of composition (what is good for 1 may not be good for ALL)

Saturday, January 9, 2010

How to fix the error: "Linux: can't open /dev/dsp" while trying to use Festival

The error:

$ festival --tts read.txt
Linux: can't open /dev/dsp


The fix:
Create file .festivalrc in the home directory of the user and paste this in it:

(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)

Then, try the "festival --tts read.txt" command again, the error should be gone, and you should hear the synthesized text to speech stream.


Share

Monday, January 4, 2010

networktraffic script - shows uploads/downloads in the shell

I didn't write this script. Credits for script: whoever wrote it and posted it on some random web site.

---

cat /usr/bin/networktraffic


#!/bin/sh

usage(){
echo "Usage: $0 [-i INTERFACE] [-s INTERVAL] [-c COUNT]"
echo
echo "-i INTERFACE"
echo " The interface to monitor, default is eth0."
echo "-s INTERVAL"
echo " The time to wait in seconds between measurements, default is 3 seconds."
echo "-c COUNT"
echo " The number of times to measure, default is 10 times."
exit 3
}

readargs(){
while [ "$#" -gt 0 ] ; do
case "$1" in
-i)
if [ "$2" ] ; then
interface="$2"
shift ; shift
else
echo "Missing a value for $1."
echo
shift
usage
fi
;;
-s)
if [ "$2" ] ; then
sleep="$2"
shift ; shift
else
echo "Missing a value for $1."
echo
shift
usage
fi
;;
-c)
if [ "$2" ] ; then
counter="$2"
shift ; shift
else
echo "Missing a value for $1."
echo
shift
usage
fi
;;
*)
echo "Unknown option $1."
echo
shift
usage
;;
esac
done
}

checkargs(){
if [ ! "$interface" ] ; then
interface="eth0"
fi
if [ ! "$sleep" ] ; then
sleep="3"
fi
if [ ! "$counter" ] ; then
counter="10"
fi
}

printrxbytes(){
/sbin/ifconfig "$interface" | grep "RX bytes" | cut -d: -f2 | awk '{ print $1 }'
}

printtxbytes(){
/sbin/ifconfig "$interface" | grep "RX bytes" | cut -d: -f3 | awk '{ print $1 }'
}

bytestohumanreadable(){
multiplier="0"
number="$1"
while [ "$number" -ge 1024 ] ; do
multiplier=$(($multiplier+1))
number=$(($number/1024))
done
case "$multiplier" in
1)
echo "$number Kb"
;;
2)
echo "$number Mb"
;;
3)
echo "$number Gb"
;;
4)
echo "$number Tb"
;;
*)
echo "$1 b"
;;
esac
}

printresults(){
while [ "$counter" -ge 0 ] ; do
NOW=`/bin/date`
counter=$(($counter - 1))
if [ "$rxbytes" ] ; then
oldrxbytes="$rxbytes"
oldtxbytes="$txbytes"
fi
rxbytes=$(printrxbytes)
txbytes=$(printtxbytes)
if [ "$oldrxbytes" -a "$rxbytes" -a "$oldtxbytes" -a "$txbytes" ] ; then
echo "$NOW RXbytes = $(bytestohumanreadable $(($rxbytes - $oldrxbytes))) TXbytes = $(bytestohumanreadable $(($txbytes - $oldtxbytes)))"
else
echo "Monitoring $interface every $sleep seconds. (RXbyte total = $(bytestohumanreadable $rxbytes) TXbytes total = $(bytestohumanreadable $txbytes))"
fi
sleep "$sleep"
done
}

readargs "$@"
checkargs
printresults




Example usage:

To monitor eth0 every 10 seconds, a total of 999 times:
networktraffic -i eth0 -s 10 -c 999

To monitor eth3 every second
networktraffic -i eth3 -s 1 -c 99999


Share

Saturday, January 2, 2010

Ubuntu: Fixing error "Error: /etc/resolv.conf must be a symlink"

My error:

root@myserver:~# sudo /etc/init.d/networking start
* Configuring network interfaces...
resolvconf: Error: /etc/resolv.conf must be a symlink
run-parts: /etc/network/if-up.d/000resolvconf exited with return code 1


The fix:

root@myserver:~# cd /etc
root@myserver:/etc# sudo rm -rf /etc/resolv.conf
(if you can't remove the file, try: chattr -i /etc/resolv.conf )
root@myserver:/etc# sudo ln -s /etc/resolvconf/run/resolv.conf
root@myserver:/etc#


Test if the solution worked:

root@zeta:/etc# /etc/init.d/networking restart
* Reconfiguring network interfaces... [ OK ]
root@zeta:/etc#