分類
程序

github用法小记

github还是挺复杂的,记录下免得下次还得搜。首先按照官方文档在网页上建好项目,本地进入对应目录初始化号帐号。然后添加remote:git remote add origin_loc https://github.com/pggdt/项目名.git。然后git pull origin_loc master同步一下。最后将本地的修改提交到github:git commit可以查看本地修改过的文件。git add 文件名,可以添加等下要上传的文件。添加后再用git commit为修改做评价。最后git push origin_loc master就提交完成了。

我就是这么做的,不保证是最正确的做法,有更好意见的请提出来。

網頁註冊賬號,本地安裝git。如果想使用SSH鑒權,秩序把本機的~/.ssh/id_rsa.pub文件內容添加到https://github.com/settings/keys即可。進入要存放項目的目錄,執行git clone [email protected]:pggdt/ulogger-server.git克隆github上的項目到本地。創建cn分支來實現自己的feature git checkout -b cn。然後通過編輯器編輯代碼,完成後通過git status查看變化的文件。通過git add changedFile 來添加文件。通過 git commit -m "更新內容"來提交更新。最後推送到github上git push origin cn。

本文更新於 2018/01/25。

分類
程序

python3批量下图

又发现一个图集,用python3抓下:

import urllib.request def main(): url='http://cdn.test.com/downloads/character' path='/home/me/Pictures/paper/paper-' for i in range(1,400): ii='' if i<10: ii="00"+str(i) elif i<100: ii="0"+str(i) else: ii=str(i) url=url+ii+".jpg" print (url) h='' try: doc=urllib.request.urlopen(url) h=str(doc.info()) except urllib.error.HTTPError: print(ii+'is not exist') if('jpeg' in h): path=path+ii+".jpg" data = urllib.request.urlopen(url).read() f = open(path,"wb") f.write(data) f.close() path='/home/me/Pictures/paper/paper-' print (str(ii)+"OK") url='http://cdn.test.com/downloads/character' if __name__ == "__main__": main()[/code]

有两点改变,python2 import的是urllib,这里用到urlopen,需要import urllib.request。还有就file已经不用了,换成open就好了。getheader函数也没有了。可以对比下python2版本的另一篇python批量下图

分類
程序

python批量下图

有个网站图片很好看,网址也很有规律,但是有的是空链接。用python都下下来了。

import urllib
def main():
  url='http://static.host.com/wallpapers/picture-'
  path='/home/me/Pictures/wallpaper/picture-'
  for i in range(0,400):
    url=url+str(i)+".jpg"
    print url
    doc=urllib.urlopen(url)
    type=doc.info().getheader('Content-Type')
    if(type.find('jpeg')!=-1):
      path=path+str(i)+".jpg"
      data=urllib.urlopen(url).read()
      f=file(path,"wb")  
      f.write(data)  
      f.close()
      path='/home/me/Pictures/wallpaper/picture-'
      print str(i)+"OK"
    url='http://static.host.com/wallpapers/picture-'

if __name__ == "__main__":
  main()

本文更新於 2014/05/26。

分類
网站

让WordPress支持webp图片尺寸

在主题的image.php中(推荐复制image.php到子主题再做修改),wp_get_attachment_metadata();函数后添加如下代码:

$文件 = wp_get_attachment_url();
$文件流 = fopen($文件, "rb");
$字节数组 = fread($文件流, 30);
fclose($文件流);
$数组 = unpack("C12格式/S9尺寸", $字节数组);
for($i=9;$i&lt;=12;$i++)
{
    $文件格式.=chr($数组['格式'.$i]);
}
if(0==strcmp ( 'WEBP' , $文件格式 )){//判断是否是webp格式图片
$metadata['width'] = $数组[尺寸8];
$metadata['height'] = $数组[尺寸9];
}
通用的Java和PHP代码参见:获取WebP格式图片的长宽

本文更新於 2014/05/19。

分類
其它

获取WebP格式图片的长宽

通过查看十六进制文件,发现WebP格式图片的长宽信息位于文件头第26、27(高),28、29(宽)这四个字节中。

Java代码:

import java.io.File; import java.io.FileInputStream; /** * @author 42 */ public class WebpSize { public static void main(String[] args) { File 文件=new File("示例.webp"); try { FileInputStream 输入=new FileInputStream(文件); byte[] 字节数组=new byte[30]; 输入.read(字节数组); if("WEBP".equals(new String(字节数组,8,4,"utf-8"))){//先判断图片格式为webp int 宽 = (((int) 字节数组[27] & 0xff) << 8) | (int) 字节数组[26] & 0xff; int 高 = (((int) 字节数组[29] & 0xff) << 8) | (int) 字节数组[28] & 0xff; System.out.print("宽:"+宽+",高:"+高); }else{ System.out.print("文件不是webp格式"); } 输入.close(); } catch(Exception e) { System.out.println(e.getMessage()); } } }[/code]

本文更新於 2014/05/19。

分類
程序

PrefixDial

做了下小更新:

--下面是v1.0的介绍--

需求:街边充话费,充完说要加拨"818P"才可以,而且所有电话都要加并不只是外地号码。而且加了818后拨出去的号码在通话记录里只显示818,无法重播。

功能:在本软件中拨打电话,自动添加"818,"前缀,并修改通话记录为拨打号码。

两个窗口,主窗口和通讯录窗口。

主窗口上面有个edittext用于输入电话号码。edittext下面有两个按钮,一个用于拨打edittext中的电话号码,一个用于打开通讯录窗口。按钮下面是和listview,放的是最近通话记录。点击条目即可拨号。

通讯录窗口就是一个listview,点击进行拨打电话。

预览图1主界面 预览图2通讯录 预览图3主界面

欢迎试用:
"818,"版下载
12593版下载 12593源码下载

本文更新於 2014/05/07。