Advice for smart (running) girls on online privacy…

So not to be a ‘creepy Steve’  a la Smart Girl’s Guide to Online Privacy (fantastic read!), but another piece of advice I’d leave for the privacy-conscious who post their photos with their running bib’s on social media (especially dating sites).

If you go to running competition results pages, like the one for the Sydney Blackmores Running Festival (not just limited to this competition – pretty much all running events use similar results websites), you’ll see that all you need to find out someone’s name, age and in some cases suburb is their bib number… So as always be wary of what you post online!

Hack something first: a lesson in input validation

I wanted to write up a lesson I learnt from a certain app (won’t mention which one here, even though the vulnerability was reported and patched rather quickly!) that offered in-app currency if you sent your friends an SMS from your phone’s contacts to invite them to the service.

I found that if you gave it a fake number, the app would give you the free credits, without checking if it had a 20 digit number!! So always check that you get valid input: even if it’s from a place you’d assume that would be valid like a phone’s contacts.

Installing LeJOS for Mindstorms NXT on Windows 8

So I had to deviate a little from the installation instructions to get LeJOS working on Windows 8, especially on a 64 bit operating system:

  1. Install a 32-bit version (ie x86) of Java JDK from the Oracle website:
    1. http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Install the RobotC NXT drivers from the RobotC site, more than likely the 64bit version:
    1. http://www.robotc.net/download/lego/
  3. Install the latest LeJOS .exe version of the setup program from Sourceforge and the JDK and the drivers should be detected automatically!
    1. http://sourceforge.net/projects/lejos/files/lejos-NXJ/

So far it’s worked for me on a Surface Pro 3 and a Macbook Pro.

A basic setup for Log4j when using Freemarker

So I’m using Log4j in a project I’m working on, and I kept getting warnings from log4j when starting to use Freemarker…

log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

In order to resolve these issues, I had to import the following classes:

import freemarker.log.Logger;
import org.apache.log4j.BasicConfigurator;

…And run the following commands:

Logger.selectLoggerLibrary(Logger.LIBRARY_LOG4J);
BasicConfigurator.configure();

Happy logging and templating!!

Monitoring a shell script (external job) running on CentOS with Jenkins

So I wanted to setup Jenkins external monitoring on a web server I have on a Centos VM, and I found a combination of these three blog posts worked!

Firstly, run the following commands :

wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
yum -y install jenkins

… or download the RPM at http://pkg.jenkins-ci.org/redhat/ and run “rpm -Uhv jenkinx*.rpm”

  • run the following:
cd /usr/lib/jenkins
unzip /usr/lib/jenkins/jenkins.war
  • Install OpenJDK while you’re at it.
  • Go to Jenkins and create a “Monitor an external job” called “New Job”
* Create an environment variable by 
$export JENKINS_HOME=http://jenkins_host:8080 , replacing "jenkins_host" with the server running Jenkins
  • To have Jenkins monitor a script, run a command like the following…
java -jar /usr/lib/jenkins/WEB-INF/lib/jenkins-core-*.jar “New Job” /path_to/myreport.sh 2>&1 > /dev/null

And you can put that command in a cron job too!

Installing cmdbuild on Ubuntu 14.04 LTS

So the instructions on the Ubuntu wiki are good, but I found I had to make some slight changes in order to get it to work on the latest (at this time!) Ubuntu LTS version (14.04). I’m not too sure how secure the server is though… comments anyone? Here are the instructions I followed to get it to work

  • Install ubuntu on your platform (I’m using VirtualBox).
  • Start up the terminal app.
    • Screen Shot 2014-08-26 at 11.02.46 am
  • Install Apache Tomcat by running:
sudo apt-get update
sudo apt-get install tomcat6 tomcat6-docs tomcat6-admin

“tomcat6-docs” is optional.

  • Edit the tomcat user file:
sudo vi /etc/tomcat6/tomcat-users.xml

…comment out the “<!– …–>” at the bottom of the <tomcat-users> tag. Copy and paste one of the <user> tags to “add a new user” with the “manager” role.

  • Edit the tomcat settings file:
sudo vi /etc/default/tomcat6

…uncommenting the “TOMCAT6_SECURITY=no” setting so we explicitly don’t use the Java security manager iaw the original instructions. I’m inclined to uncomment the “LOGFILE_DAYS=14” line to keep logfiles to:

/var/log/tomcat6
  • Install postgresql and pgadmin3 (note to start pgadmin3 once it’s installed, just search for it in the Unity search in the top left hand corner).
sudo apt-get install postgresql
sudo apt-get install pgadmin3
  • Set a password for the postgresql postgres user, replacing “INSERT_PW_HERE” with your password.
sudo -u postgres psql template1
ALTER USER postgres WITH PASSWORD 'INSERT_PW_HERE';
\q
  • Download the latest JDBC (at writing time, given it’s version 9.3.5 of postgresql and 1.7.0 of Java we’d need version JDBC41 – you can find this out by running “psql –version” and “java -version” respectively) and place it in the /usr/share/tomcat6/lib folder.
  • Download and extract the cmdbuild to a folder, and move the <>/extras/tomcat-libs/x.y/* to the /usr/share/tomcatZZ/lib folder, where x.y is the tomcat version being used (6.0 for me), and “tomcatZZ” is the folder holding Tomcat ie tomcat60 for me.
  • Rename the “cmdbuild.x.y.z.war” to just “cmdbuild.war”
  • Start Tomcat with the following command (“tomcat6” might change):
sudo /etc/init.d/tomcat6 start
  • Navigate to http://localhost:8080/manager/html , logging in with your credentials you set before in the tomcat-users.xml file.
  • Under “WAR file to deploy”, select the “cmdbuild.war” and “Deploy” it. This takes a few seconds.
  • Go to http://localhost:8080/cmdbuild oncethepageis loaded and theWARfileis deployed. You should see the following settings page:
    • Screen Shot 2014-08-26 at 4.09.24 pm
  • Enter in the following parameters for the database settings, tailoring when you like (especiallyfortheCMDBuild database.
    • Screen Shot 2014-08-26 at 4.10.44 pm
  • Thenyouwill be prompted to log in with the username “admin” and password “admin” for the demo distribution.
    • Screen Shot 2014-08-26 at 4.12.12 pm

Exporting taxonomy terms in Drupal 7

Firstly you’ll need to install the UUID Features (https://drupal.org/project/uuid_features) , Features (https://drupal.org/project/features) and UUID (https://drupal.org/project/uuid) modules.

Once all those modules are enabled, go to example.com/admin/config/content/uuid_features (or on your administration menu go to Administration –> Content Authoring –> UUID Features Integration, and under “Exportable Taxonomy term bundles” check the boxes for the relevant taxonomy terms.

Go to your features export page at example.com/admin/structure/features/ (or on your administration menu go to Administration –> Structure –> Features), create/recreate the feature and you’ll see “Taxonomy Terms” listed.

Happy exporting!!

Converting ESRI Shapefiles to CSVs using QGIS

So I’ve been trying to export the data from the AMSA (the digital data from https://www.operations.amsa.gov.au/Spatial/DataServices/DigitalData which contains about 1 million data points per month). And I found a way to export the shapefile’s data to a CSV file :D!

  1. Install QGIS from Kyngchaos for Mac users!! http://www.kyngchaos.com/software/qgis
  2. Drag the “.shp” and drop it into the “Layers” panel on the left hand panel
  3. Click on the layer and then on the menu item, and select Layers –> Save As
  4. Select “Comma Separated Values”, and select a file to save to. It might probably pay to check which projection you’re saving it to, but I found it’s smart enough to use the same projection the source file uses.
  5. Click OK.

A HTML template for Drupal module reviews

…. Because I am so painfully lazy, here is a template for reviewing Drupal modules following the guidance at https://drupal.org/node/1587704.

<strong>Issues Summary</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Basic application checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Repository checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Security review</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Licensing checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Documentation checks</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>Coding standards</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

<strong>API and best practices review</strong>
<ul>
<li></li>
<li></li>
<li></li>
</ul>

Accessing Drupal sandbox projects via the web

EDIT: OK so there’s an even easier way to do this…  Click on “Repository viewer” on the right hand menu under the “Development” heading

Screenshot 2013-12-24 14.52.26

OK, so for some reason when I want to view Drupal modules I can’t access them via the usual “git clone (git_url_here)” command.

So instead the source code can be accessed by going to drupalcode.org … but how? Good question :D!

As an example, let’s say you want to check out my sandbox project https://drupal.org/sandbox/ajosephau/2105389 ?

Go to http://drupalcode.org/sandbox/ajosephau/2105389.git

So the format is http://drupalcode.org/sandbox/”USERNAME”/”GIT_REPO_ID”.git from the URL.

To download a particular version, click on the URL “snapshot” for a particular revision.