分類
程序

java批量下图

这个代码没什么太大用途,权当复习一下java,里面的例外也处理。作用就是能下载http://www.style.com/fashionshows/complete/slideshow/F2014MEN-AMCQUEEN/这个相册里的30张图。

package fatch;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 *
 * @author 42
 */
public class Fatch {

    /**
     * 本程序获取http://www.style.com/fashionshows/complete/slideshow/F2014MEN-AMCQUEEN/相册中的30张图片
     * 通过查看图片属性发现其文件名有简单规律,虽不连续但是是有顺序的
     * first,last是网址的前半部分和后半部分
     * 先判断文件是否存在,然后将文件下载到本地
     */
    public static void main(String[] args) throws MalformedURLException, IOException {
        String imagesource="";
        String first="http://www.style.com/fashion-shows/fall-2014-menswear/london/alexander-mcqueen/collection/_ARC0";
        String last=".1366x2048.JPG";
        
        InputStream inputStream;  
        byte[] getData = null;
        for(int i=1,x=0;x<30&&i<=500;i++){
            if(i<10){
                imagesource=first+"00"+i+last;
            }else if((i>=10)&&(i<100)){
                imagesource=first+"0"+i+last;
            }else if((i>=100)&&(i<1000)){
                imagesource=first+i+last;
            }
        URL url = new URL(imagesource);  
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();  
        try {
            inputStream = conn.getInputStream();      //通过输入流获得图片数据
            getData = readInputStream(inputStream);     //获得图片的二进制数据  
        } catch (IOException ex) {
            getData=null;
        }
        
        if(getData!=null){
        File imageFile = new File(i+".JPG");    
        FileOutputStream fos = new FileOutputStream(imageFile);
        fos.write(getData);             
        fos.close();  
          
        System.out.println(x+"picture(s) downloaded"); 
        x++;
        }
        }
        
    }  
  
    public static  byte[] readInputStream(InputStream inputStream) throws IOException {  
        byte[] buffer = new byte[1024];  
        int len = 0;  
        ByteArrayOutputStream bos = new ByteArrayOutputStream();  
        while((len = inputStream.read(buffer)) != -1) {  
            bos.write(buffer, 0, len);  
        }  
          
        bos.close();  
        return bos.toByteArray();
    }
}
分類
說說

14010910

  • 最早用优盘到官网下载iso往DELL上装Ubuntu13.04,居然遇到了无线网卡无法识别,前不久从12.10升级(破小区网络升了一下午)到13.04就没问题。
  • 宜家会员送免费礼物,服务器从早上崩溃到现在。
  • 女朋友鼻炎犯了。
  • 愁。
分類
程序 网站

用php处理表单的数据

下面代码在接收到数据后先将数据储存与数据库,再将数据以电子邮件方式通知自己。

<?php
$author=$_POST["name"];$email=$_POST["email"];$title=$_POST["subject"];$message=$_POST["message"];
$con=mysql_connect("数据库地址","数据库用户名","数据库密码");
if(!$con){
	die('Could not connect: '.mysql_error());
	}
mysql_query("set names utf8");
mysql_select_db("数据库名",$con);
mysql_query("INSERT INTO `数据表名` (`id`, `date`, `author`, `email`, `title`, `message`) VALUES (NULL, CURRENT_TIMESTAMP, '$author', '$email', '$title', '$message')");
mysql_close($con);
$myNotify = "Name:$authornEmail:$emailnTitle:$titlenMessage:$message";
$myNotify = wordwrap($myNotify,70);
mail("自己的邮箱@gmail.com","your tittle",$myNotify,'From:发送自@ft.wupo.info');//邮件标题如果有中文要进行编码,否则会乱码,故这里没有使用$title
echo ""; 
exit;
?>
分類
其它

将word表格导入cdr

如果直接复制word中的表格,贴入cdr后会对不齐,而且表格的底色等也会丢失。现在发现一个导入后跟word里显示一样的方法。

现将表格单独保存并用虚拟打印机打印成pdf,然后再导入cdr,选择曲线方式导入。这样就完美了,表格效果和word中一模一样。

需要提醒的是我用的是装Adobe Acrobat时自带的Adobe PDF虚拟打印机,效果很好。我还试了Solid PDF Tools的虚拟打印机,导出的pdf再导入cdr效果就很差。

分類
說說

14010410

前天在龙岗从豆瓣看迷笛排期表的时候意外发现部分图片居然是webp格式的!我是用Opera Mobile看的,今天看豆瓣,发现又回到jpg了。我对比了下,同样一张图片(明舞台排期),jpg是89k,而webp是30k。原来豆瓣是根据联网类型判断的,移动网络才选择webp格式图片!

分類
說說

13123010

过两天迷笛,于是想先更新几篇公司的文章,到时候用手机把状态改为发布就行了。可是试了Opera Mobile和自带Webkit浏览器都不行,想着下个Chrome吧一看最低要求安卓4.0,最终试了下Opera Mini居然可以,Opera的服务器真是强悍!顺便说一句,公司的网站用的是万网的快速建站建的,总体不好用,但是很稳定。

分類
其它

Lost Highway

I'm a rolling stone all alone and lost
For a life of sin I have paid the cost.
When I pass by all the people say
'Just another guy on the lost highway.'

Just a deck of cards and a jug of wine
And a woman's lies make a life like mine.
Oh the day we met I went astray
I started rollin' down that lost highway.

I was just a lad nearly twenty-two
Neither good nor bad just a kid like you
And now I'm lost too late to pray
Lord I've paid the cost on the lost highway.

Now boys don't start your ramblin' round
On this road of sin or you're sorrow bound.
Take my advice or you'll curse the day
You started rollin' down that lost highway.