Monday, November 2, 2015

Another dRuby example

Most dRuby examples are using a multi machine/terminal/main process example. This example is for those like me, who need to harvest dRuby's power in a "single entry point" script.

Thursday, October 1, 2015

Rotated rectangle's bounding box

We have a rectangle shape, we know it's height and width. We want to rotate it by some degrees and find out it's bounding box's width and height. Here's how I did it in Ruby:

Tuesday, July 14, 2015

Easy way to throttle CPU Turbo on Windows

When you have a machine like I do that has a CPU capable of Turbo or other overclocking, then one may want to only “activate it” when really needed. This way one can avoid unnecessary fan spinups and heat.
My default CPU clock is at 2.8Ghz and capable to boost up to 3.6Ghz. To avoid always going back to the BIOS and turn the Turbo feature on and off, I have found an easier way to throttle down frequency within the Control Panel’s Power options menu.

On this video I show you an easy way to create a custom power scheme and set the CPU throttle values:

As shown on the video you can realise it’s only to change the CPU speed from 100% (with Turbo) to 99% to throttle it to the default frequency. It’s just that 1%, really! :)

To further modify/delete power schemes you really have to go to the command line.

To delete a scheme:

First let’s list all of the schemes to get their UUID:

powercfg /l

results in the list:

Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c (High performance)
Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a (Power saver)
Power Scheme GUID: dc512798-8638-4c98-9432-5e0e744ab01b (Game) *

Let’s delete Power Saver (you can’t delete the current one, marked with *):

powercfg /d a1841308-3541-4fab-bc81-f71556f20b4a

Changing power schemes with a click of the mouse

You can also create a few shortcuts to change between power schemes with just a line like this as the command:

cmd /c "powercfg /s dc512798-8638-4c98-9432-5e0e744ab01b"

This is useful when you use more than 2 schemes, because the taskbar icon only let’s you change between the most recent 2 of them.

Written with StackEdit.

Monday, March 16, 2015

Shrink Vmware Workstation Ubuntu guest's VMDK file size physically on Windows host

I will be short on the topic as you too only seeking the resolution to the problem in the title.

This tutorial is based on using Vmware Workstation 11 on Windows 8.1 host using an Ubuntu 14.04 guest. Note: you have to have the vmware tools, client additions installed on the quest machine!

First go to the Vmware client's terminal when you are ready to shrink it down and type:

sudo vmware-toolbox-cmd disk list

This will give you the mount points that can be shrinked individually.
For me I will only go with shrinking the main disk with "/" (root).

First lets wipe the free space clean so the shrinker will know what is free to get rid of:

sudo vmware-toolbox-cmd disk wipe /

To shrink:

sudo vmware-toolbox-cmd disk shrink /

That's it, after the process in my case I've had a 4.4G file shrinked down to 1.7G, which is much closer to what the client OS saw (1.5G).

Friday, March 6, 2015

How to create Jenins CI compatible JUnit report XML

Currently I use Jenkins version 1.6x. For the most curious here is an example XML that shows the structure. For those of the visual types there will be some treats after the code.

Ok now, let's see how these tags translate on the report UI.

First we are seeing failed results.

These are either failures or errors.

When looking at the test report main page, we'll see a minimal summary.

Let's look at a failed test now, where we also supplied and output (e.g. STDOUT).

Let's see how this is put together in code. I have also pointed out the components of the heading.

The heading can have another component too:

Errors are also failed tests, but you really should add an extra error output to the report for them:

And finally the passed code is a plain entry. Still, you may supply a normal output to it via the element.


The source XSD file I used to figure out how the JUnit XML should look like can be found here. Although the XSD suggests a far more feature rich XML structure, only a minor portion of that information is used by Jenkins. :(

Monday, November 17, 2014

Language injection in Ruby strings with Intellij / Rubymine

I have just discovered that Rubymine was also capable of language injection for strings, even if this is hardly documented:

The trick here is to use the correct heredoc format with defining the language inside the string.

Monday, October 20, 2014

Byobu automated window setup

I am recently working all day in a multiple virtual machine environment and became very tired of typing repetitive commands. The most irritating was to always recreate the default Byobu (with tmux) window setups, running the initial servers in them, etc. So I have asked the question on ServerFault. As a result I have created my 6+ window Byobu automator script and live happily ever since |^_^|

Here is a small GIST example for a simple, non-splitting window setup:

Friday, August 15, 2014

Windows 8 blurry/fuzzy text

Recently I have bought a new machine that came with Windows 8.1 pre installed. To make the story short the texts and some icons were super blurry an fuzzy, edgy. I have spent some hours on the net and found a clue that says new Win8.1 has sometimes the text size increased by default. So what you'll need to do to restore 100% size is:

1. Go to the Control Panel and open Display

2. Then see if you have an automatic selected, if so then have it overridden

3. The default is always 100% so make sure it is selected that way, hit Apply then log out and log in

Monday, September 9, 2013

Recreating Google Docs automatic "Saving..." status display

Developing a new Warcraft guild website gave me a handful of good opportunities to construct and recreate/imitate some edge features used in modern apps today. One of them is a "Saving" status display when you are editing a Google document. So here are the steps I wanted to mirror in my own app:

  1. when the app is constantly saving what the user inputs
  2. when it is just done saving every piece of data
  3. when some time passed and it wants to inform the user about real time status information

These are the steps for the frontend side. On the server side, well just look at this network traffic below, this absolutely has to be custom tailored to everyones infrastructure

Let's look at my original code that was born to recreate this action

The above code looks like this in the browser (sorry, it's the Hungarian version)

Now let me sum up the crucial points in the above code. Javascript is good in using callbacks, async calls. This behaviour could lead to tricky "bugs" or some hours of search on Google. When using setTimeout() with AJAX hand-in-hand then we have to think about AJAX's async nature, where calls are not finished one-by-one in a numbered row. They will finish independently on different timeframes, some fired later but finishes earlier. To overcome this I use an array to store the timeout ids and clear all of them out when the user sends more input. Now there will be no race to clear all living timeouts in time :)

I hope this little code gives some of you more ideas. Please bare with this code as it is premature and not yet ready for production (I believe).

Thursday, March 28, 2013

Ubuntu: add personal path to the global path

My best choice when I want to extend the system path is to create a profile shell script in the /etc/profile.d/ directory with and extension of .sh. The content is something like this:
export PATH=$PATH:/home/ikon/bin
This way my ~/bin directory is added to the system path.  Check it with
$ echo $PATH

Saturday, February 9, 2013

Problem installing debugger on 1.9.3 and RVM

This is a recent problem now, so if you are reading it years later try to adopt your numbers on these lines.

Version ruby 1.9.3-p327 using RVM, debugger and debugger-linecache restisted the bundle install command.
gem install debugger-linecache -v '1.1.2' -- --with-ruby-include=\$rvm_path/src/ruby-1.9.3-p374

gem install debugger -v '1.2.3' -- --with-ruby-include=\$rvm_path/src/ruby-1.9.3-p374