Skip to main content

Posts

Showing posts from 2013

Angular.js html5Mode and 404 error solution with Spring framework.

ㅇ the way to get rid of # from url   http://localhost:8080/#/centers   =>   http://localhost:8080/centers     add line in app.js   $locationProvider.html5Mode(true).hashPrefix('!'); ㅇ Other problem #1 involed in html5Mode   When you access the page with url directly like below, then you'll get 404 error.       http://localhost:8080/centers     => Need to solve it in server setting for that.     1. Devide the servlet for the direct call url service from other request.       <servlet-mapping>       <servlet-name>restful</servlet-name>       <url-pattern>/rest/*</url-pattern>    => for other request     </servlet-mapping>       <servlet-mapping>       <servlet-name>dispatcher</servlet-name>       <url-pattern>/page/*</url-pattern>  => for direct web page call service     </servlet-mapping>     2. Add url mapping to servlet configuration file (ex. dispatcher-servlet.x

sample nested view with ui-view in Angular.js

ㅇ template main template /sheepgrid/app/index.html /sheepgrid/app/views/centers.html nested view /sheepgrid/app/views/layout/default.html /sheepgrid/app/views/tab1/welcome.html /sheepgrid/app/views/tab1/userTabs.html ㅇ directive   <div class="container" ui-view/>   => for main template     <div class="panel-body">       <ul data-ui-view="tabs"></ul>       <ul data-ui-view="view"></ul>       => for nested view     </div> ㅇ route       // default route       $stateProvider.state('default', {         templateUrl : '/views/layout/default.html',         controller : 'DefaultCtrl',         abstract : true       }).state('default.centers', {         templateUrl : './views/centers.html',         controller : 'CentersCtrl',             => for main template       }).state("app", {         templateUrl : "/vie

Spring MVC on Heroku

https://devcenter.heroku.com/articles/getting-started-with-java https://devcenter.heroku.com/articles/getting-started-with-spring-mvc-hibernate#declare-process-types-with-procfile 1. pom.xml : add plugin   <!-- for heroku -->   <plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-dependency-plugin</artifactId>     <version>2.3</version>     <executions>       <execution>         <phase>package</phase>         <goals>           <goal>copy</goal>         </goals>         <configuration>           <artifactItems>             <artifactItem>               <groupId>org.mortbay.jetty</groupId>               <artifactId>jetty-runner</artifactId>               <version>7.4.5.v20110725</version>               <destFileName>jetty-runner.jar</destFileName>             </artifactItem>

jetty / tomcat maven plugin example

1. pom.xml modification     <!-- context path -->     <finalName>tz.sheepshare</finalName>     <!-- ibatis mapping xml copy -->     <resources>       <resource>         <directory>${basedir}/src/main/java</directory>         <excludes>           <exclude>**/*.java</exclude>         </excludes>       </resource>     </resources>     <!-- ㅇ maven goal : tomcat:run -->     <plugin>       <groupId>org.codehaus.mojo</groupId>       <artifactId>tomcat-maven-plugin</artifactId>       <version>1.1</version>       <configuration>         <path>/</path>    <!-- context path -->         <port>8080</port>       </configuration>     </plugin>     <!-- ㅇ maven goal : jetty:run -->     <plugin>       <groupId>org.mortbay.jetty</groupId>       <artifactId>maven-jett

Closure와 lambda 설명

ㅇ Closure lambda 차이 - lambda : 익명 함수 - Closure : 자신의 정의된 영역의 변수를 에워싸고(close over) 있는 것. 또는, 자신이 정의된 영역의 변수에 접근할 수 있는 것. Closure를 사용하기 위해서 lambda(익명함수)가 사용됨 ㅇ Closure설명 https://docs.google.com/viewer?a=v&pid=forums&srcid=MTg0MjU3MDM2ODU0NjA0MzI4MzgBMTU5MDc0MTU3NDM3MzU5MTIwMjEBUUI4NE5VVjlFLVVKATQBAXYy lambda는 람다 표현식 또는 람다 함수, 그리고 이름 없는 함수(anonymous function)라고 불리우며, 그 성질은 "함수 객체(functor)와 동일하다" 할 수 있다. // Iterative version List<Sale> salesOfAHyundai = new ArrayList<Sale>(); for (Sale sale : sales) {  if (sale.getCar().getBrand().equals("Hyundai")) {  salesOfAHyundai.add(sale);  } } // Functional version  => lambda 표현식 val salesOfHyundai = db.sales.filter(_.car.brand == "Hyundai") ㅇ javascript Closure설명 => lambda : 익명함수 function exampleClosureForm(arg1, arg2){     var localVar = 8;     function exampleReturned(innerArg){         return ((arg1 + arg2)/(innerArg + localVar));     }     /* return

Setting mongodb, redis & postgresql on heroku step by step

Setting mongodb, redis & postgresql on heroku step by step < setting mongodb on heroku > 1. create heroku app. 2. create mongodb account  * make credit on this site :  https://addons.heroku.com/    $ heroku addons:add mongohq:sandbox (free) 3. password change https://partners.mongohq.com 4. check out the connection install Tadpole DB : https://sites.google.com/site/tadpolefordb/ mongodb://<user>:<password>@paulo.mongohq.com:10037/app18663713 user: "heroku", pwd: ***** < setting redis on heroku > 1. create heroku app 2. create redis account $ heroku addons:add rediscloud:20 3. install redis  (for redis client) http://redis.io/download 4. check out heroku redis site Endpoint  pub-redis-13710.us-east-1-4.1.ec2.garantiadata.com:13710 Redis Password ***** 5. check out the connection $ redis-cli -h pub-redis-13710.us-east-1-4.1.ec2.garantiadata.com -p 13710 $ auth ****** OK $ set redis "Hello, Redis!"

Porting rails from git to heroku

Porting rails from git to heroku - service url : http://sheepweb.herokuapp.com/ - source : - server side : https://github.com/doohee323/sheepshare - front-end : https://github.com/doohee323/sheepweb ㅇ Prerequites - ror app in github - opening account in heroku https://id.heroku.com/signup - installing heroku toolbelt https://toolbelt.herokuapp.com/ 1. git clone git clone git@github.com:doohee323/heepshare.git heepshare $ cd heepshare/ $ bundle install $ bundle update $ rake db:migrate $ rails s http://localhost:3000 2. add ssh key ssh-keygen -t rsa heroku keys:add heroku keys (checking keys) cf. if you have got 5 apps in heroku, you have to remove one. https://dashboard.heroku.com/apps 3. create app $ heroku create sheeprails $ RAILS_ENV=production rake assets:precompile 4. git config $ git config --global user.email "doohee323@gmail.com" $ git config --global user.name "Dewey Hong" $ git st

Deploy angular.js app in heroku with yeoman

[ Deploy angular.js app in heroku with yeoman ] - service url : http://sheepweb.herokuapp.com/ - source : - server side : https://github.com/doohee323/sheepshare - front-end : https://github.com/doohee323/sheepweb ㅇ Prerequites - npm installation - heroku opening https://www.heroku.com/ - git installation 1. app create mkdir yotest cd yotest yo Run the Angular generator > all enter keys 1.1 check the service grunt server 2. heroku deploy configuration yo Run the Heroku generator cd git-subtree sudo ./install.sh [?] Do you want a separate git repository in dist/? (Y/n) n => copying the content in the copy / dist section vi Gruntfile.js and paste the clipboard to copy / dist section. like below, }, { expand: true, cwd: '.tmp/images', dest: '<%= yeoman.dist %>/images', src: [ 'generated/*' ] }, { expand: true, dest: '<%=

github에서 Pull Request/Push 할 경우 trello로 동기화

ㅇ github에서 Pull Request/Push 할 경우 trello로 동기화 1. 해당 repo의 settings에서 service hooks 선택 https://github.com/doohee323/tz.sheepshare/settings/hooks 2. trello 선택 후 create a consumer token 링크 클릭 3. allow 한 후에 토큰 백업 39cb71a63b48179c7b0395042ea1b872eca7f22503 4. trello BOARDID 확인 https://trello.com/b/rnkfAz0A/development => development Pull Request와 Commit List를 생성 5. 아래의 url에서 TOKEN을 위의 토큰으로 치환 https://api.trello.com/1/board/BOARDID?token=TOKEN&key=db1e35883bfe8f8da1725a0d7d032a9c&lists=all -> https://api.trello.com/1/board/rnkfAz0A?token=39cb71a63b48179c7b0395042ea1b872eca7f22503&key=db1e35883bfe8f8da1725a0d7d032a9c&lists=all {"id":"522bad91552563f261","name":"Development"~~~ 6. push 의 id를 등록 (https://github.com/doohee323/tz.sheepshare/settings/hooks) {"id":"522bc47d640e270","name":"Commit","closed":false,"idBoard":"522bad915525

Nitrous 를 putty와 filezillar로 사용

Nitrous 를 putty와 filezillar로 사용 ㅇ putty 다운로드 http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html puttygen.exe, putty.exe, pageant.exe 다운로드 ㅇ putty 설정 PuTTYgen.exe Generate button > 마우스 흔들기 > Save pubic Key, Save private Key > Key 텍스트복사 https://www.nitrous.io/app#/public_keys 에서 복사된 key 입력 Putty 셋팅 https://www.nitrous.io/app#/boxes 에서 SSH URI 확인 예를 들어 ssh://actiontest@apne1.actionbox.io:12345 Host name : apne1.actionbox.io Port : 12345 Connection > Data > Auto-login username : actiontest Connection > SSH > Auth > Private key file for authenticatin 에 아까 생성한 private key 선택 Open http://help.nitrous.io/ssh-windows/ 참조 ㅇ fileillar 사용 pageant.exe 실행 Add Key 클릭 후 아까 생성한 private key 선택 fileillar site 추가 host : apne1.actionbox.io port : 12345 protocol : SFT 로그온 유형 : 일반 사용자 : actiontest 비밀번호 : 없음

rails 설치와 IDE 구성 경험 공유

ㅇ rails 설치와 IDE 구성 경험 공유 1. windows에서 설치 => 결론 : rails 설치는 정말 쉽습니다만 IDE의 서버 기동을 제대로 하지 못했습니다. IDE의 디버깅 기능을 하면 다음의 오류가 발생합니다. Can't initialize a new Rails application within the directory of another, please Type 'rails' for help. 총 3대의 윈도우 pc에서 동일한 오류가 발생하였습니다. (ROR, aptana studio 3의 버전에 상관없이 발생 ㅜㅜ) 1.1 ROR : RailInstaller 설치 - http://railsinstaller.org 도스 콘솔에서는 아무 문제 없이 동작합니다. 1.2 IDE : aptana studio 3 또는 netbeans 설치 1.3 rails debugger gem 설치 gem install ruby-debug-ide 2. ubuntu에서 설치 => 결론 : IDE의 debugging 사용 가능 2.1 ROR : rvm로 설치 ㅇ rvm 설치 \curl -L https://get.rvm.io | bash -s stable ㅇ ruby 설치 vi .bashrc export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin::/usr/local/rvm/bin rvm install 1.9.3 ㅇ rails 설치 gem install rails --no-ri --no-rdoc --version=3.2.14 알수 없는 오류로 이것 저것 조치함... (아래 * ROR 설치 시 오류) 2.2 IDE : aptana studio 3에서 성공 2.3 rails debugger gem 설치 gem install ruby-d

Ubuntu GUI with VNC on Xenserver

Xenserver 에서 Ubuntu GUI 를 쓰기 위해서는 VNC 가 답인 듯... Installing Ubuntu Gnome GUI on Ubuntu Server 12.10 with VNC Update Repositories # apt-get update Install gnome and vnc: # apt-get install gnome-core vnc4server Start VNC Server: # vncserver (You’ll then be prompted to create and verify a new VNC connect password) Kill the currently running VNC Session: # vncserver -kill :1 Edit VNC startup config file: # vim .vnc/xstartup Uncomment the following line: unset SESSION_MANAGER Add the following line: gnome-session --session=gnome-classic & Comment Out the following two lines: x-terminal-emulator -geometry 1280x1024+10+10 -ls -title "$VNCDESKTOP Desktop" & x-window-manager & End result should look like: #!/bin/sh # Uncomment the following two lines for normal desktop: unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc gnome-session --session=gnome-classic & [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/

[Ruby on Rails] aptana studio3 에서 git / svn plug-in 설치

안녕하세요. aptana studio3 에서 git / svn plug-in 설치 시 오류가 발생합니다. 따라서 aptana studio3를 직접 다운 받지 말고 개별 설치 해야 한다.  (http://www.aptana.com/products/studio3) 설치 순서 방법은 다음과 같다.   1. Eclipse Standard 4.3, 198 MB http://www.eclipse.org/downloads/ 2. aptana aptana - http://download.aptana.com/studio3/plugin/install 3. egit egit - http://download.eclipse.org/egit/updates 4. subclipse subclipse - http://subclipse.tigris.org/update_1.8.x

ubuntu server gui in Xenserver

Xenserver상에서 ubuntu server gui 를 구성하기 위해서 일반적인 가이드로 적용되지 않았다. ㅇ Install GUI in Ubuntu Server => xenserver 에서는 안됨 (Webmin가 답일 듯) http://www.ubuntugeek.com/install-gui-in-ubuntu-server.html 1. sudo apt-get update 2. sudo apt-get install ubuntu-desktop or sudo aptitude install --without-recommends ubuntu-desktop or sudo apt-get install xubuntu-desktop (light weight desktop install xfce) 3. sudo apt-get install ttf-unfonts-core (한글 언어 설치) => virtualbox나 vmware에서 적용하는 가이드는 많았으나 xenserver에서는 ㅜ.ㅜ 속편히 webmin 로 돌아섰다. ㅇ webmin 설치 sudo aptitude install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl wget http://prdownloads.sourceforge.net/webadmin/webmin_1.470_all.deb sudo dpkg -i webmin_1.470_all.deb sudo vi /etc/apt/sources.list deb http://download.webmin.com/download/repository sarge contrib 추가 wget http://www.webmin.com/jcameron-key.asc sudo apt-key add jcameron-key.asc sudo apt-get update wge

Redis pub/sub on Spring-Data

Center 에 MDM 으로 부터 Overseas 의 분산 서버로 master data 를 분산 배포하는 구조에 적용하려 함. 1. config <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:c="http://www.springframework.org/schema/c" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd       http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> <bean id="connectionFactory"  class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">  <property name="hostName" value="localhost" />  <property name="port" value="7379" />  <property name="passw

Redis Cache on Spring-Data

1. windows에 redis 설치 ㅇ 다운로드 (windows) https://github.com/MSOpenTech/redis (2.6 download zip) https://github.com/dmajkic/redis/downloads ㅇ 압축 해제 후 배치 C:\Redis \redis-2.4.5-win32-win64\64bit\*.* -> C:\Redis ㅇ 환경 파일 수정 https://raw.github.com/antirez/redis/2.6/redis.conf (2.6 config) daemonize yes bind 127.0.0.1 loglevel notice dir C:\Redis\DB\ logfile C:\Redis\DB\log\redis.log requirepass deweyhong appendonly yes => 기록을 재 로딩 ㅇ 서버 실행 : redis-server redis.conf ㅇ 테스트 redis-cli.exe -h 127.0.0.1 -p 6379 set redis "Hello, Redis!" get redis 2. Spring redis Cache 설정 ㅇ 관련 jar spring-data-redis commons-logging commons-pool jackson-core-asl jackson-mapper-asl jedis org.springframework.beans org.springframework.context org.springframework.core org.springframework.expression spring-tx <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.spri

Transaction AOP 예외 처리

Service class 단위의 트랜잭션 처리는 다음의 설정으로 가능합니다. <!-- Transaction AOP --> <aop:config proxy-target-class="true"> <aop:pointcut id="serviceMethods" expression="execution(* *..*Service.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" /> </aop:config> <!-- Transaction --> 여기서 트랜잭션 예외 처리를 하려면 메소드 명을 다음과 같이 해야 합니다.     <!-- Transaction --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes>   <tx:method name="retrieve*" read-only="true" />   <tx:method name="get*" read-only="true" />   <tx:method name="print*" read-only="true" />   <tx:method name="start*" propagation="REQUIRES_NEW"/> <tx:method name="finish*" propagation="REQUIRES_NEW"/>