Saturday, 1 June 2013

Little myepisodes userscript (modified for Firefox)

I have updated my myepisodes userscript to work with Firefox (link), which is apparently significantly different. It would be nice if at least all browsers had the same javascript standards... oh well.

To install, you need the Greasemonkey extension and then you can add this to it!

// ==UserScript==
// @name        myeps
// @include     http://www.myepisodes.com/*
// @version     1
// @grant       none
// ==/UserScript==

function myfunc() 
 {
  // get table by class name as array
 arr = document.getElementsByClassName('showname') 
 
  // loop over array
 for (var i = 0; i < arr.length; i++) {
   
    // get show name
   name = arr.item(i).textContent; 
   
    // add torrentz.net search
   str = "http://torrentz.eu/search?f=" + name.replace(/ /g,"+")
   
    // generate link
   link = ""+name+"" 
   
    // generate 720p link
   link_720p = ""+"(720p)"+""
   
    // update cell
   arr.item(i).innerHTML = arr.item(i).innerHTML + " " + link_720p; 
  }
 }

 // run after page has loaded
window.onload = myfunc;

Friday, 17 August 2012

Writing to NTFS on OS X

Out of the box, OS X only supports reading from NTFS drives. The following steps explain how to install and where to find drivers to write to NTFS drives as well. From my experience, this works well on all recent versions of OS X, from Snow Leopard to Mountain Lion.


Step 1

Install osxfuse. For use with NTFS-3G below, make sure to tick the option "Install MacFuse compatibility layer". This is the general framework for extending OS X with new file system drivers.


Step 2

Install NTFS 3g. This is the NTFS driver for use with osxfuse. Make sure to reboot after installing. Writing to NTFS drives should now be possible. 2010.10.2 is the latest version available at the time of writing.


Step 3 (optional)

In Lion and newer you might experience a timeout bug every 15 seconds. This can be remedied with this patch: fuse_wait. To uninstall, simply reinstall the NTFS-3G driver.


More information is available on the osxfuse wiki page.

Tuesday, 7 August 2012

Git difftool

To use your favourite visuall diff-tool with git:

git difftool -t xxdiff HEAD

Or 'HEAD' can be any particular file you want to diff.

git difftool

shows a list of programs it can use... if you happen to have them installed.

There is a thread on stackoverflow that details a few more advanced options, including setting up your own difftool, but I like this one the best, due to its simplicity.

Sunday, 29 July 2012

Speed up Mountain Lion

Some useful commands too speed up Mountain Lion I came across:

Disable smooth scrolling:
defaults write -g NSScrollAnimationEnabled -bool NO

Disable rubber banding (Sadly doesn't work everywhere, applications will need to restart after):
defaults write -g NSScrollViewRubberbanding -int 0

Reset rubber banding:
defaults delete -g NSScrollViewRubberbanding

Speed up the Dock animation:
defaults write com.apple.dock autohide-time-modifier -float 0.40;killall Dock

Reset Dock animation:
defaults delete com.apple.dock autohide-time-modifier;killall Dock

2D dock, because the indicators on the new 3D dock are absolutely impossible to see:
defaults write com.apple.dock no-glass -bool true


---

That said, last year I posted some Lion commands that still work too :)

Speed up Mission Control, by reducing the length of animations and reduce the delay before switching spaces:
defaults write com.apple.dock expose-animation-duration -float 0.15
defaults write com.apple.dock workspaces-edge-delay -float 0.15
killall Dock

You can modify the 0.15 to whatever you want, but this is my preferred settings.

Remove mouse acceleration (needs a relog):
defaults write .GlobalPreferences com.apple.mouse.scaling -1

---

Alternatively, you can have a look at this configuration file which is a nice collection of useful tweaks. Most of htem are pretty harmless, but it also contains some rather agressive ones I wouldn't want to touch (like turning off auto-quarantaine of downloaded files!).

Friday, 22 June 2012

OS X terminal alerts

Sometimes when I'm running a long command I want to be alerted when it's done, so I don't have to check the other window all the time to see if it's finished.

To do so, simply append printf '\a' to your command, like so:

sleep 5; printf '\a'

This will add a 'bell' character to the message, which will bounce the dock icon and add a little badge if it is out of focus, very useful!

Tuesday, 1 May 2012

Little myepisodes.com userscript


As a little project for today to learn some javascript, I decided to modify one of my favourite websites <a href="www.myepisodes.com">myepisodes.com</a> and make it a little bit more useful, by adding torrent links directly to the show list >:)


Down below is the userscript that will modify the contents of each cell and update the link from tvrage to a torrent search engine.

Installation for Opera:


Go to Preferences > content > javascript options > User javascript folder

Set a folder to put your user javascripts if you haven't, otherwise add this script to that folder.

// ==UserScript==
// @include http://myepisodes.com/*
// ==/UserScript==


function myfunc() 
 {
  // get table by class name as array
 arr = document.getElementsByClassName('showname') 
 
  // loop over array
 for (var i = 0; i < arr.length; i++) {
   
    // get show name
   var name = arr.item(i).innerText; 
   
    // add torrentz.net search
   var str = "http://torrentz.eu/search?f=" + name.replace(/ /g,"+")
   
    // generate link
   var link = ""+name+"" 
   
    // generate 720p link
   var link_720p = ""+"(720p)"+""
   
    // update cell
   arr.item(i).innerHTML = link + " " + link_720p; 
  }
 }

 // run after page has loaded
window.onload = myfunc;

Thursday, 8 March 2012

co-sort multiple python lists

I have written a small function to sort multiple lists. The values are sorted according to the values in the first list first, then the second etc. It can take any number of lists and returns the same number.


def cosort(*lsts):
 """Takes a any number of lists and sorts them based on the values of the first list."""
 tmp = zip(*lsts)
 tmp.sort()
 return zip(*tmp)

Little testing script:


from random import shuffle

def cosort(*lsts):
 """Takes a few lists and sorts them based on the values of the first list."""
 tmp = zip(*lsts)
 tmp.sort()
 return zip(*tmp)

a = range(10)
b = ['a','b','c','d','e','f','g','h','i','j']
c = ['j','i','h','g','f','e','d','c','b','a']

shuffle(a)

for i in range(len(a)):
 print a[i],b[i],c[i]

a,b,c = cosort(a,b,c)

print 
for i in range(len(a)):
 print a[i],b[i],c[i]