when we finish up a project that was trouble from day one

❣ Chile in a Photography ❣
we're not kids anymore.

Origami Around
NASA

Janaina Medeiros
wallacepolsom

No title available
Keni

★

PR's Tumblrdome
RMH
d e v o n
noise dept.
Lint Roller? I Barely Know Her

titsay

shark vs the universe

pixel skylines
occasionally subtle

ellievsbear

No title available
seen from United States
seen from United States

seen from United States
seen from Germany
seen from United States

seen from Malaysia

seen from Norway

seen from Türkiye

seen from Malaysia
seen from Netherlands

seen from India

seen from United States
seen from Italy
seen from United States

seen from Australia
seen from Algeria
seen from United Kingdom
seen from Germany

seen from Bangladesh
seen from United States
@scribblepadofdoom
when we finish up a project that was trouble from day one
Getting the EC2 DNS names registered to an ELB
I wanted to get all the addresses registered to the ELB so I could work with fabric on the servers based on them being in the LoadBalancer. It's a bit cumbersome. I ended up with this: import boto from boto import regioninfo from boto import ec2 ACCESS_KEY_ID = '*****************' SECRET_ACCESS_KEY = '*************' elb_region = boto.regioninfo.RegionInfo( name='ap-southeast-1', endpoint='elasticloadbalancing.ap-southeast-1.amazonaws.com') elb_connection = boto.connect_elb( aws_access_key_id=ACCESS_KEY_ID, aws_secret_access_key=SECRET_ACCESS_KEY, region=elb_region) ec2_region = ec2.get_region(aws_access_key_id=ACCESS_KEY_ID, aws_secret_access_key=SECRET_ACCESS_KEY, region_name='ap-southeast-1') ec2_connection = boto.ec2.connection.EC2Connection( aws_access_key_id=ACCESS_KEY_ID, aws_secret_access_key=SECRET_ACCESS_KEY, region=ec2_region) load_balancer = elb_connection.get_all_load_balancers(load_balancer_names=['MediaPopClients'])[0] instance_ids = [ instance.id for instance in load_balancer.instances ] reservations = ec2_connection.get_all_instances(instance_ids) instance_addresses = [ i.public_dns_name for r in reservations for i in r.instances ]
Enabling bz2 support and compiling python for a virtualenv
Like last time another issue was a bz2 not being available even though on the system it was.
yum bzip2-devel wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz tar -zxvf Python-2.7.2.tgz cd Python-2.7.2/
Then configure python to be built absolute path of the virtualenv:
./configure --prefix=/var/lib/jenkins/.virtualenvs/clients/ make make install
Enabling sqlite3 support and recompiling python for virtualenv
We've set up a new build server at work and for some perplexing reasons the virtualenv python was missing support for sqlite3, even though the system python had it. Although the system python still had sqlite3. We need to make sure the dev package of sqlite3 is installed before compiling. yum sqlite3-devel wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz tar -zxvf Python-2.7.2.tgz cd Python-2.7.2/ Then configure python to be built absolute path of the virtualenv: ./configure --prefix=/var/lib/jenkins/.virtualenvs/clients/ make make install Done. :)
Chrome Extensions - Working around being unable to resize a maximized window
The chrome API lets you manipulate the size of a window through the chrome.windows.update method, however there's a bug (#50138) where if a window is maximized then it won't resize and there doesn't appear to be a way to unmaximize a window.
The only solution I can think of is to create a new window which start unmaximized with the desired dimensions and then moving the tabs over to the new window. Here's some example code I threw together which should maintain the state from one window to the new one:
Ubuntu - Installing Sun JDK instead of OpenJDK on Natty
I previously wrote how to do this under Maverick. Another Ubuntu release is out with OpenJDK, here's how to replace it with Oracles JDK:
sudo add-apt-repository "deb http://archive.canonical.com/ natty partner" sudo apt-get update sudo apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre sun-java6-plugin sudo update-java-alternatives -s java-6-sun
Django - Setting up mod_wsgi with a relative rather than absolute path.
The configuration example both on the Django website and on the mod_wsgi site itself shows a configuration where you set up the wsgi script to refer to an absolute path. That seemed like unnecessary configuration to be done every time I'm going to setup a Django site. Instead I created one where the path names are relative to the file instead. In my case the file resides under /etc/myproject/mydjangoproject/apache/django.wsgi, so I ended up with this:
import os import sys """ For safetys sake we don't want to import just 'settings' so we add the parent dir for safer a safer import.""" paths = [ os.path.normpath( os.path.join( os.path.dirname(__file__), "../" ) ), os.path.normpath( os.path.join( os.path.dirname(__file__), "../../" ) ) ] sys.path.extend( paths ) os.environ['DJANGO_SETTINGS_MODULE'] = 'deals.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
Fixing the remote host identification has changed error.
Every once in a while I run into an issue where the remote host server identification has changed because of a re-install or other reasons. This comes with an error like:
$ ssh [email protected] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is 2c:af:ca:27:89:36:c0:03:c6:9f:43:74:1e:8e:3a:0d. Please contact your system administrator. Add correct host key in /home/kit/.ssh/known_hosts to get rid of this message. Offending key in /home/kit/.ssh/known_hosts:44 RSA host key for 127.0.0.1 has changed and you have requested strict checking. Host key verification failed.
In Ubuntu you can fix this by running ssh-keygen with the -R flag, removing the key causing the problem.
$ ssh-keygen -R 127.0.0.1
How to change the title in IE7 and 8.
I had an issue where I was building fade transitions between pages for a client, so I needed to update the title. I was using [jQuery](jquery.com) for a bunch of things so naturally I would do something like: $("title").text("Wooo. New title!"); This works great in Chrome, Firefox and IE9, but not in IE7 or 8. Thankfully IE9 has a debugger so it was easy switch the browser into compatibility mode and trace the exception. Turns out in older versions of IE the title element is magical and wasn't letting jQuery appendChild (I'm also a bit surprised they aren't checking this condition.) Instead old DOM0 comes to the rescue, which lets you set a title like so: document.title = "Woo. New title!";
Ubuntu - Installing Sun JDK instead of OpenJDK on Maverick
I'm a bit frustrated that Canonical decided to use OpenJDK, even though OpenJDK still seem to have issues with some software. In my case I was trying to run PyCharm a popular Python IDE, but it wasn't rendering properly. Lets tell Ubuntu to use Sun JDK instead:
sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner" sudo apt-get update sudo apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre sudo update-java-alternatives -s java-6-sun
Until the next Ubuntu upgrade. :)
Getting raw MySQL selection data via the command line.
I've been stuffing a MySQL database with JSON and I wanted to output it to a file. One way is to write a script that makes a connection and saves it to a file, but that seems a bit excessive. The default format MySQL outputs a selection from the console is with headers and some cruft around it, with the `-sN` options you get it all of and get the raw output, then just pipe it into a file: mysql -sN -uroot -e "select json from my_table;" my database >> myjson.json
Auto updating node.js on Ubuntu
With node.js 0.4.5 out it's well over due to get aptitude to keep up with the updates:
sudo add-apt-repository ppa:jerome-etienne/neoip sudo apt-get update sudo apt-get install nodejs
Copying a MySQL database between servers over SSH
Usually when I need to copy a database from one spot to the other I log into the server that has the original database and then SSH the data to the server that is supposed to have it: mysqldump source_database source_table | ssh user@host mysql target_databases However in this case I couldn't get the server to connect to another server via SSH, so the command changes slightly. Instead we log into the receiving server and change our command to pull the data to us from the original database. ssh user@host "mysqldump source_database source_table" | mysql target_database
Setting up a SMTP server for debugging
I wrote a client that was sending emails over SMTP server and needed to debug it, but didn't want muddle my way through setting up an actual SMTP server. Instead I found two convenient options. The first is to use python where you can starts a dummy SMTP service that prints to stdout with: sudo python -m smtpd -n -c DebuggingServer localhost:25 Another option is to sign up for http://dummysmtp.com that offers a free dummy SMTP server, showing the emails on the web interface.
WordPress - Setting WordPress up on an alternative port in apache2.
Since I've been fiddling around with OpenCart lately and needed to run WordPress as well for another project I wanted to run WordPress on a different port than 80.
Step 1 - Download WordPress from WordPress.org.
Go to http://wordpress.org/ and download the latest version. Unpack it wherever you need it. I unpacked mine to /home/celc/Dropbox/www/wordpress.
Step 2 - Make the apache user the owner of the wordpress folder
This always seems to be a bit of trouble when I run WordPress in Ubuntu thats caused by apache not having enough privileges to create files and do other things it needs. I've blogged about this before in relation to installing plugins.
Step 3 - Create a database
We need to create a database for WordPress. In Ubuntu we can just run.
Step 4 - Change apache2 settings
We need a new config file in /etc/apache2/sites-available which will handle the connection on 8080.
Then we need to change /etc/apache2/ports.conf and make apache listen to 8080 by adding the following two lines.
Step 5 - Enable the site and restart apache
We need to enable the site and restart the server before it'll run properly.
Done
Navigate to your site at http://localhost:8080 and WordPress will step you through the installation process. Just follow the instructions on the screen and your site will be enabled on http://localhost:8080.
OpenCart - Setting up cURL on Ubuntu for installation.
During installation of OpenCart you are required to have certain PHP extensions active one of them is cURL, if it's not then install it like so:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Then we need to restart apache
apache2ctrl restart
Refresh the page if you are still on it and it should be working. I think OpenCart could offer up a more pleasant installation process by offering suggestions in the installation process itself on how to go about fixing minor issues like this.
WordPress - It doesn't need FTP access, it needs a writable wp-content directory.
If you've ever attempted to install WordPress on your own you might find that it's asking for your FTP/SFTP credentials. A seemingly absurd prospect since it's running on the server, and should be perfectly capable. What is happening is that the apache user doesn't have write access to wordpress/wp-content, and WordPress is trying to get around that problem by using the FTP. So we need to find the user that is running apache: Which gives: Now lets set the owner to the apache user Now you should be able to install plugins without having to set up an FTP.