Saturday, December 22, 2012

Winter brake 2012-2013

I take a winter brake, so I suspend posts and comments to this blog for a moment. Resume will be January 7, 2013.

I wish you a Merry Christmas and a Happy New Year.

Thursday, December 20, 2012

PC-BSD 9.1 is finally released.

A few days ago, PC-BSD 9.1 is finally released.


But its KDE ports packages are little confused about directory and dependency. So that I change desktop environment to LXDE since this release.


Monday, December 17, 2012

Refactored Mutual Recursion in F#

(continued from phosphorescence: Mutual Recursion in F#)

  • Defining (n -1) as predecessor function
  • Using Pipe-backward operator

"Tarai and laziest tarai" case in F# becomes more readable.
module MutualRecursion =
  let pred n = n - 1
  let rec laziestTarai x y z'x z'y z'z =
    if y < x then
      laziestTarai
        <| tarai (pred x) y (tarai z'x z'y z'z)
        <| tarai (pred y) (tarai z'x z'y z'z) x
        <| (pred <| tarai z'x z'y z'z)
        <| x
        <| y
    else y
  and tarai x y z =
    if y < x then
      laziestTarai
        <| tarai (pred x) y z
        <| tarai (pred y) z x
        <| (pred z)
        <| x
        <| y
    else y

Friday, December 14, 2012

Operators in F# (are also fucntions).

(In learning from "Programming F# 3.0, 2nd Edition")

Like as boolean operators in this article, a lot of operators in F# are also fucntions when using with surrounding parentheses.

> List.reduce (+) [1; 2; 3; 4; 5];;
val it : int = 15
> List.reduce (*) [1; 2; 3; 4; 5];;
val it : int = 120

Tuesday, December 11, 2012

Ruby 2.0.0 preview 2 on MinGW32

A week ago, Ruby 2.0.0 preview 2 has been announced.

[ruby-core:50443] [ANN] ruby 2.0.0-preview2 released

But, this release has some tricky points to compile on MinGW32.

  1. patch https://bugs.ruby-lang.org/attachments/3320/configure.in.mingw32_gcc_builtins.patch
  2. configure with --host=mingw32 option

Saturday, December 8, 2012

Mutual Recursion in F#

(In learning from "Programming F# 3.0, 2nd Edition")

F# can do "Mutual recursion" by using two reserved words - rec and and. The most famous mutual recursion is "tarai and laziest tarai" case in here. In F#, :
module MutualRecursion =
  let rec laziestTarai x y z'x z'y z'z =
    if y < x then
      laziestTarai
        (tarai (x-1) y (tarai z'x z'y z'z))
        (tarai (y-1) (tarai z'x z'y z'z) x)
        ((tarai z'x z'y z'z)-1)
        x
        y
    else y
  and tarai x y z =
    if y < x then
      laziestTarai
        (tarai (x-1) y z)
        (tarai (y-1) z x)
        (z-1)
        x
        y
    else y
> MutualRecursion.tarai 100 50 0;;
val it : int = 100

(see also : phosphorescence: Refactored Mutual Recursion in F#)

Thursday, December 6, 2012

F# 3.0 on Mac

(continued from phosphorescence: Install F# on Mac OS X)

In this day, Mono 3.0.2 (beta) is released. This is the first release bundling F# 3.0 for Mac OS X.
It's insanely easy.

Monday, December 3, 2012

list comprehensions

(In learning from "Programming F# 3.0, 2nd Edition")

F#'s List, Sequence and so forth can comprehend any functions to define its elements.
> let greetingsTo who = ["Hello, " + who; "Goodbye, " + who];;

val greetingsTo : who:string -> string list

> greetingsTo "Mr.Lawrence";;
val it : string list = ["Hello, Mr.Lawrence"; "Goodbye, Mr.Lawrence"]

Using for clause with yield can define values iteratively.
> let squaringOddNums = [ for i in 1..2..11 do yield i * i ];;

val squaringOddNums : int list = [1; 9; 25; 49; 81; 121]

And, you can the notation -> instead of do yield.
> let squaringOddNums = [ for i in 1..2..11 -> i * i ];;

val squaringOddNums : int list = [1; 9; 25; 49; 81; 121]

But, as you may notice, some cases is simpler to use List.map than to use list comprehensions.
> List.map (fun i -> i * i) [1..2..11];;
val it : int list = [1; 9; 25; 49; 81; 121]

Friday, November 30, 2012

Boolean operators in F# are just fucntions.

Of course, F# has its boolean operators.
> true || false;;
val it : bool = true
> true && false;;
val it : bool = false
But, these are syntax sugar. && and || are not only operators but also functions!
> (||) true false;;
val it : bool = true
> (&&) true false;;
val it : bool = false
I have never known the fact until reading "Programming F# 3.0, 2nd Edition".

Tuesday, November 27, 2012

F#'s variable name is allowed to use apostrophe

F#'s variable name is allowed to use apostrophe, except as first character. I have never known the fact until reading "Programming F# 3.0, 2nd Edition".
> let Mary'sCookie = "Yummy";;

val Mary'sCookie : string = "Yummy"

Saturday, November 24, 2012

Start reading "Programming F# 3.0, 2nd Edition "

I have started reading the final edition of "Programming F# 3.0, 2nd Edition".
As far as I know, It's the first book dealing both F# 3.0 and VS2012.

Thursday, November 22, 2012

FreeBSD project has announced the security incident.

FreeBSD project has announced the security incident. And PC-BSD project also announces too.

Monday, November 19, 2012

I've finished reading "Programming Microsoft ASP.NET MVC, Second Edition"

I've finished reading the Japanese edition of "Programming Microsoft® ASP.NET MVC, Second Edition".

  • This book deals with ASP.NET MVC just literally. In other words, This book does not deal with EntityFramework.
  • But, this book is useful for understanding internal architecture of ASP.NET MVC 3.
  • Japanese edition's appendix (about ASP.NET MVC 4) is not enough, so I wait for its next edition!

Friday, November 16, 2012

Some libraries for Rails 3 still depend to rake 0.9

In this week, both Rails 3.2.9 and Rake 10.x have been released. Rails itself does not depend to rake version. But, some libraries of Rails 3 are depending to rake 0.9.x. so we should fix Gemfile like below:
gem 'rails', '3.2.9'
gem 'rake', '~> 0.9'

Tuesday, November 13, 2012

Three inconvenient things of F# Units of Measure

1. Becoming error when calculate between SI one and its scaled variation

For example, conversion between meter and kilometer is not self‐evident in F#.
For help type #help;;

> open Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols;;
> let a = 195<m>;;

val a : int<m> = 195

> [<Measure>] type km;;

[<Measure>]
type km

> let b = 42<km>;;

val b : int<km> = 42

> a + b;;

  a + b;;
  ----^

stdin(5,5): error FS0001: The unit of measure 'km' does not match the unit of measure 'm'
In this case, we must create some functions to convert these.

2. Becoming error when calculate with non-SI one

For example, conversion between meter and mile is not self‐evident in F#.
For help type #help;;

> open Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols;;
> let a = 10<m>;;

val a : int<m> = 10

> [<Measure>] type mile;;

[<Measure>]
type mile

> let b = 9<mile>;;

val b : int<mile> = 9

> a + b;;

  a + b;;
  ----^

stdin(5,5): error FS0001: The unit of measure 'mile' does not match the unit of measure 'm'
In this case too, we must create some functions to convert these.

3. Cannot instantiate collection of units values with range notation

Surprisingly, F# cannot allow to instantiate collection of units values with range notation.
For help type #help;;

> open Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols;;
> seq {1<g>..10<g>};;

  seq {1<g>..10<g>};;
  -----^^^^^

stdin(7,6): error FS0001: The type 'int<g>' does not match the type 'int'
In this case, we must do the redundant operation like below:
> seq { for i in [1..10] -> i * 1<g> };;
val it : seq<int<g>> = seq [1; 2; 3; 4; ...]

Saturday, November 10, 2012

QtCreator 2.6.0 has been released

In this week, QtCreator 2.6.0 has been released. This is the first major update since Digia finish to accept whole Qt Development teams. So I re-install both Qt 4.8.3 and QtCreator 2.6.0.

Thursday, November 8, 2012

Ruby 2.0 new feature : Refinements

In previous article, I wrote the ruby code with "monkey-patching". But, since ruby 2.0, there are better way to do it. It is "Refinements".
require 'singleton'

# Fibonacci as Singleton class
class Fibonacci < Enumerator
  include Singleton

  def initialize
    super { |y|
      a = 0
      b = 1
      loop do
        y << a
        a, b = b, a + b
      end
    }
  end
end

# define a refinement
module Nth
  refine Enumerator do
    def nth(n)
      self.take(n+1).find.with_index { |elem, i| i == n }
    end
  end
end

begin
  # there are no additional methods
  puts Fibonacci.instance.lazy.nth(100)
rescue => e
  puts e
end

#using refinments
using Nth

begin
  # there is an additional method
  puts Fibonacci.instance.lazy.nth(100)
rescue => e
  puts e
end

$ cd /c/ruby-2.0.0
$ ./bin/ruby ~/fibonacci.rb
undefined method `nth' for #<Enumerator::Lazy:0x26430d8>
354224848179261915075

Monday, November 5, 2012

Ruby 2.0 new feature : Enumerator::Lazy

In functional language, The feature called "lazy evaluation" exists as its key feature. For example, fibonacci in F# is:
Microsoft (R) F# Interactive version 11.0.50727.1
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> let fibonacci = Seq.cache <| Seq.unfold (fun (current, next) -> Some(current, (next, current + next))) (0I, 1I);;

val fibonacci : seq

> fibonacci |> Seq.nth 100;;
val it : System.Numerics.BigInteger =
  354224848179261915075 {IsEven = false;
                         IsOne = false;
                         IsPowerOfTwo = false;
                         IsZero = false;
                         Sign = 1;}

Ruby 2.0's Enumerator::Lazy can do "lazy evaluation" like this:
irb(main):001:0> RUBY_VERSION
=> "2.0.0"
irb(main):002:0> fibonacci = Enumerator.new { |y|
irb(main):003:1*   a = 0
irb(main):004:1*   b = 1
irb(main):005:1>   loop do
irb(main):006:2*     y << a
irb(main):007:2>     a, b = b, a + b
irb(main):008:2>   end
irb(main):009:1> }.lazy
=> #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x23cbbc0>:each>>
irb(main):010:0> def fibonacci.nth(n)
irb(main):011:1>   self.take(n+1).find.with_index { |elem, i| i == n }
irb(main):012:1> end
=> nil
irb(main):013:0> fibonacci.nth(100)
=> 354224848179261915075

If the above sample did not use Enumerator::Lazy, it would take many many seconds.

Friday, November 2, 2012

Ruby 2.0.0 preview 1 has been announced

Today, Ruby 2.0.0 preview 1 has been announced.

[ruby-dev:46348] [ANN] ruby 2.0.0-preview1 released

On my Windows (MinGW), build goes green.

Tuesday, October 30, 2012

Improve SublimeText syntax definition file for F#

SublimeText syntax definition file is not supporting @-quote and triple-quote now. So that I fixed and pull-requested.

Saturday, October 27, 2012

Migrate JRuby from 1.6.8 to 1.7.0

In this week, JRuby 1.7.0 final has been released. This release becomes Ruby-1.9-based product. so that we should take care of migrating from 1.6.8 (or former) to 1.7.0 (or later).

  1. rename directory from jruby-1.6.8 to jruby-1.7.0
  2. rename from jruby-1.6.8/lib/ruby/gems/1.8 to jruby-1.7.0/lib/ruby/gems/shared

Thursday, October 25, 2012

Finally, Amazon launches Kindle and KindleStore in Japan

Today is the memorial day when amazon.co.jp launches Kindle and KindleStore in Japan.

amazon.co.jp sells 3 devices
  • Kindle paperwhite(normal & 3G)
  • Kindle Fire
  • Kindle Fire HD (7inch)

"Kindle Fire HD (8.9inch)" is not here. amazon.co.jp spokesman says that HD (8.9inch) cannot be lanuched in Japan because this product is not yet launched in all over the world.

Monday, October 22, 2012

AsiaBSDCon 2013 starts "Call for paper"

AsiaBSDCon 2013 starts "Call for paper".

This will be held in 14-17 March, 2013.

Friday, October 19, 2012

Japanese BTO builder launches openSUSE 12.2 pre-installed machine


Japanese BTO builder STORM launches Storm Linux Box Desktop LS - an openSUSE 12.2 pre-installed machine. It takes 32550 Yen. Probably, this is the first machine pre-installed openSUSE OS in Japan.

Tuesday, October 16, 2012

SublimeText syntax definition file for TypeScript and for F#

(1) For TypeScript

  1. Download zip file from here
  2. Unzip to "%APPDATA%\Sublime Text 2\Packages"
In here, syntax file for vim and for Emacs also exist.

(2) For F#

  1. make and change directory to "%APPDATA%\Sublime Text 2\Packages\FSharp"
  2. git clone http://github.com/hoest/sublimetext-fsharp .

Saturday, October 13, 2012

PC-BSD 9.1 RC2 is released

In yesterday, PC-BSD 9.2 RC1 is released. I cannot wait the final.

Thursday, October 11, 2012

TypeScript's interface looks like F#'s record

TypeScript is a superset of ECMAScript5 by Microsoft. And Microsoft is aiming to make some TypeScript syntaxes as ECMAScript6 specification (check the specification document). Like as coffee script syntax is similar to Ruby syntax, TypeScript syntax is similar to C# syntax. But, its interface syntax is similar to F# syntax, not C# one.

TypeScript's interface
interface Person {
    firstname: string;
    lastname: string;
}

function greeter(person : Person) {
    return "Hello, " + person.firstname + " " + person.lastname;
}

var user = {firstname: "Jane", lastname: "User"};

document.body.innerHTML = greeter(user);

F#'s record
type Person =
    { firstName : string;
      lastName : string }

let greeter (person:Person) = sprintf "Hello, %s %s" person.firstName person.lastName

let user = {firstName = "Jane"; lastName = "User"}

greeter user |> System.Console.WriteLine

Of course, these are entirely different classses and types. These just looks like similar.

Monday, October 8, 2012

Learning F# 3.0 : LINQ in F# (sample for FizzBuzz)

To use LINQ in F#, There is no need for creating mapper function. And there is also no need for using accumulator in reducer function. The below is the sample for FizzBuzz.
module FizzBuzzLinq =
    open System.Data
    open System.Data.Linq

    let fizzBuzz (fromNum:int) (toNum:int) =
        let fizzBuzzReducer (number:int) =
            match (number % 3, number % 5) with
            | (0, 0) -> "FizzBuzz"
            | (0, _) -> "Fizz"
            | (_, 0) -> "Buzz"
            | (_, _) -> number.ToString()
        let numberList = [ fromNum..toNum ]
        query { for number in numberList do
                select (fizzBuzzReducer number) }

(FizzBuzzLinq.fizzBuzz 1 40) |> Seq.iter (fun elem -> System.Console.WriteLine(elem))
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz

module FizzBuzzLinq = begin
  val fizzBuzz : fromNum:int -> toNum:int -> seq<string>
end
val it : unit = ()

Friday, October 5, 2012

Where is F# interactive of VWD2012Express?

The answer:
  • (Windows 32bit)
    C:\Program Files\Microsoft SDKs\F#\3.0\Framework\v4.0\Fsi.exe
  • (Windows 64bit)
    C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\Fsi.exe

Tuesday, October 2, 2012

Calculate the firefox year #2 (Fixed)

(Check also phosphorescence: Calculate the firefox year #2)

Firefox team announced changing their "Rapid release" plan.
I fix previous "Calculate the firefox year" F# code for this change.
module FirefoxReleaseDate =
  let calculateIn version =
    let calculateAddDays (currentDate:System.DateTime) =
      let happyHoliday = new System.DateTime(currentDate.Year, 12, 25)
      match ( (happyHoliday.Year >= 2012), (happyHoliday <= currentDate.AddDays(7.0 * 6.0)) ) with
      | (true, true) -> currentDate.AddDays(7.0 * 7.0)
      | _ -> currentDate.AddDays(7.0 * 6.0)
    let rec nextFirefoxReleaseDate (currentDate:System.DateTime) (currentVersion) =
        match currentVersion with
        | currentVersion when currentVersion >= version -> currentDate
        | _ -> nextFirefoxReleaseDate (calculateAddDays(currentDate)) (currentVersion + 1)
    let ver5ReleaseDate = new System.DateTime(2011, 6, 21)
    match version with
    | version when version >= 7 -> nextFirefoxReleaseDate (ver5ReleaseDate.AddDays(7.0 * 8.0)) 6
    | 6 -> ver5ReleaseDate.AddDays(7.0 * 8.0)
    | 5 -> ver5ReleaseDate
    | _ -> printfn "Not supported."; ver5ReleaseDate

  let calculateFirefoxYear =
    let rec incrementFirefoxYear (n:int) =
        let date = calculateIn(n)
        if n < date.Year
        then incrementFirefoxYear (n+1)
        else (n, date)
    incrementFirefoxYear(5)

let result = FirefoxReleaseDate.calculateFirefoxYear
let firefoxYearVersion = fst result
let firefoxYearDate = snd result
System.Console.WriteLine("The version equals release year ({0}) ({1:d})", firefoxYearVersion, firefoxYearDate)
System.Console.WriteLine("The version passes release year ({0}) ({1:d})", firefoxYearVersion+1, FirefoxReleaseDate.calculateIn(firefoxYearVersion+1))

Saturday, September 29, 2012

Calculate the firefox year (Fixed)

(Check also phosphorescence: Calculate the firefox year)

Firefox team announced changing their "Rapid release" plan.

The reason is "the Happy Holidays". BTW, I fix previous "Calculate the firefox year" ruby code for this change.
$ irb -rfiber -rdate
irb(main):001:0> next_firefox = Fiber.new do
irb(main):002:1*   ff5 = Date.new(2011, 6, 21)
irb(main):003:1>   ff_next = 6
irb(main):004:1>   ff_next_date = ff5 + 7 * 8
irb(main):005:1>   loop do
irb(main):006:2*     Fiber.yield ff_next, ff_next_date
irb(main):007:2>     ff_next += 1
irb(main):008:2>     ff_plan_date = ff_next_date + 7 * 6
irb(main):009:2>     ff_happy_holiday = Date.new(ff_next_date.year, 12, 25)
irb(main):010:2>     if ff_happy_holiday.year >= 2012 && (ff_next_date..ff_plan_date).include?(ff_happy_holiday)
irb(main):011:3>       ff_next_date = ff_plan_date + 7
irb(main):012:3>     else
irb(main):013:3*       ff_next_date = ff_plan_date
irb(main):014:3>     end
irb(main):015:2>   end
irb(main):016:1> end
=> #<Fiber:0x2dc0af8>
irb(main):017:0> next_firefox_version, next_firefox_date = next_firefox.resume
=> [6, #<Date: 2011-08-16 ((2455790j,0s,0n),+0s,2299161j)>]
irb(main):018:0> while (next_firefox_version < next_firefox_date.year) do
irb(main):019:1>   next_firefox_version, next_firefox_date = next_firefox.resume
irb(main):020:1> end
=> nil
irb(main):021:0> puts "The version equals release year", next_firefox_version, next_firefox_date
The version equals release year
2277
2277-11-06
=> nil

Thursday, September 27, 2012

Learning F# 3.0 : auto-property

Fundamentally, any instances on F# should be immutable. But, if we use F# as C# substitute, we might want mutable object like POCO/POJO. Until F# 2.0, we writed like that:
type Person2() =
    let mutable firstName:string = ""
    let mutable lastName:string = ""
    let mutable age:int = 0
    member this.FirstName with get() = firstName
                          and set(n) = firstName <- n
    member this.LastName with get() = lastName
                         and set(n) = lastName <- n
    member this.Age with get() = age
                    and set(n) = age <- n
But, this is a little complicated. So that, since F# 3.0, here comes the syntax sugar called auto-property:
type Person3() =
    member val FirstName:string = "" with get, set
    member val LastName:string = "" with get, set
    member val Age:int = 0 with get, set
It looks like "Plain Old F# Object"!

Monday, September 24, 2012

Euler's formula does not equal because of Float in Ruby

Euler's formula does not equal because of Float in Ruby. Let's show the example at x = Π.

$ irb -rcmath
irb(main):001:0> include CMath
=> Object
irb(main):002:0> left_euler = exp(-1.0*sqrt(-1.0)*PI)
=> (-1.0-1.2246063538223773e-16i)
irb(main):003:0> right_euler = cos(PI) + sqrt(-1.0) * sin(PI)
=> (-1.0+1.2246063538223773e-16i)
irb(main):004:0> left_euler == right_euler
=> false
irb(main):005:0> left_euler === right_euler
=> false

(check also phosphorescence: Euler's formula in Ruby)

Friday, September 21, 2012

UUID in Ruby

There are 3 ways to deal UUID in Ruby.

(1) Use SecureRandom class

Check my article.

(2) Install uuid gem

Check Github page of uuid gem.

(3) [for JRuby] Using java.util.UUID

irb(main):001:0> require 'java'
irb(main):002:0> import java.util.UUID
irb(main):003:0> UUID.randomUUID.to_s
=> "e42ccfce-d6a0-4cb5-a0c0-9fae6ca05b84"
irb(main):003:0> UUID.randomUUID.to_s
=> "80a31bb3-3fce-4e6f-9c8a-5a819de45960"

Tuesday, September 18, 2012

VWDExpress 2012 goes green for F#

A week ago, Micsosoft announced about F# Tools for Visual Studio 2012 Express for Web in this blog. That is the biggest reason for using VWDExpress 2012 instead of VWDExpress 2010.
And This can install F# MVC4 tools.

Saturday, September 1, 2012

Autumn vacation 2012, and more...

I take a autumn vacation, and I encounter the training "personnel management on correspondence education" in this month :-<

So I suspend posts and comments to this blog for a moment. Resume will be September 18, 2012.

Thursday, August 30, 2012

Qt 5 is now beta

Today, Qt 5 is now beta. Qt 5 is the first version that the architecture is totally changed to modular structure.

Monday, August 27, 2012

FreeBSD Study #10

In last Frieday, FreeBSD Study #10 was held in KDDI Web Commnications' Office.

大きな地図で見る

Today's session is "Managing storage on FreeBSD (vol.2)".
  • How to test the data transfer spped of devices
    1. internal kernel
      dd if=/dev/zero of=/dev/null bs=1024x1024 count=80
    2. read only from device da2
      dd if=/dev/da2 of=/dev/null bs=1024x1024 count=80
    3. write only to device da3
      dd if=/dev/zero of=/dev/da3 bs=1024x1024 count=80
    4. read and write data from device da2 to device da3
      dd if=/dev/da2 of=/dev/da3 bs=1024x1024 count=80
  • (4) must be slower than (2) and (3)
  • limit data transfer spped is which slower one of (2) or (3)

  • iostat: statics command of device I/O
    • IOPS
    • data transfer spped
    • %busy
    • svc_t
  • gstat: statics command of GEOM I/O (iostat GEOM version)

  • The true right way to create gmirror
    1. set gm0 as the mirror of ada1
    2. copy whole ada0 to gm0
    3. set gm0 as boot disk, and reboot
    4. add ada0 to mirror member of gm0, and wait sync between ada0 and ada1
  • The way written in FreeBSD handbook is now incorrect :-)

  • New file system feature since 9.0 (1) : GPT as default
    • because MBR cannot deal partitions over 2TB
  • New file system feature since 9.0 (2) : GPT HAST
    • Highly Available Storage
    • like gmirror over the TCP/IP network
    • deals /dev/hast/XXXX block
    • setting /etc/hast.conf in each machines mirroring

  • ZFS
    • architecture of UFS : device -> volume manager -> file system
    • architecture of ZFS : devices -> ZPOOL -> DMU -> ZFS
    • Good purposes for using ZFS
      • many devices
      • dealing petabyte-class data
    • Not good purposes for using ZFS (just a sales talk :-P)
      • speed
      • robustness
      • scalability
    • ZPOOL : Give the name as one block from one or more devices
    • ZFS Data Set : Give namespaces onto the ZPOOL
    • DMU : internal kernel for manipulating dnode
    • dnode : ZPOOL version inode
      • ZFS Data Sets on ZPOOL are dealt like inode
      • Files ans directories on each ZFS Data Sets are dealt like inode
    • ZFS' I/O = copy-on-write
    • ZFS Pros.
      • transactionable
      • lock free
    • ZFS Cons.
      • heavy for dnode
      • updating cost for large size file
    • Tips
      • SHOULD USE amd64
      • set vfs.zfs.cache.size as 0
      • tune vfs.zfs.meta_limit for your machine

Friday, August 24, 2012

PC-BSD 9.1 RC1 is released

Today, PC-BSD 9.1 RC1 is released. I will try it in next week.

Tuesday, August 21, 2012

cache_page directive for ASP.NET MVC

In Ruby on Rails, we should cache the response of the page with cache_page directive on controller.
class SampleController < ApplicationController
  caches_page :home
  caches_action :home_with_filter

  def home
    ...
  end

  def home_with_filter
    ...
  end
end

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we should use System.Web.Mvc.OutputCacheAttribute class on each actions like below:
public class SampleController : Controller

    [OutputCache(Duration=10)]
    public ActionResult Home()
    {
        ...
    }
end

The advantage of rails way is there are two directives: cache_page and cache_action. cache_page does not execute any actions and filters, but, cache_action only executes filters while ASP.NET MVC has only OutputCache attritbute that does not execute any actions and filters too.

On the other hand, the advantage of ASP.NET MVC way is easy to define expiration seconds of caching while rails' one is more difficult.

Saturday, August 18, 2012

Agile Web Development with Rails 4th edition has been updated on recent rails version

Agile Web Development with Rails 4th edition has been updated on recent rails version from 3.2.0 to 3.2.6:

The notable point is that Rails 3.2.6 is the first version support attr_accessible setting as default.

But, The file upload way on chapter 21 is still older one. See my post : phosphorescence: Sample for uploading file in Rails3 way on AWDwR 4th chapter21.

Thursday, August 16, 2012

ASP.NET MVC 4 is also ready for VWDExpress 2010 too.

In these days, Many Microsoft products comes to RTM. These products are for Windows 8 , .NET 4.5, Visual Studio 2012 and so forth. But, ASP.NET MVC 4 is also ready for Visual Studio 2010 and VWDExpress 2010 (in other words, ASP.NET MVC 4 runs on .NET 4.0 too).


After installation, dialog contains some projects related with ASP.NET MVC 4 like below:

Friday, August 10, 2012

(Reprise) JRuby for Windows users or for Non-western languages

A few days ago, JRuby 1.7.0 preview 2 has been released. But, there are still some bugs - especially, ones related with Ruby 1.9 encodings. So that I re-post the blog article : phosphorescence: JRuby for Windows users or for Non-western languages.

Windows users

As mentioned in this article by Thomas Enebo, Windows platform becomes the first-class platform as same as Unix, Linux and Mac OS(These are de-facto platforms in OSS-develop) since JRuby 1.7.0. Ruby-lang in the JRuby goes green almost. But some gem libraries are not yet. So this article calls for gem library developers to treat Windows platform.

Non-western languages

Since version 1.9, CRuby deals String class with including its own encoding. And since JRuby 1.7.0, as mentioned in this article by Charles Nutter, JRuby also deals it in the same way. It's useful way if you are reading, speaking or writing in non-western language (for me, these are in Japanese). In the current release - JRuby 1.7.0 preview2 -, It's working good for ASCII and UTF-8 characters and encodings. But It has still a bit of bugs with non-western languages and its encodings.

So I hope, if you are in non-western language(Japanese, Chinese, Korean, Arabic, Hebrew and so on), I would like you to download JRuby 1.7.0 preview2, then try and test some Ruby snippets about String, IO, or its related classes, with your own language and its encoding.

Tuesday, August 7, 2012

Easy NuGet CDN testing if you are NOT in USA.

NuGet is the Contents Delivery Network library for .NET, like as CPAN in perl and as RubyGems in Ruby. A few days ago, NuGet Team has announced that they has wanted the people not in USA to test NuGet's CDN is robust and reliable.


The test is quite easy. Above blog post explains:
  1. Download NuGet-CDN.zip
  2. unzip it
  3. run NuGet-CDN.bat

Saturday, August 4, 2012

errors.add for ASP.NET MVC

In Ruby on Rails, we should add error information of model with errors.add method from ActiveModel::Errors class.
  errors.add(:customer, 'Invalid country.')

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we should add error information of model with ViewData.ModelState.AddModelError method from System.Web.Mvc.ModelStateDictionary class.
    ViewData.ModelState.AddModelError("Customer", "Invalid country.");

Thursday, August 2, 2012

SecureRandom

SecureRandom class is the facade class to issue base64, uuid and so forth.
[1] pry(main)> require 'securerandom'
=> true
[2] pry(main)> SecureRandom.hex
=> "444adf4fe82c00ab6d9a7cdffc6d46e1"
[3] pry(main)> SecureRandom.base64
=> "B4hdEsaM3icerGi2/LIEFw=="
[4] pry(main)> SecureRandom.urlsafe_base64
=> "--gOBG02VkWhimQz-6mVyA"
[5] pry(main)> SecureRandom.uuid
=> "da3488c8-0aca-45d0-bd60-d2d1a1df1a02"

Monday, July 30, 2012

RubyKaigi restarts - RubyKaigi 2013 -

In yesterday, dates and venue of RubyKaigi 2013 has been announced. Let's check this page.

Friday, July 27, 2012

Rekonq - the konqueror alternative -

Today, KDE project has announced they start the sub project "Reconq" - the konqueror alternative. This new browser is based on Webkit and featured for HTML5. And it requires Qt 4.8.x or after.

Tuesday, July 24, 2012

FreeBSD Study #9

In last Frieday, FreeBSD Study #9 was held in KDDI Web Commnications' Office.

大きな地図で見る

Today's session is "Managing storage on FreeBSD (vol.1)".
  • What haappens between physical devices and /dev/* file on FreeBSD
    • GEOM is the framework to give abstract tiers between these
  • GEOM class
  • GEOM provider
  • GEOM consumer
  • sysctl kern.geom.*
  • Sample for mirroring on GEOM
  • File system of UNIX
    • Provide approches to file content via the file name
    • Tree structure with a single root
  • Kernel does not necessarily need file systems
  • Userland needs file systems
  • UFS
    • default file system of FreeBSD
  • Structure of UFS
    • inode
    • super block
    • how to approch the block content with inode
  • fsck
    • Check where the inode is collapsed at
  • SoftUpdates
    • Improve performance of fsck
    • Do I/O in async with strict order to add/delete block
  • SoftUpdates + Jornal (SUJ)
    • Since FreeBSD 9.0, SoftUpdates support Journaling
    • Improve the performance more

In this day, Dr Hiroki Sato has explained about Filesystem, GEOM and UFS. I have understood what is UFS+SUJ. On next month, FreeBSD Study #10 will be held and this session will continue with the theme about ZFS.

Saturday, July 21, 2012

Both FreeBSD 9.1 beta1 and PC-BSD 9.1 beta1 have been released

5 days ago, FreeBSD 9.1 beta 1 has been released. Ant then, 2 days ago, PC-BSD 9.1 beta 1 has also been released. Now I'm trying PC-BSD 9.1 beta.

Thursday, July 19, 2012

Protect mass assignment for ASP.NET MVC

In Ruby on Rails, we should protect mass assignment with defining attr_protected (black list) or attr_accessible (white list) on Model like this (via Ruby on Rails Guides).

(black list)
class SomeModel
  attr_protected :admin
  ...
end
(white list)
class SomeModel
  attr_accessible :name
  ...
end

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we should protect mass assignment with defining attribute on argument of Action method, not on Model directly.

(black list)
[HttpPost]
public ActionResult Create([Bind(Exclude="admin")]SomeModel model)
{
    ...
}
(white list)
[HttpPost]
public ActionResult Create([Bind(Include="name")]SomeModel model)
{
    ...
}

The best advantage of this approach is to be able to define black lists or white lists in each actions.

Monday, July 16, 2012

routes.MapRoute

In Ruby on Rails, we define request route on config/route.rb as DSL like this:
match ':controller(/:action(/:id))(.:format)'

I learned from the book Programming Microsoft® ASP.NET MVC, Second Edition that we define request route (1) on Global.asax as RegisterRoutes method or (2) on XXXXAreaRegistration.cs as RegisterArea method, in ASP.NEt MVC. This is the sample:
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}" // URL with parameters
    );
}

If we want to set default value for route, add anonymous object as 3rd parameter:
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Default value for parameters
    );
}
In this sample, UrlParameter.Optional means the rest of parameters.

And then, if we want to set constraint for route, add anonymous object as 4th parameter:
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Default value for parameters
        new { id = @"\d{8}" } // Constraint for parameters
    );
}

Friday, July 13, 2012

F# add-in for MonoDevelop 3.0

A few days ago, F# add-in for MonoDevelop 3.0 has been in beta.

This is easy to install, because we just install via add-in feature.


Monday, July 2, 2012

Summer short vacation 2012

I take a summer short vacation, so I suspend posts and comments to this blog for a moment. Resume will be July 13, 2012.

Friday, June 29, 2012

How to create two-dimensional array of Date class for each months (2)

(continued from phosphorescence: How to create two-dimensional array of Date class for each months (1))

If we want to create two-dimensional array for each "year and month", there are 2 ways.

gourp_by with explicit block

require 'date'
begin_day = Date.new(2011, 12, 1)
end_day = Date.new(2012, 2, -1)
hash_each_month = (begin_day..end_day).group_by{|d| [d.year, d.month]} # hash
days_each_month = (begin_day..end_day).group_by{|d| [d.year, d.month]}.values # two-dimensional array

Add method to Data class by open-class

require 'date'

class Date
  def year_month
    [self.year, self.month]
  end
end

begin_day = Date.new(2011, 12, 1)
end_day = Date.new(2012, 2, -1)
hash_each_month = (begin_day..end_day).group_by(&:year_month) # hash
days_each_month = (begin_day..end_day).group_by(&:year_month).values # two-dimensional array

Tuesday, June 26, 2012

How to create two-dimensional array of Date class for each months (1)

How to create two-dimensional array of Date class for each months:
require 'date'
begin_day = Date.new(2012, 4, 1)
end_day = Date.new(2012, 6, -1)
hash_each_month = (begin_day..end_day).group_by(&:month) # hash
days_each_month = (begin_day..end_day).group_by(&:month).values # two-dimensional array

(continue to phosphorescence: How to create two-dimensional array of Date class for each months (2))

Saturday, June 23, 2012

RubyWorld Conference 2012 starts to call for speakers

The site of RubyWorld Conference 2012 has been opened. This conference will be held in November 8 to 9 at Matsue City.

And, They the Committees start to call for speakers.

Wednesday, June 20, 2012

Installing F# 2.0 on FreeBSD

(continued from phosphorescence: Installing Mono on FreeBSD)

FreeBSD ports also have F#, but, this is not version 2.0, so that we should install F# 2.0 from source via Github.
$ git clone http://github.com/fsharp/fsharp.git
$ cd fsharp
$ autoreconf
$ ./configure
$ gmake
$ sudo gmake install
Let's check F# REPL.
$ fsharpi

Microsoft (R) F# 2.0 Interactive build (private)
Copyright (c) 2002-2011 Microsoft Corporation. All Rights Reserved.

For help type #help;;

> 

Monday, June 18, 2012

Installing Mono on FreeBSD

At this time(writing this article), FreeBSD ports provides Mono 2.11. Let's install
# cd /usr/ports/lang/mono
# make install clean
It takes long time. Then let's check C# REPL.
$ csharp
Mono C# Shell, type "help;" for help

Enter statements below.
csharp> 
That's all. But, unfortunatelly, Mono for POSIX does not contain F#...

Friday, June 15, 2012

Windows 8 release preview and ASP.NET MVC4

2 weeks ago, Windows 8 release preview and Visual Studio 2012 RC had been released. As you see, "Visual Studio 11" has been renamed to "Visual Studio 2012", and Express SKUs are ready. So I try "Visual Studio Express 2012 for Web" to develop ASP.NET MVC4.


Tuesday, June 12, 2012

If you fail upgrading KDE with FreeBSD ports from 4.7 to 4.8

If you fail upgrading KDE from 4.7 to 4.8 on FreeBSD ports, let's try these two operations.

Rebuild all ports referencing PNG

# cd /usr/ports
# portupgrade -fr graphics/png
# portupgrade
It takes long long hours.

Rebuild kalgebra

# cd /usr/ports
# pkg_deinstall kalgebra-4.7.X kde-baseapps-4.7.X
# pkgdb -F
It takes long hours. And check more details in /usr/ports/UPDATING.

Saturday, June 9, 2012

VS F# Express still does not come at this time.

A week ago, Microsoft had announced the plan for VisualStudio 2012 SKUs. In that plan, there had been three "Express" SKUs in addition to paid SKUs.
  • VisualStudio Express 2012 for Windows 8
  • VisualStudio Express 2012 for Web
  • VisualStudio Express 2012 for Windows Phone
The SKU "for Windows 8" supports only Metro-style application, so that many people guessed that there were no Express SKUs for C#, F#, VB and C++.

But, at today, Microsoft changes their plan. This Express SKU has been added.
This SKU supports C#, VB and C++. Unfortunately, as you can see, there are no support for F#. VisualStudio F# Express still does not come at this time. When the one will come?

Thursday, June 7, 2012

Debriefing of ruby standardization

In this week, Debriefing of Ruby standardization has been held. I try to write some summaries.
  • Ruby has been standarized as ISO/IEC 30170 in April, 2012.
  • When Matz started creating Ruby as "hobby program" 20 years ago, he had never thought "Ruby becomes any kind of standards" and "Ruby does not fit any kind of standards".
  • ISO advantages
    • Public purchase projects need programming language is standardized.
    • Projects about embedded system want programming language is standardized.
    • Sales talk at business : "Ruby is ISO-standarized!" :-)
  • Ruby is the first "ISO-standardized" programming language born in Japan.
  • Ruby is also the first "ISO-standardized" programming language worked by Japanese standardization team.
  • At first, JIS-standardized in Japanese (March, 2011), at second, JIS-standardized in English (July, 2011), at last, ISO standardized, so that Ruby is also the first programming language from JIS-standardization.
  • Ruby standardization is based on Ruby 1.8.7.
  • Ruby standardization contains common parts between Ruby 1.8.7 and Ruby 1.9.x.
  • Ruby standardization does not contain any parts not-compatible with Ruby 1.9.x.
  • So that current Ruby standardization is not "full set", that is just "fast track procedure".
  • mruby is almost based on Ruby standardization, without Regexp, MatchData, File and IO.
  • Notably, Ruby is still community-based programming language while Ruby is standardized.
  • Tasks after ISO-standardized
    • Refine standards as "full set"
    • Refine standards compatible with Ruby 1.9.x/2.0
    • Backport standards from ISO to JIS
And related information:
  • mruby is for embedded domain - excepting any real time systems.
  • Ruby 2.0 will be released on February, 2013.

Monday, June 4, 2012

How much level Skydrive supports ODF?

Since April 2012, SkyDrive supports Open Document Format (ODF). But, how much level?
How much level Skydrive supports toView in Desktop BrowserEdit in Desktop BrowserView in Mobile BrowserEdit in Mobile Browser
Office DocumentOKOKOKAlmost NG
Open Document FormatOKAlmost NGAlmost NGNG

Friday, June 1, 2012

MariaDB 5.5.24 has been released

In yesterday, MariaDB 5.5.24 has been released. This is the first release after Oracle had been lost by Google in the court:-)

Tuesday, May 29, 2012

libffi-3.0.11 had been released

About 2 month ago, libffi had been updated to 3.0.11. On MinGW, the DLL file built from libffi source is changed from libffi-5.dll to libffi-6.dll. So that we should rebuild not only libffi-3.0.11 but also any programs using libffi - e.g. Ruby -.

Saturday, May 26, 2012

Github for windows does not use our own MinGW

(continued from phosphorescence: Github for windows is close to (or crawls to) you)

As you see, You can use Github for windows not only for managing your Github repository but also for managing your local repository.

Github for windows can customize preferences.
But, there are no options about msysGit. In other words, while you have already your own msysGit, Github for windows installs completely another msysGit.

Thursday, May 24, 2012

Github for windows is close to (or crawls to) you

   
   
The end is near. I hear a noise at the door,
as of some immense slippery body lumbering against it.
It shall not find me. God, that hand! The window! The window!

(from Wikiquote)


Github for windows is close to (or crawls to) you - Windows users. A few days ago, Github for windows has been released. For more information, please read this article:

This application is - in other words - just a msysGit with MetroUI.

Monday, May 21, 2012

JRuby 1.7.0 preview 1

We can try and report bugs of JRuby 1.7.0 preview 1.

A few days ago, JRuby 1.7.0 preview 1 has been tagged on github. Before you try it, you must build JRuby 1.7.0 preview 1 from source with Ant.
> unzip jruby-jruby-1.7.0.preview1-0-g00c8c98.zip
> cd jruby-jruby-00c8c98/
> ant
Let's chekc the version.
> ./bin/jruby --version
jruby 1.7.0.preview1 (ruby-1.9.3-p203) (2012-05-20 fffffff) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04) [darwin-x86_64-java]
As you see, since JRuby 1.7.0, default version of Ruby becomes 1.9.3 (without --1.9 option).

Friday, May 18, 2012

Difference between Struck and OpenStruct

Ruby has two structure classes - Struct and OpenStruct.

Struct

This is the normal struct.
  • Generated struct is dealt as constant.
  • Accessor methods are not dynamic.
[1] pry(main)> Foo = Struct.new('Foo', :bar, :baz)
=> Struct::Foo
[2] pry(main)> foo = Foo.new(1, 2)
=> #<struct Struct::Foo bar=1, baz=2>
[3] pry(main)> foo.bar = 3
=> 3
[4] pry(main)> foo
=> #<struct Struct::Foo bar=3, baz=2>
[5] pry(main)> foo.qux = 4
NoMethodError: undefined method `qux=' for #<struct Struct::Foo bar=3, baz=2>
from (pry):5:in `<main>'

OpenStruct

This is dynamic struct.
  • Generated struct is dealt as variable.
  • Accessor methods are dynamic.
[1] pry(main)> require 'ostruct'
=> false
[2] pry(main)> foo = OpenStruct.new(bar:1,baz:2)
=> #<OpenStruct bar=1, baz=2>
[3] pry(main)> foo.bar = 3
=> 3
[4] pry(main)> foo
=> #<OpenStruct bar=3, baz=2>
[5] pry(main)> foo.qux = 4
=> 4
[6] pry(main)> foo
=> #<OpenStruct bar=3, baz=2, qux=4>

Tuesday, May 15, 2012

PostgreSQL Magazine has been launched

About 1 week ago, PostgreSQL Magazine has been launched and #1 has been issued. This is the nice e-book magazine, and I want to convert to PostgreSQL from MySQL and its any forks.

Saturday, May 12, 2012

QtCreator never supports MinGW anymore (and Qt maybe too.)

3 days ago, QtCreator 2.5.0 has been released. But, this release contains sad news. Since 2.5, QtCreator never supports MinGW anymore. And IMO, Qt runtime maybe follow, because current download page of Qt runtime still contains MinGW runtime binary, but does not contain any links to MinGW zip exited.

Thursday, May 10, 2012

Java7u4 enables G1GC without UnlockExperimentalVMOptions

(via http://www.infoq.com/news/2012/05/java7u4)

A week ago, Java7u4 has been released. The most notable change is we can enable G1GC without UnlockExperimentalVMOptions.
> java -XX:+UseG1GC Another args...
or,
JAVA_OPTS="-XX:+UseG1GC"
> java $JAVA_OPTS Another args...

Monday, May 7, 2012

Start reading "Programming Microsoft ASP.NET MVC, Second Edition"

I have started reading the Japanese edition of "Programming Microsoft® ASP.NET MVC, Second Edition".


The cover of English edition is below:

But, Japanese edition contains the great appendix - about ASP.NET MVC 4.

Friday, April 27, 2012

Spring short vacation 2012

In Japan, last week of April and first week of May are short vacation weeks. Of course, I take a short vacation, so I suspend posts and comments to this blog for a moment. Resume will be May 7, 2012.

Tuesday, April 24, 2012

Arguments of set command on memcached telnet (2)

(continued from phosphorescence: Arguments of set command on memcached telnet (1))

3rd argument : expiration time

3rd argument(e.g. 0) is the expiration time. If you set zero to this argument, there is no expiration. If you set any positive numbers, value is deleted automatically after the seconds of expiration time.
set some_key 2 15 1
c
STORED
get some_key
VALUE some_key 2 1
c
END
After 15 seconds,
get some_key
END

4th argument : byte length

4th argument(e.g. 1) is the byte length of value.
set some_key 3 0 1
d
STORED
replace some_key 3 0 1
HeCLIENT_ERROR bad data chunk
llo World
ERROR
replace some_key 3 0 11
Hello World
STORED
get some_key
VALUE some_key 3 11
Hello World
END

Saturday, April 21, 2012

Ruby 1.9.3-p194 has been released, and mruby

In yesterday, Ruby 1.9.3 p194 has bean released.

And, mruby has opened its repository. This is the first release not only for embedded environment but also based on Ruby's ISO. Currently, mruby is a pre-trial version, but, I checked succeeding to compile with gcc/bison(Linux, MinGW) and to do "Hello World".

Thursday, April 19, 2012

Arguments of set command on memcached telnet (1)

On memcached telnet, set command has 4 arguments:
set some_key 0 0 1

Of course, 1st argument(e.g. some_key) is the key. But, what are rest of arguments?

Monday, April 16, 2012

AsiaBSDCon 2012

3 weeks ago, AsiaBSDCon 2012 was held.

大きな地図で見る
I attend these 4 workshops.

Friday, April 13, 2012

Deal memcached with telnet on windows

(1) Enable telnet client on Windows

If you are using Windows Vista/7/8, telnet client is disabled as default on these OSs. To enable, please check the page below and do those operations:
Install Telnet Client on Windows 7 or Windows Vista

Tuesday, April 10, 2012

OSS project is different from OSS license

OSS project is different from OSS license

Two things – the one is OSS license, the other is OSS project – are different. The most important difference is that "OSS license" is defined officially by Open Source Initiative (OSI).
On the other hand, "OSS project" is not defined by anybody at all. In other words, if your project applies either cathedral model or bazaar model (See also The Cathedral and the Bazaar), there are no relations about what is OSS license. And, while any OSS licenses describe "How to use software", these do not describe "What project makes software". For more details, please check these article by Phil Haack:

How about "responsibilities to respect the freedom of others"?

Many OSS Licenses have a paragraph about "responsibilities to respect the freedom of others". For instance, GPLv3 has this paragraph:
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
In other words, OSS license never limit our use in any reasons. But, IMHO, I guess this policy is only for OSS license, not for OSS project. My question is:

If OSS license is used for criminal purposes indirectly, OSS itself is not guilty. But if OSS project or its member deal criminal purposes directly, are those guilty or not?

Saturday, April 7, 2012

ASP.NET MVC becomes Bazaar model

About 2 weeks ago, ASP.NET MVC becomes Bazaar model.

ASP.NET MVC, Web API, Razor and Open Source
ASP.NET MVC Now Accepting Pull Requests

In other words,

  • ASP.NET MVC had started to accept pull request from outside
  • ASP.NET MVC changed its license from Ms-PL to Apache Licence

Thursday, April 5, 2012

MongoDB releases C# driver with supporting LINQ

A week ago, C# driver version 1.4 released. And since this version, MongoDB C# driver supports LINQ totally!

CSharp Driver LINQ Tutorial

Monday, April 2, 2012

Friday, March 23, 2012

R.I.P. my grandfather

1923/03/23 - 2012/03/23

Tuesday, March 20, 2012

Ignore case partially in Ruby

Try phosphorescence: Ignore case partially in Ruby
$ irb
irb(main):001:0> /(?i:a)bc(?i:d)/ =~ "AbcD"
=> 0
irb(main):002:0> $~
=> #<MatchData "AbcD">
irb(main):003:0> /(?i:a)bc(?i:d)/ =~ "abcd"
=> 0
irb(main):004:0> /(?i:a)bc(?i:d)/ =~ "Abcd"
=> 0
irb(main):005:0> /(?i:a)bc(?i:d)/ =~ "abcD"
=> 0
irb(main):006:0> /(?i:a)bc(?i:d)/ =~ "ABCD"
=> nil

Saturday, March 17, 2012

Search reference documentations with DuckDuckGo

DuckDuckGo is a search engine recommended by Linux Mint and PC-BSD. The features of DuckDuckGo are:

  • Aggregates results of Google, Bing and so forth
  • Able to copy link directly in result pages
  • DO NOT TRACK

And, one more useful feature for IT developers is "Reference Zero-click Info Sources". For instance, DuckDuckGo show results for supported language and for supported command like below:

Please Check supported languages and commands in this page.

But, DuckDuckGo also show results for unsupported languages in its own way if you use ! notations:


If you favorite this, please type https://duckduckgo.com/ or ddg.gg in your address bar!

Thursday, March 15, 2012

Gel button with mini_magick

"Gel Button" is also popular effect. And of course, mini_magick can do this effect.

require 'mini_magick'

image = MiniMagick::Image.open("http://duckduckgo.com/spread/spread4.png")
width = image[:width]
height = image[:height]
image.write 'spread4.png'

image_cloned = MiniMagick::Image.open('spread4.png')
image_cloned.combine_options do |mogrify|
  mogrify.alpha 'off'
  mogrify.blur "#{width}x#{height}"
  mogrify.shade "#{width}x#{height}"
  mogrify.normalize
  mogrify.sigmoidal_contrast '8,60%'
  mogrify.evaluate 'multiply', '.5'
  mogrify.roll "+0+#{(height*0.05).to_i}"
end
image_composed = image_cloned.composite(image) do |c|
  c.compose 'Screen'
end

image_composed.write 'gel_spread4.png'

This is the original image (from Duck Duck Go).

And, this is the converted one.

Monday, March 12, 2012

Windows 8 customer preview and ASP.NET MVC4

2 weeks ago, Windows 8 customer preview and Visual Studio 11 beta had been released. The most notable feature for me is that Visual Web Development supports ASP.NET MVC4 by default. Now I'm learning.

Friday, March 9, 2012

Update summaries of PostgreSQL Conference 2012

I update summaries of PostgreSQL Conference 2012.

phosphorescence: PostgreSQL Conference 2012

Tuesday, March 6, 2012

Timetables of AsiaBSDCon 2012 are revealed

AsiaBSDCon 2012 are revealed now.
The most interest session for me is about PC-BSD.

T2B: Maintaining your own PBI package repository

Saturday, March 3, 2012

MariaDB 5.3.5 has been released

A few days ago, MariaDB 5.3.5 has been released. MariaDB 5.3.5 is the first stable release of 5.3.x. And, this release is useful for windows user (Let's check this improvements).

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.