Friday, November 9, 2012

Slide: Code Like a Pro.

https://docs.google.com/presentation/d/1f0clGqGav8v-fj2IYSQ0aCHMrLeKkfz6yc6izWsJYuM/edit

Sunday, September 30, 2012

Can't get SMTP to work, error message about passwd.db is repeated

I just enabled sendmail on my Mac Air. It works. You don't have to buy a Mac OS X server.

Please refer to this URL:
http://www.garron.me/mac/postfix-relay-gmail-mac-os-x-local-smtp.html

if you still have problem, refer to following URL:

https://discussions.apple.com/thread/1521336?start=0&tstart=0

or

http://slashusr.wordpress.com/2012/02/14/enabling-postfix-for-outbound-relay-via-gmail-on-os-x-lion-11/



how to config test report in Jenkins for GHUnit test. or JUnit test.


you have to change your shell script under Build

make clean && WRITE_JUNIT_XML=YES JUNIT_XML_DIR=tmp/test-results make test


Under Post-build Actions, check Publish JUnit test result report and enter the following in Test report XMLs:
  tmp/test-results/*.xml

Saturday, September 29, 2012

Run GHUnit test in command mode or Jenkins

You may got this error.

/bin/sh -c /Users/mingderwang/Desktop/testAsyncUploadFile/build/testAsyncUploadFile.build/Debug-iphonesimulator/Tests.build/Script-4FE869DB1614B11B00698DCF.sh Running: "/Users/mingderwang/Desktop/testAsyncUploadFile/build/Debug-iphonesimulator/Tests.app/Tests" -RegisterForSystemEvents Couldn't register com.katdc.test.Tests with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger./Users/mingderwang/Desktop/testAsyncUploadFile/RunTests.sh: line 50: 1428 Abort trap: 6 "/Users/mingderwang/Desktop/testAsyncUploadFile/build/Debug-iphonesimulator/Tests.app/Tests" -RegisterForSystemEvents Command /bin/sh failed with exit code 134 ** BUILD FAILED **

Restart your jenkins, you can fix this problem.

Same error logs may happen on "make test" in source code. You can "make clean; make; make test" again.


install Jenkins (Hudson) for CI on AWS EC2 (CentOS)

Jenkins used to call "Hudson", it can building/testing software projects continuously, just like CruiseControl or DamageControl.

Installation:

1. download jenkins from http://jenkins-ci.org/


sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
then,
     sudo yum install jenkins


2. sudo service jenkins start 

3. browse http://localhost:8080 or your hostname with port 8080.

Remark: Don't forget to add 8080 port to your Security Group for your AWS EC2 instance.


Sunday, September 9, 2012

stop EC2 instance but still charged, why?

I stop my AWS EC2 server, why it still been charged as follow? What is a provisioned storage?

Amazon EC2 EBS
  $0.12 per GB-month of provisioned storage2.133 GB-Mo0.26


the answer is :


Saturday, April 28, 2012

from my gists (ming@katdc.com)

#!/usr/bin/env node const fs = require('fs'); const optimist = require('optimist'); const codepainter = require('../codepainter'); var argv = optimist.options({ 'input': { alias: 'i', default: 'stdin', describe: 'File path to read from', type: 'string' }, 'output': { alias: 'o', default: 'stdout', describe: 'File path to write to', type: 'string' }, 'sample': { alias: 's', describe: 'Code sample path to infer the style from', type: 'string' }, // FIXME: Make it possible to specify this in a file. 'style': { describe: 'JSON string describing the coding style', type: 'string' } }).check(function (argv) { return typeof argv.sample !== 'undefined' || typeof argv.style !== 'undefined'; }).argv; var input; if (argv.input === 'stdin') { input = process.stdin; } else { input = fs.createReadStream(argv.input); input.pause(); } input.setEncoding('utf-8'); var output; if (argv.output === 'stdout') output = process.stdout; else output = fs.createWriteStream(argv.output); function transform(style) { codepainter.transform(input, style, output, function (error) { if (error) { console.error(error); return; } }); } if (typeof argv.style !== 'undefined') { var style = JSON.parse(argv.style); transform(style); } else { var sample; sample = fs.createReadStream(argv.sample); sample.pause(); sample.setEncoding('utf-8'); codepainter.infer(sample, function (error, style) { if (error) { console.error(error); return; } transform(style); }); }

plays3upload install failed.

ming@ming-laptop:~/.ssh$ ssh-keygen -t rsa -C "ming@katdc.com" Generating public/private rsa key pair. Enter file in which to save the key (/home/ming/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/ming/.ssh/id_rsa. Your public key has been saved in /home/ming/.ssh/id_rsa.pub. The key fingerprint is: 43:9f:90:a0:5c:2d:fb:93:b6:3c:fd:39:4d:ca:9c:dd ming@katdc.com The key's randomart image is: +--[ RSA 2048]----+ | o.. | | . o.... | | o o+ | | .. o . | | .S.o | | =. . | | o + o * . | | + . *.o E| | . .o. | +-----------------+ ming@ming-laptop:~/.ssh$ heroku keys:add Found existing public key: /home/ming/.ssh/id_rsa.pub Uploading ssh public key /home/ming/.ssh/id_rsa.pub ming@ming-laptop:~/.ssh$ cd ming@ming-laptop:~$ cd git ming@ming-laptop:~/git$ ls katdc-website node npm play playbars plays3upload vote4music ming@ming-laptop:~/git$ cd *website ming@ming-laptop:~/git/katdc-website$ ls app config.ru doc Gemfile.lock public README test config db Gemfile lib Rakefile script vendor ming@ming-laptop:~/git/katdc-website$ git push heroku master Agent admitted failure to sign using the key. Permission denied (publickey). fatal: The remote end hung up unexpectedly ming@ming-laptop:~/git/katdc-website$ ssh-add ~/.ssh/id_rsa Identity added: /home/ming/.ssh/id_rsa (/home/ming/.ssh/id_rsa) ming@ming-laptop:~/git/katdc-website$ git push heroku master Counting objects: 243, done. Delta compression using up to 2 threads. Compressing objects: 100% (167/167), done. Writing objects: 100% (243/243), 3.40 MiB | 279 KiB/s, done. Total 243 (delta 55), reused 243 (delta 55) -----> Heroku receiving push -----> Ruby/Rails app detected -----> Installing dependencies using Bundler version 1.1.rc.7 Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment Fetching gem metadata from http://rubygems.org/........ Installing rake (0.8.7) Installing abstract (1.0.0) Installing activesupport (3.0.5) Installing builder (2.1.2) Installing i18n (0.5.0) Installing activemodel (3.0.5) Installing erubis (2.6.6) Installing rack (1.2.2) Installing rack-mount (0.6.13) Installing rack-test (0.5.7) Installing tzinfo (0.3.25) Installing actionpack (3.0.5) Installing mime-types (1.16) Installing polyglot (0.3.1) Installing treetop (1.4.9) Installing mail (2.2.15) Installing actionmailer (3.0.5) Installing arel (2.0.9) Installing activerecord (3.0.5) Installing activeresource (3.0.5) Using bundler (1.1.rc.7) Installing thor (0.14.6) Installing railties (3.0.5) Installing rails (3.0.5) Installing sqlite3 (1.3.3) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks! /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /usr/local/bin/ruby extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel' and check your shared library search path (the location where your sqlite3 shared library is located). *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby --with-sqlite3-dir --without-sqlite3-dir --with-sqlite3-include --without-sqlite3-include=${sqlite3-dir}/include --with-sqlite3-lib --without-sqlite3-lib=${sqlite3-dir}/lib Gem files will remain installed in /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.3 for inspection. Results logged to /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.3/ext/sqlite3/gem_make.out from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:486:in `block in build_extensions' from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:446:in `each' from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:446:in `build_extensions' from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:198:in `install' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/source.rb:90:in `block in install' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/rubygems_integration.rb:82:in `preserve_paths' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/source.rb:89:in `install' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:73:in `block in install_gem_from_spec' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/rubygems_integration.rb:97:in `with_build_args' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:72:in `install_gem_from_spec' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:56:in `block in run' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:55:in `run' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:12:in `install' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/cli.rb:220:in `install' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor/task.rb:22:in `run' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor.rb:263:in `dispatch' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor/base.rb:386:in `start' from /tmp/build_1fyfbl02lb26s/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/bin/bundle:13:in `' from vendor/bundle/ruby/1.9.1/bin/bundle:19:in `load' from vendor/bundle/ruby/1.9.1/bin/bundle:19:in `
' ! ! Failed to install gems via Bundler. ! ! Detected sqlite3 gem which is not supported on Heroku. ! http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development ! ! Heroku push rejected, failed to compile Ruby/rails app To git@heroku.com:smooth-wind-1511.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku.com:smooth-wind-1511.git'

Tuesday, February 14, 2012

MongoDB security

how to add auth function in your mongoDB. > use admin > db.addUser("root", "rootpassword") add user to your tables > use table1 > db.addUser("user1", "password1") add read only user > use table1 > db.addUser("user2", "password2", true)

how to use mongoDB on AWS EC2

1. find an AIM with mongodb64 and ubuntu1004 by searching AIMs 2. make a new instance with above selected AIM. 3. it will run mongod automatically when start, don't forget to open security for 27017 to 28017 TCP port. use http://...:27017 to check it's available or not.