Delphi 推出社群版本(Community Edition)


Delphi推出了全新的社群版本(Community Edition),不像先前的starter版本。而是專業版加上iOS/Android功能。如果寫開放源始碼/免費軟體都可以,商業版的話限制為
1年收入不超過5000美金(約15萬台幣)
2成員不超過5人

 

延伸閱讀:

Learn to Program with Community Edition

Introducing Delphi and C++Builder Community Edition

Swift 3.1正式發佈

Swift 3.1在今(2017/3/28)正式發佈!3.1是次要的更新版本,主要針對目前的標準函式庫做改善以及改進。
在IBM以及各社群成員的努力下,還包含了Swift on LINUX的更新。以及部份的Swift Package Manager更新~
此外在編譯器也加上預編譯Objective-C的功能,讓編譯速度加快~

更多訊息可參考原始文章
https://swift.org/blog/swift-3-1-released/

 

 

New Sequence protocol members

The Sequence protocol now has two new members:

protocol Sequence {
  // ...
  /// Returns a subsequence by skipping elements while `predicate` returns
  /// `true` and returning the remainder.
  func drop(while predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.SubSequence
  /// Returns a subsequence containing the initial elements until `predicate`
  /// returns `false` and skipping the remainder.
  func prefix(while predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.SubSequence
}

See more at: SE-0045: Add prefix(while:) and drop(while:) to stdlib

Availability by Swift version

Swift 3.1 extends the @availability attribute to use the version of Swift to indicate the lifecycle of a declaration. As an example, an API that is removed in Swift 3.1 would be written as:

@available(swift, obsoleted: 3.1)
class Foo {
  //...
}

See more at: SE-0141: Availability by Swift version

Improved numeric conversion initializers

Swift 3.1 adds a new family of conversion initializers to all numeric types that either complete successfully without loss of information or return nil.

See more at: SE-0080: Failable Numeric Conversion Initializers

Deprecation and replacement of UnsafeMutablePointer.initialize(from:)

The version of UnsafeMutablePointer.initialize(from:) that takes a Collection is deprecated in favor of a new method on UnsafeMutableBufferPointer that takes a Sequence, with a goal of improving memory safety and enabling faster initialization of memory from sequences.

See more at: SE-0147: Move UnsafeMutablePointer.initialize(from:) to UnsafeMutableBufferPointer

Improvements to the Linux implementation

  • Implementation of NSDecimal
  • Implementation of NSLengthFormatter
  • Implementation of Progress
  • Many improvements to URLSession functionality, including API coverage and optimized usage of libdispatch
  • Improved API coverage in NSArray, NSAttributedString and many others
  • Significant performance improvements in Data. See more details here
  • Improved JSON serialization performance
  • Memory leaks fixed in NSUUID, NSURLComponents and others
  • Improved test coverage, especially in URLSession

Package Manager Updates

Editable packages

Package dependencies are now stored in the tool-managed build directory by default, and a new swift package edit command allows users to “begin editing” on a package, moving it under the user’s control (into the Packages directory), exempting it from dependency updates, and allowing the user to commit and push changes to that package.

See more at: SE-0082: Package Manager Editable Packages

Version pinning

The version of each dependency you’ve used is now recorded in a Package.pins file, which can be checked in to share those versions with other users of your package; swift package pin and swift package unpin commands provide further control. The pinned versions of a package’s dependencies are fetched by default when resolving dependencies, but swift package update will re-resolve to the latest allowable dependency versions and update the pinfile.

See more at: SE-0145: Package Manager Version Pinning

Tools version

Packages can now specify the minimum version of the Swift tools that they require. This requirement can be edited with the swift package tools-version command and is recorded at the top of the Package.swift manifest. Package versions which require newer Swift tools than those in use will be ignored by dependency resolution, so packages can adopt new Swift features without breaking clients who are using older Swift tools. The minimum tools version required determines which Swift language version is used to interpret the Package.swift manifest, and which version of the PackageDescription API is available.

See more at: SE-0152: Package Manager Tools Version

Swift language compatibility version

Packages can now specify whether their sources are written in the Swift 3 or Swift 4 language version. If not specified, a default is inferred from the Package’s minimum Swift tools version.

See more at: SE-0151: Package Manager Swift Language Compatibility Version

Other Package Manager improvements

  • Package dependency resolution is now correct in cases where it could have resolved to incorrect dependency versions previously. Dependency cycles are now detected during a build, and incremental builds will rebuild fewer sources when possible.
  • swift test now supports running tests in parallel with the --parallel flag. swift build, swift test, and all swift package commands which resolve dependencies now support fetching those dependencies in parallel with the --enable-prefetching flag.

Documentation for the Swift Package Manager can be found in the repository.

Migrating to Swift 3.1

Swift 3.1 is source compatible with Swift 3.0. To help with moving to Swift 3.1 from earlier releases of Swift, Xcode 8.3 contains a code migrator that can automatically handle many of the need source changes. There is also a migration guide available to guide you through many of the changes — especially through the ones that are less mechanical and require more direct scrutiny.

Documentation

An updated version of The Swift Programming Language for Swift 3.1 is now available on Swift.org. It is also available for free on Apple’s iBooks store.

Platforms

Linux (Ubuntu 14.04, Ubuntu 16.04 and Ubuntu 16.10)

Official binaries for Ubuntu 14.04, Ubuntu 16.04 and Ubuntu 16.10 are available for download.

Apple (Xcode)

For development on Apple’s platforms, Swift 3.1 ships as part of Xcode 8.3.

Sources

Development on Swift 3.1 was tracked in the swift-3.1-branch on the following repositories on GitHub:

The tag swift-3.1-RELEASE designates the specific revisions in those repositories that make up the final version of Swift 3.1.

The swift-3.1-branch will remain open, but under the same release management process, to accumulate changes for a potential future bug-fix “dot” release.

facebook寫自動貼文程式時access token權杖時效問題

1465550363703
在寫facebook的自動貼文或程式時,需要有access token,但access token的時效不長。該如何延長時間?
1
進入Graph API測試工具(https://developers.facebook.com/tools/explorer/)取得暫時性的權杖。
2
透過下列網址將APP_ID APP_SECRET ACCESS_TOKEN置換成對應的值

https://graph.facebook.com/oauth/access_token? client_id={APP_ID}& client_secret={APP_SECRET}& fb_exchange_token={SHORTLIVED_ACCESS_TOKEN}& grant_type=fb_exchange_token

3
如果還不行,可以利用Access Token Debugger工具(https://developers.facebook.com/tools/debug/access_token/),將暫時性的權杖輸入後,也可以取得長效(60天)的token。
那如何驗證過期與否重取得??官方給了做法
[php]
<?php
$app_id = "YOUR_APP_ID";
$app_secret = "YOUR_APP_SECRET";
$my_url = "YOUR_POST_LOGIN_URL";

// known valid access token stored in a database
$access_token = "YOUR_STORED_ACCESS_TOKEN";

$code = $_REQUEST["code"];

// If we get a code, it means that we have re-authed the user
//and can get a valid access_token.
if (isset($code)) {
$token_url="https://graph.facebook.com/oauth/access_token?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret
. "&code=" . $code . "&display=popup";
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params[‘access_token’];
}

// Attempt to query the graph:
$graph_url = "https://graph.facebook.com/me?"
. "access_token=" . $access_token;
$response = curl_get_file_contents($graph_url);
$decoded_response = json_decode($response);

//Check for errors
if ($decoded_response->error) {
// check to see if this is an oAuth error:
if ($decoded_response->error->type== "OAuthException") {
// Retrieving a valid access token.
$dialog_url= "https://www.facebook.com/dialog/oauth?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode($my_url);
echo("<script> top.location.href=’" . $dialog_url
. "'</script>");
}
else {
echo "other error has happened";
}
}
else {
// success
echo("success" . $decoded_response->name);
echo($access_token);
}

// note this wrapper function exists in order to circumvent PHP’s
//strict obeying of HTTP error codes. In this case, Facebook
//returns error code 400 which PHP obeys and wipes out
//the response.
function curl_get_file_contents($URL) {
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
$err = curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
?>
[/php]

參考:
https://developers.facebook.com/blog/post/2011/05/13/how-to–handle-expired-access-tokens/

LINE@官方帳號機器人PHP試做

1465549488137
試著寫了個PHP for LINE@ BOT API的小程式。
收到的訊息大致像這樣

Array
(
    [result] => Array
        (
            [0] => Array
                (
                    [content] => Array
                        (
                            [toType] => 1
                            [createdTime] => 1465548731679
                            [from] => ubde68bb73a93d53886dc814720423971
                            [location] => 
                            [id] => 4442057145631
                            [to] => Array
                                (
                                    [0] => u0182d0ce673d4b950318618870074d49
                                )

                            [text] => 妳好
                            [contentMetadata] => Array
                                (
                                    [AT_RECV_MODE] => 2
                                    [SKIP_BADGE_COUNT] => true
                                )

                            [deliveredTime] => 0
                            [contentType] => 1
                            [seq] => 
                        )

                    [createdTime] => 1465548731699
                    [eventType] => 138311609000106303
                    [from] => u206d25c2ea6bd87c17655609a1c37cb8
                    [fromChannel] => 1341301815
                    [id] => WB1521-3502883001
                    [to] => Array
                        (
                            [0] => u0182d0ce673d4b950318618870074d49
                        )

                    [toChannel] => 1470435594
                )

        )

)

LINE推出BOT API聊天機器人


LINE 的 BOT API Trial Account可透過 LINE 連結現有系統或服務,設立能傳送或接收 API 驅動訊息的 BOT 帳號,開發出 LINE 使用者與企業間雙向溝通的 API 功能。

https://business.line.me/
https://developers.line.me/bot-api/getting-started-with-bot-api-trial

https://developers.line.me/bot-api/overview

https://github.com/line/line-bot-sdk-php

Delphi 10.1 Berlin新亮點 -FireUI Preview、ListView Designer、TAddressBook

感謝廖啟甫大哥通知晚上的 10.1 Berlin課程,雖然沒聽完!不過有聽到了幾個不錯的功能

一、TAddressbook元件,可以存取通訊錄

二、改進Style Designer

三、超酷的可以自訂ListView Items的設計功能

四、新的字型樣式

另外還有很酷的FireUI Preview功能。

看來Delphi一直很努力的追上這幾年的不足!

未命名 - 7 未命名 - 8 未命名 - 21 未命名 - 27 未命名 - 42 未命名 - 44 未命名 - 52 未命名 - 66

Delphi 10 在Android、iOS取得內部IP方式

在寫應用程式時,常常需要知道機器的IP是什麼!答案相當簡單~只要拉出IdIPWatch這個元件
然後透過 IdIPWatch裡的LocalIP這個屬性就可以了!
相較於以前要透過Winsock來撰寫!一整個方便多了~更重要的是可以同時在Windows/Mac跟iOS/Android上面跑~

能取代parse服務的台灣MBaas平台-Lightspeed

Facebook收購國外著名的MBaaS(行動雲端平台)服務 Parse後,前幾天無預警的宣布一年後將關閉服務。也讓大家開始尋找新的MBaaS(行動雲端平台)服務,希望能為企業App加入推播、即時通訊、社交功能,來加速開發流程。
尋找解決方案中,看到台灣在2014年就有赫迅這家公司,提供了Lightspeed這個服務。包辦複雜的後端架構,而且提供推播、即時通訊以及社群互動功能加入app。
lightspeed01
目前該服務已經服務的客戶有許多知名的公司及媒體如Sony、遠傳電信、蘋果日報、蘋果動新聞、壹週刊網、窮游、海底撈火鍋、ump聯動優勢、csdn、中國銀聯。
lightspeed02
目前的申請方式需先至服務的申請頁面,然後填寫表單後核准。
lightspeed03
核准後會收到一封裡面有beta code的邀請函,然後註冊後就可以試用。
lightspeed04

lightspeed05

lightspeed06

相關聯結:
Lightspeed官方網站
sdk說明文件
試用申請
Lightspeed Admin Console
主控台

Swift 教學、學習資源

Swift 2做了些改變,像是 do while變成了 repeat while、for in 加上了where成了 for in where、switch 多了range跟pattern外也多了個 if case、多了個guard(類似if);接下來在exception例外處理有個 do catch…..然後println與print整合了,變成了 print(“”,appendNewline: false)。

學習資源:
美國史丹佛大學著名的ios開發教學線上課程 http://web.stanford.edu/class/cs193p/cgi-bin/drupal/
Apple 官方Swift Bloghttps://developer.apple.com/swift/blog/
Apple Swift 2.1官方文件 https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/
iOS開發者及作家 彼得潘 http://www.slideshare.net/deeplovepan/swift-51667357

大陸 Swift開發課程(中文) http://www.hcxy.me/

大陸開發者 王巍 http://swifter.tips/ http://onevcat.com/#blog

Apple資源 https://developer.apple.com/library/ios/navigation/