如何調試CSS的跨瀏覽器樣式bug
posted @ 2014-09-17 09:46 順其自然EVO 閱讀(328) | 評論 (0) | 編輯 收藏
blog已經轉移至github,大家請訪問 http://qaseven.github.io/
posted @ 2014-09-17 09:46 順其自然EVO 閱讀(328) | 評論 (0) | 編輯 收藏
posted @ 2014-09-17 09:42 順其自然EVO 閱讀(8398) | 評論 (1) | 編輯 收藏
posted @ 2014-09-17 09:40 順其自然EVO 閱讀(215) | 評論 (0) | 編輯 收藏
cc -D_POSIX_SOURCE file.c |
#define _POSIX_SOURCE 1 |
void *myfunc(const char*, int); #else void *myfunc(); #endif #ifdef __STDC__ void *myfunc(const char*, int); #else void *myfunc(); #endif |
posted @ 2014-09-17 09:38 順其自然EVO 閱讀(216) | 評論 (0) | 編輯 收藏
posted @ 2014-09-17 09:32 順其自然EVO 閱讀(292) | 評論 (1) | 編輯 收藏
import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class JSONTest { public static void main(String[] args) { JSONObject container1 = new JSONObject(); container1.put("ClassName", "高三一班"); System.out.println(container1.toString()); JSONArray className = new JSONArray(); className.add("高三一班"); container1.put("className", className); System.out.println(container1.toString()); JSONObject classInfo = new JSONObject(); classInfo.put("stuCount", 50); classInfo.put("leader", "rah"); container1.put("classInfo", classInfo); System.out.println(container1); JSONObject ClassInfo = new JSONObject(); JSONArray stuCount = new JSONArray(); stuCount.add(50); JSONArray leader = new JSONArray(); leader.add("rah"); ClassInfo.put("stuCount", stuCount); ClassInfo.put("leader", leader); container1.put("ClassInfo", ClassInfo); System.out.println(container1); JSONArray students = new JSONArray(); JSONObject studentOne = new JSONObject(); studentOne.put("name", "張麻子"); studentOne.put("sex", "男"); studentOne.put("age", 12); studentOne.put("hobby", "java develop"); JSONObject studentTwo = new JSONObject(); studentTwo.put("name", "王瘸子"); studentTwo.put("sex", "男"); studentTwo.put("age", 13); studentTwo.put("hobby", "C/C++ develop"); students.add(studentOne); students.add(studentTwo); container1.put("students", students); System.out.println(container1); JSONArray Students = new JSONArray(); JSONObject StudnetOne = new JSONObject(); JSONArray name1 = new JSONArray(); name1.add("張麻子"); JSONArray sex1 = new JSONArray(); sex1.add("男"); JSONArray age1= new JSONArray(); age1.add("12"); JSONArray hobby1 = new JSONArray(); hobby1.add("java develop"); StudnetOne.put("name", name1); StudnetOne.put("sex", sex1); StudnetOne.put("age", age1); StudnetOne.put("hobby", hobby1); JSONObject StudnetTwo = new JSONObject(); JSONArray name2 = new JSONArray(); name2.add("王瘸子"); JSONArray sex2 = new JSONArray(); sex2.add("男"); JSONArray age2= new JSONArray(); age2.add("13"); JSONArray hobby2 = new JSONArray(); hobby2.add("C/C++ develop"); StudnetTwo.put("name", name2); StudnetTwo.put("sex", sex2); StudnetTwo.put("age", age2); StudnetTwo.put("hobby", hobby2); Students.add(StudnetOne); Students.add(StudnetTwo); container1.put("Students", Students); System.out.println(container1); JSONArray teachers = new JSONArray(); teachers.add(0,"王老師"); teachers.add(1,"李老師 "); container1.put("teachers", teachers); System.out.println(container1); JSONArray Teachers = new JSONArray(); JSONObject teacher1 = new JSONObject(); teacher1.put("name", "小梅"); teacher1.put("introduce","他是一個好老師"); JSONObject teacher2 = new JSONObject(); teacher2.put("name", "小李"); teacher2.put("introduce","他是一個合格的老師"); Teachers.add(0,teacher1); Teachers.add(1,teacher2); container1.put("Teachers", Teachers); System.out.println(container1); } } |
{"ClassName":"高三一班"} {"ClassName":"高三一班","className":["高三一班"]} {"ClassName":"高三一班","className":["高三一班"],"classInfo":{"stuCount":50,"leader":"rah"}} {"ClassName":"高三一班","className":["高三一班"],"classInfo":{"stuCount":50,"leader":"rah"},"ClassInfo":{"stuCount":[50],"leader":["rah"]}} {"ClassName":"高三一班","className":["高三一班"],"classInfo":{"stuCount":50,"leader":"rah"},"ClassInfo":{"stuCount":[50],"leader":["rah"]},"students":[{"name":"張麻子","sex":"男","age":12,"hobby":"java develop"},{"name":"王瘸子","sex":"男","age":13,"hobby":"C/C++ develop"}]} {"ClassName":"高三一班","className":["高三一班"],"classInfo":{"stuCount":50,"leader":"rah"},"ClassInfo":{"stuCount":[50],"leader":["rah"]},"students":[{"name":"張麻子","sex":"男","age":12,"hobby":"java develop"},{"name":"王瘸子","sex":"男","age":13,"hobby":"C/C++ develop"}],"Students":[{"name":["張麻子"],"sex":["男"],"age":["12"],"hobby":["java develop"]},{"name":["王瘸子"],"sex":["男"],"age":["13"],"hobby":["C/C++ develop"]}]} {"ClassName":"高三一班","className":["高三一班"],"classInfo":{"stuCount":50,"leader":"rah"},"ClassInfo":{"stuCount":[50],"leader":["rah"]},"students":[{"name":"張麻子","sex":"男","age":12,"hobby":"java develop"},{"name":"王瘸子","sex":"男","age":13,"hobby":"C/C++ develop"}],"Students":[{"name":["張麻子"],"sex":["男"],"age":["12"],"hobby":["java develop"]},{"name":["王瘸子"],"sex":["男"],"age":["13"],"hobby":["C/C++ develop"]}],"teachers":["王老師","李老師 "]} {"ClassName":"高三一班","className":["高三一班"],"classInfo":{"stuCount":50,"leader":"rah"},"ClassInfo":{"stuCount":[50],"leader":["rah"]},"students":[{"name":"張麻子","sex":"男","age":12,"hobby":"java develop"},{"name":"王瘸子","sex":"男","age":13,"hobby":"C/C++ develop"}],"Students":[{"name":["張麻子"],"sex":["男"],"age":["12"],"hobby":["java develop"]},{"name":["王瘸子"],"sex":["男"],"age":["13"],"hobby":["C/C++ develop"]}],"teachers":["王老師","李老師 "],"Teachers":[{"name":"小梅","introduce":"他是一個好老師"},{"name":"小李","introduce":"他是一個合格的老師"}]} 四、遍歷JSON實例 以上面的輸出的JSON字符串進行按順序給它遍歷 String ClassName1 = (String) container1.get("ClassName"); System.out.println("ClassName data is: " + ClassName1); JSONArray className1 = container1.getJSONArray("className"); System.out.println("className data is: " + className1); JSONObject classInfo1 = container1.getJSONObject("classInfo"); System.out.println("classInfo data is: " + classInfo1); JSONObject ClassInfo1 = container1.getJSONObject("ClassInfo"); System.out.println("ClassInfo data is: " + ClassInfo1); JSONArray students1 = container1.getJSONArray("students"); System.out.println("students data is: " + students1); JSONArray Students1 = container1.getJSONArray("Students"); System.out.println("Students data is: " + Students1); JSONArray teachers1 = container1.getJSONArray("teachers"); for(int i=0; i < teachers1.size(); i++){ System.out.println("teahcer " + i + " is: "+ teachers1.get(i)); } JSONArray Teachers1 = container1.getJSONArray("Teachers"); for(int i=0; i < Teachers1.size(); i++){ System.out.println("Teachers " + i + " is: "+ Teachers1.get(i)); } |
ClassName data is: 高三一班 className data is: ["高三一班"] classInfo data is: {"stuCount":50,"leader":"rah"} ClassInfo data is: {"stuCount":[50],"leader":["rah"]} students data is: [{"name":"張麻子","sex":"男","age":12,"hobby":"java develop"},{"name":"王瘸子","sex":"男","age":13,"hobby":"C/C++ develop"}] Students data is: [{"name":["張麻子"],"sex":["男"],"age":["12"],"hobby":["java develop"]},{"name":["王瘸子"],"sex":["男"],"age":["13"],"hobby":["C/C++ develop"]}] teahcer 0 is: 王老師 teahcer 1 is: 李老師 Teachers 0 is: {"name":"小梅","introduce":"他是一個好老師"} Teachers 1 is: {"name":"小李","introduce":"他是一個合格的老師"} |
posted @ 2014-09-16 09:52 順其自然EVO 閱讀(261) | 評論 (0) | 編輯 收藏
1 //用來存放字典,字典中存儲的是圖片和圖片對應的位置 2 NSMutableArray *imageArray = [NSMutableArray arrayWithCapacity:resultArray.count]; 3 4 //根據匹配范圍來用圖片進行相應的替換 5 for(NSTextCheckingResult *match in resultArray) { 6 //獲取數組元素中得到range 7 NSRange range = [match range]; 8 9 //獲取原字符串中對應的值 10 NSString *subStr = [str substringWithRange:range]; 11 12 for (int i = 0; i < face.count; i ++) 13 { 14 if ([face[i][@"chs"] isEqualToString:subStr]) 15 { 16 17 //face[i][@"gif"]就是我們要加載的圖片 18 //新建文字附件來存放我們的圖片 19 NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init]; 20 21 //給附件添加圖片 22 textAttachment.image = [UIImage imageNamed:face[i][@"png"]]; 23 24 //把附件轉換成可變字符串,用于替換掉源字符串中的表情文字 25 NSAttributedString *imageStr = [NSAttributedString attributedStringWithAttachment:textAttachment]; 26 27 //把圖片和圖片對應的位置存入字典中 28 NSMutableDictionary *imageDic = [NSMutableDictionary dictionaryWithCapacity:2]; 29 [imageDic setObject:imageStr forKey:@"image"]; 30 [imageDic setObject:[NSValue valueWithRange:range] forKey:@"range"]; 31 32 //把字典存入數組中 33 [imageArray addObject:imageDic]; 34 35 } 36 } 37 } |
1 //從后往前替換 2 for (int i = imageArray.count -1; i >= 0; i--) 3 { 4 NSRange range; 5 [imageArray[i][@"range"] getValue:&range]; 6 //進行替換 7 [attributeString replaceCharactersInRange:range withAttributedString:imageArray[i][@"image"]]; 8 9 } |
posted @ 2014-09-16 09:52 順其自然EVO 閱讀(1737) | 評論 (1) | 編輯 收藏
// unit test code [TestMethod] public void Debit_WithValidAmount_UpdatesBalance() { // arrange double beginningBalance = 11.99; double debitAmount = 4.55; double expected = 7.44; BankAccount account = new BankAccount("Mr. Bryan Walton", beginningBalance); // act account.Debit(debitAmount); // assert double actual = account.Balance; Assert.AreEqual(expected, actual, 0.001, "Account not debited correctly"); } |
//unit test method [TestMethod] [ExpectedException(typeof(ArgumentOutOfRangeException))] public void Debit_WhenAmountIsLessThanZero_ShouldThrowArgumentOutOfRange() { // arrange double beginningBalance = 11.99; double debitAmount = -100.00; BankAccount account = new BankAccount("Mr. Bryan Walton", beginningBalance); // act account.Debit(debitAmount); // assert is handled by ExpectedException } |
// class under test public const string DebitAmountExceedsBalanceMessage = "Debit amount exceeds balance"; public const string DebitAmountLessThanZeroMessage = "Debit amount less than zero"; // method under test // ... if (amount > m_balance) { throw new ArgumentOutOfRangeException("amount", amount, DebitAmountExceedsBalanceMessage); } if (amount < 0) { throw new ArgumentOutOfRangeException("amount", amount, DebitAmountLessThanZeroMessage); } // ... |
[TestMethod] public void Debit_WhenAmountIsGreaterThanBalance_ShouldThrowArgumentOutOfRange() { // arrange double beginningBalance = 11.99; double debitAmount = 20.0; BankAccount account = new BankAccount("Mr. Bryan Walton", beginningBalance);\ // act try { account.Debit(debitAmount); } catch (ArgumentOutOfRangeException e) { // assert StringAssert.Contains(e.Message, BankAccount. DebitAmountExceedsBalanceMessage); } } |
[TestMethod] public void Debit_WhenAmountIsGreaterThanBalance_ShouldThrowArgumentOutOfRange() { // arrange double beginningBalance = 11.99; double debitAmount = 20.0; BankAccount account = new BankAccount("Mr. Bryan Walton", beginningBalance);\ // act try { account.Debit(debitAmount); } catch (ArgumentOutOfRangeException e) { // assert StringAssert.Contains(e.Message, BankAccount. DebitAmountExceedsBalanceMessage); return; } Assert.Fail("No exception was thrown.") } |
posted @ 2014-09-16 09:51 順其自然EVO 閱讀(1348) | 評論 (0) | 編輯 收藏
cc -D_POSIX_SOURCE file.c |
#define _POSIX_SOURCE 1 |
void *myfunc(const char*, int); #else void *myfunc(); #endif #ifdef __STDC__ void *myfunc(const char*, int); #else void *myfunc(); #endif |
posted @ 2014-09-16 09:51 順其自然EVO 閱讀(266) | 評論 (0) | 編輯 收藏
QSqlDatabase::database().transaction(); QSqlQuery query; query.exec("SELECT id FROM employee WHERE name = 'Torild Halvorsen'"); if (query.next()) { int employeeId = query.value(0).toInt(); query.exec("INSERT INTO project (id, name, ownerid) " "VALUES (201, 'Manhattan Project', " + QString::number(employeeId) + ")"); } QSqlDatabase::database().commit(); |
posted @ 2014-09-16 09:51 順其自然EVO 閱讀(199) | 評論 (0) | 編輯 收藏