Skip to main content

Posts

Move like a Ninja on Terminal Console

If you are in IT and do a lot of stuff on terminal, this is the post for you. In the following post, we will explore various key shortcuts to jump and edit on console. Note:- Short keys may behave differnt on differnt OS systems. These keys best work with Linux sytem, For mac OS you have to enable Option key as Meta key in case of Alt . I have never checked these on windows, Please share your experinece with windows in comments. ------------------------------------------------------------------ Edit Control Move forward one char: Ctrl + f Move backward one char: Ctrl + b Move forward one word: Alt + f Move backward one word: Alt + b Move to end: Ctrl + e #Like End Move to start: Ctrl + a #Like Home Jump toggle between current location and start: Ctrl + xx Delete forward one char: Ctrl + d #Like Delete Delete backward one char: Ctrl + h #Like Backspace Delete forward one word: Alt + d Delete backward one word: Ctrl + w Delete to end: Ctrl + k Delete to start: Ctrl + u Undo: Ct
Recent posts

Get Create Table Query for all Tables in MySQL

 In a MySQL database whenever we need to generate the create table query for any existing table. We can use the below query. show create table test_table; If you need to generate create table query for all the tables then the above query will be cumbersome because you have to run it for every table. We can use mysqldump to generate create table query for all the tables in one go. Open your favorite terminal and execute the below command to check if you have the mysqldump on your system. If you don't have it, please install it first. Usually, it comes with mysql-client software but check the web for more help. mysqldump --version Now you have mysqldump ready, We can use the below command to generate the create table query for all the tables. mysqldump -h ${HOST} -u ${USER} -p -d --compact --column-statistics=0 ${DB_NAME}|egrep -v "(^SET|^/\*\!)" > tables.sql ${} represents the variable you can replace with your DB config. We have used -p So it will prompt for the passwo

Volume Zero after Login or Unlock in Mac

After reaching office, as soon you opened your laptop it resumes the video/audio you left last night. Sometimes it can be embarrassing, So what we can do is write a script to set volume zero every time your laptop wakes up from login or unlock. The following script is for macOS only. The idea is the same for every OS, you just need to find the right hook and commands. First, we will install the software sleepwatcher which provides the hook for sleep and wakeup events in the OS. Open the terminal and execute the below command. brew install sleepwatcher brew services start sleepwatcher If everything executed correctly. The sleepwatcher has been installed and running in the background. Now we need to figure out how to execute the desired commands on sleep and wakeup events. If we execute below command ps -ef | grep 'sleepwatcher' you will see output something like this.   502   510     1   0 12:07PM ??         0:16.26 /usr/local/sbin/sleepwatcher -V -s ~/.sleep -w

Waiting Animation in Python Script

It is very often that we are writing some scripts and we need to put some sleep before executing the next step. During the sleep time of script Either you can use simple sleep and print a line or you can use little waiting animation during the sleep. Try running the below script, It will provide you some animation during sleeping time. The script is quite simple and self-explanatory. Feel free to modify and experiment with the script to get some kooler waiting animation. import time import sys import random ###################- Core Methods -################ def next_pos(i, fwd): if fwd: return i+1 else: return i-1; def nextchar_cursor(pattern): while True: for cursor in pattern: yield cursor #######- Simple spin and wait -##################### def spinner(speed, wt): cursor = nextchar_cursor("-/\\|") st = 1.0 / speed for i in range(wt): rs = "%3d" % (wt-i) for j in range(speed):

java.lang.IllegalArgumentException: Could not instantiate implementation: org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager

If you are trying to get started with Janus Graph with Apache Cassandra. You may get the following error. Caused by: org.janusgraph.diskstorage.TemporaryBackendException: Temporary failure in storage backend at org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager.getCassandraPartitioner(CassandraThriftStoreManager.java:219) ~[janusgraph-cassandra-0.2.0.jar:na] at org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager.<init>(CassandraThriftStoreManager.java:198) ~[janusgraph-cassandra-0.2.0.jar:na] ... 48 common frames omitted Caused by: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused (Connection refused) at org.apache.thrift.transport.TSocket.open(TSocket.java:187) ~[libthrift-0.9.2.jar:0.9.2] at org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:81) ~[libthrift-0.9.2.jar:0.9.2] at org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory.makeR

HTTP2 Server Push in Apache2

Server Push is one of the most significant features in the HTTP/2 protocol. In this post, We will see a very simple demo of the Server Push feature using HTTP/2. Below is the list of tools and tech used in the demo. Ubuntu 16.04 Chrome 60.0.3112.101 Apache2 Some browsers require TLS 1.2 to support HTTP/2. So We need to configure https on Apache server. Try to open the URL https://localhost in your browser. If the above URL not responding, It means you need to configure HTTPS on your Apache server. Please refer to the digital ocean page. https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04 I hope the URL https://localhost is working now and We can proceed further. We will do it into 2 parts. Part-I: We will just enable the HTTP/2 protocol Part-II: We will configure server push feature Part-I: Enable HTTP/2 First, check the below points. Make sure you have the http2 module in your apache. Naviga

Decorator Pattern : Real Life Example and Java Code Example

Decorator Pattern The Decorator Pattern provides a mechanism to dynamically attach the additional responsibilities to an object at runtime. Inheritance also provides the same but it is not flexible and does statically. We will see further in detail why Inheritance is not a good option as compared to Decorator Pattern. One important thing about the Decorator Pattern, It does not affect the core functionality just attach some additional. Real Life Example: Take the example of a bicycle store. When someone comes to buy a bicycle, The distributor shows the basic bicycle with core functionalities. After selecting the bicycle, He asks for the accessories you want to attach. Suppose there are accessories like carrier,stand-leg,front-light,front-box,bike-bell. The service man decorates your bicycle with accessories(additional functionalities without affecting the core functionality) as per your requirement. Java Code Example: We will try to implement the above real life exam