Justin Kelly various ramblings

Google Plus photos extension for non Chromebook Pixels

Earlier today Google released a new Chrome extension for Google+ Photos that only works on the new Chromebook Pixel.

I’ve been after the functionality of this extension for my non-Pixel PCs/laptops. So quickly unminifed the source code, removed the pixel only limiation and loaded in Chrome.

The extension works fine - but may be missing some features that are in the Pixel version.

I’ve uploaded this extension to GitHub but won’t be uploading to the chrome webstore or distributing a .crx for it. Installation instructions are below.

https://github.com/justinkelly/google_plus_photos

ReadMe from GitHub

Status

  • The original extensions javascript has been unminified and adjusted so that it not starts on a non Chromebook Pixel

Install

  • Download
  • In Chrome open chrome://flags and Enable ‘Experimental Extensions APIs’
    • refer screenshot below
  • In Chrome Manage Extensions page enable ‘Developer mode’
    • refer 1. in screenshot below
  • Then click ‘Load unpacked extension’ and choose the folder for this git repo

Use

Once installed you can now launch Google+ Photos from your Chrome apps menu, refer below screenshot of startup in Win 7

Auto select all text with jQuery

If you’re stuck using an older version of jQuery ( < 1.9 ) and need to auto select all text in a dynamically created input field you can combine .select() with .live() to make it work.

Refer the javascript code and demo below to see it in action.

Code

Result

Twitter sidebar for Octopress

Since Twitter has decommissioned the old Twitter API, the Twitter sidebar in Octopress based blogs has stopped working. A few blogs have started to add the new Twitter widget to the sidebar but its quite garish.

My solution just copies the Google Plus sidebard and re-formats for Twitter - just refer the bottom right in the sidebar of this page to see it in action

New sidebar file

Create a new file source/_includes/custom/asides/twitter2.html

CSS

Update the sass/partials/sidebar/_googleplus.scss and add in

.twitter2
{
    @extend .googleplus;
}

Note: I’m not using the googleplus class for the new twitter sidebar as it causes problem for my Octopress / Google Plus comments javascript

Config

In _config.yml add the new sidebar file to the default_asides

default_asides: [custom/asides/twitter2.html, ...

Remove the original asides/twitter.html from the default_asides: line

URL rewriting with Nginx and Vanilla forum

Having just migrated a number of sites from Apache to the Nginx webserver here’s the below Nginx config to get URL rewriting working correctly with Vallia Forums

location /forum {try_files $uri $uri/ @forum;}
location @forum {rewrite ^/forum(.+)$ /forum/index.php?p=$1 last;}

This assumes you already have the configs to get PHP working with Nginx and have the forum installed at /forum

A number of forum posts detail a much more complex way to get Vanilla working - but as long as you have PHP running fine all you need is the above config and it’ll work

Migrate MySQL to MariaDB in Ubuntu 12.10

If you have MySQL installed on an Ubuntu (12.10) server and are looking to migrate to MariaDB , here are the steps to migrate over to MariaDB 10.

MariaDB is a drop-in replacement for MySQL - you don’t need to export then import your databases - it just works

Remove MySQL

sudo apt-get install software-properties-common
sudo apt-get remove mysql-server
sudo apt-get remove mysql-server-5.5
sudo apt-get remove mysql-server-core-5.5

Add MariaDB repository

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirror.aarnet.edu.au/pub/MariaDB/repo/10.0/ubuntu quantal main'
sudo apt-get update
sudo apt-get install mariadb-server

Check that its worked

mysql --version

If the migration was a success it’ll says the distribution of mysql is MariaDB - similar to below

mysql  Ver 15.1 Distrib 10.0.3-MariaDB, for debian-linux-gnu (i686) using readline 5.1

Simple javascript function to format the date as YYYY-MM-DD

Tired of concatenating Date.getYear() Date.getMonth(), and Date.getDay() to format todays date in Javascript?

Heres a simple javscript function I use to output the date in YYYY-MM-DD format

Code

Result

How to fix Ubuntu unlock wireless/Gnome keyring issues

Even if you manage to get wireless/wifi working fine in Ubuntu, one annoying issue (if you have auto login set) will be that the ‘Gnome keyring’ will keep prompting you for a password every time you login or wake from hibernation - so that it could connect to my Wi-Fi network.

The solution is simple but one you shouldn’t have to worry about:

  • Right click the Network Manager icon in your panel
  • Select Edit Connections, and switch to the Wireless tab
  • Select the connection you want to work with and click the Edit button
  • Check the boxes for Connect Automatically and Available to all users.

2 decimal places in Javascript/jQuery

I always forget how to format a number as 2 decimal places in Javascript/jQuery, its extremely simple, just use the unmemorable toFixed() function - refer below is an example

    $("#total"+row_number).html($total,toFixed(2));

Ubuntu Numlock

If your using a smaller Ubuntu or Debian based distro (lubuntu, solusOS, etc..) you’ll often find that numlock on the keyboard isn’t turned on my default. Just paste the below commands into the commandline and numlock will be on by default.

    sudo apt-get update
    sudo apt-get -y install numlockx
    sudo sed -i 's|^exit 0.*$|# Numlock enable\n[ -x /usr/bin/numlockx ] \&\& numlockx on\n\nexit 0|' /etc/rc.local

Commandline Dropbox client

Looking for a simple way to upload files from your server to Dropbox without doing a full sync?

By using the script from Andrea Fabrizi your easily upload or download individual files to and from Dropbox from the commandline

Setup

Download the script from github with wget

wget https://raw.github.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh

Make it executable

chmod +x dropbox_uploader.sh

Run the dropbox_uploader script ./dropbox_uploader.sh and it’ll print out the below:

This is the first time you run this script.
Please open this URL from your Browser, and access using your account:

-> https://www2.dropbox.com/developers/apps

If you haven't already done, click "Create an App" and fill in the
form with the following data:

App name: MyUploader888
Description: What do you want...
Access level: App folder or Full Dropbox

Now, click on the "Create" button.

When your new App is successfully created, please type the
App Key, App Secret and the Access level:

# App key: 

Open up the url https://www2.dropbox.com/developers/apps in your browser, sign into Dropbox and click the Create an app button

Fill in the app name as listed by the script, select ‘Core’ and ‘App folder access’ (this will create a folder call /App/MyUploader888 in your Dropbox director. If you want to access all files in your Dropbox select ‘Full Dropbox’

Dropbox will now show you your API details for this app, get the ‘App key’ and paste it into commandline Then paste in the ‘App secret’ when requested

# App key: jxxxxxxxxxxxxxxp
# App secret: sxxxxxxxxxxxxxx4
# Access level you have chosen, App folder or Full Dropbox [a/f]: 

Select the access level and it’ll provide you with link to verify the app.

https://www2.dropbox.com/1/oauth/authorize?oauth_token=nxxxxxxxxxxxxxxf

Open the link in your browser and Allow the app access

Your now setup to upload/download individual files from the command line to and from Dropdox

Usage

To upload a file from your server to Dropdox just run

./dropbox_upload.sh upload myfiles.zip

If you have selected the Full Dropbox access you can sepecify the folder location to upload to

./dropbox_upload.sh upload /some/folder/indropbox.com/myfiles.zip

Other commands available are download which uses the same style as the uppload command, delete,list,info and unlink