2013年1月18日 星期五

Installation for Shiro Plugin on Grails


Installation

  1. grails create-project shiroPluginTest
  2. cd shiroPluginTest
  3. grails install-plugin shiro
  4. grails shiro-quick-start --prefix="Sec"
    automatically create : domain/SecUser, domain/SecRole, controller/AuthController , Config/ShiroSecurityFilter
  5. insert some data into Project. edit "Config/Bootstrap.groovy"
    Bootstrap.groovy
    class BootStrap {
        def init = { servletContext ->
            def u1 = new SecUser(username: 'user', passwordHash: new Sha1Hash('user').toHex())
            u1.save()
            def u2 = new SecUser(username: 'admin', passwordHash: new Sha1Hash('admin').toHex())
            u2.save()
            def role= new SecRole(name:'user').addToUsers(u1)
            role.addToPermissions("*:*")
            role.save()
            def role2= new SecRole(name:'admin').addToUsers(u2)
            role2.addToPermissions("*:*")
            role2.save()
        }
        def destroy = {
        }
    }
  6. grails create-controller shiroTest
  7. grails generate-views shiroTest
  8. grails run-app
  9. try to go to any page, and see the login page is work correct
install the LDAP server
........(still working)

Reference:

Installation of MongoDB


Introduction

MongoDB (from "humongous") is a scalable, high-performance, open source, document-oriented database. Written in C++.

Installation

  1. download it in here (depend on your platform)
  2. unzip it into a folder. example : c:\mongodb\
  3. create the database file path. example : c:\mongodb\data\
  4. execute the mongodb. c:\mongodb\bin\mongod --dbpath=c:\mongodb\data\
  5. the mongodb will open at port 27017(data connection) and 28017(control panel)
  6. open the browser and enter the URL( http://localhost:28017 , and see the result as follow :

Extension - Master and Slave Structure

Concept(working)
we setting the Master/Slave structure in local computer.
  1. create the database file paths : c:\mongod\master_data\, c:\mongod\slave_data1\, c:\mongod\slave_data2\
  2. start the master : c:\mongodb\bin\mongod --master --dbpath=c:\mongod\master_data\ --port 10000
  3. start the slave1 : c:\mongodb\bin\mongod --slave --source localhost:10000 --dbpath=c:\mongod\slave_data1\ --port 20000
  4. start the slave2 : c:\mongodb\bin\mongod --slave --source localhost:10000 --dbpath=c:\mongod\slave_data2\ --port 30000
  5. done

MongoDB on Grails

Installation
  1. grails create-app mongodbTest
  2. grails install-plugin mongodb-morphia
  3. add data source
    grails-app/conf/DataSource.groovy
    mongodb {
      host = 'localhost'
      port = 27017
      databaseName = 'test'
      username = "YOUR_USERNAME"
      password = "YOUR_PASSWORD"
    }
    }
  4. grails create-mongodb-class Car
  5. add some attributes for db-class
    grails-app/mongo/Car.groovy
    class Car{
        String brand
        String title
    }
  6. grails generate-all Car
  7. grails run-app (make sure the mongodb is open)
  8. add some data by browser
  9. done

Future Work

Sharding structure(working)

Reference

2013年1月17日 星期四

smaf to wav solution


Survey

midi -> smaf(mmf,spf) -> wav
  1. midi-> smaf(mmf) : RetroCode<support MA2,3,5>
  2. smaf-> wav :
  • recorder software : total recorder, mp3mymp3(free), Audacity(free)
  • auto-play script : sikuli

    figure. the sikuli script
  • recording by python api : pyaudio
    recorder.py
    import pyaudio
    import wave
    p = pyaudio.PyAudio()
    stream = p.open(format = FORMAT,
                    channels = CHANNELS,
                    rate = RATE,
                    input = True)
                    #frames_per_buffer = chunk)
    print "* recording"
    all = []
    for i in range(0, RATE / chunk * RECORD_SECONDS):
        data = stream.read(chunk)
        all.append(data)
    print "* done recording"

Final version

System structure
Step by step
1. open stereo mode

figure. setting stereo mix mode on Windows 7
hint
the option is hidden on Windows 7
2. open recorder(server)
  • make sure the softwares
    • python 2.7
    • pyaduio
  • execution server
    • command line : #python server_recorder.py
    • IDEL : execfile("C:\server_recorder.py")
3. open player(client)
  • open mexa emulator
  • create folder /sampleData/jscl_storage_root/mc/(the StorageConnection use)
  • copy smaf music in /sampleData/jscl_storage_root/mc/MEXA/*.spf
  • running MIDlet
4. collection data
you can see the wav file in Default path - C:\Python27\smaf2wav\

Reference

python lib for midi
open source project for smaf player