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.

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

automatic-screenshot-insertion-in-org

Original idea from http://emacsworld.blogspot.com/2011/05/automatic-screenshot-insertion-in-org.html

Original script using imagemagick:

Using scrot :

(defun org-screenshot ()
  "Take a screenshot into a time stamped unique-named file in the same directory as the org-buffer and insert a link to this file."
  (interactive)
  (setq filename
        (concat
         (make-temp-name
          (concat (buffer-file-name)
                  "_"
                  (format-time-string "%Y%m%d_%H%M%S_")) ) ".png"))
  (call-process "scrot" nil nil nil  "-s" filename)
  (insert (concat "[[" filename "]]"))
  (org-display-inline-images))

How to resize LVM logical volumes with ext4 as filesystem


# Unmount the filesystem and check its' LV
umount /mnt/foo
e2fsck -f /dev/mapper/vg0-foo

# Shrink ext4 and then the LV to the desired size
resize2fs -p /dev/mapper/vg0-foo 40G
lvreduce -L 40G /dev/mapper/vg0-foo

# Before continuing, run e2fsck. If it bails because the partition
# is too small, don't panic! The LV can still be extended with
# lvextend until e2fsck succeeds, e.g.:
# lvextend -L +1G /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo

# Resize the filesystem to match the LVs size, check and mount it
resize2fs -p /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo
mount /mnt/foo

umount /mnt/bar

# Extend the LV to use all free space
lvextend -l +100%FREE /dev/mapper/vg0-bar
e2fsck -f /dev/mapper/vg0-bar

# Resize the partition to fill the LV
resize2fs -p /dev/mapper/vg0-bar
e2fsck -f /dev/mapper/vg0-bar
mount /mnt/bar

source:
source