分類
程序

Js AES加解密

密码:
原文:

密文:

加密js用的是Jeff.Mott.OR的crypto-js

本文更新於 2016/04/22。

分類
程序

在线小六壬

公曆:

如果輸入框不支持時間選擇,請以2015-05-19T10:36格式輸入查詢。

本文更新於 2021/05/04。

分類
程序

Google Geocoding API好用

之前用qpython写了个小程序记录地理位置,反向地理编码(就是根据经纬度查询实际位置)用的是SL4A的Android模块,它就是调用底层谷歌的方法查询。但是现在一谷歌不稳定,二新手机没有装谷歌框架,所以完全无法反向地理编码。今天看了下谷歌的Geocoding API,用php转发了一下获取到的json,用起来就方便多了。而且谷歌的这个服务不用繁琐的验证,不限制客户端,甚至连帐号都不用,真是良心啊!当然由于“地理编码是一项既耗时又耗资源的任务”,所以每天发送的地理位置查询请求不得超过 2,500 个,这对于少量用户足够了。代码可以到右上角github里下载。

分類
程序 网站

自动检查网页更新

需求:http://www.cnca.gov.cn/ywzl/gjgnhz/jkzl/这个网页会公布进口水产品境外生产企业注册名单,但公布日期不一定,所以想自动检查美国(2014年07月21日)这个条目是否更新了,如果更新了发邮件通知我。方法:获取网页,查看网页是否存在“美国(2014年07月21日)”若不存在则更新了。发邮件用PHPMailer的SMTP发送邮件很方便。

check.php

<?php
ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
set_time_limit(0);//通过set_time_limit(0)可以让程序无限制的执行下去
$interval=60*60*10;//单位是秒,每10小时执行一次
do{
	$run = include 'config.php';
	if(!$run) die('process abort');
	
	$url = "http://www.cnca.gov.cn/ywzl/gjgnhz/jkzl/"; 
	$ch = curl_init(); 
	curl_setopt ($ch, CURLOPT_URL, $url); 
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,20); 
	$content = curl_exec($ch); 
	curl_close($ch); 
	$hasAutime=strpos($content,'美国(2014年07月21日'); 
	$hasAu=strpos($content,'美国');//防止没有下载到网页误触发,方法不可取
	
	 if (!$hasAutime && $hasAu){
	  require 'mail/mySendMail.php';
	  
	  $subject="内容有更新";
	  $body="内容有更新,请访问<a href='http://www.cnca.gov.cn/ywzl/gjgnhz/jkzl/'>http://www.cnca.gov.cn/ywzl/gjgnhz/jkzl/</a>";
	  if(mySendMail("[email protected]","name",$subject,$body)){
				 echo "有更新,已发送邮件提醒";
		 } else {
				 echo "有更新,邮件发送失败";
		 }
		 die('process abort');
	 } else {
		 echo "not modified";
	 }
	
	sleep($interval);
}while(true);
?>
分類
程序

qpython3

qpython3是一个能在安卓手机上执行python3脚本的软件,很好用。通过SL4A(qpython3已内置),可以方便的编写出实用的安卓脚本程序。

https://github.com/pggdt/loc/tree/master/qpython3-cn这个是我用python3写的一个获取并保存地理位置的小程序。用到的有SL4A中location部分,webview部分,python3中的urllib等,最后用了下bootstrap美化。

分類
程序

把照片重命名为拍摄时间

主要问题就是获取照片的EXIF信息中的拍摄时间。Java的话推荐Drew Noakes的metadata-extractor。python3用Pillow就行了。另外还有一个好用的python3库可以获取exif信息,EXIF.py Python3 port,短小精悍可以用在qpython3上。

实现了下java,成品和源码都在https://github.com/pggdt/rename-JPG-to-Date。先基于后缀名判断下是否是jpg文件,然后有exif信息的重命名为“年年月月日日-时时分分秒秒”格式,如果同一秒还有照片就在文件名后加1。如果勾选了重命名为最后修改时间,则会继续重命名没有exif信息的照片,将它们的名字改为图片的最后修改日期。

分類
程序

Eclipse用法

我是在ubuntu12.04上用的adt-bundle,安装好Sun Java后解压就可以使用了。关于ubuntu12.04上安装Sun Java,参考Ubuntu安装SunJava

为Eclipse安装WindowBuilder

In order to install WindowBuilder on Eclipse 4.3 (Kepler) Modeling let’s click on Help -> Install New Software… and choose (into “Work with:” field ) the main Kepler Update Site (http://download.eclipse.org/releases/kepler), expand the Category “General Purpose Tools” (make sure that “Group items by Category” flag be selected) and choose the following items:

  • SWT Designer
  • SWT Designer Core
  • WindowBuilder Core
  • WindowBuilder Core UI
  • WindowBuilder GroupLayout Support
  • WindowBuilder Java Core

Then press the Next button and follow the wizard until it asks to restart Eclipse. Let’s accept pressing Restart Now button. If you download instead the package Eclipse 4.3 (Kepler) for RCP and RAP Developers WindowBuilder is included.