Puma and rails to auto start on Linux rc.local

1
su ubuntu -c 'source /etc/profile && cd /home/ubuntu/downloads/redmine-2.1/ && NEWRELIC_ENABLE=true rails s Puma -e production -p 8080 -d'

DBSNMP、SYSMAN密码修改重新配置EM

1
emca -config dbcontrol db

Vagrant VirtualBox 下Nginx, Apache编辑CSS文件后乱码

原因:

VirtualBox’s Shared Folders 对 sendfile() 支持不完善

解决方法:

pache:

1
EnableSendfile off

NGINX:

1
sendfile off;

什么是 sendfile()

fog and openstack

.fog config file

1
2
3
4
5
:default:
:openstack_auth_url: http://192.168.1.113:35357/v2.0/tokens
:openstack_username: admin
:openstack_api_key: admin
:openstack_tenant: admin

SSH hang on expecting SSH2_MSG_KEX_DH_GEX_GROUP

This solved it for me:
http://www.snailbook.com/faq/mtu-mismatch.auto.html

“You probably have an MTU/fragmentation problem. For each network interface on both client and server set the MTU to 576, eg ifconfig eth0 mtu 576″

If 576 doesn’t work try 1000.

Node.js and Express Application Tools

  • Git for version control (Heroku dependency)
  • Jade for templating
  • Stylus for CSS preprocessing
  • Redis for session storage
  • MongoDB for campaign storage
  • Mongoose, a MongoDB ORM
  • Passport for authentication
  • Jake, like Make, but for Javascript
  • Make for running tests. (I hope to use only Make or Jake but ran into issues getting Mocha to run with Jake)
  • Mocha for testing
  • JSHint for code linting
  • Docco for documentation

ubuntu 10.04 upstart use other user instead of root

example

1
exec su -s /bin/sh -c 'exec "$0" "$@" > /tmp/easypaas.log 2>&1' ubuntu -- /home/ubuntu/cloudfoundry/vcap/dev_setup/bin/vcap_dev start

Postfix bounces email handler by python script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
# -*- coding: utf-8 -*-
# export PYTHONIOENCODING=utf-8
import MySQLdb
import string
import email
from cStringIO import StringIO
from email import message_from_string
from flufl.bounce import scan_message
import re, sys, os

class DB:
  conn = None

  def connect(self):
    self.conn = MySQLdb.connect(host='10.0.0.1', user='xx_rw', passwd='123456', db='xxx', use_unicode=True, charset="utf8")

  def query(self, sql, string):
    try:
      cursor = self.conn.cursor()
      cursor.execute(sql,string)
    except (AttributeError, MySQLdb.OperationalError):
      self.connect()
      cursor = self.conn.cursor()
      cursor.execute(sql,string)
    return cursor


def main():
  db = DB()
  sender=sys.argv[2]
  recipient=sys.argv[1]
  email_input = sys.stdin.readlines()
  parser = email.FeedParser.FeedParser()
  msg = None
  for msg_line in email_input:
   msg = parser.feed(msg_line)
  msg = parser.close()

  #filter_recipient = scan_message(message_from_string(string.join(message, ' ')))
  filter_recipient = scan_message(msg)
  if (len(filter_recipient)>0):
    db.query("""INSERT INTO email_bounces (`sender`, `recipient`) VALUES(%s, %s)""", (filter_recipient, recipient))

if __name__ == "__main__":
  main()

如何查看screen下的窗口历史

1
ctrl+a [

然后使用上下箭头,或者翻页查看。

how to start with non-master branch?

What about renaming the “initial master”, i.e.:

1
2
3
4
git init
git add .
git commit -m "intial checkin"
git branch -m non-master-branch