分类:'就通一点' 的所有文章

贴代码:从命令行卸载程序, Windows XP/Vista/Win7

主要写给自己用,因为天天都跟windows命令行打交道,装了个CCleaner就是因为它比windows自己的“添加/删除程序”要快。最近实现工作中要用到的东西,顺便做得更加通用一点,贴到这里。还挺方便的,因为命令行更快。

保存成u.py,然后如下运行:

D:\Documents\Dropbox\Coding\active>u apple
multiple matches, please choose:

  1  Apple Mobile Device Support
  2  Apple Software Update
  3  Apple Application Support

select a number, Ctrl+C to quit: 3

        Apple Mobile Device Support

press ENTER to uninstall, Ctrl+C to stop
Python语言: Command line uninstaller for Windows Applications
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#Author : Zhongfang Ren
#         yid: renzhongfang
#         email: realfun AT gmail.com
#         website: http://2maomao.com/blog/, http://fayaa.com
#Purpose: Command line uninstaller for windows XP(Vista and Win7 not tried yet)
#Date   : Wednesday, March 23, 2011, 10:42:34
#

import sys, os, getpass
import subprocess as exe
import _winreg as R

target = ''
if len(sys.argv) > 1:
  target = sys.argv[1]

uninstalls = []

for root in (R.HKEY_LOCAL_MACHINE, R.HKEY_CURRENT_USER):
  with R.OpenKey(root, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") as key:
    keys = []
    i = 0
    while True:
      try:
        keys.append(R.EnumKey(key, i))
        i += 1
      except Exception as e:
        #print e
        break

    for k in keys:
      try:
        with R.OpenKey(key, k) as hkey:
          try:
            v = R.QueryValueEx(hkey, "DisplayName")
            v = str(v[0])
            if v.lower().find(target.lower()) >= 0:
              uninstalls.append((v, R.QueryValueEx(hkey, "UninstallString")[0]))
          except Exception as e:
            #print e
            pass
      except:
        pass

try:
  if not uninstalls:
    print "uninstall for %s not found" % target
  elif len(uninstalls) == 1:
    print
    print "\t%s" % uninstalls[0][0]
    print
    raw_input("press ENTER to uninstall, Ctrl+C to stop")
    exe.call(uninstalls[0][1])
  else:
    print "multiple matches, please choose:\n"
    i = 1
    for nu in uninstalls:
      print "%3d " % i, nu[0]#, '\t', nu[1]
      i += 1
    print
    val = 0
    while val <=0 or val > len(uninstalls):
      try:
        val = int(raw_input("select a number, Ctrl+C to quit: "))
      except ValueError:
        pass
    name, uninst = uninstalls[val-1]
    print
    print "\t%s" % name
    print
    raw_input("press ENTER to uninstall, Ctrl+C to stop")
    exe.call(uninst)
except KeyboardInterrupt:
  pass
finally:
  print

  • Share/Bookmark

命令行奇技淫巧一则 - 查找超大文件

查找某个目录下的超大文件
dir /S /-C /A | ggrep " \d{9,} (?!bytes)"

这一个命令会输出当前目录及其子目录下所有大于100M的文件

参见:
ggrep: http://dir.filewatcher.com/d/OpenBSD/3.4/powerpc/ggrep-2.5.1.tgz.124943.html
正则表达式:Regular Expression

  • Share/Bookmark

最近访问Twitter的方法

Twitter 最近无法直接访问了,修改hosts也不行,但如果早有准备,访问Twitter仍然可以非常简单和直接。

1. 尝试:http://dabr.co.uk ,界面友好,
2. 上面提到的Dabr其实是开放源码的,自己有服务器的都可以搭建,比如:

@scavin(小众软件) 的 http://t.appinn.com/
@Sofishhttp://g.happinesz.cn/
另1:使用Dabr架设私人Twitter手机版
另2:现在怎样访问Twitter?

3. 还可以在Gmail里使用直接推 ,具体用法参见望月的blog:简单几步,将你的Gmail变成Twitter

PS: 最近小宝宝来到身边,天天都要陪着玩儿,乐不思博了…

  • Share/Bookmark

把Outlook联系人导出到Google联系人

这两天在玩Google Phone,G1的机型,G2的系统,总体上用起来还不错,视频文件列表第一次打开比较慢

由于原来一直用Windows Mobile的,联系人都同步到Outlook,所以也没想到要导出来
现在暂用Phone了,又不想麻烦的一条条加联系人,就去搜了一下导出Outlook联系人的文章

结果发现有两种方式可以做到:
1. Windows Mobile手机跟m.google.com同步
 具体步骤参见笑来的blog:Windows Mobile手机与Google日历如何同步?

2. 直接Outlook Contacts导出到dos格式的csv,然后到http://google.com/contacts/上面去导入
 但是我在导出的时候遇到了问题 - 导出出来的中文是乱码

试了几次发现时Outlook Contacts导出到csv时的问题,可以这样绕过去:
 先导出到excel,然后从excel里面“另存为”csv格式就行了

  • Share/Bookmark

Google搜索结果里的链接打开有点儿慢?用YesScript扩展吧

Google搜索结果里面的每个链接看上去都是直接链接到网站
原来我就怀疑:这样的话Google怎么统计用户点击数据呢?

后来有个事情促使我去探索到底是什么原因:
在家里用Google太慢了,而且因为GFW的原因,有时候会挂,一挂了以后短时间内哪个Google结果链接都打不开

实际上,每个搜索的结构链接<a>里面都有一段脚本:

<a onmousedown=
"return rwt(this,'',”,’res’,'5′,’AFQjCNG1aS0e_ZXWJweG5uZk8bMmDIov3g’,'&amp;sig2=ZybsjNXV2WabD4U0uu8XDA’)" />

当你点击链接的时候,这段脚本就会更新这个链接

你可以在Firefox下试试搜索Test
然后:
1. 把鼠标移动到一个链接上,看看Firefox左下角的状态栏,里面的链接是啥
2. 然后按住鼠标左键(注意是“按住”,先不要松开),再看看状态栏的连接

知道这个,解决起来就简单了 - 给Firefox安装NoScript或者YesScript扩展就行了
NoScript默认不允许Javascript、然后用白名单来控制。YesScript默认允许、然后用黑名单控制。

我喜欢第二个,因为阮一峰的blog“关于网页设计的一些统计数字”里面说到:84.8%的网页使用Javascript
而且,发芽网本身就离不开Javascript,我更不喜欢用NoScript啦

于是安装了YesScript,然后Google搜索以后在打开右下角BlackListed图标点一下,以后Google搜索打开就不会经过Google服务器绕一次啦。

  • Share/Bookmark

下一页 »