This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sudo the previous command | |
sudo !! | |
# for example, apt-get will failed because current user is not root | |
apt-get install vim | |
sudo !! | |
# !! will be replaced with previous command, enter enter again to run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# show more lines with -C | |
grep -C 2 "test" temp.log | |
# If there's a match, it will show two more lines before and | |
# after the match line. | |
# -A is for after, -B is for before | |
# -n : show the line number | |
# -l : just show the filename | |
# -i : case insesentive search | |
# -w : match the word | |
# -c : show the count number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str = "This is Jason, I'm a programmer." | |
if str.find("Jason") != -1: | |
foundYou = True | |
# Here is the Python way to do that: | |
if "Jason" in str: | |
foundYou = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = foo(); | |
b = bar(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if myName: | |
# myName is exist and not empty | |
print "Hello " + myName | |
else: | |
print "Please input your name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class customersSystem | |
def say_hello(): | |
if customer_name and customer_name in customer_list: | |
print "hello " + customer_name | |
# the code needs to be change and it is longer than 80 | |
if customer_name and customer_name in system_database.get_customer_list(): | |
print "hello" + customer_name | |
# To format this code, "=" will not help you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# overrider the class functions for test only | |
MyClass.ConnectServer = lambda *a, **kw: None | |
# simple lambda functions to override real function | |
def test_connection(): | |
run_connection_fun(lambda: False) | |
run_connection_fun(lambda: True) | |
def run_connection_fun(connect_fun) | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sorted(customers, key=lambda c: c.name.last) | |
reduce(lambda x, y: x.balance + y.balance, customers) | |
map(lambda x: x*x*x, range(1, 11)) | |
# [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000] | |
filter(lambda x: x%2 != 0 and x%3 != 0, range(2, 25)) | |
# [5, 7, 11, 13, 17, 19, 23] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
|-- prj1 | |
|-- prj2 | |
|-- prj3 | |
|-- prj4 | |
`-- tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Processing response from /ip1 | 5497 | SharedPool-Worker-318 | |
Sending read-repair-mutation to /ip1 | 5628 | SharedPool-Worker-380 | |
Sending READ_REPAIR message to /ip1 | 5681 | MessagingService-Outgoing-/ip1 | |
READ_REPAIR message received from /ip1 | 5809 | MessagingService-Incoming-/ip1 | |
Timed out while read-repairing after receiving all 6 data and digest responses | 2005779 | SharedPool-Worker-380 |
OlderNewer