Adding Additional IPs to Linode Servers

Update: I no longer use Linode, but I had this draft laying here, so decided to publish anyhow.


If you have an additional IP address on your Linode Ubuntu box, you'll need to add it to your /etc/network/interfaces file, so open that up using nano or a similar tool, you'll need to add eth0:1 to the auto line, then an iface block, so that it looks similar to this:

# The loopback network interface
auto lo eth0 eth0:1 eth0:2
iface lo inet loopback

# The primary network interface
iface eth0 inet static
  address 85.159.209.124
  netmask 255.255.255.0
  gateway 85.159.209.1

iface eth0:1 inet static
  address 109.237.26.62
  netmask 255.255.255.0

Save that file, restart networking and then try pinging your new IP address.

Update: I no longer use Linode, but I had this draft laying here, so decided to publish anyhow. If you have an additional IP address on your Linode Ubuntu box, you'll need to add it to your /etc/network/interfaces file, so open that up using nano or a similar…

Read More

Running Ubuntu Landscape-Server in Docker on Ubuntu 14.04

If you use a few Ubunutu servers then you may have come across their management product called Landscape. It's a pretty complex solution to set up, however with advances in Docker and useful work from the UK Home Office, there is now a Docker image you can use to run it, take a look at this Github repo for more information.

If you use a few Ubunutu servers then you may have come across their management product called Landscape. It's a pretty complex solution to set up, however with advances in Docker and useful work from the UK Home Office, there is now a Docker image you can use to run…

Read More

Inspecting SQLite Databases in Appcelerator Titanium Projects

If you're using SQLite for your project and you'd like to query the database directly. For Android based devices or emulators, you can do the following:

You'll need to remember your database name, if you're using commonJS, you can do something similar to:

exports.getDatabase = function() {
    return Ti.Database.open('app.db');
};

Next, find out what devices you have connected using adb:

adb devices

This will return a list similar to this:

List of devices attached 
10.0.0.2:5555    device

Next, use the ADB shell command to boot into the device:

adb -s 10.0.0.2:5555 shell

This will drop you into a shell on the device. Next, find the database file. In the first code snippet here, you can see our database name is app.db, so we'll use a combination of find and grep to find the file on the device:

cd /; find * | grep app.db

And this will return the SQLite file and it's journal, like this:

root@vbox86p:/ # cd /; find * | grep app.db
data/data/com.example.audit/databases/app.db
data/data/com.example.audit/databases/app.db-journal

Now you can use the CLI tool to open the database, like so:

sqlite3 data/data/com.example.audit/databases/app.db

And you'll be dropped into the CLI tool. You can get a list of tables by using .tables and exit the program via .quit.

The reference for this post came from this wonderful blog post.

If you're using SQLite for your project and you'd like to query the database directly. For Android based devices or emulators, you can do the following: You'll need to remember your database name, if you're using commonJS, you can do something similar to: exports.getDatabase = function() { return Ti.Database.open(…

Read More

Virtualmin Migrated Site Error 'AuthGroupFile'

I noticed with the Virtualmin export feature that the Apache htpasswd sometimes doesn't carry through when you import the package, you'll end up with an error similar to this:

[Tue Jan 19 10:54:22.551737 2016] [core:alert] [pid 28447] [client 1.2.3.4:55007] /home/website/public_html/.htaccess: Invalid command 'AuthGroupFile', perhaps misspelled or defined by a module not included in the server configuration

To fix this error, you'll need to enable the authz_groupfile module, for example on Ubuntu, you can use this command:

a2enmod authz_groupfile

Restart Apache and it'll start working as usual again.

I noticed with the Virtualmin export feature that the Apache htpasswd sometimes doesn't carry through when you import the package, you'll end up with an error similar to this: [Tue Jan 19 10:54:22.551737 2016] [core:alert] [pid 28447] [client 1.2.3.4:55007] /home/website/public_…

Read More

Find Your Most Used Bash Commands

If you want to see what your most used commands are within Terminal (will work on Linux too). You can run this command:

history | awk '{print $2}' | sort | uniq -c | sort -rn | head

If you want to see what your most used commands are within Terminal (will work on Linux too). You can run this command: history | awk '{print $2}' | sort | uniq -c | sort -rn | head…

Read More

Running Ghost in Docker on Ubuntu 14.04

If you're interested in running Ghost for your blog inside Docker. It's pretty simple to get it up and running.

docker run --name=ghost --restart=always -d -p 123.123.123.123:80:2368 -v /docker/data-volumes/ghost:/var/lib/ghost ghost

I found it better to use a data volume with a mount point of /var/lib/ghost to get it running. The following links were useful in getting up and running:

https://allaboutghost.com/deploying-ghost-with-docker/
https://github.com/docker-library/ghost/issues/7

If you're interested in running Ghost for your blog inside Docker. It's pretty simple to get it up and running. docker run --name=ghost --restart=always -d -p 123.123.123.123:80:2368 -v /docker/data-volumes/ghost:/var/lib/ghost ghost I found it better to use a data…

Read More

Virtualbox does not start on Mac OSX

If you've recently upgraded your Mac to OSX El Capitan and you have an issue where Virtualbox has decided to no longer work, try this:

for bin in VirtualBox VirtualBoxVM VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT VBoxHeadless; do
    sudo chmod u+s "/Applications/VirtualBox.app/Contents/MacOS/${bin}"
done

Found via this link on StackOverflow.

If you've recently upgraded your Mac to OSX El Capitan and you have an issue where Virtualbox has decided to no longer work, try this: for bin in VirtualBox VirtualBoxVM VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT VBoxHeadless; do sudo chmod u+s "/Applications/VirtualBox.app/Contents/MacOS/${bin}" done Found via this link…

Read More

Fix: Titanium & GenyMotion Player Not Found

In the recent update of GenyMotion (Android Emulator) there's a change which breaks its compatibility with Titanium Studio. You'll need to open Terminal and create a symlink to fix it, start by opening Terminal and running:

cd /Applications/Genymotion.app/Contents/MacOS/

and then type:

ln -s player.app/Contents/MacOS/player

Shut Titanium Studio and GenyMotion both down and then restart Titanium Studio and it should work as usual after that point.

In the recent update of GenyMotion (Android Emulator) there's a change which breaks its compatibility with Titanium Studio. You'll need to open Terminal and create a symlink to fix it, start by opening Terminal and running: cd /Applications/Genymotion.app/Contents/MacOS/ and then type: ln -s player.app/Contents/…

Read More

Real IP for Nginx / Laravel Forge when using Cloudflare

If you use Cloudflare, you'll need to configure Nginx to provide the real IP addresses, you can do this by installing

apt-get install nginx-extras

Then edit /etc/nginx/nginx.conf and within the http block add:

#CloudFlare
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20; 
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;
real_ip_header CF-Connecting-IP;

Save the file, restart Nginx and then you'll see the real user IP address within your app. You can read more about this on Cloudflare's website.

Remember to keep an eye on the Cloudflare IP list for changes.

If you use Cloudflare, you'll need to configure Nginx to provide the real IP addresses, you can do this by installing apt-get install nginx-extras Then edit /etc/nginx/nginx.conf and within the http block add: #CloudFlare set_real_ip_from 199.27.128.0/21; set_real_ip_from…

Read More

Think Different.


Jobs' Stanford speed is something I always find interesting to watch:

Jobs' Stanford speed is something I always find interesting to watch:…

Read More

Git Commit with A Random whatthecommit.com Message

Probably shouldn't advise people to do this:

git commit -m `curl --silent http://whatthecommit.com/index.txt`

That'll commit your current state with a random message from the fantastic whatthecommit.com website.

Probably shouldn't advise people to do this: git commit -m `curl --silent http://whatthecommit.com/index.txt` That'll commit your current state with a random message from the fantastic whatthecommit.com website.…

Read More

Docker + rtorrent = Docktorrent

I download a lot of linux images, by far the quickest way is via torrent. Recently discovered a nice implementation of rtorrent in a Docker image, via docktorrent, simple enough to run:

docker run -itd \
    --restart=always \
    --dns 8.8.8.8 \
    -p 31405:80 \
    -p 45566:45566 \
    -p 9527:9527/udp \
    -v /path/to/mount/rtorrent:/rtorrent \
    -e UPLOAD_RATE=1024 \
    kfei/docktorrent

The 31405 is the public facing port for the web interface, make sure that you forward both 9527 and 45566 as it'll need those to run.

I download a lot of linux images, by far the quickest way is via torrent. Recently discovered a nice implementation of rtorrent in a Docker image, via docktorrent, simple enough to run: docker run -itd \ --restart=always \ --dns 8.8.8.8 \ -p 31405:80 \ -p 45566:45566 \ -p 9527:…

Read More

Prevent OSX From Opening Photos or Image Capture Automatically

Came across this OSX tip recently which will prevent Photos or Image Capture:

defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool YES

Came across this OSX tip recently which will prevent Photos or Image Capture: defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool YES…

Read More

Handling HTML Checkboxes with a default value

I've used this tip myself previously, it's useful if you want to set a default for a checkbox, such as false:

Add an input of type "hidden", and set the value to false before you declare the one with your true value, so for example, you could do this:

<input type="hidden" name="agree_to_terms" value="false">
<input type="checkbox" name="agree_to_terms" value="true">

There was this blog post that reminded me of this.

I've used this tip myself previously, it's useful if you want to set a default for a checkbox, such as false: Add an input of type "hidden", and set the value to false before you declare the one with your true value, so for example, you could do this: <…

Read More

Recursive FTP Get with wget

Pretty useful for downloading everything in an FTP account:

 wget -m --tries=0 --continue --server-response --timeout=0 --retry-connrefused ftp://username:[email protected]

Pretty useful for downloading everything in an FTP account: wget -m --tries=0 --continue --server-response --timeout=0 --retry-connrefused ftp://username:[email protected]

Read More

Type Hinting in PHP7

I'm happy that PHP7 has finally been released, I've been wanting to correctly return type hint for such a long time. You can now do this comfortably:

<?php
declare(strict_types=1);

function getAge(int $age) : int {
    return $age;
}

echo var_dump(getAge(43));
?>

But more usefully, you can type hint interfaces to guarantee the classes you get returned (which is actually far, far more useful and beneficial).

I'm happy that PHP7 has finally been released, I've been wanting to correctly return type hint for such a long time. You can now do this comfortably: <?php declare(strict_types=1); function getAge(int $age) : int { return $age; } echo var_dump(getAge(43)); ?> But more usefully, you…

Read More

Laravel Blade Set Class by Current Route Name

If you need to set an active class on a list item for a menu, you can do something like this below:

<li class="{{ (Route::getCurrentRoute()->getAction()["as"] == "dashboard.index") ? 'active' : '' }}"><a href="{{ route("dashboard.index") }}">Home</a></li>
<li class="{{ (Route::getCurrentRoute()->getAction()["as"] == "reports.index") ? 'active' : '' }}"><a href="{{ route("reports.index") }}">Reports</a></li>
<li class="{{ (Route::getCurrentRoute()->getAction()["as"] == "settings.index") ? 'active' : '' }}"><a href="{{ route("settings.index") }}">Settings</a></li>

This will only work if you name all your routes, it could easily be adjusted to handle non-named routes as well.

If you need to set an active class on a list item for a menu, you can do something like this below: <li class="{{ (Route::getCurrentRoute()->getAction()["as"] == "dashboard.index") ? 'active' : '' }}"><a href="{{ route("dashboard.index") }}">Home</a></li>…

Read More

Google Search Quality Ratings

Interesting new document provided by Google which details their search quality ratings. It's nice to see them actually release something like this officially.

Interesting new document provided by Google which details their search quality ratings. It's nice to see them actually release something like this officially.…

Read More

Larry Wall on Triangulation

I really enjoyed listening to the creator of Perl talk about his work on a recent episode of Triangulation - thought it was worth noting here as a reminder.

I really enjoyed listening to the creator of Perl talk about his work on a recent episode of Triangulation - thought it was worth noting here as a reminder.…

Read More