末日前几天

the days before Doomsday

Xcode 快捷键收集整理

最近工作比较忙,没有什么时间学习ios,用xcode的时间就更少了,所以以前记得那些快捷键现在都有些生疏,今天又学习了几个,想到整理一下,以后遇到更多的再慢慢添加,慢慢完善.
以下是感觉经常用到的很有用的一些:

鼠标三击     选中当前行
⌘+/  当前行添加注视符//
⌘+shift+1  打开welecome to Xcode窗口
⌘+shift+2  打开Organizer窗口
选中方法后按control+option+⌘+/  迅速在Organizer-Documentation中查看帮助信息
⌘+~ 再主窗口与Documentation之间切换我经常用到的
option+鼠标左击 迅速查看简短帮助信息
⌘+鼠标左击 定位到方法或属性声明的位置
⌘+0  隐藏、显示Utilities区域
⌘+option+0 现实、隐藏Navigator区域

⌘+]  代码向右缩进
⌘+[  代码向左缩进
option+⌘+[ 向上移动行
option+⌘+] 向下移动行

⌃+⌘+E Edit all in scope
⌃I Re-indent code

Ctrl+a 去行首
Ctrl+k 删除到行尾
Ctrl+a+k+k  删除当前行

鼠标双指再触摸板来回滑动可以来回切换编辑的文件或者
Ctrl+⌘+Left/Right  在文件编辑器中前进或者后退 
Ctrl+⌘+Up/Down  在.h与.m文件之间切换
⌘+\  添加、删除断点

⌘+R 编译运行

squid-3.2.5 CentOS X86_64 Configure: Error: C Compiler Cannot Create Executables

squid-3.2.5 在CentOS X86_64位的环境下默认配置编译会遇到错误,如下:

checking whether the C compiler works... no
configure: error: in `/opt/packages/goodlePackages/squid/squid_src/squid-3.2.5':
configure: error: C compiler cannot create executables

x86_64解决办法如下:

1
2
3
./configure CXXFLAGS="-g -O2"  CFLAGS="-O2 -march=x86-64" --prefix=/usr/local/squid
make
make install

i686

1
2
3
./configure -disable-64bit CFLAGS="-O3 -march=i686" --prefix=/usr/local/squid
make
make install

Mac 下的 Open命令

mac下的应用程序是一个有结构的目录(想在Finder下查看程序目录内容,可以在程序目录上右击选择 “Show Package Contents” 像下图一样).

open-command.png

安装程序也是简单的把这个目录copy到你想要的地方就可以,大部分是 ~/Application 或者 /Application 下.

但想要在命令行下运行程序怎么办?你总不能在命令行下运行一个目录吧!

这个时候发现了/usr/bin/open命令,就是干这个的.

比如,我想在命令行下运行Firefox,运行下面的命令即可

1
open -a /Applications/Firefox.app

想在命令行下,用 Finder 打开此时的路径的话,运行下面的命令

1
open ./

想要用系统默认程序打开响应的文件,运行下面的命令

1
open Readme.md

open命令的其他参数:

/usr/bin/open --help
open: unrecognized option `--help'
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
Help: Open opens files from a shell.
      By default, opens each file using the default application for that file.  
      If the file is in the form of a URL, the file will be opened as a URL.
Options: 
      -a                Opens with the specified application.
      -b                Opens with the specified application bundle identifier.
      -e                Opens with TextEdit.
      -t                Opens with default text editor.
      -f                Reads input from standard input and opens with TextEdit.
      -F  --fresh       Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
      -R, --reveal      Selects in the Finder instead of opening.
      -W, --wait-apps   Blocks until the used applications are closed (even if they were already running).
          --args        All remaining arguments are passed in argv to the application's main() function instead of opened.
      -n, --new         Open a new instance of the application even if one is already running.
      -j, --hide        Launches the app hidden.
      -g, --background  Does not bring the application to the foreground.
      -h, --header      Searches header file locations for headers matching the given filenames, and opens them.

Windows Office Excel Vba Script 一例

上周学习vba的总结.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Sub getData()

    '单引号开始的是注视行
    '声明变量
    Dim RowNumMax As Integer, RowNumMax2 As Integer
    Dim ASht As Worksheet, BSht As Worksheet
    Dim Site

    '根据表格名字获得表格,并赋值个变量
    Set ASht = Sheets("Sheet1")
    Set BSht = Sheets("Sheet2")
    '锁定屏幕更新
    Application.ScreenUpdating = False
    On Error Resume Next

    '检查表格数据
    '定位数据的函数有两个Range 或者 Cells
    'Range是表示法是Range("E2")
    'Cells的表示法是坐标类似Cells(1,1)

    If ASht.Range("E2") = "" Then
    MsgBox "E2列中没有网站数据"
    ASht.Activate
    ASht.Cells.Select
    End
    End If

    ASht.Select
    RowNumMax = ASht.[E65536].End(xlUp).Row   'E列最下面一行的行数,中间有空格也行

    BSht.Select
    RowNumMax2 = BSht.[A65536].End(xlUp).Row
    BSht.Range("A2:A" & RowNumMax2).ClearFormats

    '清除格式
    ASht.Select
    ASht.Cells.Select
    Selection.ClearFormats
    '快捷设置选中单元格de属性
    With Selection.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With

    'for循环
    For x = 2 To RowNumMax + 1
        Site = ASht.Range("E" & x)
        '不等于操作符 &lt;&gt;
        If Site &lt;&gt; "" Then
         'MsgBox Site
          'Unique
           For a = 2 To RowNumMax + 1
               If a &lt;&gt; x Then
                    If Site = ASht.Range("E" & a) Then
                        MsgBox "E" & a & "跟E" & x & "重复,整理被迫中断"
                    End
                End If
               End If
           Next a

         For xx = 2 To RowNumMax2 + 1
             'MsgBox BSht.Range("A" & xx)
             'If xx &gt; 3 Then
             'Exit For
             'End If
             If Trim(Site) = Trim(BSht.Range("A" & xx)) Then
               BSht.Range("A" & xx).Interior.ColorIndex = 15
              'MsgBox "A" & xx
              '字符串处理函数Trim去除字符串开头结尾的空格符号,跟php的一样
              '换行符常量,vbLf
              '利用Replace函数删除换行符              
               ASht.Range("F" & x) = Replace(Trim(BSht.Range("H" & xx)), vbLf, "")
               'ASht.Range("G" & x) = Trim(BSht.Range("K" & xx))
               ASht.Range("H" & x) = Replace(Trim(BSht.Range("C" & xx)), vbLf, "")
               ASht.Range("J" & x) = Replace(Trim(BSht.Range("B" & xx)), vbLf, "")
               ASht.Range("K" & x) = Replace(Trim(BSht.Range("F" & xx)), vbLf, "")
               'MsgBox BSht.Range("F" & xx).Formula =
               'BSht.Range("D" & xx).MergeArea.Cells(1, 1) 读取合并单元格的值
               ASht.Range("L" & x) = Replace(Trim(BSht.Range("D" & xx).MergeArea.Cells(1, 1)), vbLf, "")
             End If

         Next xx

        Else

         ASht.Range("F" & x) = ""
         ASht.Range("H" & x) = ""
         ASht.Range("J" & x) = ""
         ASht.Range("K" & x) = ""
         ASht.Range("L" & x) = ""

        End If
        'If x &gt; 3 Then
        'Exit For
        'End If
    Next x

    ASht.Range("F2:G53").ClearContents
    'ASht.Range("G2:G5555").ClearContents

    Application.ScreenUpdating = True
End Sub

Config Awstats on Window2003 or Linux With GeoIP/QQWry

awstats.png

Awstats是一个日志分析工具(web log分析为强),很好很强大,不多解释,感兴趣的wiki一下。这是一个安装教程文章.

首先是awstas在windows 2003下与iis6的配置过程,然后是在Linux下和Nginx一起的配置,紧跟着Linux下与Lighttpd一起配置的过程,总之,这个可能是目前市面上最仔细全面安装awstas的教程了.

使终端(iTerm2/Terminal)色彩缤纷

因为经常使用终端 (iTerm|Terminal) ssh到服务器上去,所以整日盯着黑乎乎的屏幕很头痛,还不利于眼睛,所谓“工欲善其事,必先利其器”,所以今天就想让终端也色彩缤纷起来,让我们锻炼眼睛识别颜色的能力吧.

terminal-colorful.png

Xcode打包app命令-PackageApplication

xcode提供有这样一个perl脚本工具,可以打包一个app为ipa文件,为上传app store做准备. 路径是

`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication

添加-help参数查看PackageApplication用法帮助,或者添加-man参数查看完整的帮助信息。

`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication -help
Usage:
    PackageApplication [-s signature] application [-o output_directory]
    [-verbose] [-plugin plugin] || -man || -help

    Options:

        -s   certificate name to resign application before packaging
        -o              specify output filename
        -plugin         specify an optional plugin
        -help           brief help message
        -man            full documentation
        -v[erbose]      provide details during operation

More Useful

查看app里被Xcode优化了的png图片

问题:当我们构建自己的ios app时,Xcode会优化压缩我们的程序里的png图片,如果想再次查看正常图片的话,需要反压缩,怎么做呢?
答案:用Xcode自带的工具。

Q: When I build my iOS application, Xcode optimizes the PNG files within my application’s bundle, meaning that Preview can’t display them. How can I view these optimized files?

A: This optimization is done by the pngcrush tool, which you can find inside Xcode. The pngcrush tool supports a command line option, -revert-iphone-optimizations, that undoes the optimizations done during the Xcode build process. So, to view an optimized PNG file, you should first undo the optimization and then open it with Preview.

Listing 1 shows how you can use the pngcrush tool to convert an iOS-optimized PNG file (Local.png) to a standard PNG file (Local-standard.png).

Listing 1: Undoing iOS PNG optimization

1
2
3
$ /Applications/Xcode.app/Contents/Developer\
/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush \
-revert-iphone-optimizations -q Local.png Local-standard.png

If you have Xcode installed in a non-standard place, you can locate the tool using xcode-select, as shown in Listing 2.

Listing 2: Using xcode-select to locate pngcrush

1
2
3
$ "`xcode-select -print-path`"\
/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush \
-revert-iphone-optimizations -q Local.png Local-standard.png