Sunday, May 22, 2011

Social circle.

Google has put out a new cross-referencing set of pages. They basically tie your profile page to your know friends and contacts. Check it out for your self.

http://www.google.com/s2/search/social#socialconnections

cleaning up ubuntus file usage

FIRST OF ALL get into the apt-get and clear out the apps you dont want. Then purge, autoclean, autoremove, orphan remove all the remain pieces until nothing is left

Heres the basic clean up (plus some setup)
sudo apt-get -y install gtkorphan logrotate localepurge fslint
sudo apt-get autoremove
sudo apt-get clean all 
sudo apt-get autoclean all
sudo localepurge
dpkg -l | grep '^rc'| cut -d' ' -f3 | xargs dpkg -P

When you take out packages the best way is to --purge or autoremove them
 sudo apt-get --purge remove bluez-utils bluez-gnome 
 sudo apt-get autoremove bluez-utils bluez-gnome 

Then execute gtkorphan and keep killing unneed deps until it cant find any.

The Disk Usage Analyzer to sort out the biggest space wasters. Its found at Applications->Accessories->Disk Usage Analyzer.

There is also the computer janitor. Its at System > Administration > Computer Janitor.

And you can also hunt down the dead log files and other crap in you system with fslint.

You may need to loop around the whole process a few times to get it really clear

Several useless packages that tend to be installed by default are(sorry list is very short I got hacking before I thought about writing it down);
  • gnome-pilot
  • mesu-utils
Refer http://maketecheasier.com/8-ways-to-maintain-a-clean-lean-ubuntu-machine/2008/10/07

PHP: getting the users IP address

$_SERVER['REMOTE_ADDR']; 

c++ chomping white space

A Bit of code to chomp strings in c++

#include <string>
#include <iostream>

int main()
{
  std::string str;
  getline(std::cin, str);

  std::cout << "'" << str << "'" << std::endl;
    
  std::string::size_type pos = str.find_last_not_of("\n \t");
  if(pos != std::string::npos) 
  {
    str = str.substr(0, pos+1);
  }
    
  std::cout << "'" << str << "'" << std::endl;
}

Quick way list your LAN machines

Here is a quick way to grab the Ethernet MACs and IPs of the machines that are up on your LAN

arp -a

Suming a list of numbers of the shell

Manipulating lists on the shell can be done with awk. The most common one I encounter is summing numbers. Here is a quick bit of shell magic to sum up the size of all log files below a certian dictionary. Awk has much more power than this however.

find . -type f | grep "\.log" | xargs ls -al | sed "s/  */ /g" | cut -d " " -f 5 | awk -F: '{total+=$1} END{print total}'

Friday, May 6, 2011

Shell repeat/do/while for a count

Gahh.. simple thing but annoying its for bash shell

 i=245; while [ $i -ne 33 ]; do  echo $i; i=`expr $i - 1`; done