Posts

[Level 1] How to get ram spec in Ubuntu

If you want to get the ram module information from Ubuntu. Please use command dmidecode with type 17. ex. $ sudo dmidecode --type 17 | more Wish this helps. regards, Stanley Huang

[Level 1] Install maven in Ubuntu

In Ubuntu, you could use apt-get to install maven. # apt-get -y install maven2 Wish this helps. regards, Stanley Huang

[Level 1] Install git in Ubuntu

If you want to install git in Ubuntu, you could use apt-get command: # apt-get -y install git-core git-doc git-gui gitk Wish this helps. regards, Stanley Huang

[Level 3] Cassandra stress tool from git in Ubuntu.

If you want to do the stress test for Cassandra. You could try an open source project call cassandra-stress of zznate. First you must to have git client and maven. Please reference here: git installation , maven installation Clone the src from git. # git clone https://github.com/zznate/cassandra-stress.git Then you would find a folder named "cassandra-stress", cd it and build the binary. # cd ./cassandra-stress # mvn install and mvn would create a sub folder "target", cd it and run the stress script. # cd ./target/appassembler/ # sh ./bin/stress -o insert -b 1000 -n 2000000 localhost:9160 Wish this helps. regards, Stanley Huang

[Level 3] Run python in shell script.

If you want to wrap python script into shell script. You could use the following sample code. #!/bin/sh # -*- mode: Python -*- """:" # bash code here; finds a suitable python interpreter and execs this file. # prefer unqualified "python" if suitable: python -c 'import sys; sys.exit(sys.hexversion < 0x020500b0)' 2>/dev/null \ && exec python "$0" "$@" for pyver in 2.6 2.7 2.5; do which python$pyver > /dev/null 2>&1 && exec python$pyver "$0" "$@" done echo "No appropriate python interpreter found." >&2 exit 1 ":""" import os, sys print os.path.dirname('/Hello/World/c.txt') $ ./test.sh /Hello/World Wish this helps. regards, Stanley Huang

[Level 2] Cassandra token generation tool by Python.

#!/bin/env python import sys if (len(sys.argv) > 1): num=int(sys.argv[1]) else: num=int(raw_input("How many nodes are in your cluster? ")) for i in range(0, num): print 'node %d: %d' % (i, (i*(2**127)/num)) $ ./cassandraTokenGenTools.py How many nodes are in your cluster? 5 node 0: 0 node 1: 34028236692093846346337460743176821145 node 2: 68056473384187692692674921486353642291 node 3: 102084710076281539039012382229530463436 node 4: 136112946768375385385349842972707284582 Wish this helps. regards, Stanley Huang

[Level 2] JSON module in Python.

#!/bin/env python import json import random data = {} for i in range(0,2): key = 'i%s' % i data[key] = {} for j in range(0,3): subkey = 'j%s' % j data[key][subkey] = {} for k in range(0,4): item = 'k%s' % k value = int(random.random() * 100) data[key][subkey][item] = value print json.dumps(data) $ ./testPython.py {"i1": {"j0": {"k3": 93, "k2": 98, "k1": 0, "k0": 3}, "j1": {"k3": 53, "k2": 28, "k1": 99, "k0": 69}, "j2": {"k3": 3, "k2": 93, "k1": 74, "k0": 28}}, "i0": {"j0": {"k3": 67, "k2": 98, "k1": 15, "k0": 92}, "j1": {"k3": 70, "k2": 22, "k1": 63, "k0": 3}, "j2": {"k3": 88, "k2": 28, ...