Windows 7 connect to WEP encrypted wireless network








WEP is insecure and you should try not to use it. However, in some cases you have to use WEP. (e.g. Mac OS X Lion Internet sharing supports only WEP).

I have a Windows 7 netbook, I want to connect it to the WEP encrypted wireless network created by my Mac book pro (OS X Lion). However, it just failed to connect.
Searched and found the following solution:
  1. Open "Network and Sharing Center".
  2. Select "Set up a new connection or network".
  3. Select "Manually connect to a wireless network".
  4. Enter the network name(ESSID): e.g. WILSON_MBP, and Save
  5. Try connect to the network and enter the WEP key, if it keeps failing to connect, do the following steps:
  6. "Manage Wireless Networks" and Select the network that you just created, open it
  7. Activate "Security" tab, if the Security Type is "No authentication (Open)", change it to "Shared"; if the Security Type is "Shared", change it to "No authentication (Open)".
  8. Now you can connect to the network and re-enter the WEP key.

See Also




Install DevStack on Ubuntu 12.04 LTS Precise: hangs when running stack.sh script








The script hangs on the following line:
instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`

Solution

  • Open a new terminal window, run the following command:
    sudo killall -9 dmidecode



Mac OS X: create a bootable Mountain Lion USB disk








Prerequisites

  1. A USB flash drive with as least 8GB capacity.
  2. Install OS X Mountain Lion.app downloaded from Apple AppStore.(Or the InstallESD.dmg inside the app directory.)

Procedures

  • Method 1: Use Disk Utility
    1. Right click the Install OS X Mountain Lion.app, in the context menu, select "Show Package Contents". In Contents/SharedSupport directory, you can find InstallESD.dmg
    2. Plug in the USB drive an launch Disk Utility, which is in /Applications/Utilities
    3. Select the USB drive in Disk Utility, activate the "Partition" tab,
      1. Partition Layout:1 Partition
      2. Format:Mac OS Extented(Journaled)
      3. Click Options... button, and set partition type to GUID Partition Table
      4. click Apply button to format the USB drive.
    4. Drag InstallESD.dmg into Disk Utitlity and select it.
    5. Activate Restore tab, drag the newly formatted USB drive into Destination field
    6. Click Restore button, it will start restore the image into the USB drive.
    7. NOTE: The whole process will take about half an hour. Right at the end, you might get an error message: "Could Not Restore - Invalid Argument". You can simply ignore it. The image should be restored to the USB drive successfully.
  • Method 2: Use Lion Diskmaker
    1. Make sure your USB disk's partition type is GUID Partition Table, if not, re-partition your USB as described in Method 1 using Disk Utitlity. Otherwise, the disk made by Lion Diskmaker may not be able to boot.
    2. Download and run Lion Diskmaker
    3. Select Install OS X Mountain Lion.app then start making the disk.



Mac OS: Backup Keychain files








cp -r ~/Library/Keychains /path/to/backup-dir



Firefox: backup saved passwords








  • Method 1:
    1. Go to your Firefox profile directory.
    2. Copy the following 2 files: key3.db and signons.sqlite to the backup destination.
      cp signons.sqlite key3.db /path/to/backup-dir
  • Method 2:
    1. Install Firefox Addon: Password Exporter
    2. Mac: Firefox -> Preferences -> Security -> Import/Export Passwords
      Windows: Tools -> Options -> Security -> Import/Export Passwords



lsof: list open files








  • List files opened by the user:
    lsof
  • List files opened by the user:
    sudo lsof
  • List all open sockets:
    sudo lsof -i

See also




Mac OS X: disable spotlight on external USB drive








When a USB drive connects to the Mac, the spotlight will try to indexing the files on the drive. To check the activities of the spotlight, run
lsof | grep spotlight
. It might not be the behavior we want. To disable spotlight on the external drive, try the following: The mdutil command can be used to manage spotlight. Run the following command in Terminal:
sudo mdutil -i off /Volumes/USBHD
will turn off spotlight indexing on external drive /Volumes/USBHD.

See also




Office 2011 for Mac: Reset registration key








  1. Remove the following two files:
    rm ~/Library/Preferences/com.microsoft.office.plist
    rm ~/Library/Preferences/Microsoft/Office\ 2011/OLE\ Registration\ Database
    
  2. Restart your Mac
  3. Open any Office application, it will ask for the registration key.

See also




Mac OS: backup and restore Microsoft Office 2011








I. A script to back up Microsoft Office 2011 into a zip file

#!/bin/bash

#
# File name: backup-office2011.sh
#

usage() {
    echo "Usage: $(basename $0) <dest-dir>"
}

if [[ -z $1 || ! -d $1 ]]; then
    echo "Destinated directory is not valid: $1" 1>&2
    usage
    exit
fi

DST=$1

zip -r $DST/MS_OFFICE2011_BACKUP.zip \
       /Applications/Microsoft* \
       /Applications/Remote\ Desktop\ Connection.app \
       /Library/Application\ Support\Microsoft \
       /Library/Automator \
       /Library/Fonts/Microsoft \
       /Library/Fonts\ Disabled \
       /Library/Internet\ Plug-Ins\SharePoint* \
       /Library/LaunchDaemons/com.microsoft.* \
       /Library/Preferences/com.microsoft.* \
       /Library/PrivilegedHelperTools/com.microsoft.* \
       /Library/Receipts/Office2011* \
       $HOME/Library/Application\ Support\Microsoft \
       $HOME/Library/Preferences/com.microsoft* \
       $HOME/Library/Preferences/Microsoft \
       $HOME/Documents/Microsoft\ User\ Data

II. Usage

  • Backup Microsoft Office 2011:
    ./backup-office2011.sh /Volumes/USBDISK/backups/
  • Restore Microsoft Office 2011 from the backup zip:
    cd /; sudo unzip /Volumes/USBDISK/backups/MS_OFFICE2011_BACKUP.zip

See Also




Java: File separator and path separator








File.separatorFile.pathSeparator
Window\;
Unix(Mac, Linux)/:
import java.io.File

public class Test {
    public static void main(String[] args){
         System.out.println(File.separator);
         System.out.println(File.pathSeparator);
    }
}



VLC player: How to enable Broadcom Crystal HD decoder








Broadcom Crystal HD Decoder is an hardware decoder for playing HD videos. It is normally installed on some netbooks to enhance the performance of HD video play.
  1. To utilize the HD decoder, first you need to install its driver.
  2. To enable Broadcom Crystal HD Decoder, you need to download and install the following version of VLC player: http://nightlies.videolan.org/build/win32/backup/branch-20111219-0202/. And you need to add "--codec crystalhd" argument to the VLC Player command(shortcut).
  3. After installed the above, you can run C:\Program Files\Broadcom\Broadcom CrystalHD Decoder/DTS_Info.exe, it will show an icon in system tray. When a HD video is be played and the Crystal HD decoder is being utilized, the icon will be changed/flashing.

See also




Samsung n220 netbook: How to enable Broadcom BCM70015 crystal HD decoder








  1. Install Broadcom Crystal HD Decoder drivers
  2. Install K-lite Codec Pack Standard (with Media Player Classic Home Cinema). During the installation select System default for the H.264 decoder
  3. To check if the HD decoder is used:
    • run "C:/Program Files/Broadcom/Broadcom CrystalHD Decoder/DTS_Info.exe", it will start as an icon in system tray.
    • Open and play a HD video using Media Player classic, you should be able to see the DTS_info icon is flashing if the crystal HD decoder is being used by the player.



Install TWiki on Ubuntu 12.04 Precise LTS








  1. Install Apache 2 and other required packages:
    sudo apt-get install apache2 libgdal-perl libcgi-session-perl libhtml-tree-perl liberror-perl libfreezethaw-perl libgd2-xpm rcs
  2. Download TWiki-5.1.2.tgz from http://twiki.org/cgi-bin/view/Codev/DownloadTWiki
  3. Install TWiki-5.1.2:
     
        cd /var/www
        tar -zxvf /path/to/TWiki-5.1.2.tgz
        chown -R www-data:www-data /var/www/twiki
        cp /var/www/twiki/bin/LocalLib.cfg.txt /var/www/twiki/bin/LocalLib.cfg
      
  4. Configure TWiki in Apache 2:
    • Go to http://twiki.org/cgi-bin/view/TWiki/ApacheConfigGenerator to generate your twiki configuration file online
    • save the generated configuration to /etc/apache2/conf.d/twiki.conf
    • Here is my twiki.conf:
      # Autogenerated httpd.conf file for TWiki.
      # Generated at http://twiki.org/cgi-bin/view/TWiki/ApacheConfigGenerator
      
      # We set an environment variable called blockAccess.
      #
      # Setting a BrowserMatchNoCase to ^$ is important. It prevents TWiki from
      # including its own topics as URLs and also prevents other TWikis from
      # doing the same. This is important to prevent the most obvious
      # Denial of Service attacks.
      #
      # You can expand this by adding more BrowserMatchNoCase statements to
      # block evil browser agents trying the impossible task of mirroring a twiki
      #
      # Example:
      # BrowserMatchNoCase ^SiteSucker blockAccess
      # BrowserMatchNoCase ^$ blockAccess
      
      BrowserMatchNoCase ^Accoona blockAccess
      BrowserMatchNoCase ^ActiveAgent blockAccess
      BrowserMatchNoCase ^Attache blockAccess
      BrowserMatchNoCase BecomeBot blockAccess
      BrowserMatchNoCase ^bot blockAccess
      BrowserMatchNoCase Charlotte/ blockAccess
      BrowserMatchNoCase ^ConveraCrawler blockAccess
      BrowserMatchNoCase ^CrownPeak-HttpAgent blockAccess
      BrowserMatchNoCase ^EmailCollector blockAccess
      BrowserMatchNoCase ^EmailSiphon blockAccess
      BrowserMatchNoCase ^e-SocietyRobot blockAccess
      BrowserMatchNoCase ^Exabot blockAccess
      BrowserMatchNoCase ^FAST blockAccess
      BrowserMatchNoCase ^FDM blockAccess
      BrowserMatchNoCase ^GetRight/6.0a blockAccess
      BrowserMatchNoCase ^GetWebPics blockAccess
      BrowserMatchNoCase ^Gigabot blockAccess
      BrowserMatchNoCase ^gonzo1 blockAccess
      BrowserMatchNoCase ^Google\sSpider blockAccess
      BrowserMatchNoCase ^ichiro blockAccess
      BrowserMatchNoCase ^ie_crawler blockAccess
      BrowserMatchNoCase ^iGetter blockAccess
      BrowserMatchNoCase ^IRLbot blockAccess
      BrowserMatchNoCase Jakarta blockAccess
      BrowserMatchNoCase ^Java blockAccess
      BrowserMatchNoCase ^KrakSpider blockAccess
      BrowserMatchNoCase ^larbin blockAccess
      BrowserMatchNoCase ^LeechGet blockAccess
      BrowserMatchNoCase ^LinkWalker blockAccess
      BrowserMatchNoCase ^Lsearch blockAccess
      BrowserMatchNoCase ^Microsoft blockAccess
      BrowserMatchNoCase ^MJ12bot blockAccess
      BrowserMatchNoCase MSIECrawler blockAccess
      BrowserMatchNoCase ^MSRBOT blockAccess
      BrowserMatchNoCase ^noxtrumbot blockAccess
      BrowserMatchNoCase ^NutchCVS blockAccess
      BrowserMatchNoCase ^RealDownload blockAccess
      BrowserMatchNoCase ^Rome blockAccess
      BrowserMatchNoCase ^Roverbot blockAccess
      BrowserMatchNoCase ^schibstedsokbot blockAccess
      BrowserMatchNoCase ^Seekbot blockAccess
      BrowserMatchNoCase ^SiteSnagger blockAccess
      BrowserMatchNoCase ^SiteSucker blockAccess
      BrowserMatchNoCase ^Snapbot blockAccess
      BrowserMatchNoCase ^sogou blockAccess
      BrowserMatchNoCase ^SpiderKU blockAccess
      BrowserMatchNoCase ^SpiderMan blockAccess
      BrowserMatchNoCase ^Squid blockAccess
      BrowserMatchNoCase ^Teleport blockAccess
      BrowserMatchNoCase ^User-Agent\: blockAccess
      BrowserMatchNoCase VoilaBot blockAccess
      BrowserMatchNoCase ^voyager blockAccess
      BrowserMatchNoCase ^W3C blockAccess
      BrowserMatchNoCase ^w3search blockAccess
      BrowserMatchNoCase ^Web\sDownloader blockAccess
      BrowserMatchNoCase ^WebCopier blockAccess
      BrowserMatchNoCase ^WebDevil blockAccess
      BrowserMatchNoCase ^WebSec blockAccess
      BrowserMatchNoCase ^WebVac blockAccess
      BrowserMatchNoCase ^Webwhacker blockAccess
      BrowserMatchNoCase ^Webzip blockAccess
      BrowserMatchNoCase ^Wells blockAccess
      BrowserMatchNoCase ^WhoWhere blockAccess
      BrowserMatchNoCase www\.netforex\.org blockAccess
      BrowserMatchNoCase ^WX_mail blockAccess
      BrowserMatchNoCase ^yacybot blockAccess
      BrowserMatchNoCase ^ZIBB blockAccess
      BrowserMatchNoCase ^$ blockAccess
      
      <IfModule mod_perl.c>
          # Mod_perl preloading
          PerlSwitches -T
      </IfModule>
      
      # The ScriptAlias defines the bin directory as a directory where CGI
      # scripts are allowed.
      # The first parameter will be part of the URL to your installation e.g.
      # http://example.com/do/view/...
      # The second parameter must point to the physical path on your disc.
      ScriptAlias /twiki/bin "/var/www/twiki/bin"
      
      # The Alias defines a url that points to the twiki pub directory, which
      # is the root of file attachments.
      Alias /twiki/pub "/var/www/twiki/pub"
      
      Alias /twiki "/var/www/twiki/bin/view"
      
      # Block access to typical spam related attachments
      # Except the TWiki directory which is read only and does have attached html files.
      SetEnvIf Request_URI "/pub/.*\.[hH][tT][mM][lL]?$" blockAccess
      SetEnvIf Request_URI "/pub/TWiki/.*\.[hH][tT][mM][lL]?$" !blockAccess
      
      # This specifies the options on the TWiki scripts directory. The ExecCGI
      # and SetHandler tell apache that it contains scripts. "Allow from all"
      # lets any IP address access this URL.
      <Directory "/var/www/twiki/bin">
          AllowOverride None
          Order Allow,Deny
          Allow from all
          Deny from env=blockAccess
      
          Options ExecCGI FollowSymLinks
          SetHandler cgi-script
      
          # Password file for TWiki users
          AuthUserFile /var/www/twiki/data/.htpasswd
          AuthName 'Enter your WikiName: (First name and last name, no space, no dots, capitalized, e.g. JohnSmith)'
          AuthType Basic
      
          # File to return on access control error (e.g. wrong password)
          ErrorDocument 401 /bin/view/TWiki/TWikiRegistration
      
      
      # When using Apache type login the following defines the TWiki scripts
      # that makes Apache ask the browser to authenticate. It is correct that
      # scripts such as view are not authenticated.
      <FilesMatch "(attach|edit|manage|rename|save|upload|mail|logon|rest|.*auth).*">
         require valid-user
      </FilesMatch>
      
      
      </Directory>
      
      # This sets the options on the pub directory, which contains attachments and
      # other files like CSS stylesheets and icons. AllowOverride None stops a
      # user installing a .htaccess file that overrides these options.
      # Note that files in pub are *not* protected by TWiki Access Controls,
      # so if you want to control access to files attached to topics you need to
      # block access to the specific directories same way as the ApacheConfigGenerator
      # blocks access to the pub directory of the Trash web
      <Directory "/var/www/twiki/pub">
          Options None
          AllowOverride None
          Order Allow,Deny
          Allow from all
          Deny from env=blockAccess
      
          # Disable execusion of PHP scripts
          php_admin_flag engine off
      
          # This line will redefine the mime type for the most common types of scripts
          AddType text/plain .shtml .php .php3 .phtml .phtm .pl .py .cgi
      
      #add an Expires header that is sufficiently in the future that the browser does not even ask if its uptodate
      # reducing the load on the server significantly
      #IF you can, you should enable this - it _will_ improve your twiki experience, even if you set it to under one day.
      # you may need to enable expires_module in your main apache config
      #LoadModule expires_module libexec/httpd/mod_expires.so
      #AddModule mod_expires.c
      #<ifmodule mod_expires.c>
      #  <filesmatch "\.(jpg|gif|png|css|js)$">
      #       ExpiresActive on
      #       ExpiresDefault "access plus 11 days"
      #   </filesmatch>
      #</ifmodule>
      
      </Directory>
      
      # Spammers are known to attach their stuff and then move it to trash where it remains unnoticed.
      # We prevent viewing any attachments directly from pub
      <Directory "/var/www/twiki/pub/Trash">
         deny from all
      </Directory>
      
    • Allow configure TWiki from local ip (and/or remote admin hosts) by adding following to /etc/apache2/conf.d/twiki.conf:
      <FilesMatch "^configure.*">
             SetHandler cgi-script
             Order Deny,Allow
             Deny from all
             Allow from 127.0.0.1,192.168.20.8,192.168.20.11
      </FilesMatch>
      
  5. Reload Apache 2:
    sudo /etc/init.d/apache2 reload
  6. Edit /var/www/twiki/bin/LocalLib.cfg:
    $twikiLibPath = "/var/www/twiki/lib";
  7. Configure your twiki: go to http://yourtwikihost.org/twiki/bin/configure,  setup admin password and paths, save it.
  8. Add following line to /var/www/twiki/lib/LocalSite.cfg (DO NOT append to the very end of the file)
    $TWiki::cfg{ScriptUrlPaths}{view} = '';
    
    to short view action so that /twiki/view/WikiWord can be shorten to /twiki/WikiWord

See also




Apache 2: Symbolic link not allowed or link target not accessible








While I was setting up Apache 2 on Ubuntu Linux, I want to change the default DocumentRoot from /var/www to /store/services/www, my site configuration is below:
        DocumentRoot /store/services/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /store/services/www/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
When accessing the web page, got permission error. Also see error in /var/log/apache2/error.log:
[Sat Dec 08 22:40:41 2012] [error] [client 192.168.20.11] Symbolic link not allowed or link target not accessible: /var/www

The problem:

Struggle for a few minutes, found what the problem is: Apache needs read & execute permissions to not only the target directory, but it needs rx permissions to all the way through until reaching the target directory. For example, in the configuration above, we have the target directory /store/services/www, we need to set the permission of all the parent folders so that the apache user(e.g www-data) have at least read & execute permission.

The solution:

sudo chmod 755 /store
sudo chmod 755 /store/services
sudo chown -R www-data:www-data /store/services/www



Mac OS X: create a zip archive excludes .DS_Store files








zip -x "*.DS_Store" -r foo.zip foo/


See also




Mac OS X: create/extract split zip archives








I. Create split zip archive

  • To create a split zip archive (a series of files named zip, z01, z02...), run following command in Terminal:
    zip -s 100m -x "*.DS_Store" -r split-foo.zip foo/

II. Extract split zip archive

  • To extract a split zip archive (a series of files named zip, z01, z01...), run following command in Terminal:
    1. First, combine the split archive to a single archive:
      zip -s 0 split-foo.zip --out unsplit-foo.zip
    2. Extract the single archive using unzip:
      unzip unsplit-foo.zip

See also




Ubuntu 12.04 Precise: Install Java 7








Install Java 7

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo update-java-alternatives -s java-7-oracle

Uninstall Java 7

sudo apt-get remove oracle-java7-installer

See also