Advarsel mod Stofa Net og Stofa TV!!!

July 6th, 2010

Jeg blev meget glad, da jeg så af kabel-tv udbyderen Stofa tilbød 50 mbit på min vej. De var meget hurtige til at få sendt udstyret ud, og jeg kom næsten problemfrit på.

Det kørte perfekt de første 2 uger. Derefter begyndte jeg at ryge af nettet næsten tilfældigt. Jeg forsøgte at få deres support til at hjælpe mig, som lavede alle mulige målinger, og godt kunne se at der var noget i vejen. Jeg snakkede med naboerne, som også havde haft problemer i et stykke tid – en af dem havde faktisk haft det sådan i et år!!

Stofa er dog ikke istand til at hjælpe og deres drifts SMS og email er næsten som spam!! VÆLG ALDRIG STOFA HVIS DU STÅR OG SKAL BESTILLE INTERNET!!!

Jeg håber det her når ud på Google, så andre ikke begår samme fejl som jeg selv.

Ruby-GTK behavior in JRuby-GTK (using Java’s GTK)

June 25th, 2010

When I first started playing around with JRuby, I quickly found out, that the GTK-extension for Ruby did not work with JRuby, since it was a native C-extension, which could not be loaded into Java.

To load GTK in JRuby anyway, I had to install the Java GTK on my Ubuntu machine. This is pretty easy – just fire off a “sudo aptitude install libjava-gnome-java” and your done…

Java’s GTK is a lot different from the Ruby version. First of all a lot of the Ruby-objects has optimized constructors. You can construct a window with a title by doing:

window = Gtk::Window.new("The title")

In Java this is not possible, so if you give the argument your app fails. This meant that JRuby wasnt able to handle some of my GTK-apps. I then decided to write a kind of wrapper, which would emulate the behavior of the Ruby-GTK in JRuby-GTK (Java’s GTK). This turned out to be a lot harder than I first thought.

First off I had to make dynamic events-classes for the connect-method, to first do it the Java-way and then call blocks in Ruby to turn it into the Ruby way – which I had never done before.

All in all I was able to get the following examples to work in JRuby with Java’s GTK loaded:

require "knj/jruby-gtk2/gtk2.rb"
require "knj/jruby-gtk2/gladexml.rb"

class WinAppEdit
	def initialize
		@glade = GladeXML.new("win_app_edit.glade"){|h|method(h)}
		@glade["window"].show_all
	end

	def on_btnSave_clicked
		print "Save clicked.\n"
	end

	def on_btnCancel_clicked
		print "Cancel clicked.\n"
	end

	def on_window_destroy
		print "Destroyed!\n"
		Gtk.main_quit
	end
end

WinAppEdit.new

Gtk.main

And the normal one:

require "knj/jruby-gtk2/gtk2.rb"

button = Gtk::Button.new("Test")
button.connect("clicked") do
	print "Clicked!\n"
end

win = Gtk::Window.new("Trala")
win.add(button)
win.show_all

win.connect("destroy") do
	print "Destroy!\n"
	Gtk.main_quit
end

Gtk.main

Why go through all of this, just so my Ruby-GTK applications can run through JRuby? Scalability, real threads, packaged Java-apps and so on…

The whole thing can be checked out at my account on GitHub:

http://github.com/kaspernj/knjrbfw

http://github.com/kaspernj/knjrbfw/blob/master/jruby-gtk2/gtk2.rb

http://github.com/kaspernj/knjrbfw/blob/master/jruby-gtk2/gladexml.rb

Be warned that this project is far from done – its actually more a proof of concept for myself :-)

Ruby and GTK on the N900

January 10th, 2010

I finally compiled Ruby and GTK packages for the N900. It was a very big disappointment, when I found out that neither the official or the extras repositories had any ruby-gtk packages – even though Ruby itself had been packaged (but not optified).

Because of this, I decided to compile my own Ruby packages, which I have just tested on my phone (I cross-compiled them on my laptop).

Borders on images with rounded corners using GD-lib in PHP

November 25th, 2009

I just extended my “image.php”-script (which I have written about in a previous post) to be able to add borders on images. Nothing special really – except the script also supports doing it with rounded corners. Its actually just extending the rounded-corners-function, because it would be a hell doing it manually on a picture, after it had gotten rounded corners.

Its done by adding “edgeborder=htmlcolor”. Like this:

https://www.kaspernj.org/image.php?picture=temp/kasper_test_blog.jpg&edgeborder=0000ff&edgesize=35&bgcolor=000000&force=true&width=400

…which will result in:

This enables me to make nice rounded images with borders – without having to send tons of HTML to the client. The image is even cached through the image.php-cache – saving both the server and the client for tons of calculations. Just sending a cached image to every clinet – wee :-)

Chrissi’s iPhone: Jailbreak, SSH automount and VLC+MPlayer media players

November 25th, 2009

Today Christina had a lot of trouble with getting her iPhone working with Linux. Since Apple apparently hate their own customers (Microsoft 2 anyone?), I had to take several steps to get some basic functionality up and running on her expensive phone.

First of all she needed to transfer music back and forward to the phone. My first guess was just using iTunes under VirtualBox – but that was just too ugly and complicated. I then jailbroke her phone using BlackRain’s tool. It was pretty easy, once I got my Windows-box connected.

I then installed Cydia – and through that SSH.

I then installed the “ipod-convenience” package on her laptop and was able to mount the iPhone via “iphone-mount”. Shortly after I found out that Apple fucked every application which worked with the iTunes-music-dir format up – simply because they didn’t want the iPhone to work with anything else than their own iTunes (wtf!?). Fucking retards…

I then installed MPlayer and vlc4iphone to get basic media functionality up again… Further more I set up “autofs” on Christina’s laptop and copied her SSH-key to her phone, so she didnt have to mount anything. I altered the DHCP-config, so her phone always were on the same IP. Then I made the following config in “/etc/auto.iphone” for “/media/iphone_auto”:

iPhone -fstype=fuse,allow_other,reconnect,uid=1000,gid=1000 sshfs\#192.168.1.155:/var/mobile/Media

Everytime Christina now accesses /media/iphone_auto/iPhone – her system will automatically try to mount her iPhone via SSHFS (SSH File System).

She can now copy music, pictures and all the other stuff over by using Nautilus (the filemanager of Gnome – Linux).

This whole thing was even easier on the OpenMoko-phone I played with a year back… I am never going Apple…

Glade auto connect in JRuby

November 15th, 2009

I have been playing a lot around with JRuby lately (since I was scared away from IronRuby by another lame Microsoft-patent). I have been really disappointed by the Gtk-implementation in Java – it really misses a lot of the good stuff from PHP-GTK – like the auto-connect functionality.

I decided I wanted to write my own Glade Auto Connect functionality to learn some more about JRuby – it turned out a bit harder than I expected. In the end I got it working with some of the basic widgets (GtkButton::Clicked, GtkWindow::destroy, GtkTreeViewSelection::changed and so on). I am adding support for more events as I continue my adventure into JRuby.

It works like this – when you want to spawn a new Glade-object, you do it through my function:

class MyWindow
  def initialize
    @glade = GladeAutoConnect("gladefile.glade", "window", self)
  end

  def on_window_destroy
    print "The window was closed!\n"
  end
end

No more connecting events manually – just write the event-names in the Glade-application directly. This functionality really shortens the code – which is what I like about Ruby: Less code to write. Right now it produces some eval-code though, which I plan to remove, when I learn more about how to dynamically make new classes in Ruby.

The code can bee seen here:
http://knjrbfw.kaspernj.org/jruby_gtk.rb

HowTo: Make a simple GtkWindow with IronRuby, GtkSharp, Glade and events (not Ruby-Gtk!)

November 8th, 2009

To make this a lot easier for the ones of us using Ubuntu, I added IronRuby to my Ubuntu-repository. Read more about how to set it up here:

http://wiki.kaspernj.org/index.php/KnjUbuntuRepository

Afterwards do a: “sudo aptitude install ironruby glade libgtk2.0-cil libglade2.0-cil”.

While you are at it, install “glade” (”glade-3″ if you are using Jaunty, I think). Make a new project folder – I have called mine “IronRubyTest”. Make a small Glade-file (not GtkBuilder) with a label and a button. Remember the names – I called mine “window1″, “label1″ and “button1″.

To load the Glade-file, we have to import some modules first. To get the names of the modules, type “gacutil -l | grep gtk” and “gacutil -l | grep glade”. Type this in the beginning of your Ruby-code:

require "gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"
require "glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"

Be aware you properly have to use the lines, that you got from the “gacutil grep”-command.Its possible that yours can be different. Then type this afterwards in the Ruby-file:

include Gtk
include Glade


We are now ready to begin coding our class:

class MainWindow
  def initialize
    Application.init

    tha_glade = Glade::XML.new("test.glade", "window1", nil)
  end
end

Notice the “Application.init” – I guess this is to init the Gtk-stuff, like you would do in other languages when you are using Gtk.

The GladeXML-object is stored in the “tha_glade”-variable. “window1″ is the name of the Window, which can be set through Glade.

...
    tha_window = tha_glade.GetWidget("window1")
    tha_window.ShowAll
    tha_window.destroyed{|sender, e|
       Application.Quit
    }

    tha_button = tha_glade.GetWidget("button1")
    tha_button.clicked{|sender, e|
       tha_window.destroy
    }
...

We store the GtkWindow in the “tha_window” variable. Afterwards we attach some code to the destroy-event – we actually make the application kill itself, when we close the Window.

Further more we store the GtkButton in the “tha_button” variable. Afterwards we make the button close the window – which calls the other event and kills the application.

main_window = MainWindow.new
Application.run

The code here is placed at the very end of the file – not included in any function or class. This start our MainWindow-class, loads the window and everything and starts a loop, so our application doesnt end itself after loading the window and all.

The entire code can be seen here:

require "gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"
require "glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"

include Gtk
include Glade

class MainWindow
	def initialize
		Application.init

 		tha_glade = Glade::XML.new("test.glade", "window", nil)

		tha_window = tha_glade.GetWidget("window")
		tha_window.ShowAll
		tha_window.destroyed{|sender, e|
			Application.quit
		}

		tha_button = tha_glade.GetWidget("button1")
		tha_button.clicked{|sender, e|
			tha_window.destroy
		}
	end

	def on_button1_clicked(object, event)
		print "hmm\n"
	end
end

main_window = MainWindow.new
Application.run

New cool image-PHP-script, which can be used from every programming language

November 4th, 2009

I just wrote a new set of cool image-functions and a small script to automatically invoke and cache stuff it generates.

The script is able to do smart resizes, resizes, padding, rounded edges, caching, equal sizes, set quality and dynamically output in different support formats (jpeg, png, bmp, wbmp, gif etc).

To start with an example, I have uploaded a picture (”kasper_test_blog.jpg”) and symlinked to the script, so I can call it. It is a picture of me holding a speech at the 2007 OpenSource Days conference. I now want the same width and height + rounded edges on the picture. I set src of an <image> to “image.php?picture=temp/kasper_test_blog.jpg&equaldim=true&edgesize=35&bgcolor=000000&force=true&width=400&padding=15&paddingorigsize=true” resulting in:

This will:

  1. Make the width and height the same size because of “equaldim=true”.
  2. Make 35 size rounded corners because of “edgesize=35″.
  3. Use black as the backgroundcolor for everything because of “bgcolor=000000″.
  4. Not use cache because of “force=true”.
  5. Force the width to 400 pixels because of “width=400″ (could also have used “height=400″).
  6. Make 15 pixels of padding on top, bottom, left and right because of “padding=15″ (still using black as color for the padding because of “bgcolor=000000″).
  7. When using padding, instead of increasing the image-size by the padding, it will keep the original size because of “paddingorigsize=true”.

Other possible parameters are:

  1. “quality=85″ – sets a specific quality of the outputted image. Good when using it for a lot of thumbnails.
  2. “type=jpg” – output the image as JPG (default is PNG). Could also be “type=bmp”, “type=gif”, “type=png”, “type=wbmp” or whatever.
  3. “smartsize=200″ – makes the width or height to 200 – based on which is the larger one. Great for handling sizes on a personal gallery.

The sourcecode for the script and its framework can be found here:

  1. http://knjphpframework.kaspernj.org/scripts/image.php
  2. http://knjphpframework.kaspernj.org/functions_knj_picture.php
  3. http://knjphpframework.kaspernj.org/functions_knj_picture_bmp.php

Upgraded to Karmic!

October 30th, 2009

I finally upgraded to Karmic. This is the first time I have not been part of the beta or alpha.

Still, I noticed some problems. First of all, I still use KDE 3 – I am still scared of KDE 4 since the initial unstable release and dont dare using it… yet.

I had no items in KControl what so ever. I solved this by installing “kdebase-kde3″ and “kpersonalizer-kde3″ and executing this command:

sudo ln -s /opt/kde3/etc/xdg/menus/kde-settings.menu /etc/xdg/menus

Further more I could configure the CPU frequency applet in Gnome to change frequency without requesting my password. This can be solved by entering this:

gksudo gedit /usr/share/polkit-1/actions/org.gnome.cpufreqselector.policy

Scroll to the end of the file and change the “…admin_auth_passwd” (or something) to “yes”.

This post serves mostly as my own personally note for the future :-)

Writing wp-posts directly from my phone!

October 4th, 2009

After reading a former class-mates blog, I found the application wpToGo, which I can use to write blog-posts directly from my phone.

Now I just need to get better at hitting the right keys, when I write on the phone!