Halaman

Rabu, 13 November 2013

c++ defines, what is the meaning of that dreaded ## signs.. :)

That ## syntax maybe looks like evil, but as a lovely c++ programmer, you need to use and get familiar with that syntax

When i first saw this syntax.. the ants starts to creep on my stomach as my lack of skill in pronounces, i could not find the right keyword to google that '##' syntax.. :(

when you see something like this on some c++ header file:

#define CF(className) create##ClassName(){}


this macro if applied for example..

CF(kittyClass);

That macro, by the compiler will be translated to

createKittyClass(){};

Yep, and that is all folks.. :)

Jumat, 02 Agustus 2013

[Tizen] Problem starting emulator

Does your hardware support hardware virtualization? if not i share your pain :( if you download and install the Tizen SDK ver 2.1 there is a solution posted to make your emulator runs.. yes it runs.. but it is veeeryyyy slooowww..

Steps:

  1. Create your new emulator
  2. Run the emulator
  3. Wait for it to load
  4. Right click and then open the shell
  5. Type the following command : 
    1. su
    2. sed -i 's/notify/oneshot/g' /usr/lib/systemd/system/user-session@.service
  6. If you would like to use the manual way of changing that one, buut this one is on your OS'es command prompt
    1. sdb pull /usr/lib/systemd/system/user-session@.service user-session@.service
    2. Edit that file using notepad, Modify "Type=notify" to "Type=oneshot"
    3. sdb push user-session@.service /usr/lib/systemd/system/user-session@.service
    4. Now verify by typing these on your emulator's shell:
      cat /usr/lib/systemd/system/user-session@.service
  7. Restart the emulator

Senin, 01 Juli 2013

[Wordpress]problem of wordpress post thumbnail images not resized correctly

Let's open the article with the following code snippet, taken from WP's(WordPress'es) function image_get_intermediate_size from the file media.php from

   if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
   $file = $data['file'];
    list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
    return compact( 'file', 'width', 'height' );
   }

Well, what's wrong with that statement? there is nothing wrong with that statement, it is just that when you have an original image size which width or height was the same as the default thumbnail size, since the autogenerated thumbnail width is always lesser than the original image, then the 'autogenerated' thumbnail size will always be returned

Consider the following example, you have your original image at the resolution of 200px * 135px.
Note that the default thumbnail size generated by WP is 150px * 135px, and then you have the following code which is intended to show the featured image for the current page:

<?php echo get_the_post_thumbnail($page->ID, array(200, 135)); ?>

You will not get your 200px * 135px as you intended, instead the code will give you a 150px * 135px thumbnail size, since the later rule from the if stament presented earlier fits to these sizes perfectly, it will gives you a cropped and scaled image of 150px * 135px

A fast fix would be specifying get_the_post_thumbnail($page->ID, array(200, 136)) which will give you a 'slightly distorted' thumbnail, another fix would be implementing a default thumbnail size via WP's function set_post_thumbnail_size on your theme's function.php file

Minggu, 26 Mei 2013

[Delphi] DevExpress Ribbon - how to

Since it's is a rather sparse documentation, i think i will try to post how to add a Ribbon Control to the Delphi XE application

  1. Open Delphi!
  2. Create a new VCL Form Application
  3. Open your main pas file
  4. Change the ancestor for the TForm, to TdxCustomRibbonForm
  5. Add the unit dxRibbon
  6. Drop a dxBarManager and then assign it to your dxRibbon
  7. On dxRibbon, right click and then choose Tabs Editor..
  8. Add a TdxRibbonTab, and then highlight that newly created ribbon tab
  9. On you inspector, click on Groups and then click on the ellipsis to create a new Ribbon Tab Group
  10. For the time being, leave it as is..
  11. Double click you dxBarManager, create a new Toolbar
  12. Create a new command and then drop that command to your toolbar
  13. Now let's go back to your previously created Ribbon Tab Group, in the inspector, see the property Toolbar and assign it the toolbar you created on step 11
  14. Okayh, that's one great strong basic, now go wild!
Cheers!

Kamis, 17 Januari 2013

[YII] Quick Start, YII Tutorial in 2 minutes!

Yii as simple as 1..2..3 For this tutorial, i assume that you are working in windows environtment and already setup your local webserver (xampp, wamp, etc..)
  1. Download Yii anywhere you wanted, extract them to any folder you wanted.., for this example let's say after you download the zip file, you extract it to c:\yii
  2. Open up command prompt / terminal
  3. Change your dir to the directory where you put your php.exe, in my case it is in C:\xampp\php
  4. On that dir, execute the command:
    php "C:\yii\framework\yiic" webapp MyAppName
  5. Now move the folder MyAppName to your htdocs folder,
    in my case i move entire folder to C:\xampp\htdocs
  6. That is it.. now you have a fully working MVC Yii application
    Open your browser and then go to the address http://localhost/MyAppName

Rabu, 16 Januari 2013

[Delphi] MDI On a TPanel, RTTI power example

Ummh, since it's 3 AM, and just as a quick note on delphi power, MDI child on a TPanel and an introduction to a RTTI usage..
You will need Delphi XE and TMS Component
procedure TForm1.AdvOfficeMDITabSet1TabClose(Sender: TObject;
  TabIndex: Integer; var Allow: Boolean);
var
  form : TForm;
begin
  form := AdvOfficeMDITabSet1.GetChildForm(AdvOfficeMDITabSet1.AdvOfficeTabs[TabIndex]);
  form.Close;
  Allow := False;
end;

procedure TForm1.New1Click(Sender: TObject);
var
  c : TForm;
begin
  c := TForm2.Create(Self);
  c.Parent := Panel2;
  c.SetBounds(0, 0, Panel2.Width, Panel2.Height);
  c.Caption := 'Yohan ' + IntToStr(Panel2.ControlCount);
  (c as TForm2).EllipsLabel1.Caption := c.Caption;
  c.Show;

  //introducing the power of delphi RTTI!
  if(c.ClassType = TForm2) then
    AdvOfficeMDITabSet1.AddTab(c);
end;