Wednesday, February 29, 2012

I understand "git commit --amend"

I had just known that the git command "git commit --amend" was existing. But I didn't know what it was and when/how I could use this. But when I have been researching about Bill of Rights in previous post, I understand it. Like as "amendments" re-define and re-design the last version of United States Constitution, "git commit --amend" re-defines and re-designs the last commit.

Monday, February 27, 2012

Consumer Privacy Bill of Rights

In the book I have introduced contains the difference between US and EU. The typical difference is that EU has taken top-down privacy approach despite US has taken bottom-up privacy approach. But, 3 days ago, US government announced "Consumer Privacy Bill of Rights".

PDF : Consumer Privacy Bill of Rights
News : White House Releases Long-Anticipated Privacy Report

So that US will change its privacy approach to top-down like EU's. I try to the "Privacy and Big Data" authours:


And accept a reply:


I'm looking forward to read the refined book.

Friday, February 24, 2012

PostgreSQL Conference 2012

PostgreSQL Conference 2012 was held at here.

大きな地図で見る
I attended these sessions:

Tuesday, February 21, 2012

The future of MVC4

One week ago, Microsoft announced that ASP.NET MVC4 beta had been released. And Scott Guthrie said some important things in his blog like below:
  • ASP.NET MVC4 installer contains EntityFramework 4.3
  • ASP.NET MVC4 installer contains Razor template engine v2
  • ASP.NET MVC4 only supports .NET Framework 4 and VisualStudio 2010. In other words, it doesn't support .NET Framework 4.5 and VisualStudio 11 at this beta release. These all will be supported at RTW in this September.

Saturday, February 18, 2012

Two little stumbling points of ImageMagick

IMHO, there are two little stumbling points when I use ImageMagick command line. The first one is for Windows only, but the other one is for all platforms.

The Convert issue

The official usage page explains what is "The Convert issue". This is because that any default Windows environment contains convert.exe command, so that there is the risk of conflicting with ImageMagick's convert.exe. This is the reason why Windows installer add ImageMagick's root path to the system path, not to the user's path. And you can also avoid this risk as written in "The Convert issue".

Command options are not liner.

In CUI commands, their command options generally have two simple rules.
  • Command options start with the character -(minus).
  • Command options are interpreted in liner.
But, in ImageMagick, these are not true. In other words, there are another two rules. You could find this in all over ImageMagick examples.
  • Command options start with... not only the character -(minus) but also the character +(plus). Plus option is the shortcut for corresponding minus option with default values.
  • Command options are interpreted with ()(paren) priority.
Off course, these rule is so powerful to generate complex image effects, but it's not easy for ImageMagick newbies.

Thursday, February 16, 2012

Ruby 1.9.3 p125 has bean released

A few hours ago, Ruby 1.9.3 p125 has bean released. This is the security fix for Ruby OpenSSL. See the page below, for more information:

Of course, it's ready for MinGW. Install operations are as written in phosphorescence: Clean installation Ruby 1.9.3 preview1 with MinGW and MSYS.

Monday, February 13, 2012

FreeBSD is the easiest way to use Rails3 with nginx

To use ports on FreeBSD is the easiest way to use Rails3 with nginx.

(1) rubygem-rails port has configuration for rubygem-passenger

(2) rubygem-passenger port has configuration for nginx

(3) nginx port has configuration for many plug-ins.

BTW, rubygem-activerecord port has configuration for PostgreSQL.
So that you can choose BSD-License Friendly products (Ruby 1.9.3, nginx and PostgreSQL) to using Rails3.

Friday, February 10, 2012

specular reflection with mini_magick (2)

(continued from phosphorescence: specular reflection with mini_magick (1))

"Specular Reflection" consists of 4 operations.
  1. clone from original image and rotate it
  2. add transparency to cloned image
  3. combine original image and cloned one
  4. resize combined image
In this article, I introduce the operation of both (3) and (4) with referring ImageMagick's sample page and using mini_magick. Roughly instructions are below:

  1. Create canvas with extending the vertical length
  2. Put the rotated image onto the bottom of this canvas
  3. Put the original image onto the top of this canvas

Sample of concrete implementation is below:
require 'mini_magick'

original_file = "original.jpg"

image_cloned = MiniMagick::Image.open(original_file)

background_color = 'black' # set background color
COMPOSITE_GRAVITY = 'north'
TRANSPARENCY = '65%'
REFLECTION_FACTOR = Math.sqrt(2)

image_cloned.combine_options do |mogrify|
  mogrify.flip
  mogrify.fill background_color
  mogrify.colorize TRANSPARENCY
end

image_original = MiniMagick::Image.open(original_file)

image_cloned.combine_options(:convert) do |convert|
  new_width = image_original[:width]
  new_height = (image_original[:height]*REFLECTION_FACTOR).to_i
  convert.size "#{new_width}x#{new_height}"
  convert.xc background_color
  convert.swap '0,1'
  convert.gravity COMPOSITE_GRAVITY
  convert.geometry "+0+#{image_original[:height]}"
  convert.composite
end

image_combined = image_cloned.composite(image_original) do |c|
  c.gravity COMPOSITE_GRAVITY
end

output_file = "reflected_#{background_color}.jpg"
image_combined.write output_file
puts "#{output_file} is generated."

These are the output samples.

for white background:

for black background:

Tuesday, February 7, 2012

specular reflection with mini_magick (1)

"Specular Reflection" - a.k.a. "mirror effect" - is the most popular effect for image file to be good-looking. This effect consists of 4 operations.
  1. clone from original image and rotate it
  2. add transparency to cloned image
  3. combine original image and cloned one
  4. resize combined image
In this article, I introduce the operation of both (1) and (2) with referring ImageMagick's sample page and using mini_magick.

This ruby script is like below:
require 'mini_magick'

image_original = MiniMagick::Image.open("original.jpg")

image_cloned = image_original.clone

image_cloned.combine_options do |c|
  c.flip
  c.fill 'white' # set background color
  c.colorize '65%'
end

image_cloned.write "cloned_rotate_transparent.jpg"

You can change the argument(color name) of fill method depending on the background color where you want to put the image file onto. These are original image and rotated and transparent one.


(continue to phosphorescence: specular reflection with mini_magick (2))

Saturday, February 4, 2012

JRuby 1.7 becomes 1.9 mode as default mode

In this issue ticket - http://jira.codehaus.org/browse/JRUBY-6387 - JRuby team surveys that JRuby 1.7 becomes 1.9 mode as default mode or not. And then, decided!!

Thursday, February 2, 2012

Ruby on Rails 3.2 had been released. (with one stumbling point)

About two weeks ago, Ruby on Rails 3.2 had been released. To update to the rails 3.2.0 or higher, you not only do the "gem update" or "bundle update" but also copy rails command file and rackup command file manually. There is only one stumbling point when updating to the rails 3.2.0 or higher - despite ruby-gems related with rails are upgraded successfully, rails command and rackup command are NOT.