Jul 19, 2009

Some updates

  • Vacation finished :(
  • Changed my gsm company Turkcell to Vodafone
  • Uploaded last.fm data to my libre.fm
  • Uploaded some old photos to my picasa
  • Created google profile
  • Got about 8 kg. in 20 days

Jun 24, 2009

Format ruby code for your blog

I was looking for a ruby syntax highlighter for my blog and found syntax and found 3 good usage tips but all tips for a specific platform;
All good but thought to make a more crossplatform and more usable, it's here;

First install syntax and add CSS style to your site as told all three blogs beginning and forget the other parts of them.

#!/usr/bin/env ruby

require 'rubygems'
require 'syntax/convertors/html'

if ARGV.size == 0 then
require 'Qt4'
app = Qt::Application.new []
clipboard = Qt::Application.clipboard
@code = clipboard.text
elsif ARGV.size == 1
@code = File.read(ARGV[0])
else
puts "without argument converts clipboard content\nUsage:\n"
puts "cbtohtml.rb [filename.rb]\ncbtohtml.rb [filename.rb] > output.html\n"
exit
end

convertor = Syntax::Convertors::HTML.for_syntax "ruby"
puts convertor.convert(@code)
Copy code block and save as "cbtohtml.rb" and give permission to run on unix type oses "chmod +x cbtohtml.rb". Without parameter using Qt4 to get clipboard text and it's the most crossplatformed style :) . With parameter using standart stdout that you can pipe to a file. Loading Qt4 when needed can be good for performance as can see below when converting files. Choosing CLI with parameter for really big files maybe a smart thing.

"cbtohtml.rb" copied clipboard:

[slmn@azrael cbtohtml]$ time ./cbtohtml.rb &>/dev/null

real 0m0.726s
user 0m0.313s
sys 0m0.043s
from file:

[slmn@azrael cbtohtml]$ time ./cbtohtml.rb cbtohtml.rb &>/dev/null

real 0m0.189s
user 0m0.133s
sys 0m0.023s
Now some KDE 4 plasma magic; Unlock Widgets > Add Widgets ... then add "Paste" plasmoid to you panel or desktop. enter Paste Settings look the shot below and give the path like in your computer.
You only need copy the ruby code want to convert then click "cbtohtml" from Paste plasmoid. Long live KDE :)

Jun 23, 2009

Reconstruction

After 2nd blog wipe decided to blog again, first thing first "Hello World!"

Last 1 year was not insteresting played WoW, waited KDE 4, updated my archlinux everyday like a crazy, lots of times tried to learn Qt all failed bored after a couple days, gained a little ruby skills when using at work... Now my new hobbies are plasma programming, again Qt programming after Qt started to develop anonymous git server and QtCreator, microblogging at identi.ca as you see at side panel, my little sweet archlinux KDE 4 desktop at work Xfce desktop at home, of course WoW after second 80 level Warlock started to level a Death Knight...

Not many changes about my social life biggest ones are my friend Ahmet SIRTMAC gone for 6 months military duty, changed house now 50 meters to work, got a little anemic disease last month gone er and got 2 unit blood still using medicines, will go vacation between 27 June - 10 July, hiya!!!

You will see me a lot after vacation, want to write about Qt, KDE, plasma, ruby, archlinux, WoW and social life.