Wednesday, October 10, 2012

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

Wednesday, September 26, 2012

ubuntu 10.04 upstart use other user instead of root

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

Saturday, September 1, 2012

Postfix bounces email handler by python script

#!/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()

Tuesday, August 28, 2012

如何查看screen下的窗口历史

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

Wednesday, August 15, 2012

how to start with non-master branch?

What about renaming the "initial master", i.e.:

git init
git add .
git commit -m "intial checkin"
git branch -m non-master-branch

Wednesday, August 8, 2012

Is there any PHP function to convert current age to date?


before or on today - 18 years
after today - 19 years

before or on today - 50 years
after today - 51 years

dob <= (today -18 years) and dob > (today - 51 years)

$lower = date('Y-m-d', strtotime('today -18 years'));
$upper = date('Y-m-d', strtotime('today -51 years'));
$query = "SELECT FirstName FROM users WHERE dob >= '$lower' AND dob < '$upper';";


Note that if you plan on dates before 1970 (52-ish), you should likely use DateTime instead of date and sttrtotime (I actually only use DateTime in actual code, but date/strtotime make for much briefer examples).

An example of 85 years ago with DateTime:


$d = new DateTime('today -85 years');
$s = $d->format('Y-m-d'); //1927-06-03 as of 3 June 2012