This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File file = new File("/path/to/file"); | |
SAXReader reader = new SAXReader(); | |
Document document = reader.read(file); | |
XPath pathSelector = DocumentHelper.createXPath("/root/childOne/leaf[@attributeName='attributeValue']"); | |
List pathNodes = pathSelector.selectNodes(document); | |
for(Object pathNode : pathNodes) { | |
Element pathElement = (Element) pathNode; | |
System.out.println(pathElement.getTextTrim()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte[] input = args[0].getBytes(); | |
byte[] key = args[1].getBytes(); | |
SecretKeySpec aesKey = new SecretKeySpec(key, "AES"); | |
Cipher cipher = Cipher.getInstance("AES", "SunJCE"); | |
System.out.println("Input : " + new String(input)); | |
cipher.init(Cipher.ENCRYPT_MODE, aesKey); | |
byte[] encryptedText = new byte[cipher.getOutputSize(input.length)]; | |
int encryptedTextLength = cipher.update(input, 0, input.length, encryptedText, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.util.UUID; | |
import com.sun.tools.attach.AttachNotSupportedException; | |
import com.sun.tools.attach.VirtualMachine; | |
import com.sun.tools.attach.VirtualMachineDescriptor; | |
public class MyPID { | |
public static void main(String[] args) throws AttachNotSupportedException, IOException { | |
String uniqueId = UUID.randomUUID().toString(); | |
System.setProperty("process.unique.id", uniqueId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JMXServiceURL serviceUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+ipAddress+":"+port+"/jmxrmi"); | |
String[] credentials = { userName, password }; | |
Map<String, Object> env = new HashMap<String, Object>(); | |
env.put(JMXConnector.CREDENTIALS, credentials); | |
JMXConnector connector = JMXConnectorFactory.connect(serviceUrl, env); | |
MBeanServerConnection connection = connector.getMBeanServerConnection(); | |
ObjectName managedObject = new ObjectName(domainName, "name", objectName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String authToken = new BASE64Encoder().encode(username + ":" + password); | |
URLConnection urlConnection = url.getUrl().openConnection(); | |
urlConnection.setDoOutput(true); | |
urlConnection.setConnectTimeout(5000); | |
urlConnection.setRequestProperty("Authorization", "Basic "+authToken); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read -s -p "Password: " PASSWORD; echo | |
read -s -p "Confirm Password: " PASSCONFIRM; echo | |
if [[ "$PASSWORD" != "$PASSCONFIRM" ]]; then | |
echo "Passwords do not match, exiting" | |
exit -1 | |
fi | |
echo "Passwords match!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar cvf - $DIRECTORY | xz - > $OUTPUT_FILE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto lo | |
iface lo inet loopback | |
auto eth0 | |
iface eth0 inet static | |
address 192.168.0.2 | |
netmask 255.255.255.0 | |
gateway 192.168.0.1 | |
dns-nameservers 8.8.8.8 8.8.4.4 | |
metric 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync --exclude=.git -ave ssh --delete MyDirectory/ root@remotehost:/srv/files/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date +%Y-%m-%d --date="@$[`date +%s` - 86400]" | |
DATE=$(date +%Y-%m-%d --date="@$[`date +%s` - 86400]") |