Simple toggle of for my touchpad

Posted in this blog on October 12th, 2011 by blambi

During a lesson today I noticed that after an update of xorg and other fun stuff my laptops touchpad was a bit over sensitive. And since I use a marble mouse anyway this was just horrible to try to write anything (yay cursor jumping around the whole screen like it was crazy).

So after some looking around on ways to solve this i found out that one can reconfigure input devices during runtime with xinput.

After looking into what device i should “attack” it seems that ‘bcm5974′ was the correct one and setting its property Device Enabled (121) to 0 it disabled the touchpad.

I hacked together this little script so I can do this a bit quicker later on.

#!/bin/bash

STATE=$( xinput list-props 11 | awk '$3 == "(121):" { print $4 }' )

if [ $STATE == 0 ]; then
    xinput set-prop 11 121 1
    echo "Touchpad enabled"
else
    xinput set-prop 11 121 0
    echo "Touchpad disabled"
fi
Tags: ,

Kittens in the Web

Posted in this blog on April 22nd, 2011 by blambi
ב”ה

During a lecture related to javascript, well more specific jQuery.

Our lecturer showed us that a large Swedish newspaper uses jQuery and well we did some exercises (trough *firebug*) there and well for the fun of it I decided to write a wee snippet that replaces all images on with cute kitten images from Place Kitten:

  $('img').each( function() { this.src = "http://placekitten.com/" + this.width + "/" + this.height }

So after having written the above but not posting it (yea silly me), I wanted to show a way to write a simple greasemonkey script doing the same but for pages even lacking jQuery:

  var imgz = document.getElementsByTagName( 'IMG' );

  for( var x = 0; x < imgz.length; x++ )
    imgz[x].src = "http://placekitten.com/" + imgz[x].width + "/" + imgz[x].height

Try that against wikipedia and get a quite wikikitten or
something :D (or with charlie sheen places holders…)

WikiKittens!

Tags: ,

Tradera.com and Privoxy

Posted in this blog on December 12th, 2010 by blambi
ב”ה

I noticed some days ago that tradera.com had changed their design a bit, and somehow my privoxy config (did not know that was it at the time) was a bit overzealous and made it impossible to make bids.

So mailed the JavaScript errors happily to the support and got a quite unexpected reply, since I had mentioned that I used GNU/linux debian and had the problem in both Webkit based browsers and Iceweasel.

I will just translate the first and another “helpful tip”:

- Start Internet Explorer, And go to “Utilites” och click on “Internet Options”
- Under the tab “General” you can klick on the buttons “Remove Cookies” and “Remove Files”.

Hmmm did you miss the part, not running Windows? But anyway I just hope this is an template they send out.

But this one was even better:

-Do you have a router connected?

Yeaa that really is the issue when I posted my questions this trough your online help-form. And second of all what does this have to do with Javascript errors?

So I decided that I did not want to waste more energie and tested with my “nothing but default and no proxy” profile and wait I could bid, not a big nasty general bug then, so fired up firebug to see what has up again in my normal profile.

Nothing special Google Analytics getting blocked as usual, so something broke their lightbox/modal what ever you want to call it.

So first test was to give tradera a special treatment in privoxy with the action -filter. That actually worked.

But since I did not want google tracking me even on this one single page so after some testing this was a quite good anti tracker and banner free environment:

-filter
+filter{img-reorder}
+filter{banners-by-size}
+filter{banners-by-link}

But wait one banner was left! So I added it to my “banner sites not currently handled by banners-by-link set like which have the following rules:

+block{Blocked image request.}
+handle-as-image

And after all this it works like before, just not really sure what broke their JavaScript still…

Tags: ,

Simple map/filter in JavaScript

Posted in this blog on December 10th, 2010 by blambi
ב”ה

Just for fund during a lesson in well JavaScript I decided that I wanted to solve the problem in a quite different way, but the exercise etc is not really what I wanted to write about.

So here are the definitions:

function map( haystack, func )
{
    /* runs function for each element in haystack */
    var ret = new Array();
    for( var x in haystack )
        ret.push( func( haystack[x] ) )
    return ret;
}

function filter( haystack, func )
{
    /* runs function for each element in haystack and adds them if not false */
    var ret = new Array();
    for( var x in haystack )
    {
        var res = func( haystack[x] );

        if( res != false )
            ret.push( haystack[x] );
    }
    return ret;
}

Quite simple and works really well. An usage example would be something like this:

map( document.getElementsByTagName( "div" ),
         function( div ) {
             if( div.id == "" && typeof div.style != "undefined" ) {
                 div.style.background = "red";
             } } );

That is set backgroud to red for all divs without an id.

(in the real solution i have a lot of nice wrapper functions so this is even shorter there.)

Tags: ,

Bad SSH Guests?

Posted in this blog on December 9th, 2010 by blambi
ב”ה

For a while I have been using a modified version of ssh-faker.py that writes failed unlocks to a sqlite database. I have a PHP script for checking what is new etc and some small statistics.

Sample of this data would be:

IP                     Country                    Tries   Last Try
110.77.129.166  Thailand                    59      2010-12-09 18:18:49
217.65.220.245  Russian Federation    30      2010-11-28 02:36:33
203.199.200.63  India                         15      2010-11-24 14:34:35

I find this quite interesting since it gives a interesting view of how many probably zombie computers there really is in different countries.

So what is ssh faker? Well it is a little program that one adds to /etc/hosts.deny like this: sshd : ALL : twist /opt/sshfaker/ssh-faker.py %a. So when a user/program connects from an IP address not listen in /etc/hosts.allow the connection is given to ssh-faker instead. The user has then to enter a (unencrypted) key to make ssh-faker add it’s IP to hosts.allow.

My current SSH fail info: http://blambi.hopto.org/ssh.php

Diff to make ssh-faker.py also write to a sqlite database:

--- ssh-faker-org.py	2010-12-09 21:38:05.000000000 +0100
+++ ssh-faker.py	2010-12-03 01:01:54.000000000 +0100
@@ -4,21 +4,24 @@
 # This is a python program that basicaly does the same job as
 # ssh-faker by Charles Howes, but aims to fix some of the issues I had
 # with that program.
+# This version also logs to an sqlite database

-# Copyright (C) 2008 Patrik Lembke <blambi@chebab.com>
+# Copyright (C) 2008-2010 Patrik Lembke <blambi@chebab.com>

 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.

 PASSWORD = "password"
 FAKE_VERSION = "SSH-1.99-OpenSSH_3.7.1p1"
-JUST_DROP=False # If false emulates ssh-faker more.
-TIMEOUT=60 # sec
-SYSLOG_NAME="sshd"
+JUST_DROP = False # If false emulates ssh-faker more.
+TIMEOUT = 60 # sec
+SYSLOG_NAME = "sshd"
+SQLITEDB = "/var/www/databases/sshd-tries.db"

 import sys, signal, syslog, time
+import sqlite

 def write_syslog( ip, message ):
     """Write message to syslog."""
@@ -26,6 +29,25 @@
     syslog.syslog( 'Got "%s" from %s' %( message, ip ) )
     syslog.closelog()

+def write_db( ip, message ):
+    """Writes ip (if new) and message to our sqlite db"""
+    db = sqlite.connect( SQLITEDB )
+    cur = db.cursor()
+
+    # Check if it exists
+    cur.execute( "SELECT RowID FROM hosts WHERE ip == %s", [ip] )
+
+    try:
+        row_id = cur.fetchone()[0]
+    except:
+        cur.execute( "INSERT INTO hosts (ip) VALUES ( %s )", [ip] )
+        row_id = cur.lastrowid
+        #db.commit()
+
+    cur.execute( "INSERT INTO tries ( host, got, t_stamp ) VALUES ( %d, %s, datetime( \'now\' ) )", [ row_id, message ] )
+    db.commit()
+    db.close()
+
 def unlock_ip( ip ):
     allow = open( "/etc/hosts.allow", 'a+' )
     allow.write( "# %s\n" % time.strftime("Added at %c") )
@@ -77,6 +99,8 @@
             unlock_ip( remote_ip )
         else: # Log other data to syslog
             write_syslog( remote_ip, read_input )
+            write_db( remote_ip, read_input )
+
             if JUST_DROP:
                 drop()
             else:
Tags: ,

Killzone

Posted in this blog on October 18th, 2010 by blambi
ב”ה

(warning: post about little plastic men)

Just played my first game of killzone.

For those who don’t know what killzone is; It is a fan expansion for Warhammer 40k with a focus on skirmish battles, and small squads of troops.

I had a tiny squad of orks, about 125points worth and my SO had 130p of Kroot Mercenaries. The scenario we played was called extraction, in this My goal was to protect one of my squad members since this one had some kind of information (we fleshed out the fluff a bit) that the Kroot clan wanted. And of course her mission was to brutally knock the poor “little” fellow unconscious and drag away with him (which she did by trowing a grenade at him, and there by making him fall two stories!).

I won mostly by sheer luck in the end of round five. But it was a really even fight (only my team leader and another nob was alive in the end).

So in the end I really recommend Killzone.

Some of the great blogs about this little corner of the hobby:

Tags:

An Update

Posted in this blog on August 17th, 2010 by blambi
ב”ה

So what have I been up to? Well besides taking it easy after finally getting some free time, there have actually been both hacking and tweeking on a lot of projects.

A thing not quite unusual for me is to forget to release stuff, but well some like blamlib and kakwiki is currently in a very beta/alfa state and well I want their new additions etc at least working before a release.

In kakwiki I have mostly been working on rewriting old and rather bad code, and well semi clean room rewrites is quite interesting. Why I choose to rewrite stuff in that manner is mostly to avoid being influenced to write solutions that well are kind of odd, or not to my liking.
Also the “simp” interface can handle most required things like read, write, list … etc articles now.

In blamlib there have been some work on moving .protocols to .net (no not C# and that kind of stuff, just blamlib.net) instead of .network that is rather deprecated. Also trying to write a IRC client based on .net stuff but that is quite low currently. Also the .web.kakwiki is up to date with kakwiki (simp).

In the board game projects dank dungeons have gotten a rewrap and total rule rewrite for the third time, some day I will finish that one to.

Tags: ,

Paint Station

Posted in this blog on July 23rd, 2010 by blambi

ב”ה

I had for some time endured the semi ordered chaos one gets, when just having all paint pots albeit small and in some order.

But well the thing that changed that was well each time I used a collection of pots for a specific paint job and knew that I would paint more figures with that selection I put them in front of all the other pots. Yea after some time I had weary little room for well the painting.

So after looking around for different and hopefully better solutions, and not really finding anything superb. But then I remembered the painting stations I had seen some times at the local games workshop store.

Of it was to their web-page to take a look if this was something they where selling. And yep they do.

But since my cash flow is rather weak currently I would rather put those 270kr on well something else (like paint/figures/something else outside of that hobby). Since I have moved “quite” recently we have a a pile or two of smaller cardbord boxes and some bigger ones, so why not try if I could use one to create a simple even if not the largest paint station around, for well no price at all.

And well here is the result, works quite well to enforce some kind of order (and a plus, the cats do not longer feel urges to play with the pots.)

image of paint station

If anyone wonders why there seems to be spray paint in the box it was previously used when priming figures but that over since Shlomo liked to sleep in that one… cat fur on newly primed figure is not what I call fun..

Tags:

That Greasy Monkey

Posted in this blog on June 21st, 2010 by blambi

ב”ה

For different reasons I have been rather tied up and been quite silent here for a while, fear not that doesn’t mean that I have stopped hacking.

But on to the issue at hand that i thought could have be of more interest to others.

I recently moved back to iceweasel, yea that is rather scary but the other browser I used wasn’t really mature enough yet, sad but true. So what did I do then? Well of course looked into if I could make iceweasel behave close enough to my other browser and also be thinkerd with to behave more like another old timer of mine galeon.

So I installed the following addons:

  • Edit Cookies
  • Greasemonkey
  • It’s All Text!
  • Tabs Menu
  • URL Alias

And I must say I’m really quite pleased, after moving around the GUI a bit and also thinkering quite a lot with the diffrent addons I got something that was a mix of epiphany and galeon with quite a bit of extras.

Not surprising I have already written two rather simple greasemonkey scripts:

  • Privoxy to NetPostive
    Transforms thouse ugly 503 errors of privoxy to the stile and messages from NetPositive (think BeOS)
  • Games Workshop auto country selector
    Since I let my cookies die of when I closes the browser some sites wish that you should select language/country etc so I made this little thing that fixes that for you on games workshops page.

And at last I must say that I really like being able to summon a emacs-client with an text areas text in side it and saving pushes it back to the text area.

Tags: ,

Sadly no comments

Posted in this blog on May 11th, 2010 by blambi

B”H

I disabled the comments for people who have not commented before, since well I have got just to much spam lately that got trough the filter. It was about ~10-30 a day so I just became feed up with it..

I hope to solve this in another way later on but for now (and since the blog is rather quite too) it will be this way.

Sorry

Comments are enabled again, hopefully it will work better this time :)