Showing posts with label Tech Tips. Show all posts
Showing posts with label Tech Tips. Show all posts

Wednesday, July 24, 2019

Change date in Mac via terminal


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

sudo date MMDDHHmmYY

(Month,date,hour,minute,year)
For e.g.,  sudo date 0101101019 to change date to 10 hour 10 min of 2019 Jan 01.


Sunday, July 21, 2019

Sort unix folders by size


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

du -ks * | sort -n -r

 


Wednesday, July 25, 2018

Column selection in Eclipse


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

Eclipse also offers column selection functionality similar to popular text editors Notepad++, Sublime Text2.

On a Mac, need to press "cmd + option + A"
On Windows and Linux, you need to press "alt + shift + A"

Please note doing above will take you to block selection mode, and you need to press same keys again to come back to normal mode.

Source: https://stackoverflow.com/questions/1053725/how-do-i-enable-the-column-selection-mode-in-eclipse


Wednesday, July 18, 2018

Validate firewall connectivity using nc


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

In absence of telnet we can use nc (which version??) to validate connectivity.

nc -w 2 -v 10.0.0.1 < /dev/null; exitCode=$?; echo "Exit code = $exitCode"; if [ $exitCode -ge 1 ]; then echo "No connectivity"; else echo 'SUCCESS!!!'; fi; >> fw_validation.txt



Wednesday, November 1, 2017

Bash for loop examples


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

For loop example in bash script:
To get yarn log files for multiple spark jobs, we can use this command.
for i in `cat appid.txt`; do echo $i; yarn logs -applicationId $i > sparkjob_01sep_logs/$i.log; echo "——"; done




For loop with sequence and ssh into multiple servers:
To login into multiple servers and run a command, we can use below command.

for i in `seq 101 125`;do ssh -q machinename$i "hostname;ls -ltr";done



Friday, February 10, 2017

Java - redirect standard output stream to file


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------


 We can redirect all System.out.println output to a file with below code snippet.

 System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("/tmp/output.txt"))));

Monday, January 30, 2017

Create a desktop shortcut in Mac with Automator


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------


Open Automator
File > New
select Application
Then add "Run Shell Script" option
Give the command to run, here I am giving Google chrome canary with no proxy option

/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --no-proxy-server=
Then Save with the name you want.







By default this will show automator icon.
Here is how to set your favorite icon.
Right click on Chrome canary icon and select "Get Info"



Then click on the icon and press Cmd+c
to copy the icon.
Now open info window on newly created icon, select the icon in the same place (which shows automator icon) press Cmd+v to paste the previously copied icon.


Change proxy settings only for Chrome


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

Disable proxy setting
Add command line parameter --no-proxy-server= to the command. (In windows, add this to the target path in the shortcut properties)

Specify different proxy
Add command line parameter --proxy-server="127.0.0.1:8080" to the command

Specify no proxy server list
Add command line parameter like this --proxy-bypass-list="127.0.0.1;localhost"


Friday, February 26, 2016

Find out license information of all maven dependencies


Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart
-----------------------------------------------

You want to use a maven dependency and you also need to know about the license information. If it is only one dependency you can easily check it. But each maven dependency more dependencies itself to do its work. That means you have to find out license information of all those jars also.

For example, if you want to use cassandra-unit jar (https://github.com/jsevellec/cassandra-unit) you have to know the license of this jar and 41 other jars also. You see how painful it is. To use one jar you have to find out information of 41 jars, think if you want to use some 10 jars, how many more jars you need to check.

Here maven plugin maven-project-info-reports-plugin comes to the rescue. This plugin can find out all the information you need.

I followed below steps to solve my problem.

Step 1:
I have created a new maven project in the eclipse and added my dependency (cassandra-unit). Then I have added maven-project-info-reports-plugin in the reports section.

Now pom file looks like below.

Step 2

Then run maven goal mvn project-info-reports:dependencies  and it will create a html file at target/site/dependencies.html which gives you all the information you need.

You can see license details of the Maven site plugin


POM.XML

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.reddy</groupId>
    <artifactId>SampleDependencies</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.cassandraunit</groupId>
            <artifactId>cassandra-unit</artifactId>
            <version>2.2.2.1</version>
        </dependency>

    </dependencies>



    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </reporting>



</project>


Sunday, January 26, 2014

to view only directories in Unix


If you have ever wanted to show a list of subdirectories underneath the current directory while at the terminal prompt, there’s a simple command that can help.
Simply run the following command from the bash terminal prompt, which filters the file listing to only show folders:

ls -l | grep ^d
Since typing that whole command every time you want to show a list of directories might get a little tiring, you can use the alias feature to assign it to something you can more easily remember:
alias lsd="ls -l | grep ^d"
Now when you type “lsd” at the prompt, you will see a list containing only the directories, which can be very useful when you are trying to navigate through a messy set of folders.

Sunday, January 19, 2014

Some useful VI editor commands


J – to join two lines
Deletion
dl – single character, dw – Single word, dd – single line, d$ – to the end of the line
Editing
i – insert mode, A – append to the end of the line, o – insert in next line
Misc
:set list – to see special characters
:%s/str1/str2/g – search and replace

Sunday, January 12, 2014

Some useful variables in Unix


$$ = The PID number of the process executing the shell.
$? = Exit status variable.
$0 = The name of the command you used to call a program.
$1 = The first argument on the command line.
$2 = The second argument on the command line.
$n = The nth argument on the command line.
$* = All the arguments on the command line.
$# The number of command line arguments.

Sunday, January 5, 2014

Read password from shell script


Since you don't want password to be not displayed on terminal you need to disable echo before reading password. Once password is read you need to enable it again.

#————————————————————
#  Read Password
#————————————————————
/usr/ucb/echo -n “Please Enter Password For User ${SUSER}: “
stty -echo
read SPSWD
stty echo
clear

Friday, December 2, 2011

How to do MySQL port forwarding using PuTTY

1. Go to Session: enter site name, port, etc…
2. Window > Behaviour : Window Title can be set here.
3. Connection > Data: User name should be given Auto-login username.
4. Connection > SSH : check Enable Compression.
5. Connection > SSH > Tunnels: enter local port number in Source Port, the port to be forwarded in Destination in the form : and click on Add to create the tunnel.
For MySQL client, this local port will be the port and localhost will be the machine.

Create windows short cut for this.
1. Create a short cut for PuTTY and change its command like below.
C:\Users\user\Desktop\putty.exe -ssh -pw -load
Source: http://www.jfitz.com/tips/putty_config.html

Thursday, July 7, 2011

Find recursively and copy files in Unix

I was trying to do a recursive search in Unix using find command and then copy all those files to a specific folder.

I found below command does that.

find . -name *2011-03-19* -exec cp {} /home/Reddy/logs/ \;

Important thing is, we need to escape the ending semi-colon.

{} is the place holder for putting the search result, i.e., the file name found.

Wednesday, October 1, 2008

Enable the tools disabled by virus

If you got a virus usually it will disable the following things so that you can't be able to delete the virus.

It will disable Folder Options menu item from View menu, disables the Task Manager, and disables the Registry Editor.

You can enable all these from the Group Policy editor by yourself manually.

  • Go to Windows > Run > gpEdit.msc
  • Folder Options: Go to User Configuration > Administrative Templates > Windows Components > Windows Explorer > Removes the Folder Options menu item from the Tools menu. Disable this option. Now you should be able to see Folder Options in the View menu of your explorer window.
  • Task Manager: Go to User Configuration > Administrative Templates > System > Ctrl+Alt+Del Options > Remove Task Manger. Disable this option.
  • Registry Editor: Go to User Configuration > Administrative Templates > System > Prevent Access to Registry Editing Tools. Disable this option.
But, it is good to have alternatives for these things since viruses usually disables the default tools but not the alternative softwares.

You can use Process Explorer as alternative for Task Manager. Similarly you can use Explorer2 as alternative for default windows explorer. If you don't like Explorer2 many more explorer softwares are available, you can choose from any of those. I don't know alternatives for the Registry Editor. Please feel to share those you know in the comments section below.

Related Posts:
Stop viruses coming from Pen Drives
Remove Amvo.exe virus, Funny UST Scandal, Fun.exe DC.exe SVIQ.exe
Task Manager, Registry Accessing disabled?
Disable Autoplay, Messenger Service
Important steps while cleaning virus
What is this process

Subscribe to my site feed for receiving more tips. You can get more tips in your email for free.

Latest Posts