Posted (Updated ) in Uncategorized

JQuery UI supports a really handy feature called content via AJAX whereby when you click/display a tab, it will create a div element to load your content into, then perform the AJAX call and drop it in. But what happens when you want to specify the element to load the AJAX request into? Thankfully after a bit of digging around it’s not only possible, but pretty easy.

Here’s an example of AJAX load with JQuery UI Tabs:

1
2
3
4
5
6
7
<div id="tabs">
    <ul>
        <li><a href="ajax-content-1.html">Tab 1</a></li>
        <li><a href="ajax-content-2.html">Tab 2</a></li>
        <li><a href="ajax-content-3.html">Tab 3</a></li>
    </ul>
</div>

And here’s how you can specify the panel elements. Simply add an aria-controls attribute to your tab LI element that points to the ID of your target panel element:

1
2
3
4
5
6
7
8
9
10
11
<div id="tabs">
    <ul>
        <li aria-controls="my-first-tab"><a href="ajax-content-1.html">Tab 1</a></li>        <li aria-controls="my-second-tab"><a href="ajax-content-2.html">Tab 2</a></li>        <li aria-controls="my-third-tab"><a href="ajax-content-3.html">Tab 3</a></li>    </ul>
 
    <div id="my-first-tab"></div>    <div id="my-second-tab"></div>    <div id="my-third-tab"></div></div>

 

Demo

Read More »

Posted (Updated ) in Uncategorized

If you refresh or come back to a site often, it’s handy to have JQuery UI tabs remember which tab you were last on as you left. This simple script will handle that for you:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
jQuery(function($) {
    var index = 'qpsstats-active-tab';
    //  Define friendly data store name
    var dataStore = window.sessionStorage;
    var oldIndex = 0;
    //  Start magic!
    try {
        // getter: Fetch previous value
        oldIndex = dataStore.getItem(index);
    } catch(e) {}
 
    $( "#tabs" ).tabs({        active: oldIndex,
        activate: function(event, ui) {
            //  Get future value
            var newIndex = ui.newTab.parent().children().index(ui.newTab);
            //  Set future value
            try {
                dataStore.setItem( index, newIndex );
            } catch(e) {}
        }
    });
});

No other code is necessary. Add your tab markup as you normally would (Remember to give it a matching ID):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<div id="tabs">	<ul>
		<li><a href="#tabs-1">Tab 1</a></li>
		<li><a href="#tabs-2">Tab 2</a></li>
		<li><a href="#tabs-3">Tab 3</a></li>
	</ul>
	<div id="tabs-1">
		first tab
	</div>
	<div id="tabs-2">
		second tab
	</div>
	<div id="tabs-3">
		third tab
	</div>
</div>

 

Demo

Read More »

Posted in Uncategorized

If you have a bunch of MP4 files and want to convert to MKV without needing to reencode each file, this can be done with a super handy little tool called avconv.

Install avtools

You’ll need homebrew for this step.

1
brew install avtools

 

Do the conversion

I have a folder of MP4 files. To bulk convert them:

1
for f in *.mp4; do avconv -i "$f" -codec copy -map 0 "${f%.mp4}.mkv"; done

The above will create identically named MKVs next to your MP4s. Once you’re happy, just delete all your MP4s.

 

Bonus: Bulk merge ASS subtitles

If you have identically named ASS subtitle files next to your shiny new MKVs, you can bulk merge them using mkvmerge from mkvtoolnix with:

1
2
brew install mkvtoolnix
for f in *.mkv; do mkvmerge -o "./muxed/$f" "$f" "${f%.mkv}.ass"; done

Thanks to user MestreLion for his answer on AskUbuntu.

Read More »

Posted in Uncategorized

Spent an hour grappling with this last night. Here’s how to get the PS3 controller working on Yosemite.

Pair the PS3 controller with your mac:

It seems Yosemite’s bluetooth device list is a little buggy and devices can show in the top bar bluetooth drop down but not in the system configuration bluetooth page for some devices. The PS3 controller is one of these devices.

After a while digging around the net I found some working instructions thanks to user DillingerEscapeHam on Reddit:

  • Plug PS3 controller into laptop
  • See Bluetooth device in status bar menu (though just a bt address, not named “Playstation Controller”)
  • Click to Connect device in status bar menu
  • Open System Preferences
  • No device listed
  • Unplug controller
  • Attempt to turn controller on without cable (no response, no flashing lights)
  • Controller was now listed correctly as Playstation controller in status bar menu and was listed as Connected
  • Disconnect controller via menu.
  • Unplug and start controller with PS button. It connects correctly.

After you get the controller paired you’ll need either a game that supports the controller or an app like Joystick Mapper (paid) or Enjoy2 (free) which allows binding of keyboard keys or mouse buttons/swipes to controller events. I recommend forking out the $6 for Joystick Mapper, as I’ve had issues with sensitivity on Enjoy2.

That should be all there is to it. I’m currently playing Hearthstone with a PS3 controller on Yosemite just fine!

Read More »

Posted (Updated ) in Uncategorized

It’s a pretty common problem. You have a file titled firefly – 02 – the train job.mkv when it should be Firefly – 02 – The Train Job.mkv. It’s slow and arduous to rename manually especially if you have a lot of files so below is a single command to do it all for you!

1
rename "s/ ([a-z])/ \U\1\E/g" *.mkv

In the above example:

  • \U means uppercase
  • \1 means the first match (in our case that’s the first alpha after a space)
  • \E means end uppercase
  • *.mkv applies the rename command to all files ending in .mkv in the current folder.

Thanks to akf from stackoverflow for his helpful answer on this one.

Read More »

Posted (Updated ) in Uncategorized

It seems OSX 10.9 comes with a “feature” (previously off by default) whereby after 2 minutes on battery (the default display off time) the machine goes to sleep. This of course kills the wi-fi resulting in constant dropping of SSH connections, reconnection to IM clients (spamming friends) and a host of other internet related issues. It was badly thought out, badly implemented and just an all around bad choice.

In previous iterations of OSX there were two sliders; one for how long before putting the computer to sleep and the other for putting the display to sleep. Here’s a screenshot of the Energy Saver options in 10.9. Noticed the two have been unhelpfully merged:

Energy Saver Preferences in OS-X 10.9

 

Fixing this behavior is thankfully very simple and requires only a single terminal command:

1
sudo pmset -a sleep 0

Here are my power management settings after the change:

$ pmset -g
Active Profiles:
Battery Power		-1*
AC Power		-1
Currently in use:
 standbydelay         10800
 standby              1
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 darkwakes            0
 gpuswitch            2
 disksleep            10
 sleep                0
 autopoweroffdelay    14400
 hibernatemode        3
 autopoweroff         1
 ttyskeepawake        1
 displaysleep         2
 acwake               0
 lidwake              1

And with that you should be back to having a properly functioning laptop. If you ever need to revert the change for whatever reason, use:

1
sudo pmset -a sleep 1

Read More »

Posted (Updated ) in Uncategorized

I just installed Ubuntu 13.04 in Virtualbox 4.2.16 and found much to my annoyance that the VM thought my mouse was a little higher than it actually was:

Ubuntu thinks my mouse is a little higher than it actually is

It turns out this is caused by having 3D acceleration turned on in VM Settings – Display window. After doing a bit of sleuthing I came across a forum post on virtualbox.org with a command that did the trick nicely.

Simply open a terminal and run

VBoxManage setextradata global GUI/Customizations noStatusBar

Restart your VM and voila. Perfect mouse working with 3D acceleration!

Mouse Y-Axis working as it should

Read More »

Posted (Updated ) in Uncategorized

Disclaimer: The details of this post are shamelessly ripped from phatness.com. All credit to those guys, I just wanted a copy for myself for future reference.


On every OS ever, Home, End, Pg Up and Pg Down keys work like so:

- Home -> move the cursor to the beginning of the line
- End -> move the cursor to the end of the line
- Pg-Up -> move the cursor up the length of the viewport
- Pg-Dn -> move the cursor down the length of the viewport

But OSX in all its infinate wisdom decided that doesn’t make sense. Instead they should work like so:

- Home -> move (nothing, not even the cursor, just your view) to the beginning of the DOCUMENT
- End -> move (nothing, not even the cursor, just your view) to the end of the DOCUMENT
- Pg-Up -> move (nothing, not even the cursor, just your view) up the length of the viewport
- Pg-Dn -> move (nothing, not even the cursor, just your view) down the length of the viewport

Now I’m not one to criticise… but that’s stupid and anyone who likes it is stupid 😉

 

How to Fix

There’s a really useful open source utility out there called DoubleCommand which is highly recommended and I’m sure broadly used. If you want a non-application solution there are also some config files to edit to get the job done.

Most Applications

Create a file
/home/<username>/Library/KeyBindings/DefaultKeyBinding.dict and add the following:

{
    "\UF729"  = "moveToBeginningOfLine:";
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    "\UF72B"  = "moveToEndOfLine:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";
    "\UF72C"  = "pageUp:";
    "\UF72D"  = "pageDown:";
}

Terminal

Terminal preferences

Terminal preferences

Open Terminal – Preferences – Settings – Keyboard. Edit each of the following setting their action to ‘send string to shell’.

Key		Escape Sequence
 
Home		\033[1~
End		\033[4~
Page Up		\033[5~
Page Down	\033[6~

Now open /home/<username>/.inputrc and add:

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On

Other notes

Restart your machine for changes to take affect. Restarting individual applications also works if you can’t restart for whatever reason. I hear Firefox needs its own changes – if you happen to know what those are comment below and I’ll add them in.

Read More »

Posted in Uncategorized

SublimeCodeIntel is perhaps the most useful and heavily installed package for Sublime Text but it’s also very difficult to get working. The most common issue people run into is the dreaded endless

Info: processing `PHP': Please wait…

This can be fixed by navigating to the SublimeCodeIntel package directory and running build.sh. For build.sh to compile we first need to install two things: pcre and XCode Command Line Tools. Annoyingly this is around 1.6GB of files!

 

Installing XCode Command Line Tools

Head over here and click View in Mac App Store. Hit install and watch your progress in the Purchases tab.

Once installed open it up and go to XCode – Preferences – Downloads – Components and install Command Line Tools.

 

Installing pcre

This little script is required by the scintilla package of SublimeCodeIntel. First install MacPorts then run:

sudo port install autoconf
sudo port install pcre
sudo cp /opt/local/include/pcre.h /usr/include/

You’re done! Navigate to the SublimeCodeIntel package directory and run sh src/build.sh. If all goes well at the end of compilation you’ll see a done! message. Restart Sublime Text and you’re good to go.

Read More »

Posted (Updated ) in Uncategorized
Removed 'Clear Scrollback' shortcut

Removed ‘Clear Scrollback’ shortcut

This would have to be far and away the most annoying ‘feature’ of Pidgin.

In just about every web browser, Ctrl+L is used to highlight the URL bar allowing easy navigation via the keyboard. In pidgin it’s used to clear the scrollback of the active window. As a web developer I’m always hitting Ctrl+L in the browser however every now and then I won’t take notice to which window is active on my desktop at the time and use it while Pidgin is active, clearing out the conversation I’m having with my contact at the time. Frustrating!

There was a bug post here about it but as usual the devs don’t particularly care and instead just pointed to their FAQ page. For convenience here’s how you remove the shortcut:

Open ~/.purple/accels and change

; (gtk_accel_path "<PurpleMain>/Tools/Preferences" "<Primary>p")

to

(gtk_accel_path "<main>/Conversation/Clear Scrollback" "")

Remember to remove the semicolon at the start of the line!

 

Read More »

Page 1 of 3123