GreaseMonkey gottcha – script not triggering ?

In the unlikely event you haven’t discovered GreaseMonkey it’s ideal for tweaking the presentation of a website to suit your own taste.

A good example of this would be the ad sponsored block of links typically at the top of the list of search results.  These are often presented in a box with a subtly different background colour, alas this colour is usually so subtle that especially on a laptop screen you can’t see it! (if I was suspicious I’d think it was done that way on purpose!)

Doing a quick hack for this rather than searching for someone else’s script is probably quicker and certainly good practice.

My search engine of choice is startpage and I was scratching my head trying to figure out why the script wasn’t being triggered – then I looked again at the URL (check the page info when right clicking on the page with firefox)

https://startpage.com/do/metasearch.pl

The thing here is the second slash after the domain name I’d assumed that the filter https://startpage.com/* would basically capture everything – turns out this isn’t sufficient and https://startpage.com/*/* is what’s required.

Just one more minor irritation is that ID attributes are *supposed* to be unique within a document, however the div at the bottom of the results also shares the same ID.  While there are facilities to get arrays of all tags with shared class attributes, as far as I’m aware this is not the case with ID’s.  I decided to just brute force through all the div tags in a document searching for the same target ID, there may well be a more elegant way to do this but what the hey it works!

I’ve included the script here for anyone who’s not used GreaseMonkey but fancies a play…

// ==UserScript==
// @name        startpage ad
// @namespace   codifies@bedroomcoders.co.uk
// @description makes the background for the ad links actually visible
// @include     https://startpage.com/*/*
// @version     1
// @grant       none
// ==/UserScript==

//var el = document.getElementById("sponsored_container");
//el.style.backgroundColor = '#8080ff';

// *sigh* all id's *should* be unique

var all = document.getElementsByTagName("div");

for (var i=0, max=all.length; i < max; i++) {
     if (all[i].id=="sponsored_container") {
       all[i].style.backgroundColor = '#a0a0ff';
     }
}

 

 

Posted in Uncategorized | Leave a comment

SpritePlacer get physics

SpritePlacer

While far from complete, SpritePlacer now has physics.  Each sprite can have multiple physics shapes added to it.  This allows you to have sprites that aren’t rectangular.  You can see an example of this on the left (click to enlarge), the dumbbell shapes each have three physics shapes.  Two spheres and a rectangle are sufficient to make the collision shape for the sprite.  In addition to the collision shapes (and properties like restitution friction and density) its also possible to have different body types, as well as static and dynamic bodies you can have kinematic bodies.  While there isn’t much use for kinematic bodies at the moment they might be quite useful once I’ve implemented scripting.

There is a bunch of stuff still to implement physics wise and I’ll be resetting sprite positions once the editor is put back into edit mode after “running” the physics.

While I initially just wanted a way to place a bunch of sprites in a “level”, by the time I’ve added physics and scripting I’ll have in effect a 2d game creator.  I’m not sure just yet what events to support (collision, level loaded etc) but its funny how a simple project can gradually evolve into something else altogether!

Posted in Uncategorized | Leave a comment

SpritePlacer a level editor

Straight off the code is at https://github.com/chriscamacho/SpritePlacer As its using libGDX its cross platform, however if you want it to work on a Mac or Android device you’ll need to add your own simple platform stub.

There is nothing special about this simple level editor but it does boast a rudimentary file selection dialog, which is separate enough that you should be able to very easily integrate it into your own projects.

I have to say that I struggle somewhat with libGDX’s GUI as do anything in the wrong order and all sorts of odd things happen! This isn’t helped by the far too sparse javadoc and a wiki that usually just shows you a small bit of code instancing some widgets but not really using them or explaining how they are intended to be used…

But still you can usually bully it (eventually) into some sort of behaviour even if you’re unsure you’re using it in the right way!

LibGDX’s Sprite class is wrapped into a pixy class to store extra properties and also utility functions and a static list of all created pixies.

I chose to save and load from XML and while its only a single layer of hierarchy I still found XML useful.

Saving was by far the easiest task after dumping a very simple header its quite straight forward to iterate in turn through each pixy. The pixy class has a simple method to dump an XML representation of itself to a string.

Loading was a little more complex but I used the built in SAX parser as it doesn’t load the whole document into memory as an object.  The SAX parser uses callbacks as its traversing the document, which once you get your head round actually makes like easier.  Still that said saving is a one paragraph method and loading is a whole multiple method class in its own right!

Although probably not an ideal example of an XML parser, its probably a fair real world example to inspire your own parser (off the top of my head I can think a few ways to improving it – oh dear there I go again wanting to fix working things!)

In the future other than on going tidying I plan to add some kind of more useful user defined data than just a string and may also consider adding scripting and even box2d support.

Development is rather sporadic, but then no one knows about it to contribute so its just me when I get chance…

 

Posted in Uncategorized | Leave a comment

Debians “handy” fstab entries

Having just installed Debian (XFCE) on my “new” SSD (and boy does it fly! AND I get an extra hour out of the battery!) I hit a rather irritating puzzle.

Whenever I mounted a USB stick is was mounted without write permissions (rather infuriating as it kind of defeats the purpose of *convenient* portable storage) – Well as you do, I fiddled, googled, swore and then by chance happened to plug in a second USB stick and low and behold that had proper permissions, with a little experimentation I also discovered if I inserted them in a different order the original stick could get proper permissions (providing another had broken permissions)

eventually noticed that some where mounted in

/media/usb0

and some where in

/media/<username>/<uuid>

Well what’s going on here two automount deamons fighting? what?

Eventually I tracked it down to entries for /media/usb0 etc. in /etc/fstab, now I always thought that fstab was really only for fixed none removable devices that *needed* to be mounted at boot time.  Frankly I’d expect better of people from Debian I mean the person who wrote the line to mount /media/usb0 in fstab what, oh what, were they thinking – simply not the place to do it!

Fortunately like most issues in Linux once you know what the issue is, fixing it is trivial – in this case simply removing the misconfigured lines in fstab made the issue go away, now everything is happily mounted in

/media/<username>/<uuid>

where it should be and with the permissions it should have….

 

Posted in Uncategorized | Leave a comment

Whats worse that secure boot ? a badly implemented bios !

NB if you’ve landed here from a search, because you have this issue read below about using a usb keyboard…

All in all I’m very happy with my Fujitsu Lifebook AH532, it’s got a great little cpu with a gpu (HG4000) that’s got plenty of grunt, does all the OpenGL experimenting I throw at it an can even play quite intensive games…

The only one real fly in the ointment is the BIOS, seems if you change your hard drive you are forced to install the new OS in EFI mode (bios mode boot install fails to be booted by the bios) having then installed an EFI bootloader, you can’t get into the BIOS…

A quick google will tell you that its a well known about issue and needs a reflashed BIOS – slight issue you can’t get into the boot menu either, so you have to reset this NVram – great news the two pads you have to short are under the memory – real handy that (still tempted to solder some wires on them and bring it out into a switch (probably in the HD bay) for easier access.

Anyhoo long story short I had allsorts of problems getting back access to by BIOS eventually eventually downgrading to the previous version of the BIOS….

At one point the keyboard wasn’t working at which point I found I could get into the BIOS with a USB keyboard – joy of joys! Now I was in the rest of the laptop to get back a broken tag of plastic that was rattling about and I did reseat the keyboard connector so I can’t tell for sure if that was the issue, but…. I can’t help but think that maybe the inaccessible BIOS and boot menu bug is because the built in keyboard isn’t properly initialised – you will get a beep because its registering a key press – just the wrong one…

If someone does install Linux on a new hard drive and has these same issues, before flashing your BIOS can you try getting into the BIOS with a USB keyboard – if it works or not please DO TELL me by leaving a comment here…. (ta!)

I now finally have a machine booting in BIOS mode (ie grub-pc not grub-efi) and I have access to the BIOS and boot menu… and the really good news – it actually was worth the hassle this SSD I install gives me a 7 second boot time (not that thats important) but it gives an indication of how zippy my machine is…

 

Posted in Uncategorized | Leave a comment

Configuring Alps laptop touch pad

Here mainly for my own historical notes (but if you happen to drop in here via google – you’re most welcome!) is how I configured my Alps touch pad to do tap clicks, middle button and scrolling etc…

First of you’ll need dkms

sudo apt-get install dkms

dkms is rather handy and will automagically(tm) compile and install from source code kernel modules when you install/upgrade a kernel package…

You’ll need the source from http://www.dahetral.com/public-download at the time of writing the source is at version 1.3.   You should end up with the source in usr/src/psmouse-alps-1.3 if you like this can be a symlink to your own development folder…

It behoves me to thank both the original creator and current contributors of this and wonder why it isn’t just part of the kernel source….

Then its just a case of telling dkms where it is and to get on with it…

sudo dkms add psmouse/alps-1.3
sudo dkms autoinstall
sudo rmmod psmouse
sudo modprobe psmouse

Just a quick note – while you can sudo su and execute the above commands without sudo, I prefer not to as its all too easy to forget to exit the su session and end up doing unintended things still using the root account…

While there are skeleton Xorg configs to use in /usr/share I found a more comprehensive example below – while not all of the features work on my hardware they might work for others…

On Debian testing (jessie) I had to create the following directory

 sudo mkdir /etc/X11/xorg.conf.d

into which I dropped the following config file (50-synaptics.conf)

Section "InputClass"
 Identifier "Touchpad" # required
 MatchIsTouchpad "yes" # required
 Driver "synaptics" # required
 Option "MinSpeed" "0.5"
 Option "MaxSpeed" "1.0"
 Option "AccelFactor" "0.075"
 Option "TapButton1" "1"
 Option "TapButton2" "2" # multitouch
 Option "TapButton3" "3" # multitouch
 Option "VertTwoFingerScroll" "1" # multitouch
 Option "HorizTwoFingerScroll" "1" # multitouch
 Option "VertEdgeScroll" "1"
 Option "CoastingSpeed" "8"
 Option "CornerCoasting" "1"
 Option "CircularScrolling" "1"
 Option "CircScrollTrigger" "7"
 Option "EdgeMotionUseAlways" "1"
 Option "LBCornerButton" "8" # browser "back" btn
 Option "RBCornerButton" "9" # browser "forward" btn
EndSection

You should only need to restart your xorg session (log out and back in) but if you want to be paranoid you can do a windows (reboot)

While corner buttons don’t work for me, the useful bits like 2 finger scrolling and best of all middle and right mouse button clicks (2 or 3 finger tap) all work great! double tap and drag all in one gesture will also allow selecting too.

Enjoy!

 

Posted in Uncategorized | Leave a comment

Microsoft helping Linux again…

Well I thought it might be the case and from my recent experiences it seems that yet again Microsoft have shot themselves in the foot. With coming so late to the mobile arena (and by mobile I mean tablets etc as well as phones) MS now seem to be wanting to force their desktop users into a touchscreen / mobile paradigm regardless as to whether that’s appropriate or even useful for their workflow. Given that the hardware requirements for their new OS are so redonkulous, the dropping of XP support has conspired to make the perfect storm which has no doubt blind sided MS.

I’ve noticed in conversation for a while now that people are generally uneasy with the direction computing is heading, whether its the future plans for the MS app store (have no illusions that before long it will be the only way you can install/publish software) or the absurd notion that TV advertisers would have us believe – that you MUST throw away old but perfectly functioning and usable hardware.

It’s from this perspective that I’ve heard increasing interest in Linux, for some its just replacing XP and for others its finding out if they might be able carry on their favorite activities but without MS.

At this point its well worth following an aside and asking does the lack of XP support really matter? Here’s a little thought experiment (which you could try if bored!) Take an unpatched original release of the XP install disk, after doing a default install connect the machine to the internet. Without the need to even browse any dodgy sites, just sat there connected to the internet, I would seriously doubt your experiment would last 10 minutes without being exploited – from now on your machine is helping with DDoS attacks or worse helping people anonymously download the most vile illegal material hopefully beyond your imagination …

This somewhat sobering look of what can happen to a machine without support shows what is to come for XP. I have no doubt that already there are some dodgy sites selling script kiddies nicely prepackaged tools that will scan for and use exploits that MS probably do know of but are now doing nothing about. As anyone who’s used Linux regularly knows this is where Linux scores very highly over Windows (any iteration) not only are updates much more frequent but they are much less of a drama even allowing the practical use of your machine (while they happen) and not necessitating the crossing of fingers.

This is one of the corner stones of security the prompt and frequent patching of exploits or even potential exploits.

So could MS have avoided all this? Well, yes actually – you see for years now MS have viewed an OS as some kind of “experience” (remind me what does XP stand for?) in reality all many of us want is a way to launch applications and a glorified file manager… and if a company really can’t make this run on even really modest hardware, even including an app store, then you have to wonder have they lost the ball let alone dropped it….

 

 

 

Posted in Uncategorized | Leave a comment

Olimex A20 battery consumption

2014-03-07-235844_1366x768_scrotStill no enclosure or firm idea of what I’m putting in it, but a keyboard does look certain!

The first power consumption test I did using a 6600mah (3v7 LiPo) is shown with the brown line, because I was running the LCD backlight at 100% and using a conventional laptop hard drive the power circuit called a halt when the battery was still half charged. I strongly suspect that I was simply drawing too much current for the battery to deliver as it became more depleted.

For the second test (in blue) I used a less retina burning but still quite readable 40% backlight and a solid state hard drive I managed to ride the battery all the way down to 11% with a total duration of over four and a half hours.  Although I’m probably putting a bit more of a drain on the battery than I should, I can set an alarm for 30% and shutdown at 20% and still get a little over four hours battery life, not too shabby.

The (power management) reported current is shown in orange, presumably the current is on an upward slope as the battery delivers decreasing voltage…

During these test, the system was put under a low load (10%-20% single core use) grabbing a web page once every 90 seconds, the readings were take once a minute. As the usage was continuous this for me gave an automated rough equivalent of normal use by an actual user, doing browsing and office type activities – ie not 100% on all cores compiling a kernel, while running an immersive 3d first person perspective shooter!

 

 

 

Posted in Uncategorized | 3 Comments

Olimex A20 GLES2.0 and Open Dynamics Engine

Threw this up cause its what I do almost any new platform I explore ;)

I’m in the process of converting my GLES2.0 framework away from GLFW and back to Xlib as I’ve had different issues with different embedded platforms using GLFW, oddly I’ve not seen these issues with my Xlib code…

The Allwinner A20 board here is showing 128 moving “3d” objects falling on a (very) simple mesh, the shaders in use are very simple texture and single light point shading with ambient lighting.  This is running on top of Debian (armhf) running LXDE.  This isn’t pushing a single thread to its limit on this platform and if I separated the dynamics and rendering into their own threads I could probably get 50% more performance (at a guess!)

If you’re interested in the Allwinner A20 be sure and checkout my previous two posts…

Posted in Uncategorized | Leave a comment

The kit arrived – a review of Olimex components

olimex-boxes Its been a few week so its been enough time to give me a good handle on the kit and give a fair minded review from my own perspective.  The first thing I’m going to talk about is rubbish! actually nothing to do with the end product but essential none the less.  I’m sure you’ve either heard of, or even experienced the horror stories about inadequate packaging, from LCD screens “protected” by a thin sheet of bubble wrap and an envelope, to equally thin envelopes containing thousands of pieces of fragmented plastic… I was very heartened to see how Olimex sent the package (which arrived promptly unlike the USPO, it seems UPS don’t just leave stuff in a warehouse for over a week at a time…) Inside the thick waterproof UPS plastic bag was a stout quality carton, inside which were a fair number of hard foam blocks containing the above pictured boxes, all with their own bubble wrapped packages – some with more foam inside.  Its really nice to see that a company is serious about getting their kit to you in good condition rather than shave a few cents of the price (which is ultimately self defeating…)

Build quality wasn’t restricted to the boxes however, throughout build quality is good and I have to say that the products are basically at least as advertised ! so there’s a turn up for the books!

The (A20) board is quite well thought out and the serial-debugnumber of GPIO pins is massively generous, more than I’ve seen in a number of FPGA boards! Given that just about every peripheral connection of the SoC is brought out to a connector this is quite extraordinary, and very nice to see… One thing you’ll want to bring to the party is a serial to USB connector, if like me you have a max232 breakout board and separate serial-usb cable then you’ll need to power the level shifter, usefully the +5 pin of GPIO socket 2 is right next the the 3v3 debug socket…

There are really only two criticisms I can level at the Olimex kit, the hardware and software… don’t worry not all of the hardware and not all of the software!

First of all the hardware issue – alongside the A20 I ordered a touch screen LCD, I can live with the fact that the touch screen is not attached (A little double sided tape soon sorts that) but after carefully aligning the right hand side of the display area, I discovered it was over two millimetres smaller than the actual display area… not ideal… additionally as to be expected from a resistive touch screen, accuracy is somewhat of an issue – no great surprise.  If you want a kiosk type screen with large buttons, then its just the ticket, however gtk/system menu selection even with a stylus are going to be problematic especially near the screen edges.

The software issue – is mainly due to the nature of the flexibility of the board, it could easily be put in an industrial setting running headless, but then just as easily it could slot into a hand held games system.  Due to this even the “ultimate” SD image, should only really be consider as your starting point, although I’ve not done much with the Android image I get the feeling from the forum that the same is the case there…

Olimex has done a lot of the work for us though, their various blog posts contain many useful nuggets of information that can be used to build your own image.  Oddly though debootstrap hasn’t been mentioned, basically given a bootable image and a kernel you can install Debian onto new media very easily.

full-setupa20physics

So what can be done with an A20 system?  Well actually quite a lot, aside from an LCD display you can as easily link it to a HDMI or VGA monitor.  When doing Kernel hacking the previously mentioned debug serial port is very useful.  There is even a SATA interface, however you’ll need a low power device (SSD for example) if you want to do anything on battery power, indeed even with a 6600mAh battery you’re probably pulling more current than you should even with an SSD device.  3D support for the time being is with a binary blob – *sigh* – EGL is a little picky however, for example I couldn’t get GLFW 3.1 to open a window, that said when I changed my framework back to using Xlib everything just worked, but then again my Java wrapper for GLES is working very erratically :( !

My overall impression of the Olimex components is really very favourable especially their LCD modules which are very sensibly priced.  Once you get time to dig into the internals of the A20 it’s really a very nice piece of kit, if you’d set out to build a board without comprise I really don’t think you’d be upset if you came up with this product, it genuinely does get the most out of the A20 SoC.

Given that I want to use a SATA device I’m going to have to look at the battery side of things again and I do fancy stripping that zippy keyboard from its case… I’m going to have to have a think about what kind of enclosure I’m going to put all this kit into (sensible enclosure suggestions most welcome!) … oh and there’s a honeymoon coming up, so it could be a while before my device is fully built…

Posted in Uncategorized | 3 Comments