*.swp
*.ef
*.conf
+*.diff
dvwa
import UIKit
-let str = "Hello, playground.小狗:🐶 锤子:🔨"
+// String values can be constructed by passing an array of Character values
+let catCharacters: [Character] = ["C", "a", "t", " ", "猫"]
+let catString = String(catCharacters)
+print(catString)
+
+// Character 加到String的方法
+var welcome = "Hello World"
+let exclamationMark: Character = "!"
+welcome.append(exclamationMark)
+print(welcome)
+
+// ############# Type Alias ################
+typealias AudioSample = UInt
+
+let maxAmplitudeFound = AudioSample.max
+
+
+// ############# Tuple ################
+let http404Error = (404, "Page Not Found")
+let (httpRetCode, _) = http404Error
+print("Http RetCode \(httpRetCode) Error Message \(http404Error.1)")
+
+let httpStatus = (statusCode: 200, description: "OK")
+print("Http RetCode \(httpStatus.statusCode) Message \(httpStatus.description)")
+
+
+// ############# Optionals ################
+let possibleNumber = "123"
+let convertNumber : Int? = Int(possibleNumber) // of type Int?
+
+if convertNumber != nil {
+ print("ConvertNumber is \(convertNumber)")
+ print("ConvertNumber is \(convertNumber!)")
+} else {
+ print("ConvertNumber is nil")
+}
+
+// ############# Optionals Binding ################
+if let actualNumber = Int(possibleNumber) {
+ print("\"\(possibleNumber)\" has an integer of \(actualNumber)")
+} else {
+ print("\"\(possibleNumber)\" could not to be converted to an integer")
+}
+
+if let firstNumber = Int("4"), let secondNumber = Int("42"), firstNumber < secondNumber && secondNumber < 100 {
+ print("\(firstNumber) < \(secondNumber) < 100")
+}
+
+// ############# Implicitly Unwrapped Optionals ################
+let possibleString: String? = "An Optional String"
+let forcedString: String = possibleString!
+
+let assumedString: String! = "An Implicitly Unwrapped Optional String"
+let implicitString: String = assumedString
+
+print("\(possibleString!) \(forcedString) \(assumedString) \(implicitString)")
+
+// ############# Nil-Coalescing Operator ################
+let defaultColorName = "yellow"
+var userDefinedColorName: String?
+// 等价于 userDefinedColorName == nil ? defaultColorName : userDefinedColorName
+var colorNameToUse = userDefinedColorName ?? defaultColorName
+print(colorNameToUse)
+
+userDefinedColorName = "red"
+colorNameToUse = userDefinedColorName ?? defaultColorName
+print(colorNameToUse)
+// ############# Nil-Coalescing Operator ################
+for index in 1...5 {
+ print("Closed Range Operator \(index) of [1,5]")
+}
+
+for index in 0..<5 {
+ print("Half-Open Range Operator \(index) of [0,5)")
+}
+
+var word = "cafe"
+print("the number of characters of \(word) is \(word.characters.count)");
+word += "\u{301}"
+print("the number of characters of \(word) is \(word.characters.count)");
+
+
+let str = "Hello, playground.小狗:🐶 锤子:🔨"
// Index
-let strInx:String.Index = str.startIndex
+var strInx:String.Index = str.startIndex
str.index(after: strInx)
-print(strInx)
+print(str[strInx])
+for strInx in str.characters.indices {
+ print("\(str[strInx])", terminator: "")
+}
+print()
+// utf8 编码格式
+for c in str.utf8 {
+ print(c, terminator: "-")
+}
+print()
+
+// unicode
+for c in str.unicodeScalars {
+ print("\(c)\t\(c.value)")
+}
+
+welcome.insert("~", at: welcome.endIndex)
+print(welcome)
+// contentsOf 是一个 Collection 所以要加 .characters
+welcome.insert(contentsOf: " Hello Swift".characters, at: welcome.index(before: welcome.endIndex))
+print(welcome)
+
+welcome.remove(at: welcome.index(before: welcome.endIndex))
+print(welcome)
+
+let range = welcome.index(welcome.endIndex, offsetBy: -12)..<welcome.endIndex
+welcome.removeSubrange(range)
+print(welcome)
+
+
+
+// ############# Working with Characters ################
for c in str.characters {
print(c, terminator: "")
}
print()
+print("The String is: \(str)")
+
+
// Print separator & terminator
var company:Array<String> = [ "Apple", "Google", "Facebook", "Tencent" ]
print(company[0], company[1], company[2], company[3], separator: "#", terminator: " $$$$$\n")
}
let keys = [Int](DictD.keys)
-print(keys)
+print(keys)
\ No newline at end of file
--- /dev/null
+/*
+ * ------------------------------------------------------------------------
+ * File Name: string.cc
+ * Author: Zhao Yanbai
+ * 2017-01-02 12:04:22 Monday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+#include<iostream>
+#include<string>
+using namespace std;
+
+int main(int argc, char *argv[]) {
+
+ string s = "Hello World!!\n";
+ decltype(s.size()) punct_cnt = 0;
+
+ for(auto c : s) {
+ cout << c;
+ if(ispunct(c)) {
+ punct_cnt++;
+ }
+ }
+
+ cout << punct_cnt << " punctuation characters in " << s;
+
+ for(auto &c : s) {
+ c = toupper(c);
+ }
+
+ cout << s;
+
+ return 0;
+}
#HISTCONTROL=ignorespace # 命令前加空格避免记入历史
HISTCONTROL=ignoreboth
-export PATH=/usr/local/sbin:$PATH
#export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
+export PATH=/usr/local/sbin:$PATH
export PATH=/Users/Ace/.local/bin:$PATH
export GOBIN=/Users/Ace/.local/bin
export PATH=/Users/Ace/workspace/github/metasploit-framework:$PATH
alias grep='grep --color'
alias egrep='egrep --color'
alias msf='msfconsole'
+alias cdw='cd ~/workspace/'
"为不同的文件类型设置不同的空格数替换TAB
-"autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set ai
-"autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sw=4
-"autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set ts=4
-"autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sts=4
+autocmd FileType php,python,h,c,java,perl,shell,bash,vim,ruby,cc,cpp set ai
+autocmd FileType php,python,h,c,java,perl,shell,bash,vim,ruby,cc,cpp set sw=4
+autocmd FileType php,python,h,c,java,perl,shell,bash,vim,ruby,cc,cpp set ts=4
+autocmd FileType php,python,h,c,java,perl,shell,bash,vim,ruby,cc,cpp set sts=4
"golang默认使用TAB
"autocmd FileType go set ai
for name, value in D.items() :
print "{0:10} : {1:10d}".format(name, value)
+D = {x:x**2 for x in range(10)}
+print(D)
+
D = dict(a=1, b=2, c=3)
print D
for item in file_sz.items() :
print "{1}:\t{0}".format(item[0], item[1])
-
-
-
x = dict()
for i in range(0, 10) :
x[i] = x.get(i, i)
for i in sorted(x.keys()) :
- print x[i]
+ print x[i],
+print("")
+# Another Make Empty Dictionary Method
+x = { }
+for i in range(0, 10) :
+ x[i] = x.get(i, i)
+for i in sorted(x.keys()) :
+ print x[i],
for x in range(len(a)) :
print x,
+else :
+ print("")
a += b
print a
+questions = ['name', 'quest', 'favorite color']
+answers = ['lancelot', 'the holy grail', 'blue']
+for q, a in zip(questions, answers):
+ print('What is your {0}? It is {1}.'.format(q, a))
+
# 按下标循环
print L
for i, v in enumerate(L) :
- print i, v
+ print("[{0},{1}]".format(i, v)),
+else :
+ print("")
+
+
+# list 只适合快速后入后出,可以很方便地利用append 和 pop实现栈的功能
+# 要实现前出后入的队列功能就很慢,此时比较适合deque,用append 和 popleft实现
+from collections import deque
+
+queue = deque(['Apple', 'Microsoft', 'Google'])
+queue.append('Tencent')
+queue.append('Baidu')
+queue.append('Alibaba')
+queue.popleft()
+print queue
+
print "a^b: ", a^b
+Set = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
+print(Set)
+
+
+#Empty Set
+EmptySet = set() # not { }
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------
# File Name: utils.py
#判断一个对象是否可以迭代
-print isinstance('0xACE', collections.Iterable)
-print isinstance([1, 2, 3, 4], collections.Iterable)
-print isinstance(0xACE, collections.Iterable)
+print(isinstance('0xACE', collections.Iterable))
+print(isinstance([1, 2, 3, 4], collections.Iterable))
+print(isinstance(0xACE, collections.Iterable))
+
+
+s = u'这是一个中文字符串'
+
+print('{!a}'.format(s)) # !a apply ascii()
+print('{!s}'.format(s)) # !s apply str()
+print('{!s}'.format(s)) # !r apply repr()
#include<stdio.h>
int main()
{
- char ch;
+ unsigned int ch;
while(scanf("%x",&ch) != EOF)
- printf("%c",ch);
+ printf("%c",(unsigned char)ch);
return 0;
}