The library is a simple API in Ruby for Microsoft Translator V2

MsTranslate

The library is a simple API in Ruby for Microsoft Translator V2

The Microsoft Translator services can be used in web or client applications to perform language translation operations. The services support users who are not familiar with the default language of a page or application, or those desiring to communicate with people of a different language group.

Installation

Add this line to your application’s Gemfile:

gem 'ms_translate'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ms_translate

Usage

first step set your appId

$ MsTranslate::Api.appId = 'MyRealAppId'

traNslate method:

$ MsTranslate::Api.translate('Hello World!)
$ => Ciao, Mondo!

Method not implemented

  1. Microsoft.Translator.AddTranslation Method
  2. Microsoft.Translator.AddTranslationArray Method

Test

You need to insert your appId into

# File 'spec/lib/ms_translate/api_spec.rb'
@api_real =  'INSERT_YOUR_APPID'

Contributing

  1. Fork it
  2. Create your feature branch (
    git checkout -b my-new-feature

    )

  3. Commit your changes (
    git commit -am 'Added some feature'

    )

  4. Push to the branch (
    git push origin my-new-feature

    )

  5. Create new Pull Request

Author

endorse

WaYdotNET, you can follow me on twitter @WaYdotNET or take a look at my site waydotnet.com

Copyright

Copyright (C) 2012 Carlo Bertini – @WaYdotNET

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Padrino-admin Twitter Bootstrap v2.0 is ready

(Padrino Admin TwitterBootstrap 2.0)

  • Padrino-Modal: rack-flash and delete function into modal πŸ˜€
  • highlights error field
  • tof helper: Automatic replace true or false with relative image (list.slim and list.haml)
  • Breadcrumbs
  • Automatic time_ago_in_words when column model is created_at or updated_at
  • Migrate function for MiniRecord

Padrino-Modal

All result from rack-flash and delete request, now is automatic insert into modal javascript plugin

highlights error field

tof_helper

Automatic replace true or false with relative image (list.slim and list.haml)

Breadcrumbs

Automatic Breadcrumbs system:

time_ago_in_words

Automatic time_ago_in_words when column model is created_at or updated_at

MiniRecord migrate

Migrate function for MiniRecord

Demo:

http://padrino.waydotnet.com/admin
user: test@padrinorb.cpm
password: test

By WaYdotNET

Padrino Admin another new layout (based on Twitter Bootstrap v2.0-wip)

http://glowing-leaf-7114.heroku.com/admin/
user: test@padrinorb.com
pass: test

PLEASE DON’T CHANGE LOGIN/PASSWORD

Additional feature:

  • ✔ Padrino-Modal: rack-flash and delete function into modal πŸ˜€
  • ✔ highlights error field
  • ✔ tof helper: Automatic replace true or false with relative image (list.slim and list.haml)
  • ✔ Breadcrumbs
  • ✔ Automatic time_ago_in_words when column model is created_at or updated_at
  • ✔ Migrate function for MiniRecord

clone my repository and enjoy πŸ˜€

https://github.com/WaYdotNET/padrino-framework

See the code and comment please !!!!

CoffeScript (1.1.1) on Windows: simple method !

CoffeScript (1.1.1) on Windows: simple method !


Inspiration: http://blog.mnasyrov.com/post/2872046541/coffeescript-on-windows-how-to-roast-coffee

To use CoffeScript you need:

  1. Node.js
  2. CoffeeScript
  3. Batch file to run CoffeeScript

 

STEP 1: Node.js

 

I’m very very lazy dev… πŸ˜€
And i don’t recompile NodeJs into Windows….. but I’m using v0.4.7 from http://node-js.prcn.co.cc/ [many thx]
and install into:

D:>cd ToolsNodeJsbin

D:ToolsNodeJsbin>node --version
v0.4.7

 

STEP 2: CoffeeScript

 

Use the last version , grab it from https://github.com/jashkenas/coffee-script
and install into:

D:ToolsCoffeeScript

Check version

D:ToolsNodeJsbinnode /cygdrive/D/Tools/CoffeeScript/bin/coffee --version
CoffeeScript version 1.1.1

Node.js need unix-path


Step 3: Batch file

 

I don’t know well bat syntax, and my code is VERY VERY ugly.. but it works πŸ˜›

 

@echo off

:: Directories of the tools
SET coffeeDir=D:ToolsCoffeescriptbin
SET nodeDir=D:ToolsNodeJsbin

:: var
SET a=%1
SET b=%2
SET c=%3
SET d=%4
SET e=%5
SET f=%6
SET g=%7
SET h=%8
SET i=%9

:: Check input value if exist and if it's option or file

:A
IF "%a%"=="" GOTO :B
IF "%a:~0,1%"=="-" GOTO :B
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %1') DO SET a=%%o
:B
IF "%b%"=="" GOTO :C
IF "%b:~0,1%"=="-" GOTO :C
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %2') DO SET b=%%o
:C
IF "%c%"=="" GOTO πŸ˜€
IF "%c:~0,1%"=="-" GOTO πŸ˜€
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %3') DO SET c=%%o
πŸ˜€
IF "%d%"=="" GOTO :E
IF "%d:~0,1%"=="-" GOTO :E
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %4') DO SET d=%%o
:E
IF "%e%"=="" GOTO :F
IF "%e:~0,1%"=="-" GOTO :F
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %5') DO SET e=%%o
:F
IF "%f%"=="" GOTO :G
IF "%f:~0,1%"=="-" GOTO :G
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %6') DO SET f=%%o
:G
IF "%g%"=="" GOTO :H
IF "%g:~0,1%"=="-" GOTO :H
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %7') DO SET g=%%o
:H
IF "%h%"=="" GOTO :I
IF "%h:~0,1%"=="-" GOTO :I
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %8') DO SET h=%%o
:I
IF "%i%"=="" GOTO :COMMAND
IF "%i:~0,1%"=="-" GOTO :COMMAND
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %9') DO SET i=%%o

:COMMAND
FOR /f %%o IN ('%nodeDir%/cygpath.exe -a -u %coffeeDir%') DO SET p=%%o
%nodeDir%node %p%/coffee %a% %b% %c% %d% %e% %f% %g% %h% %i%

 

set the PATH environment variable contains a path to coffee.bat

the name of the file is very important,Β  in my case it works well with coffee-rack

Enjoy

Many thanks to:

Mikhail Nasyrov => http://blog.mnasyrov.com/post/2872046541/coffeescript-on-windows-how-to-roast-coffee
Node.js self-contained Windows binaries => http://node-js.prcn.co.cc/index.html
Jeremy Ashkenas => http://jashkenas.github.com/coffee-script/

LAZY Agnostic Application Generators (padrino-lazy)

Overview

Through padrino-lazy, we can include some common properties shared between the model object used a base model object

Padrino is very good framework, and almost follows the DRY principle (Don’t Repeat Yourself) When we need to have some common properties shared between the model object of our ORM, using the generator padrino-gen, We can only include these properties in each model to generate.

I hope this idea will be included in Padrino Framework.
Principle / Step

  1. generate a model
  2. convert the model into base model ( move this model into lib/ folder)
  3. save config file with model base’s list
  4. generate a model from base model
  5. generate a migration file

Usage

Step 1-2-3

$ padrino-lazy base --c config_file --b base_model_name --f field_to_create

Step 4-5

$ padrino-lazy model --c config_file --b base_model_name --f field_to_create --m model_name

Install

gem install padrino-lazy --pre

Example

$ padrino-lazy base --c config --b BaseModel --f "create_at:datetime is_active:boolean"

now we have

lib/base_model.rb class BaseModel


include DataMapper::Resource

  # property ,
  property :id, Serial
  property :create_at, DateTime
  property :is_active, Boolean

end

config/config.yml


---
- base: BaseModel
fields: create_at:datetime is_active:boolean
$ padrino-lazy model --c config --b BaseModel --f "name:string have_children:boolean born:date foo:integer"  --m User

app/models/user.rb

class User <  BaseModel

  # property ,
  property :name, String
  property :have_children, Boolean
  property :born, Date
  property :foo, Integer
end

db/migrate/001_create_users.rb


migration 1, :create_users do
  up do
    create_table :users do
      column :id, Integer, :serial =&gt; true
      column :name, String
      column :have_children, Boolean
      column :born, Date
      column :foo, Integer
    end
  end

  down do
    drop_table :users
    end
  end

db/migrate/002_add_basic_model_to_user.rb


migration 2, :add_basic_model_to_user do
  up do
    modify_table :users do
      add_column :name, String
      add_column :have_children, Boolean
      add_column :born, Date
      add_column :foo, Integer
  end
end

down do
modify_table :users do
drop_column :name
drop_column :have_children
drop_column :born
drop_column :foo
end
end
end

Known issue

  • VERY VERY alpha code !! (thanks to my pig/lazy side πŸ˜€ )
  • β€”f options need dobule quote around fields
  • β€”b write in CamelCase
  • TESTING only with datamapper and activerecord into linux machine

TODO:

  • Test all code !
  • Use Padrino::Generators instead of Commander
  • Default config file name (very lazy πŸ˜› )

THANK

  • Team Padrino
  • DaddYE
  • Piedinodifata

CODE
https://github.com/WaYdotNET/padrino-lazy

RMagick on Ruby 1.9.1 (i386-mingw32) Work !!! :D [UPDATE]

RMagick on Ruby 1.9.1 (i386-mingw32) Work !!! πŸ˜€
Ispirate from :
installing rmagick with mingw and ruby 1.9
and
http://groups.google.com/group/rubyinstaller/browse_thread/thread/c837c4438d91208b
but , on my laptop don’t work….

With Windows 7 work well:

Step 1: DOWNLOAD

1) Ruby => http://rubyforge.org/frs/download.php/74298/rubyinstaller-1.9.2-p180.exe
2) DevKit => http://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.1-20101214-1400-sfx.exe
3) ImageMagick => http://www.imagemagick.org/download/binaries/ImageMagick-6.6.7-9-Q16-windows-dll.exe
4) RMagick => https://github.com/rmagick/rmagick/zipball/master
5) type-windows.xml => http://www.imagemagick.org/source/type-windows.xml

Step 2: Install

1) Ruby => c:Ruby192
2) DevKit => c:DevKit
3) ImageMagick => c:ImageMagick-6.6.7-Q16 [WITH HEADER !!!!!!!]
3.a) Replace c:ImageMagick-6.6.7-Q16configtype-ghostscript.xml  with type-windows.xml
4) RMagick => c:rmagick-rmagick

Step 3: Set Enviroment variable

1) PATH = C:Ruby192bin;C:ImageMagick-6.6.7-Q16
2) CPATH = C:ImageMagick-6.6.7-Q16include
3) LIBRARY_PATH = C:ImageMagick-6.6.7-Q16lib

Step 4: Configure DevKit
(from https://github.com/oneclick/rubyinstaller/wiki/Development-Kit)

1) cd c:DevKit
2) ruby dk.rb init
3) ruby dk.rb install
4) C:DevKitdevkitvars.bat (THANKS TO Joachim  => http://www.waydotnet.com/blog/2010/02/rmagick-on-ruby-1-9-1-i386-mingw32-work-d/#comment-86618621)

Step 5: Compile RMagick

1) run C:DevKitmsys.bat
2) cd /c/rmagick-rmagick
3) ruby setup.rb
4) ruby setup.rb install

Step 6: Check

1) ruby -v
        ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
2) identify --version
    Version: ImageMagick 6.6.7-9 2011-02-21 Q16 http://www.imagemagick.org
	Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
	Features: OpenMP

If you experience problems concerning “extconf.rb”, you should try:
http://phosphor-escence.blogspot.com/2010/12/if-you-fail-install-rmagick-on-mingw.html
from
http://www.waydotnet.com/blog/2010/02/rmagick-on-ruby-1-9-1-i386-mingw32-work-d/#comment-166014708
http://www.waydotnet.com/blog/2010/02/rmagick-on-ruby-1-9-1-i386-mingw32-work-d/#comment-317551623


In my case :
1) Install Ruby 1.9.1 (i386-mingw32) from http://www.rubyinstaller.org/, direct link

2) Install Development Kit (DevKit) from http://www.rubyinstaller.org/addons.html, direct link

3) Install ImageMagick 6.5.6-8-Q8 from http://www.imagemagick.org , direct link with header !!!!

4) Download Rmagick from source : http://github.com/rmagick/rmagick , direct link or git clone git://github.com/rmagick/rmagick.git

5) Replace !ImageMagick Path!configtype-ghostscript.xml with

http://www.imagemagick.org/source/type-windows.xml

 

 

6) Set enviroment variable :
set CPATH=!ImageMagick Path!include
set LIBRARY_PATH=!ImageMagick Path!lib
set PATH=!ImageMagick Path!
[EDIT]
set PATH = !ruby_path!bin
set PATH = !ruby_path!devkitmsys1.0.11bin
set PATH = !ruby_path!devkitgcc3.4.5bin
[EDIT]
7) run “ruby setup.rb” [EDIT] from msys.bat ( !ruby_path!devkitmsys1.0.11msys.bat ) [EDIT]

 

8) run “ruby setup.rb install” or “gem build *.gemspec” and “gem install *.gem”

9) Enjoy πŸ˜€

identify –version
Version: ImageMagick 6.5.6-8 2009-10-03 Q8 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

 

ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]

Many thanks to :
Rmagick staff => http://rmagick.rubyforge.org/
rogerdpack => http://betterlogic.com
Alexey Borzenkov => not have link, sorry
Luis Lavena => http://blog.mmediasys.com
RubyInstaller => http://www.rubyinstaller.org
RubyInstaller Group => http://groups.google.com/group/rubyinstaller
puts WaYdotNET => Carlo Bertini

Photo Resize from console :D

Qui raccolgo un po di script che mi sono fatto x la vita di tutti i giorni πŸ˜€

Photo resize (photo_resize)

piccolo script in ruby che serve per fare delle thumbnails di foto, passando almeno la cartella contenente le foto (strano :D)

Require:

ruby (test with: ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux] ||ruby 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux] || jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [amd64-java] )
rmagick (http://rmagick.rubyforge.org/)
optiflag (http://optiflag.rubyforge.org/)

syntax:

----------------                                      
    Description:        Folder with image to resize   
           Flag:        -s (Required, takes 1 argument) 
      Long Form:        --source                        
Alternate Flags:        -source, -S, -from              
----------------
    Description:        Folder to save the thumbnails, auto => source/thumb
           Flag:        -t (Optional, takes 1 argument)
      Long Form:        --target
Alternate Flags:        -target, -T, -to, -To
----------------
    Description:        Width max
           Flag:        -pw (Optional, takes 1 argument)
      Long Form:        --photo_width
Alternate Flags:        -width
----------------
    Description:        Height max
           Flag:        -ph (Optional, takes 1 argument)
      Long Form:        --photo_height
Alternate Flags:        -height
----------------
    Description:        Filter type: ex. jpg,JPG , default => jpg,JPG
           Flag:        -pt (Optional, takes 1 argument)
      Long Form:        --photo_type
Alternate Flags:        -type
----------------
    Description:        Help
           Flag:        -h (Optional, takes 0 arguments)
      Long Form:        --help
Alternate Flags:        -help, -?, -?
----------------
    Description:        Extended Help
           Flag:        -superhelp (Optional, takes 0 arguments)
      Long Form:        --superhelp

Tutti i miei script li trovate qui:
http://www.waydotnet.com/blog/scripts/

[SOLVED] log4r 1.1.4 & ruby 1.9.1 => GDC.rb and NDC.rb syntax error, unexpected ‘:’, expecting keyword_then or ‘;’ or ‘n’

EDIT: SOLVED , vedere commento πŸ˜€

log4r 1.1.4 & ruby 1.9.1 => GDC.rb and NDC.rb syntax error, unexpected ‘:’, expecting keyword_then or ‘;’ or ‘n’

GDC.rb

--- GDC.rb	Thu Jan 28 17:03:12 2010

+++ GDC.rb.new	Thu Jan 28 16:50:37 2010

@@ -13,10 +13,10 @@

     private_class_method :new

 

     def self.check_thread_instance()

-      if ( Thread.main != Thread.current ):

+      if ( Thread.main != Thread.current )

 	raise "Can only initialize Global Diagnostic Context from Thread.main" 

       else

-	if ( Thread.main[GDCNAME] == nil ):

+	if ( Thread.main[GDCNAME] == nil )

 	  Thread.main[GDCNAME] = $0

 	end

       end

line 19
repalce
if ( Thread.main[GDCNAME] == nil ):
with
if ( Thread.main[GDCNAME] == nil )

NDC.rb

--- NDC.rb	Thu Jan 28 17:03:09 2010

+++ NDC.rb.new	Thu Jan 28 16:51:35 2010

@@ -15,7 +15,7 @@

     private_class_method :new

 

     def self.check_thread_instance()

-      if ( Thread.current[NDCNAME] == nil ):

+      if ( Thread.current[NDCNAME] == nil )

 	Thread.current[NDCNAME] = Array.new

 	Thread.current[NDCNAMEMAXDEPTH] = NDCDEFAULTMAXDEPTH

       end

@@ -65,7 +65,7 @@

 

     def self.push( value )

       self.check_thread_instance()

-      if ( Thread.current[NDCNAME].length < Thread.current[NDCNAMEMAXDEPTH] ):		

+      if ( Thread.current[NDCNAME].length < Thread.current[NDCNAMEMAXDEPTH] )

 	Thread.current[NDCNAME].push( value )

       end

     end

[SOLVED] ruby 1.9.1 mingw32 wxruby => undefined reference to ‘wxGraphicsRenderer::CreateBitmap’

Hi to all,
i’ve compiled wxWidgets with this options:

./configure --enable-optimise --enable-stl --enable-unicode
--disable-threads --enable-static  --with-opengl --disable-shared
--enable-monolithic --disable-debug --with-libjpeg=builtin
--with-libpng=builtin  --with-zlib=builtin --enable-graphics_ctx
--enable-mediactrl --enable-unicode --with-libtiff=builtin
--with-expat=builtin --enable-gui -enable-xrc --enable-mdi --enable-gif
--enable-pcx --enable-iff --enable-png --enable-xpm

and also compiled StyledTextCtrl .

My system is :
Windows xp sp3
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
gcc.exe 3.4.5
swig.exe 1.3.38
rake 0.8.7

when compiled wxruby (from svn), i’ve recived this error:

c:msysMinGWbin..libgccmingw323.4.5........mingw32binld.exe:
warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.
C:msys1.0srcwxWidgets-2.8.10/lib/libwx_mswu-2.8.a(monolib_graphcmn.o):graphcmn.cpp:(.text+0x3374):
undefined reference to `wxGraphicsRenderer::CreateBitmap(wxBitmapconst&)'
collect2: ld returned 1 exit status
rake aborted!
Command failed with status (1): [g++ -shared -L.obj/AboutDialogInfo.o o...]

[SOLVED]

IF i compile wxWidgests 2.8.10 i’ve this error:

C:msys1.0srcwxWidgets-2.8.10/lib/libwx_mswu-2.8.a(monolib_graphcmn.o):graphcmn.cpp:(.text+0x3374): 
undefined reference to `wxGraphicsRenderer::CreateBitmap(wxBitmap 
const&)'

If i compile with wxWidgets 2.8.9 WORK !!!

this is the gem :
svn version: 2107
http://www.waydotnet.com/ruby/wxruby-ruby19-2.0.1.svn-x86-mingw32.gem

Only problem when install without –no-rdoc

πŸ˜€

reference:
http://www.ruby-forum.com/topic/202491

64bit:

./configure --enable-optimise --enable-stl --enable-unicode --enable-threads --enable-static  --with-opengl --disable-shared --enable-monolithic --disable-debug --with-libjpeg=builtin --with-libpng=builtin  --with-zlib=builtin --enable-graphics_ctx --enable-mediactrl --enable-unicode --with-libtiff=builtin --with-expat=builtin --enable-gui -enable-xrc --enable-mdi --enable-gif --enable-pcx --enable-iff --enable-png --enable-xpm --with-odbc=sys CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC