Install Android Eclipse

Hi guys, when telling a story it’s always best to start at the beginning, so the first thing to do on my journey is talk about how are we going to install Android Eclipse. My workstation is a MacBook but the process is the same on both Windows and Linux. I’ve put together a short video of the entire thing, from downloading Eclipse and the Android SDK to installing Eclipse, the ADT (Android Development Tools) plugin and then configuring ADT to use the Android SDK!

The steps are really simple.

  1. Download and install the Eclipse IDE for Java Developers from https://www.eclipse.org/downloads/
  2. Download and extract the Android SDK from https://developer.android.com/sdk/index.html
  3. Install the ADT plugin in Eclipse

After following these 3 easy steps to install Android Eclipse you should be ready to go!

Learning Android

If you’re new to the Android mobile operating system, Learning Android is the perfect way to master the fundamentals. This gentle introduction shows you how to use Android’s basic building blocks to develop user interfaces, store data, and more. You’ll build an example application throughout the course of book, adding new features with each chapter. You’ll also build your own toolbox of code patterns that will help you program any type of Android application with ease.

10 Most Used Linux Commands

Whilst skimming my Bash history today looking for an esoteric one liner I’d written earlier I started to ponder what my most used commands were, it’s easy enough to find out! This is actually output from my Mac, not a Linux box, I tricked you 😀


Chill:~ rus$ history | awk {'print $2'} | sort | uniq -c | sort -nr | head -n 10
106 ssh
49 ls
44 cd
42 curl
34 scp
25 vi
15 mv
15 cp
12 grep
10 rm

ssh looks to be number one, which is understandable as I do a lot of work on remote machines.. so what does my usage pattern on remote servers look like?


root@xflipnag2:~# history | awk {'print $2'} | sort | uniq -c | sort -nr | head -n 10
211 vi
160 ls
150 cd
89 svn
39 grep
38 ps
28 cat
24 /usr/lib/nagios/plugins/check_http
24 puppet
20 puppetapply

This time it really is a Linux box, running OEl6 if you must know! Pretty similar, it’s a monitoring node so recently I’ve been using the check_http command to run some HTTP tests. Puppetapply is an alias of ours to run Puppet in a manner that will make changes, by default it runs noop.

It’s nice to see grep rocking, one of my favourite commands really. Though I’m surprised sed hasn’t shown up anywhere!

What are your 10 most used commands?

Income Report February 2013

This blog is and has always been a blog of integrity, righteousness. A stalwart blog where I document my IT struggles and things I like to eat. Basically a combination of everything I hate in the world and everything I love, all in one place. And it’s going to remain that way. I will never sell out!

I like to read the Internet sometimes, I think I’m about half way through and so far nothing’s happened. But over the last few weeks I’ve been reading Smart Passive Income, basically a blog where some guy allegedly makes $50kpm by telling other people that he’s er .. making $50kpm. I think he’s making shit up personally, but it’s kind of inspiring. I’ve had Adsense running on this site for 2 years I think now, maybe more, who knows, and strangely I’m not retired and am still getting my fists dirty with magical computer machines. This blog has become amusingly popular though, although I don’t have a hardcore following it’s nice to read the odd comment about how I’ve helped someone create a Yum repository.

Anyway as an experiment, I’ve never tried this affiliate marketing thing before, so I’ve decided to document the process on this site and have a whirl. As such on a few of my pages I’ve added affiliate links to books I’ve read (honestly, I have actually read them, we’ve pretty much got the entire O’Reilly catalogue in our current office and everyone around me is stupid so it’s not like I’ve anyone I can ask for help, well other than that one guy who’s really smart but he just tells me to go away).

Now Commission Junction, the affiliate I’m trying out, in conjunction with O’Reilly, will give me a whopping 5% of whatever revenue I generate for them, which is pretty bad ass. I’ve run the numbers! Adsense reckons I got 3889 page views in February, Analytics reckons 4,542, Awstats reckons 6332 unique visitors, I’m going to go with the Awstats metric as Apache logs don’t lie. If 1% of 6332 people click through to an affiliate (63.32 people), and 1% of those guys buy a book (0.6332 people) at say $30 (making me $1.5) I’ll make $0.94 a month! Over a year that might even hit $10 in which case I can retire to Zimbabwe.

Anyway enough rambling, lets get on with the magic and proudly broadcast to the world how minted I am off a blog focusing on my work life and local burgers.

February 2013 Income Report

Unique Visitors: 6332
Adsense Clicks: 1
Adsense: £0.33

Hell yeah! I’m bringing home the bacon! I will be excited to see what next month brings!

OSX Lion JAVA_HOME

Apple’s OS Lion has a pretty neat trick for handling the JAVA_HOME variable


Chill:bin rus$ /usr/libexec/java_home
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

which is super awesome as you can simply do


Chill:bin rus$ export JAVA_HOME=$(/usr/libexec/java_home)
Chill:bin rus$ echo $JAVA_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

to make sure you have the correct $JAVA_HOME set up, every time!

I’ve added this commend to my ~/.profile file so that whenever I open a new terminal, the $JAVA_HOME variable gets set correctly!

Burger At The Thomas Kemp

Last week I helped a friend of mine move house, and in return he also let me buy him dinner .. He lives up near the Thomas Kemp and I hadn’t been there for a while so it was pretty much set in stone what I’d be eating.

From their menu description:

Thomas Kemp Beef Burger – £7.95
Our homemade beef burger with horseradish, gherkins, tomato & mixed leaves.

Burget At The Thomas Kemp

I can’t remember if the cheese and bacon was an added extra, but what was unexpected was a massive dollop of mayonnaise on the burger and a distinct lack of horseradish… it wasn’t entirely horrific, in fact it was quite a nice change as I never put mayonnaise on my burgers, that’s weird.

The ‘chips’ however were shit, especially compared to my mates deliciously soft and crispy fries, which I ended up eating most of as he wasn’t that hungry. The ones served with the burger were, probably ‘hand cut’ as that’s all the rage, chunks of potato, fried to the degree that they weren’t crispy in the slightest but were still incredibly greasy, which really defeated the point. It’s hard to get chips with their skin on right, and the Thomas Kemp didn’t. Compared to their other style of chip it was a real let down.

Burget At The Thomas Kemp

The cheese was deliciously melty and the bacon was fantastically bacony and the array of salad in the burger complimented it, rather than fell out, but I do have a gherkin fetish and have been adding more fresh tomato to my diet in recent weeks. Whilst I’m in no way pretending the addition of salad was healthy, it added to the overall taste and texture of each bite, which is the point.

The highlight of the burger was the bread, deliciously soft and crunchy ciabatta, the burger meat itself was also nice, the entire experience was thoroughly delicious but, due to the standard of pub burgers steadily increasing, not mind blowingly special. I would definitely eat it again though, but I’d prefer their other chips..

Google Is So High On Adverts It’s Forgotten How To Search The Internet

So, I really like the song Papua New Guinea by Future Sound of London, so on a whim I decided to try and see if there were any Linux Sysadmin roles going over there, I think there’s a huge oil industry out there and they must use computers, right?

linux systems administrator papua new guinea

Turns out the first search result returned matches because of the png file extension? Ok, that’s the TLA for Papua New Guinea but what .. that’s the most relevant result? Really Google?

I expect, with Google’s complete lack of ability, to probably end up page 1 for linux systems administrator papua new guinea even though this site is predominantly about beefburgers nowadays and not linux systems administration or Papua New Guinea!

I keep running in to stuff like this as I do fairly esoteric searches so I’m going to continually update this post with screenshots as I go (if I remember ( unlikely ( As an aside, it would be really cool if WordPress did bracket highlighting like VIM does … ) ) ) …

Syntax Highlighting In VIm

Syntax highlighting in vim can be super tricky, by default a lot of desktop environments seem to have white terminals, which is a bit dumb as it’s easier to read white on black than black on white, as such the default vim syntax highlighting is often unreadable if you have a black terminal, giving blue comments on a black background and the like.

The fix for this is to set your vim background to dark, e.g.


set background=dark

You can either set this on a per session basis, but as I always use black terminals I’ve set this in my .vimrc file in my home directory.

Learning the vi and Vim Editors

Learning the vi And Vim Editors is a great book thoroughly covering both editors and the incredible power they contain. There’s a reason it’s been one of the most popular editors in the world since 1979!

Installing OpenSIPS on Redhat Enterprise Linux 5

We’ve got to set up a SIP Registrar for a fantastic new project that one of our clients recently announced 😉 on RHEL5 so we’re going to trial OpenSIPS, backed with MySQL to see how it performs.

There’s a RHEL5 repository mirror here https://centos.leurent.eu/ that I’ve mirrored locally. If you don’t know how to create your own repositories you can read about that here.

First off I installed the opensips-mysql.x86_64 package to guarantee we pull in OpenSIPS as well as it’s MySQL dependencies.


[root@dollrose repos]# yum install opensips-mysql.x86_64
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package opensips-mysql.x86_64 0:1.7.1-0 set to be updated
--> Processing Dependency: opensips = 1.7.1 for package: opensips-mysql
--> Running transaction check
---> Package opensips.x86_64 0:1.7.1-0 set to be updated
--> Processing Dependency: perl(Frontier::RPC2) for package: opensips
--> Running transaction check
---> Package perl-Frontier-RPC.noarch 0:0.07b4-5.el5 set to be updated
--> Processing Dependency: perl(HTTP::Status) for package: perl-Frontier-RPC
--> Processing Dependency: perl(HTTP::Daemon) for package: perl-Frontier-RPC
--> Processing Dependency: perl(Apache::Constants) for package: perl-Frontier-RPC
--> Processing Dependency: perl(HTTP::Request) for package: perl-Frontier-RPC
--> Processing Dependency: perl(XML::Parser) for package: perl-Frontier-RPC
--> Processing Dependency: perl(LWP::UserAgent) for package: perl-Frontier-RPC
--> Running transaction check
---> Package mod_perl.x86_64 0:2.0.4-6.el5 set to be updated
--> Processing Dependency: perl(BSD::Resource) for package: mod_perl
---> Package perl-XML-Parser.x86_64 0:2.34-6.1.2.2.1 set to be updated
---> Package perl-libwww-perl.noarch 0:5.805-1.1.1 set to be updated
--> Processing Dependency: perl-HTML-Parser >= 3.33 for package: perl-libwww-perl
--> Processing Dependency: perl(HTML::Entities) for package: perl-libwww-perl
--> Processing Dependency: perl(Compress::Zlib) for package: perl-libwww-perl
--> Running transaction check
---> Package perl-BSD-Resource.x86_64 0:1.28-1.fc6.1 set to be updated
---> Package perl-Compress-Zlib.x86_64 0:1.42-1.fc6 set to be updated
---> Package perl-HTML-Parser.x86_64 0:3.55-1.fc6 set to be updated
--> Processing Dependency: perl-HTML-Tagset >= 3.03 for package: perl-HTML-Parser
--> Processing Dependency: perl(HTML::Tagset) for package: perl-HTML-Parser
--> Running transaction check
---> Package perl-HTML-Tagset.noarch 0:3.10-2.1.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
opensips-mysql x86_64 1.7.1-0 opensips 96 k
Installing for dependencies:
mod_perl x86_64 2.0.4-6.el5 rhel 4.0 M
opensips x86_64 1.7.1-0 opensips 5.7 M
perl-BSD-Resource x86_64 1.28-1.fc6.1 rhel 29 k
perl-Compress-Zlib x86_64 1.42-1.fc6 rhel 52 k
perl-Frontier-RPC noarch 0.07b4-5.el5 epel 40 k
perl-HTML-Parser x86_64 3.55-1.fc6 rhel 92 k
perl-HTML-Tagset noarch 3.10-2.1.1 rhel 14 k
perl-XML-Parser x86_64 2.34-6.1.2.2.1 rhel 210 k
perl-libwww-perl noarch 5.805-1.1.1 rhel 376 k

Transaction Summary
=================================================================================================================================================================================================================
Install 10 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 11 M
Is this ok [y/N]: y
Downloading Packages:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 131 MB/s | 11 MB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Compress-Zlib 1/10
Installing : perl-BSD-Resource 2/10
Installing : mod_perl 3/10
Installing : perl-HTML-Tagset 4/10
Installing : perl-HTML-Parser 5/10
Installing : perl-libwww-perl 6/10
Installing : perl-XML-Parser 7/10
Installing : perl-Frontier-RPC 8/10
Installing : opensips 9/10
Installing : opensips-mysql 10/10

Installed:
opensips-mysql.x86_64 0:1.7.1-0

Dependency Installed:
mod_perl.x86_64 0:2.0.4-6.el5 opensips.x86_64 0:1.7.1-0 perl-BSD-Resource.x86_64 0:1.28-1.fc6.1 perl-Compress-Zlib.x86_64 0:1.42-1.fc6 perl-Frontier-RPC.noarch 0:0.07b4-5.el5
perl-HTML-Parser.x86_64 0:3.55-1.fc6 perl-HTML-Tagset.noarch 0:3.10-2.1.1 perl-XML-Parser.x86_64 0:2.34-6.1.2.2.1 perl-libwww-perl.noarch 0:5.805-1.1.1

Complete!

Create the opensips user


adduser opensips

Then edit /etc/opensips/opensipsctlrc and make the following changes


SIP_DOMAIN=localhost
DBENGINE=MYSQL
DBHOST=localhost
DBNAME=opensips
DBRWUSER="opensipsrw"
DBRWPW="opensips"
DBROOTUSER="root"
USERCOL="username"
INSTALL_EXTRA_TABLES=ask
INSTALL_PRESENCE_TABLES=ask

We can now run opensipsdbctl create and create the database and tables


[root@dollrose opensips]# opensipsdbctl create
MySQL password for root:
INFO: test server charset
INFO: creating database opensips ...
INFO: Core OpenSIPS tables succesfully created.
Install presence related tables? (y/n): y
INFO: creating presence tables into opensips ...
INFO: Presence tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist? (y/n): y
INFO: creating extra tables into opensips ...
INFO: Extra tables succesfully created.

Edit /etc/opensips/opensips.cfg and enable the following options


loadmodule "db_mysql.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("auth_db", "load_credentials", "")

Now we can create a couple of new soft phone accounts using the opensipctl add command


[root@dollrose opensips]# opensipsctl add 1234 1234
new user '1234' added
[root@dollrose opensips]# opensipsctl add 5678 5678
new user '5678' added

We can then create the MySQL user and grant him credentials on the database.


[root@dollrose opensips]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 417
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON opensips.* TO opensips@localhost IDENTIFIED BY 'opensipsrw';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON opensips.* TO opensips@127.0.0.1 IDENTIFIED BY 'opensipsrw';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

We can now start OpenSIPS!


[root@dollrose opensips]# /etc/init.d/opensips start
Starting opensips:


root@dollrose opensips]# netstat -lpn | grep 5060
tcp 0 0 10.20.0.11:5060 0.0.0.0:* LISTEN 4253/opensips
tcp 0 0 87.252.58.21:5060 0.0.0.0:* LISTEN 4253/opensips
tcp 0 0 127.0.0.1:5060 0.0.0.0:* LISTEN 4253/opensips
udp 0 0 10.20.0.11:5060 0.0.0.0:* 4253/opensips
udp 0 0 87.252.58.21:5060 0.0.0.0:* 4253/opensips
udp 0 0 127.0.0.1:5060 0.0.0.0:* 4253/opensips

I win! :D

Take Screenshot Mac

To take a screenshot on a Mac you can use the following simple keyboard shortcuts:

To save a screenshot to the desktop on a Mac

  • Command-Shift-3 : Take a screenshot of the Mac screen, and save it as a file on the desktop.
  • Command-Shift-4 : Hold down the mouse button and select an area of the Mac screen to save a screenshot of that area as a fiile on the desktop.
  • Command-Shift-4 : Press the space key and then click a window to take a screenshot of that window and save it as a file on the desktop.

To save a screenshot to the clipboard on a Mac

  • Command-Control-Shift-3 : Take a screenshot of the Mac screen, and save it to the clipboard.
  • Command-Control-Shift-4 : Hold down the mouse button and select an area of the Mac screen to save a screenshot of that area to the clipboard.
  • Command-Control-Shift-4 : Press the space key and then click a window to take a screenshot of that window to the clipboard.

 

Iptables Block Outgoing Traffic

We need to give one of our customers to an internal server, for this we’ve enabled remote SSH access. Even though we trust them we don’t want anyone to use the server as a launchpad to attack other remote servers, or a launch pad to attack internal servers for that matter, in case their account and SSH keys are compromised. So to prevent this we are using iptables to block outgoing traffic from the external IP.

You can’t specify a network interface to block outbound traffic from, but you can specify IP addresses to block outgoing traffic

iptables -A OUTPUT --source a.b.c.d -m state --state NEW -j DROP

The above command will block all new outgoing traffic from the a.b.c.d source IP, preventing anyone gaining unauthorised access from launching attacks out of our network!

Linux iptables Pocket Reference O’Reilly’s Linux iptables Pocket Reference is a simple book that contains amazing snippets just like this. Rather than a complete reference it just gets down to the nitty gritty of using iptables to actually do things!