1. *, **, etc for creating headings, sub headings
2. To continue headers, press <enter> in normal mode
3. >>, << to convert sub headers to headers or vice versa
4. <Tab> and <S-Tab> to fold headers
5. zm, zr to close the whole list
This file contains hidden or 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
| # to find a pid by port | |
| lsof -n -i:$PORT | grep LISTEN |
This file contains hidden or 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
| # pull & start the container | |
| docker run busybox | |
| # list all the images | |
| docker images | |
| # to remove all the images | |
| docker rmi $(docker images -q) | |
| # to remove the exited containers |
This file contains hidden or 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 Proxy: | |
| def __init__(self, target_object): | |
| object.__setattr__(self, 'msg', OrderedDict()) | |
| object.__setattr__(self, '_obj', target_object) | |
| def __getattr__(self, name): | |
| if name in self.msg: | |
| self.msg[name] += 1 | |
| else: | |
| self.msg[name] = 1 |
This file contains hidden or 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
| # Java style of file handling | |
| # Good example of sandwich code | |
| filename='test.txt' | |
| try: | |
| file = open(filename) | |
| print(file.readlines()) | |
| except Exception as e: | |
| print(e.args[0]) | |
| finally: |
This file contains hidden or 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 Person { | |
| constructor(name){ | |
| this.name = name; | |
| } | |
| } | |
| class Employee extends Person { | |
| constructor(id, name){ | |
| super(name); | |
| this.id = id; |
This file contains hidden or 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
| function printName(isFirstName){ | |
| console.log(firstName); // Variables hoisted to the top | |
| console.log(lastName); | |
| if (isFirstName){ | |
| var firstName = 'Prasanna'; | |
| }else { | |
| var lastName = 'V' | |
| } | |
| } |
This file contains hidden or 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
| def array_to_hash(arr) | |
| hash_val = Hash.new | |
| arr.uniq.each {|n| hash_val[n] = arr.grep(n)} | |
| hash_val | |
| end | |
| # array_to_hash([1,2,3,2,1]) => {1=>[1, 1], 2=>[2, 2], 3=>[3]} |
NewerOlder