Instantly share code, notes, and snippets.

View JavaMapAdapter.java
import _.model.MapEntry;
import _.model.MapType;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.util.HashMap;
import java.util.Map;
public class JavaMapAdapter<K,V> extends XmlAdapter<MapType<K,V>, Map<K, V>> {
View pom.go
package models
import (
"encoding/xml"
"errors"
"io/ioutil"
"os"
"gopkg.in/resty.v1"
"crypto/tls"
"encoding/json"
View promises.js
function getLocation() {
return new Promise(function (resolve, reject) {
resolve('Lucknow');
});
}
function getWeather(location) {
return new Promise(function (resolve, reject) {
resolve('It\'s 39 degrees in ' + location);
});
View displayMatchingArrayElements.js
db.gSearchParseResultBundle.find({"units.displayedUrl":"www.toptarif.de/gasvergleich"},{_id:0, units:{$elemMatch:{"displayedUrl" : "www.toptarif.de/gasvergleich"}}});
View downloadFileIOUtils.java
private byte[] downloadObject(String srcUrl) throws IOException
{
URL url = new URL(srcUrl);
InputStream in = new BufferedInputStream(url.openStream());
return IOUtils.toByteArray(in);
}
View scp_commands.sh
Copy Jars to remote locations
#!/bin/bash
nodes="192.168.2.70 192.168.2.71 192.168.2.72 192.168.2.73 192.168.2.74 192.168.2.75"
for node in $nodes
do
echo deploy node: $node
ssh -o StrictHostKeyChecking=no user@$node 'mkdir /home/user/vrnet &'
View SimpleImageConverter.java
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
public class SimpleConvertImage {