2018-08-10 11:01:41   Visit  10
a点到b的射线方位角   Math.atan2(b.y-a.y,b.x-a.x)*180/Math.PI

转:javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 解决方案
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 解决方案
这个是jdk导致的,jdk里面有一个jce的包,安全性机制导致的访问https会报错,官网上有替代的jar包,换掉就好了

目录 %JAVA_HOME%\jre\lib\security里的local_policy.jar,US_export_policy.jar

JDK7 http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html

JDK8 http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

https://www.cnblogs.com/1995hxt/p/6185399.html

2018-07-28 22:28:51   Visit  22

select 'alter system kill session '''||sid|| ','||serial#||''';' from v$session where username =' ';

2018-07-28 22:21:17   Visit  32

select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0

2018-07-27 21:12:49   Visit  24

sdo_relate(t.geom, sdo_geometry(:geometry,null),\'mask=ANYINTERACT\')=\'TRUE\'

JavaScript在浏览器中把文本保存为文件的方法

经过测试第二种方法可以保存更多的文本不至于卡死

var saveTextAsFile1 = function (text, fileName, success, error) {
    var data = text;
    if (!(text instanceof Array)) {
        data = [text];
    }
    var file = new File(data, fileName);
    var reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = function (r) {
        var url = reader.result;
        downLoadFile(url, fileName,
            function () {
                success && success();
            }, function () {
                error && error();
            });
    };


}

/**
 * 下载文件
 * @param {string, Array} text 
 * @param {string} fileName 
 * @param {function} success 
 * @param {function} error 
 */
var saveTextAsFile = function (text, fileName, success, error) {
    var data = text;
    if (!(text instanceof Array)) {
        data = [text];
    }
    var urlObject = window.URL || window.webkitURL || window;
    var export_blob = new Blob(data);
    var url = urlObject.createObjectURL(export_blob);
    downLoadFile(url, fileName,
        function () {
            success && success();
        }, function () {
            error && error();
        });
}
2018-07-26 01:00:21   Visit  36

jQuery 获取指定url标题



function getTitleOfUrl(u, callback) {
    var url = \\\"jsapi/proxy.jsp?\\\" + u;
    $.ajax({
        url: url,
        complete: function (e) {
            var text = e.responseText;
            text = text.replace(/\\\\s*/g,\\\"\\\");
            var reg = /<title>(.*)\\\\<\\\\/title>/;
            window.b = e;
            title = text.match(reg)[1];
            callback&&callback(title,e)
        }
    })
}
var u = \\\"http://leechg.com\\\";
getTitleOfUrl(u, function(title,e){
    console.log(title)
})

2018-07-04 15:02:10   Visit  41

bootstrapValidator 同一个页面两个form

bootstrapValidator 同一个页面两个form出现随机一个form无法验证的问题

经验证发现是页面内通过ajax加载子页面内容导致 bootstrapValidator .js重复加载,bootstrapValidator 没有记住之前配置的验校内容,导致后一个加载的子页面上的form没法验校。

解决方法

在子页去掉bootstrapValidator .js的加载

bootstrapValidator 不符合jQuery组件的画风

ORA-01483: DATE 或 NUMBER 绑定变量的长度无效

hibernate、 java 、Spring环境下访问数据库,使用org.hibernate.Session 的get方法获取实体时出现

ORA-01483: DATE 或 NUMBER 绑定变量的长度无效

经反复排查,发现是因为记录中的一个clob字段为空导致的

临时解决方法
修改java代码使其默认值为一个空格

2018-06-08 14:51:54   Visit  81

Unsupported Image Type

public static BufferedImage toBufferedImage(File imgFile, int maxWidth, int maxHeight){
            if(imgFile.exists()){
                try {
                    // ImageIO 支持的图片类型 : [BMP, bmp, jpg, JPG, wbmp, jpeg, png, PNG, JPEG, WBMP, GIF, gif]
                    String types = Arrays.toString(ImageIO.getReaderFormatNames());
                    String suffix = null;
                    // 获取图片后缀
                    if(imgFile.getName().indexOf(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\".\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\") > -1) {
                        suffix = imgFile.getName().substring(imgFile.getName().lastIndexOf(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\".\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\") + 1);
                    }// 类型和图片后缀全部小写,然后判断后缀是否合法
                    if(suffix == null || types.toLowerCase().indexOf(suffix.toLowerCase()) < 0){
                        logger.error(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"Sorry, the image suffix is illegal. the standard image suffix is {}.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" + types);
                        return null;
                    }
                    Image img = ImageIO.read(imgFile);
                    // 根据原图与要求的缩略图比例,找到最合适的缩略图比例
                    int width = img.getWidth(null);
                    int height = img.getHeight(null);
                    int[] wh=calcWH(width,height,maxWidth,maxHeight);
                    int w=wh[0];
                    int h=wh[1];
                    if(w==width && h==height){
                        logger.debug(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"宽度高度没有压缩,返回源文件!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
                        return ImageIO.read(imgFile);
                    }
               
                    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
                    Graphics g = bi.getGraphics();
                    g.drawImage(img, 0, 0, w, h, null);
                    g.dispose();
                    return bi;
                } catch (IOException e) {
                    logger.error(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"generate thumbnail image failed.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\",e);
                    try {
                        Image img ;

                        //Find a suitable ImageReader
                        java.util.Iterator readers = ImageIO.getImageReadersByFormatName(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"JPEG\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
                        javax.imageio.ImageReader reader = null;
                        while(readers.hasNext()) {
                            reader = (javax.imageio.ImageReader)readers.next();
                            if(reader.canReadRaster()) {
                                break;
                            }
                        }
                        //Stream the image file (the original CMYK image)
                        javax.imageio.stream.ImageInputStream input =   ImageIO.createImageInputStream(imgFile); 
                        reader.setInput(input); 

                        //Read the image raster
                        java.awt.image.Raster raster = reader.readRaster(0, null); 
                        raster.getWidth();
                        //Create a new RGB image
                        int width = raster.getWidth();
                        int height = raster.getHeight();
                        int[] wh=calcWH(width,height,maxWidth,maxHeight);
                        int w=wh[0];
                        int h=wh[1];
                        BufferedImage bi;
                        bi = createJPEG4(raster);
                        
                        
                        //bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); 
                        //Fill the new image with the old raster
                        //bi.getRaster().setRect(w/width, h/height,raster); 
                        
                        //g.drawImage(raster, 0, 0, w, h, null);
                        img = bi.getScaledInstance(w, h, Image.SCALE_SMOOTH);
                        
                        BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
                        Graphics g = bi2.getGraphics();
                        g.drawImage(img, 0, 0, w, h, null);
                        g.dispose();
                        return bi2;
                    } catch (Exception e1) {
                        e1.printStackTrace();
                        //com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader r = new com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader();
                    }
                }
            }else{
                logger.warn(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"the image is not exist.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
            }
            return null;
        }
    
        private static BufferedImage createJPEG4(Raster raster) {
            int w = raster.getWidth();
            int h = raster.getHeight();
            byte[] rgb = new byte[w * h * 3];
    
            // 彩色空间转换
            float[] Y = raster.getSamples(0, 0, w, h, 0, (float[]) null);
            float[] Cb = raster.getSamples(0, 0, w, h, 1, (float[]) null);
            float[] Cr = raster.getSamples(0, 0, w, h, 2, (float[]) null);
            float[] K = raster.getSamples(0, 0, w, h, 3, (float[]) null);
    
            for (int i = 0, imax = Y.length, base = 0; i < imax; i++, base += 3) {
                float k = 220 - K[i], y = 255 - Y[i], cb = 255 - Cb[i], cr = 255 - Cr[i];
    
                double val = y + 1.402 * (cr - 128) - k;
                val = (val - 128) * .65f + 128;
                rgb[base] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff
                        : (byte) (val + 0.5);
    
                val = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128) - k;
                val = (val - 128) * .65f + 128;
                rgb[base + 1] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff
                        : (byte) (val + 0.5);
    
                val = y + 1.772 * (cb - 128) - k;
                val = (val - 128) * .65f + 128;
                rgb[base + 2] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff
                        : (byte) (val + 0.5);
            }
    
            raster = Raster.createInterleavedRaster(new DataBufferByte(rgb,
                    rgb.length), w, h, w * 3, 3, new int[] { 0, 1, 2 }, null);
    
            ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            ColorModel cm = new ComponentColorModel(cs, false, true,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            return new BufferedImage(cm, (WritableRaster) raster, true, null);
        }

参考https://www.aliyun.com/jiaocheng/822407.html