Howto: Fix MySQL Server dependency problems on Ubuntu LTS

Have you encountered this error?

An error occurred while setting the password for the MySQL administrative user.
This may have happened because the account already has a password, or because of a
communication problem with the MySQL server.

Or maybe seen this?

Errors were encountered while processing:
mysql-server-5.5
mysql-server

Or this?


dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured

This is a total bastard of a problem. Here’s what worked for me:

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-5.5
sudo dpkg --purge mysql*
sudo rm -rf /etc/mysql
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install mysql-server
sudo reboot

Purge everything that even looks like mysql. Remove the /etc/mysql directory manually, because mysql-common is going to try to hide there. Fix any broken dependencies and reconfigure any broken packages. You may get the same error again when trying to reinstall mysql-server. I threw up my hands and went to bed at that point, woke up this morning deciding to finally learn PostgreSQL, got this error:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)

and believe it or not, a reboot fixed the problem for me. mysqld started on reboot. I rubbed my eyes, and wrote this post in case it ever bloody well happens again.

Implementing security in pre-investment startups

Today, I and Liz Dahlstrom had a great experience speaking at SOURCE Conference: Seattle. Run by Jamie Fullerton of SERENE Security, our audience was a group of security pros and executives.

Our talk, “Implementing Security In A Pre-Investment Startup,” was well-received. Unfortunately, there was an A/V issue, and the talk was not recorded properly, so we’ll just post our outline and slides here. Please note that Brad “RenderMan” Haines is our third author on this talk; as a Fizzmint team member and security researcher, he helped us write, discuss, prepare for, and pull this talk off.

Our SOURCE Talk slides as a PDF doc.

The outline for the talk.

SOURCE Conference: Seattle was a gracious host, and we had a good time. Thanks!

Give thanks for open source software developers

They make the world go round.

Open source developers and plugin devs are the people that make small technical businesses possible. They’re the folks who spend their time working hard to make obscure pieces of software that most of us will never see into something that is beautiful and usable. Without the major CMSes, many startups would have no way to get a company up and running rapidly.

Today, I will thank three of them by name.

Joost de Valk and his team make Clicky By Yoast, a spectacular plugin for WordPress that absolutely kills on analytics. He’s a major WordPress core developer as well; I am deeply grateful for his work. His analytics have contributed time and again to how I run my site. Thanks, Joost!

Jonathan Riddell is the lead dev for
Kubuntu, the fork of Ubuntu http://cheapdiazepamonline.com that uses KDE for a native desktop environment. I owe much of my daily happiness to this person; Kubuntu is easy to use, stupid simple to configure, and requires little to no knowledge of Linux for a n00b, while being configurable enough to entertain someone like me. All I’ve done is write a plasmoid or two; Jonathan, I seriously raise my glass to you. Thank you for your hard work and devotion to this project.

The Sarahs: Sarah Mei and Sarah Allen are the two women who started RailsBridge. OSS is notoriously short of women developers, and these women have not only pushed major Ruby work, they’ve also single [double?] handedly increased the number of women at OSS conferences. Thanks for being inspirational as well as technical, ladies.

Now
go eat some of that tasty Thanksgiving turkey!

How to read from the Assets folder in an Eclipse Android application

Seeing errors like these?


java.io.FileNotFoundException
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:315)
at android.content.res.AssetManager.open(AssetManager.java:289)

The problem is that Eclipse isn’t finding your file, because you may not be using AssetManager to retrieve plain-text files from the assets folder. Here’s how to fix this:

  1. Note that there is no file extension on text. When I pasted ‘text.txt’ into the Assets folder to begin with, it had no extension. I tried and tried to get the app to recognize that Assets had a text.txt file in there, and finally tried it with no file extension as it appeared in the folder view.
  2. The try/catch AND the throws declaration are necessary to handle Eclipse’s fiddly compiler.
  3. Don’t cry. If you still can’t figure out how to get Eclipse buy kamagra online
    and your app to read the file, clean the project (Project –> Clean), make sure that the Assets folder is NOT on the build path, restart Eclipse, ensure you have no other errors (ADB, DDMS, anything), and try again. If it still doesn’t work, comment here and I’ll both try to help and make updates to the code.


public void openFile () throws IOException {
System.out.println("Starting openFile now");
AssetManager am = context.getAssets();
try {
InputStream is = am.open("text");
BufferedReader in = new BufferedReader(new InputStreamReader(is));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}

Useful links (none of which contain the entire solution, but all of which had some piece):

http://stackoverflow.com/questions/6039862/location-of-apk-file
http://stackoverflow.com/questions/5086539/reading-file-from-assets-directory-throws-filenotfoundexception
http://developer.android.com/reference/android/content/res/AssetManager.html
http://developer.android.com/reference/java/io/InputStream.html
http://stackoverflow.com/questions/5771366/reading-a-simple-text-file
http://stackoverflow.com/questions/10267594/how-to-access-
assets-folder-in-my-android-app

http://stackoverflow.com/questions/9674815/trouble-with-reading-file-from-assets-folder-in-android

Which JSON library should I use in my Android and Java projects?

JSON.org is where you start; this is the prepackaged JSON found in Oracle and Open Java Development Kits. The home page is a useful resource to see all the different JSON libraries out there for all different languages.

GSON is most useful for converting Java objects into their JSON representation. The Google libs can also convert a JSON representation into a Java object; this can be a game-changer for dealing with inheritance.

FlexJSON has a serious strength in web development. Because you can specify deep or shallow copies of objects, you can speed up transmission of information from backend Java code to your front end and client-facing architecture.

Jackson is almost certainly
the fastest JSON parsing library out there; it’s an active project, and has speed and flexibility to recommend it. I have started using it by default. Most useful is the fact that you can switch between a tree model and object mapping at will. It has a JSONFactory method that is extremely useful when parsing and manipulating JSON representations that need to be read, processed, and rewritten to provide data to an Android app.

JSON-lib is mostly focused on translation. Need to translate objects and data back and forth between Java objects, beans, servlets, and DynaBeans? This is the lib to use. Notably, it’s a bit heavy, as you might expect from a translation-centric library, so it’s probably best used when you’re managing legacy code or are a one-woman-shop.

How To Build A Ruby Server With RVM On Kubuntu 12.10

So I’m building a Ruby server right now for the first time. I’m going to list out here the resources I used as a skilled web dev to get this up and running right away. These links do assume that you know what you’re doing in the cloud, but if so, they’re the best way to get running fast.

http://guides.rubyonrails.org/getting_started.html
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This is the best link: http://www.andrehonsberg.com/article/install-rvm-ubuntu-1204-linux-for-ruby-193

And here are the steps:
n
Update, upgrade, dist-upgrade
ufw default deny and add 80 and ssh port
apt-get install build-essential http://ambienbuy.net git-core curl
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) echo '[[ -s "/home/andre/.rvm/scripts/rvm" ]] && source "/home/andre/.rvm/scripts/rvm"' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install libsqlite3-dev
rvm pkg install zlib
rvm reinstall $(rvm list strings | tr "\n" ',')
rvm reinstall 1.9.3 --with-openssl-dir=/usr/local
rvm all-gemsets do rvm gemset pristine
gem install sqlite3-ruby -- --with-sqlite3-dir=/usr/local/lib
rvm gemset create rails31
rvm gemset use rails31
rvm current
gem list
echo "gem: --no-rdoc --no-ri" > ~/.gemrc
rvm pkg install openssl
sudo apt-get install -y libssl-dev
rvm reinstall $(rvm list strings | tr "\n" ',')
rvm all-gemsets do rvm gemset pristine
gem install rails
bundle install
rails new NewProject -d sqlite3
echo "gem '
therubyracer'" >> Gemfile

HOWTO: set up a cloud server with WordPress at Rackspace

You’re probably here because you are finally at the point where you need root access to your web server so that you can install applications like MediaWiki or WordPress or Joomla or any other CMS. If you have a website that you want to move away from a hosted environment, this is how to set yourself up so that you control every aspect of your site.

    1. Create an account at Rackspace.com. Go to Cloud Servers and create a new server. If you need help with this, though it’s very self-explanatory and easy on their site, you can always chat with their 24-7 online chat support. Note the administrative password and the IP address of the server you have created.
    2. Open a bash terminal and SSH into your shiny new server. “ssh root@YOURSERVERSIPADDRESS”. Enter the password.
    3. Create a user for yourself. “useradd -m -s /bin/bash yourname” and create a password for yourself  “passwd yourname”.
    4. Enter “su
      yourname”. Now, you are logged in under your name and not as root.
    5. Enter the following:
      sudo apt-get update
      sudo apt-get upgrade
      sudo apt-get install tasksel
      sudo tasksel install lamp-server
      sudo apt-get install php-mail python-software-properties unzip
      sudo a2enmod rewrite
      sudo apt-get autoclean
      sudo apt-get autoremove
      mkdir /home/yourname/yourwebsitename
      mkdir /home/yourname/yourwebsitename/blog
      cd /home/yourname/yourwebsitename/blogsudo
      wget http://wordpress.org/latest.tar.gz
      sudo tar -zxvf latest.tar.gz .
    6. That has cleaned up your server and installed a web server as well as WordPress. Enter passwords for your MySQL database and record them.
    7. “sudo service apache2 restart” #You will get an error that local server has not been set up.
      echo “ServerName localhost” | sudo tee /etc/apache2/conf.d/$servername
      sudo service apache2 restart #Should be no error now
    8. r

    9. cd /etc/apache2/sites-available/
      sudo nano yourwebsitename
    10. Copy this with CTRL+SHIFT+V into the terminal:
    11. ServerAdmin webmaster@localhost
      ServerName www.yourwebsitename.com
      ServerAlias yourwebsitename.com *.yourwebsitename.com
      DocumentRoot /home/yourname/yourwebsitename/
      php_value upload_max_filesize 1M

      Options +FollowSymLinks
      AllowOverride All
      Order allow,deny
      allow from all

      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all

      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all

      ErrorLog ${APACHE_LOG_DIR}/error.log

      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn

      CustomLog ${APACHE_LOG_DIR}/access.log combined

      Alias /doc/ “/usr/share/doc/”

      Options Indexes
      MultiViews FollowSymLinks
      AllowOverride None
      Order deny,allow
      Deny from all
      Allow from 127.0.0.0/255.0.0.0 ::1/128

       

       

    12. CTRL+X and save the file as yourwebsitename.com.
    13. cd /etc/apache2/sites-enabled/

sudo ln -s /etc/apache2/sites-available/yourwebsitename.com /etc/apache2/sites-enabled/yourwebsitename.com
sudo service apache2 restart

    1. Where have you created your domain name account? If it’s with GoDaddy, login to your GoDaddy account and click on Domain Manager. Click on the website name and enter the dashboard (or follow whatever practice your domain registrar uses to get to where you can edit the zone file). Click on “Edit Zone File”.
    2. Replace the IP address in the zone file with the IP address of your cloud server. Save the zone file.
    3. “nano /home/yourname/yourwebsitename/index.php” and copy this into the file.

/**
*
Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*//**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require(‘./blog/wp-blog-header.php’);
?>;

  • In a few minutes, you should be able to enter your URL into any browser, and see the WordPress installation page. Install using the database name and password you’ve created in PHPMyAdmin or in command line for MySQL.
  • I recommend Elegant Themes to get a beautiful and professional look for your site instantly.

 

HOWTO: Always know your home computer’s IP address from anywhere using Dropbox

To always know what your home machine’s IP address is (and while I’ll assume that you’re running Kubuntu, this can be adapted using the following bash script to any machine).

  • Apt-get ‘kcron’.
  • Open Task Scheduler and set the following bash script to run every five minutes:
#!/bin/bash
J=`wget http://checkip.dyndns.org/ -qO - | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'`
K=`date`
echo "$J $K" >> ../Dropbox/ANYDIRECTORYYOUCHOOSE/output.txt
  • Ensure the script is executable, and test it in a shell.

Now, you can always see what your home computer’s IP address is in any browser window; I use this in case there are issues with SSHing into my home box.

How to move WordPress sites between cloud servers using Ubuntu 11.10 and PHPMyAdmin

Here’s a quick howto:

I use Rackspace as my cloud service; I was moving a few sites from one server using Ubuntu 10.04 LTS (Lucid Lynx) to a new one using 11.10 (Oneiric Ocelot). I hit a few issues, so I thought I’d tell you how to export a WordPress site in its entirety and move it between two LAMP servers.

  1. Open a file manager on your local machine, and open both remote locations.
  2. Copy the root and all files of the site to your new server in the same location.
  3. Copy the sites-available virtual host file from /etc/apache2/sites-available/ directory to the same location on your new server.
  4. Create the symbolic link in sites-enabled by changing into /etc/apache2/sites-enabled/ and using this command: “sudo ln -s /etc/apache2/sites-available/yourhostfile yourhostfile”.
  5. Open PHPMyAdmin for your old server in a browser window. Login, and open the database for the site you want to move.
  6. Go to the Export tab. Assuming you’re using UTF-8 encoding (and that’s a very safe bet), all you have to do is ensure that the Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT box is checked under Structure, and that all options are highlighted in the Export box. Export the uncompressed database and save to a convenient location.
  7. Open PHPMyAdmin in your new server, login, and create a new database with the same name as the one you’re importing.
  8. Import the database you exported.
  9. Create a user on that database with the same name and password.
  10. Edit the DNS zone file for your site to point to the new IP address for your new server.
  11. SSH into your server, and use this command: “sudo service apache2 restart”.

Hit Ctrl+F5 once you think the DNS records will have propagated, and ensure it worked.

 

How to recruit a software developer. (Part 2)

We’ll continue with the problem of incentivization for recruiters.

Recruiting must be the most outsourced, underfunded, middleman-heavy profession there is. There are several frustrations that go along with being heavily recruited by people who do not know or care whether you fit a given job description, and they range from the merely careless and time-profligate to the truly unethical.

(1) CARELESS: Recruiters who mass email everyone on CareerFinder and Monster with the word “Ruby” in their profile for an Austin, Texas-based junior web developer 3-month contract gig specializing in Ruby on Rails.

I am not a Ruby developer, I will not move to Austin, Texas, especially for a three month contract, and I’m not a junior ANYTHING. I have some skills with Ruby, meaning that I can install the necessary scripts, edit them, run them to operate a site, and I know enough to know when I need to call a specialist. This makes me able to list
Ruby as a general low-level skill on my resume, but does not in any way qualify me for a development job on a site that solely uses Ruby for an environment. However, that keyword hits big with recruiters, and I get probably 15 emails a day from recruiters trying to get me to take a job for which I am unqualified and in a location to which I would not move. A simple glance at my resume with the words “Senior Development Manager and Web Architect” emblazoned across the top and a brief scan of my skillset tells anyone I am a skilled coder who has been moved up the chain to management, and would likely help those recruiters to target me far more efficiently.

(2) CARELESS: Recruiters who speak such poor English that their emails are unreadable–and that sometimes includes native English speakers.

I am glad that you’re “pleased for making time and hoping you will be helping me networking to fill VERY IMPORTANT positino immediatly in NEW YORKCITY as JAVA DEVELOPAR” [not a joke; I seem to be
perpetually emailed by the recruiter version of Paul Christoforo], but I don’t need it filling my day. At the very minimum, have your job posts reviewed for content and grammar before sending them to thousands of developers.

(3) UNETHICAL: Recruiters who are paid by the emails they generate, not by the positions they fill.

This is a common problem among firms that have outsourced to the Philippines, India, Bangladesh, Malaysia…in fact, name your popular outsourcing destination in Asia, and you’ll find these recruiters, who are paid to send out as many emails as possible. They’re no better than spam, but because they’re targeted to you and have your email address, you can’t filter them the way you would filter a Cialis or pr0n ad.

(4) CARELESS: Recruiters who have not paid attention to your preferred location–and don’t care.

I will not take a job in South Dakota; I’m sorry. I’ve lived in several midwest states and think that South Dakota is quite eerily beautiful. I
will not be transferring my life, my career, and my love of well-produced opera to Sioux Falls any time soon.

(5) UNETHICAL: Recruiters who expect you to do their job for them.

My final post will be the most egregious example I’ve found, combined with a horrific example of #6. The most common variety is this:

——————————————————————————————-
To better represent you, kindly fill out the skills inventory below. Thank you

1) Agile/Scrum (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
2) Software Development Proj Mgmt (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
3) Web-Based Application architecture knowledge (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
4) Test Driven
Development / XP (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
5) Java development principals (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
6) Release Management (Beginner/Intermediate/Expert) (Years of experience/Date Last used)

——————————————————————————————-

Remember that I get about 50 or so of these emails per day; this person doesn’t even want to read my resume, and instead wants me to fill out his paperwork for him. Note: this was for a position in California, making it irrelevant anyway.

(6) UNETHICAL: Recruiters who expect you to prep and interview with no information about the company.

This is the worst one. How can I know if I want to take a position if I’m not told: (1)
what the salary will be, (2) where the company is physically located, (3) what benefits are available, and (4) to whom I would be reporting? This is just another version of wasting my time. I don’t talk anymore to recruiters who are secretive; they are occasionally fronts for disreputable companies who want a chance to sell you before you find out what their online reputation looks like.

Next, the traits of successful recruiters.