Python Module to Obfuscate JavaScript

Rajendra Dharmkar
Updated on 12-Sep-2019 07:26:07

1K+ Views

You can use the jsmin module to minimize/obfuscate javascript code using Python. Install jsmin using:$ pip install jsminTo use jsmin in your python project to minimize a js file, say hello.js, you can use it as follows:>>> from jsmin import jsmin >>> with open('hello.js') as js_file: ...     minified = jsmin(js_file.read()) >>> print minifiedYou'll get the minified JS code printed to your shell. You can also use jsmin as a command line tool:$ python -m jsmin hello.jsYou can read more about jsmin on pypi docs: https://pypi.python.org/pypi/jsmin

Check if a String Contains Certain Text in JavaScript

Nikitha N
Updated on 12-Sep-2019 07:21:59

176 Views

The jQuery search() method is used to check whether a string contains a certain text in JavaScript.You can try to run the following code to check whether “Tutorialspoint: Free Video Tutorials” contains the “Free Video” text in JavaScript or not:           JavaScript String search() Method                        var re = "Free Video";          var str = "Tutorialspoint: Free Video Tutorials";          if ( str.search(re) == -1 ) {             document.write("Does not contain" );          } else {             document.write("Contains" );          }          

Which Equals Operator to Use in JavaScript Comparisons

Sravani S
Updated on 12-Sep-2019 07:10:20

157 Views

Double equals (==) is abstract equality comparison operator, which transforms the operands to the same type before making the comparison.For example,4 == 4     // true '4' == 4   // true 4 == '4'   // true 0 == false // trueTriple equals (===) are strict equality comparison operator, which returns false for different types and different content.For example,4 === 4     // true 4 === '4'   // false var v1 = {'value': 'key'}; var v2 = {'value': 'key'}; v1 === v2   //false

Write Data to a CSV File in Java

Maruthi Krishna
Updated on 12-Sep-2019 06:52:18

2K+ Views

How to read/A library named OpenCSV provides API’s to read and write data from/into a.CSV file. Here it is explained how to read the contents of a .csv file using a Java program.Maven dependency    com.opencsv    opencsv    4.4    org.apache.commons    commons-lang3    3.9 The CSVReader class of the com.opencsv package represents a simple csv reader. While instantiating this class you need to pass a Reader object representing the file to be read as a parameter to its constructor. It provides methods named readAll() and readNext() to read the contents of a .csv fileUsing the readNext() ... Read More

Writing Data from Database to CSV File

Maruthi Krishna
Updated on 12-Sep-2019 06:47:26

4K+ Views

You can write data into a .csv file using the OpenCSV library and, you can communicate with MySQL database through a Java program using the mysql-java-connector.Maven dependencyThe following are the dependencies you need to include in your pom.xml file to write data to a .csv file from a database table.    com.opencsv    opencsv    4.4    org.apache.commons    commons-lang3    3.9    mysql    mysql-connector-java    5.1.6 Writing data to a CSV fileThe CSVWriter class of the com.opencsv package represents a simple CSV writer. While instantiating this class you need to pass a Writer object ... Read More

FileOutputStream in Java

Maruthi Krishna
Updated on 12-Sep-2019 06:42:20

368 Views

This writes data into a specific file or, a file descriptor (byte by byte). It is usually used to write the contents of a file with raw bytes, such as images.To write the contents of a file using this class −First of all, you need to instantiate this class by passing a string variable or a File object, representing the path of the file to be read.FileOutputStream outputStream = new FileOutputStream("file_path"); or, File file = new File("file_path"); FileOutputStream outputStream = new FileOutputStream (file);You can also instantiate a FileOutputStream class by passing a FileDescriptor object.FileDescriptor descriptor = new FileDescriptor(); FileOutputStream outputStream ... Read More

Writing Data to a File Using BufferedWriter Class in Java

Maruthi Krishna
Updated on 12-Sep-2019 06:37:17

1K+ Views

The BufferedWriter class of Java is used to write a stream of characters to the specified destination (character-output stream). It initially stores all the characters in a buffer and pushes the contents of the buffer to the destination, making the writing of characters, arrays and Strings efficient.You can specify the required size of the buffer at the time of instantiating this class.ExampleIn the following Java program, we are trying to print a line on the console (Standard Output Stream). Here we are invoking the write() method by passing the required String. Live Demoimport java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; public class BufferedWriterExample ... Read More

BufferedReader Class in Java

Maruthi Krishna
Updated on 12-Sep-2019 06:26:28

8K+ Views

The BufferedReader class of Java is used to read the stream of characters from the specified source (character-input stream). The constructor of this class accepts an InputStream object as a parameter.This class provides a method named read() and readLine() which reads and returns the character and next line from the source (respectively) and returns them.Instantiate an InputStreamReader class bypassing your InputStream object as a parameter.Then, create a BufferedReader, bypassing the above obtained InputStreamReader object as a parameter.Now, read data from the current reader as String using the readLine() or read() method.ExampleThe following Java program demonstrates how to read integer data ... Read More

Variable Arguments in Java

Maruthi Krishna
Updated on 12-Sep-2019 06:19:50

672 Views

While defining a method, In general, we will specify the arguments it accepts along with the type as −myMethod(int a, String b){ }Suppose if you need to accept more than one variable of the same type you need to specify the variables one after the other as −myMethod(int a, int b, int c){ }You can also pass a variable number of arguments of a particular type, to a method. These are known as variable arguments or, varargs. They are represented by three dots (…)Syntaxpublic myMethod(int ... a) {    // method body }Once you use variable arguments as a parameter ... Read More

Append Content to an Existing File using Java

Maruthi Krishna
Updated on 12-Sep-2019 06:15:25

487 Views

In most scenarios, if you try to write content to a file, using the classes of the java.io package, the file will be overwritten i.e. data existing in the file is erased and the new data is added to it.But, in certain scenarios like logging exceptions into a file (without using logger frameworks) you need to append data (message) in the next line of the file.You can do this using the Files class of the java.nio package. This class provides a method named write() which acceptsAn object of the class Path, representing a file.A byte array holding the data to ... Read More

Advertisements