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.
Friday, December 30, 2011
run hadoop on aws ec2 by yourself.
$/usr/bin/hadoop namenode -format
11/12/31 06:28:39 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = ip-10-146-3-18.ap-northeast-1.compute.internal/10.146.3.18
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 0.20.2-cdh3u2
STARTUP_MSG: build = file:///tmp/topdir/BUILD/hadoop-0.20.2-cdh3u2 -r 95a824e4005b2a94fe1c11f1ef9db4c672ba43cb; compiled by 'root' on Thu Oct 13 21:51:41 PDT 2011
************************************************************/
11/12/31 06:28:39 INFO util.GSet: VM type = 32-bit
11/12/31 06:28:39 INFO util.GSet: 2% max memory = 19.33375 MB
11/12/31 06:28:39 INFO util.GSet: capacity = 2^22 = 4194304 entries
11/12/31 06:28:39 INFO util.GSet: recommended=4194304, actual=4194304
11/12/31 06:28:40 INFO namenode.FSNamesystem: fsOwner=hduser
11/12/31 06:28:40 INFO namenode.FSNamesystem: supergroup=supergroup
11/12/31 06:28:40 INFO namenode.FSNamesystem: isPermissionEnabled=true
11/12/31 06:28:40 INFO namenode.FSNamesystem: dfs.block.invalidate.limit=1000
11/12/31 06:28:40 INFO namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s)
11/12/31 06:28:40 INFO common.Storage: Image file of size 112 saved in 0 seconds.
11/12/31 06:28:40 INFO common.Storage: Storage directory /tmp/hadoop-hduser/dfs/name has been successfully formatted.
11/12/31 06:28:40 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at ip-10-146-3-18.ap-northeast-1.compute.internal/10.146.3.18
************************************************************/
Refer to http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/
install Hadoop 0.20 to your AWS EC2 (CentOS)
$cd /etc/yum.repos.d
$sudo wget http://archive.cloudera.com/redhat/cdh/cloudera-cdh3.repo
$sudo yum update yum
$sudo yum search hadoop
$sudo yum install hadoop-0.20
Subscribe to:
Posts (Atom)