- To show hidden files - I
- To toggle NerdTree - Ctrl + n
- To surround a word with " - ysiw" (instead of iw - other text objects can be used like ip, iW )
- To change " to ' - cs"'
To toggle zoom in a pane - Ctrl + w, o
| 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]} |
| function printName(isFirstName){ | |
| console.log(firstName); // Variables hoisted to the top | |
| console.log(lastName); | |
| if (isFirstName){ | |
| var firstName = 'Prasanna'; | |
| }else { | |
| var lastName = 'V' | |
| } | |
| } |
| class Person { | |
| constructor(name){ | |
| this.name = name; | |
| } | |
| } | |
| class Employee extends Person { | |
| constructor(id, name){ | |
| super(name); | |
| this.id = id; |
| # 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: |
| 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 |
| # 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 |
| # to find a pid by port | |
| lsof -n -i:$PORT | grep LISTEN |
| Reference: https://prakhar.me/docker-curriculum/#busybox | |
| # Run a static website in background. d - detach mode, P - expose all ports, --name give name to the running container | |
| docker run -d -P --name static-site prakhar1989/static-site | |
| # To see the ports used | |
| docker port static-site | |
| # Docker networks |