User script to add information to draftfantasyfootball.co.uk transfers page

I have no clue about football, yet I’m in a fantasy league. I’ve written this user script to pull injury information from ‘http://www.physioroom.com/news/english_premier_league/epl_injury_table.php’ and the likely lineups from ‘http://www.fantasyfootballscout.co.uk/team-news/’.

Injury information is shown with an ‘Injured’ badge in the status column. Players that are expected to play in the next match are highlighted by adding a black border and black text to the player’s position symbol.

Requires Tampermonkey

fpldraft

Running a Canon CanoScan FS 2710 on Windows 10

…Isn’t easy.  

I have an Adaptec AHA-2940 SCSI controller, which doesn’t have any drivers available on their support site for x64 systems.  I found them on a forum somewhere (perhaps not overly trust worthy): AdaptecAic78xx.  They have been taken from a Windows 7 x64 system apparently.

These aren’t signed, so you have to disable driver signing:

  1. Hit the start button, power and then shift-click restart.  
  2. Select “Troubleshoot”->“Advanced options”->“Windows Startup Settings”->restart.  
  3. When the system starts up you get a selection of options.  Option 7 disables driver signing requirements.  

Then you can go to device manager, update the driver, go to “have disk” and select the folder extracted from the zip linked above.

The next bit isn’t all that intelligent, but works.  Go buy VueScan, it seems to have drivers for every scanner under the sun.  

Spotify web client minimized mode bookmarklet

I was playing around with casting spotify from Chrome to Chromecast, and disliked the cluttered interface here’s a bookmarklet that can be dragged to the bookmarks bar.  When clicked, it toggles the interface to show a more minimal look.  

SpotMini

spotSm

Here’s the code:

if (typeof spotTgShown == 'undefined') {
var spotTgShown = true;
};

function spotTg() {
if (spotTgShown){
spotTgShown = false;
spotSm();
} else {
spotTgShown = true;
spotLg();
}
};

function spotSm() {
$('now-playing').setStyle('right', 'auto').setStyle('left', '0');
$('main-nav').setStyle('visibility', 'hidden');
$('main').setStyle('visibility', 'hidden');
$('suggest-area').setStyle('visibility', 'hidden');
$('now-playing-widgets').setStyle('visibility', 'hidden');
$('now-playing').setStyle('width', '100%');
$$('body').setStyle('overflow', 'hidden');
$('wrapper').setStyle('min-width', '0px');
};

function spotLg() {
$('now-playing').setStyle('left', 'auto').setStyle('right', '0');
$('main-nav').setStyle('visibility', 'visible');
$('main').setStyle('visibility', 'visible');
$('suggest-area').setStyle('visibility', 'visible');
$('now-playing-widgets').setStyle('visibility', 'visible');
$('now-playing').setStyle('width', '');
$$('body').setStyle('overflow', '')
$('wrapper').setStyle('min-width', '');
};
spotTg();

Cast audio only from Google Chrome to Chromecast

This is a not particularly satisfying work around, but it seems to work.

My issue was that the Google Cast extension and GPU processing in Chrome were hammering my CPU and the audio from Spotify was choppy.  If only there was a way to have audio only.  Well there is, kind of.  Take your tab into a new window and reduce the window size to nothing.  This caused my CPU usage to drop dramatically, and the audio streams nicely now.  My TV just displays a thin grey line accross the center of the screen, which I assume is the single pixel of my window or something.  I’m pretty happy with that.  

tinyChrome
Changing tracks is a pain in the ass…

Samsung TV average selling prices by day on eBay

I always assumed that everyone bought everything on eBay on a Sunday, as they had nothing better to do. Realising this was utterly unfounded, I decided to do a little (not hugely scientific) research. I gathered the average selling price for the last 200 Samsung TVs to sell on eBay for various sizes. Here’s a chart of the results.

tvSellingPricesByDay

As  you can see, it doesn’t seem to make any difference what day the item finishes.  More expensive items seem to have more volatility though.  Also, larger TVs are more expensive.  

The reason I chose only Samsung was to limit the number of results, in an attempt to gather data over a longer time period (without expending to much effort).  I used this bookmarklet to gather the data.  

Average selling price for completed eBay items on each day of the week

Here’s a bookmarklet to let you know what the average price of items shown in eBay was on each day of the week.

  1. Drag eBayDayAvg to your address bar.
  2. Navigate to a completed and sold page on eBay.
  3. Click on the bookmarklet.

It’s probably best to run it on a page with the max results as high as possible, and try it on a few pages.  Also limit the page to display the most relevant items.

eBayDayAvg

Here’s the code:

msg = '';
days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
items = {0:[],1:[],2:[],3:[],4:[],5:[],6:[]};
$('.sresult ').each(function() {
 title = $(this).find('.lvtitle').text();
 if (!(title.includes('fault') || title.includes('spare') || title.includes('issue') || title.includes('damage'))){
 price = parseFloat($(this).find('.lvprice').text().replace('£', ''));
 date = new Date(Date.parse($(this).find('.timeleft').text() + ' ' + new Date().getFullYear()));
 items[date.getDay()].push(price);
 }
});
for(item in items) {
 if (items[item].length > 0) {
 msg += days[item] + ': ' + items[item].reduce(function(a, b){return a+b;}) / items[item].length + '\r\n'
 }
};
alert(msg)

 

Convert LatLng to Point and Point to LatLng in Google Maps API v3

Having googled this, I found code to go one direction, but not the other.  Here’s both.

function latLngToPoint(latLng) {
 var topRight = map.getProjection().fromLatLngToPoint(map.getBounds().getNorthEast());
 var bottomLeft = map.getProjection().fromLatLngToPoint(map.getBounds().getSouthWest());
 var scale = Math.pow(2, map.getZoom());
 var worldPoint = map.getProjection().fromLatLngToPoint(latLng);
 return new google.maps.Point((worldPoint.x - bottomLeft.x) * scale, (worldPoint.y - topRight.y) * scale);
}

function PointTolatLng(point) {
 var topRight = map.getProjection().fromLatLngToPoint(map.getBounds().getNorthEast());
 var bottomLeft = map.getProjection().fromLatLngToPoint(map.getBounds().getSouthWest());
 var scale = Math.pow(2, map.getZoom());
 return map.getProjection().fromPointToLatLng(new google.maps.Point((point.x / scale) + bottomLeft.x, (point.y / scale) + topRight.y));
}

Automate feedback in eBay

Being lazy/efficient, I decided to script the feedback for all the junk I bought from eBay.  The following three lines will give the best feedback for all items listed in the feedback page, then you can just hit submit.  This can be entered, e.g., in Chrome developer tools console (F12, top right tab).

jQuery(":radio[value='positive']").prop('checked',true).click();
jQuery("img[alt*='Very']").click()
jQuery("input[id*='comment']").val("Great. Thanks. ")

The comment could be changed to something more descriptive.  Then I just checked through them and hit the “Leave Feedback” button.

PowerShell – Delete all directories with a given name recursively

 

It turns out to be a bit of a pain to delete all the directories/folders with a certain name.  This’ll do it.

Get-ChildItem C:\path\to\start\directory -Include search1,search2 -Recurse -force | Remove-Item -Recurse -Force

It just gets all the child items in a directory recursively and then removes them.  The -Recurse parameter on the Remove-Item is so that the entire directory and its contents are removed.  search1 and search2 are the the names it is looking for – more or less could be included.

Network configuration for CentOS minimal on VMware Workstation

This was a pain.

As I didn’t want to hang around too long, I downloaded the minimal ISO for CentOS.  I attempted to create a VM, but this failed when VMware tools were installing:

Installing VMware Tools, please wait...
mount: special device /dev/hda does not exist
mount: block device /dev/sr0 is write-protected, mounting read only
/etc/rc5.d/S99local: line 25: eject: command not found
/etc/rc5.d/S99local: line 25: eject: command not found

I had to create a new VM without an OS, then mount the ISO as the CD drive, reboot and install that way.

Then I had to somehow configure the network.  I couldn’t install VMware tools because perl wasn’t installed, so I don’t know if that might have fixed it.

I ended up editing /etc/sysconfig/network-scripts/ifcfg-eth0, and I had to use VI because I couldn’t install nano…  An issue I had was that I didn’t know what the gateway was – I had NAT networking setup in VMware workstation.  There’s a handy tool to find out bundled with VMware Workstation.  It also works with VMware player, but doesn’t come with it.  I found it here:

C:\Program Files (x86)\VMware\VMware Workstation\vmnetcfg.exe

I selected the NAT network, then NAT settings, and this shows the gateway:

Virtual Network Editor

My /etc/sysconfig/network-scripts/ifcfg-eth0 ended as this:

DEVICE=eth0
HWADDR=00:0C:29:FC:8F:27
NM_CONTROLLED=no
ONBOOT="yes"
IPADDR=192.168.153.20
BOOTPROTO=none
NETMASK=255.255.255.0
GATEWAY=192.168.153.2
DNS1=8.8.8.8
DNS2=8.8.4.4
USERCTL=no
TYPE=Ethernet

The device, MAC and a few others were already set.  The DNS entires I have used are Google’s DNS servers.  The IP address I chose was a free one (all apart from .1 should be free, I think) on the network – select the DHCP settings for the network in the Virtual Network Editor to see the address range.  I also updated the file /etc/sysconfig/network to this:

NETWORKING=yes

That file didn’t need the gateway, as I read elsewhere.  I then restarted the network:

service network restart

I was then able to connect to the internet and install perl and then VMware tools.  It all turned out to be a complete waste of time, but ah well.

Vmware Workstation->VM (to the right of File, Edit, View)->Install VMware Tools…

yum install perl
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cd /tmp
tar -xzf /mnt/cdrom/VMwareTools-<version>.tar.gz
cd vmware-tools-distrib
./vmware-install.pl
[hit enter a lot to accept all the defaults]

Meh