Halaman

Tampilkan postingan dengan label hints. Tampilkan semua postingan
Tampilkan postingan dengan label hints. Tampilkan semua postingan

Senin, 18 Agustus 2014

Solving Git always shows modified files even if they are not modified

Sometime when working on multiple environment(Windows, *nix), the new line character at the end is not visible to the human eye, but even if that is not visible, versioning system such as git will treat them as modifications.

When installing Git on windows machine, we usually press the "next" button rapidly that we are not aware that we are telling the Git to add automated "crlf" or "lf" to each line of the checked-out source code. The symptom such as :
  1. Always shows modified files even if we are not changing a particular file
  2. Even after revert or a hard --reset the modified files is showing
To remedy the situation use the following command in sequence:
  1. git config --global core.autocrlf false
  2. git reset --hard
  3. git status
The list of modified files which we are not modify should be gone now. 

Cheers! ;)

Minggu, 26 Januari 2014

How to find out built in defines from a specific GCC compiler?

A little trick i read from LuaJit's makefile and the gcc manual page. To list all built-in defines use the following (assuming that you don't have yohan.h file on the current directory..)

# touch yohan.h
# gcc -E -dM yohan.h

and if the "yohan.h" contains your own code of defines, it will also be resolved.. giving you the exact picture of what's happening with your sources defines

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

Rabu, 02 November 2011

Packet Sniffer

When you are working with the internet / network, you need to make sure that the packet you sent/receive is what you are planning to get / send

This open source packet sniffer is a very great project. It could even sniff your password when you even though you send them using ssl/encryptions

Here is the link to that wonderfull project : http://code.google.com/p/ospy/

Very nice!!

Senin, 16 Mei 2011

Hints : jangan pernah membandingkan float dan integer

Yapp!!
Walaupun  kelihatan sederhana, namun untuk dunia programming, sungguh sangat di-'haram' kan untuk membanding kan integer dan float dalam conditional..

hari ini dalam pembuatan game pipe the mob, saya mencari bug yang ternyata di akibatkan oleh variable-variable inih!! menghabiskan waktu cukup lumayan.. ~12 jam di depan komputer hanya untuk menemukan kesalahan ternyata ada pada pembandingan float dan integer..

hixs..

Lesson learned! :D