end of line sequences
Windows end of line sequence: \r\n
Unix end of line sequence: \n
Mac end of line sequence: \r
Tips and tutorials on Wi-Fi(802.11), Windows, Linux, PHP, MySQL, Codeigniter, Android
Search This Blog
-
For converting Error Vector Magnitude (EVM) from db to %(percentage), we can use the below formula EVM in % = 100 * (10^(EVM in dB/20)) ...
-
Lot of people mix the term RSSI and RSS in the RF industry, the Field engineers, developers, testers. RSSI - Received Signal Strength In...
-
For excluding files and directories while using diff, we can pass the exclude pattern in the command line. Say for you u want to exclud...
18 September, 2015
end of line sequences in different OS
11 September, 2015
Recovering moved or deleted files in Linux
I was developing one C program which I spend 1 day writing with around 500 lines of code in Ubuntu 12.04
for compiling in GCC, I used the below command
# gcc server.c -o server.c
instead of giving gcc server.c -o server
now my whole source code was replaced with the binary file :( :( , a simple mistake which caused my whole source code got deleted or replaced. I had a habit of pressing for auto completing the file names.
After searching for some time googling, i got a solution which worked for me and saved my 9 hours of work.
I got the help form this below link
http://www.cyberciti.biz/tips/linuxunix-recover-deleted-files.html
repeating what is said there and which i tried and worked for me
in the console with sudo permission
sudo grep -a -B[size before] -A[size after] 'filename or unique content' /dev/[your_partition] > file.txt
-i : Ignore case distinctions in both the PATTERN and the input files i.e. match both uppercase and lowercase character.
-a : Process a binary file as if it were text
-B Print number lines/size of leading context before matching lines.
-A: Print number lines/size of trailing context after matching lines.
my command was
sudo grep -a -B10 -A1000 'UNIQUE_SERVER_IP' /dev/sda1 > file.txt
UNIQUE_SERVER_IP was the #define i did it in my source code. After the command is over, open the file.txt with vi or any text editor and search for the string 'UNIQUE_SERVER_IP'. you should find your source code around the string, copy paste and save to the required file name
I got the my source code back in some time.
09 September, 2015
counting number of lines in c and include files in Linux
After writing source code in Linux, if you want to count the number of lines in .c and .h files
find . -name '*.c' -o -name '*.h' | xargs wc -l
Converting IP Address from string in dot format to 32 bit integer
C program to convert IPv4 address from String formatted in dat notation like "10.0.0.1" to a 32 bit integer in Linux
#include<stdio.h>
#include <arpa/inet.h>
main()
{
uint32_t ip;
struct in_addr ip_addr;
ip = inet_addr("10.0.0.1");
printf("IP Integer: %d\n", ip);
ip_addr.s_addr = ip;
printf("The IP address is: %s\n", inet_ntoa(ip_addr));
}
#include<stdio.h>
#include <arpa/inet.h>
main()
{
uint32_t ip;
struct in_addr ip_addr;
ip = inet_addr("10.0.0.1");
printf("IP Integer: %d\n", ip);
ip_addr.s_addr = ip;
printf("The IP address is: %s\n", inet_ntoa(ip_addr));
}
06 September, 2015
Cassandra cqlsh queries
Below are the commands useful for querying the cassandra database .
These are executed by logging into the Cassandra command line interface(CLI), CQLSH
1) showing the keyspaces(or databases )
describe keyspaces;
2) Showing Tables in the keyspace(or database)
2.1. use <keyspace_name>;
2.2 describe tables; this will show the tables in the keyspace(database)
3) Creating Index to an Exiting table with column
CREATE INDEX tripid_idx ON table_4(tripid);
4) To show TABLE info using cqlsh
DESC TABLE table_1 ;
These are executed by logging into the Cassandra command line interface(CLI), CQLSH
1) showing the keyspaces(or databases )
describe keyspaces;
2) Showing Tables in the keyspace(or database)
2.1. use <keyspace_name>;
2.2 describe tables; this will show the tables in the keyspace(database)
3) Creating Index to an Exiting table with column
CREATE INDEX tripid_idx ON table_4(tripid);
4) To show TABLE info using cqlsh
DESC TABLE table_1 ;
Subscribe to:
Posts (Atom)
tmux enabling mouse interaction
Add the below line to the ~/.tmux.conf setw -g mouse on save the file and exit from the tmux shell, you should be able to use your mouse to ...