Wednesday, August 8, 2012

Homebrew - Tips & Tricks

brew install coreutils

Wine - Tips & Tricks

Install msi file with wine:
wine msiexec -i YourMSIFile.msi

Use winetricks to quickly install many preconfigured packages like:
(winetricks can be installed with homebrew and with mac ports)

mono
Visual C++
Internet Explorer
MS .Net Framework
Direct X
and many more

Tuesday, August 7, 2012

Tutorial - Sencha Touch & ExtJS Code Completion for Aptana & Eclipse

Prerequisites:
Aptana or Eclipse installed
Sencha Touch SDK downloaded and extracted


Quick Installation Guide:


  1. Install Spket IDE Plugin
    1. Start Aptana/Eclipse
    2. Go to Help => Install New Software...
    3. Add new Software Site
      • Name: Spket IDE
      • Location: http://www.agpad.com/update/
    4. Install all Packages from the new Software Site
  2. Configure Spket IDE Plugin 
    1. Open Aptana/Eclipse Preferences
    2. Go to Spket => JavaScript Profiles
      1. Click "New..."
        • Name: SenchaTouch
      2. Select new Profile (SenchaTouch)
        1. Click "Default"
        2. Click Add Library
          • Library: ExtJS
        3. Select "ExtJS" => Click "Add File"
          • Find the "touch.jsb3" File in the root Directory of the Sencha Touch SDK and click ok
        4. Expand the newly added jsb3 file
          • Select all available options: e.g: Classes, DOM, Manifest
    3. Restart Aptana/Eclipse
  3. Test the Code Completion
    1. Open a javascript file => type "Ext.a" and press "ctrl+space"

Detailed Installation Guide:

  • Install the Spket IDE Eclipse Plugin

    1. Start Aptana/Eclipse
    2. Go to Help
    3. Select Install New Software...
    4. Click Add...
    5. Insert the following data in the popup window
      • Name: Spket IDE
      • Location: http://www.agpad.com/update/
    6. Click Ok 
    7. Select all the packages under Spket IDE
    8. Click Next => Next =>
    9. Accept the License Agreement 
    10. Click Finish
    11. After the installation has finished => Click Restart Now
  • Configure the Spket IDE Plugin
    1. Open the Preferences (Mac OSX: Aptana Studio 3 => Preferences)
    2. Go to Spket => JavaScript Profiles
    3. Click New...
      • Name: SenchaTouch
    4. Select new newly created Profile: SenchaTouch
    5. Click Default (to make it the default profile for all projects)
    6. Click Add Library
      • Library: ExtJS
    7. Select the newly create Library: ExtJS
    8. Click AddFile
      • Go to your Sencha Touch SDK Folder and select the "touch.jsb3" file in the root directory (of the sdk)
    9. Expand the newly added jsb3 file
    10. Select all available options
    11. Click Ok
    12. Restart Aptana
  • Test the Code Completion
    1. Open a javascript file
    2. Press "ctrl + space" for code completion
      • Example:

Note: The Code Completion only works for the "Spket JavaScript Editor", which should be the default javascript editor after the installation of the Spket Plugin.

You can check/edit the default javascript editor at:
Preferences => General => Editors => File Associations => and search for "*.js"

"Spket JavaScript Editor" should be marked as default:

Monday, August 6, 2012

Play 2 - Code Snippets & Link List (Playframework Scala)

Link List:

Tutorials:
Play 2.0: Akka, Rest, Json and dependencies
Play 2, Akka, Websockets, Backbone.js and Leaflet – just having fun, really
Play!ing (2.0) with Twitter Bootstrap, WebSockets, Akka and OpenLayers
Getting Started with Play 2, Scala, and Squeryl
Tutorial: Play Framework 2 with Scala, Anorm, JSON, CoffeeScript, jQuery & Heroku

Plugins:
Maven Plugin (Play 2)


Code Snippets:

jsonp support
// Controller Action
def jsonTest = Action { implicit request =>
   // create a json object
   val json = Json.toJson(Map("test" -> "hallo world"))
   // look for the callback parameter in the request 
   request.queryString.get("callback").flatMap(_.headOption) match {
      // return jsonp object 
      case Some(callback) => Ok(Jsonp(callback, json)) 
      //  objectreturn a json
      case None => Ok(json)
   }
}


akka actor usage with promise

Actor
case class Request()
case class Response()

object MyActor {
 
 implicit val timeout = Timeout(20 second)
 
 lazy val default = {
  val actor = Akka.system.actorOf(Props[MyActor])
  actor
 }
 
 def test() = {
  (default ? Request()).asPromise
 }
}

class MyActor extends Actor {

 def receive = {
  case Request => {
   sender ! Response 
  }
 }
 
}

Controller
object Application extends Controller {
 def test = Action { implicit request =>
  val promise = MyActor.test()
  Async {
   promise.map(promise => {
    promise match {
     case Response => Ok("Got Response from Actor")
    }
   })
   
  }
 }
}