The 6 Keys to Winning Heads-Up Sit ‘n Go Play

Construct a Postflop Game Plan

When you connect with the flop it’s important to decide on a game plan for the hand. You will sometimes want to check one or more streets to induce bluffs and limit the size of the pot. For instance, suppose you raise on the button with K8 offsuit. Your opponent calls and the flop comes A K Q. You should usually check behind either the flop or the turn, as few opponents will call three streets on this board with a hand worse than your 2nd pair.

You should also semi-bluff aggressively in heads-up, playing fast with your draws as your opponent will often be caught without a hand and be forced to fold. However, you should rather not make pure bluffs on multiple streets without a good reason. In time you will recognize good opportunities to make plays. For example, after raising preflop, you should usually make a continuation bet (c-bet) on the flop. A good bluffing opportunity arises if your opponent calls your c-bet and then a scare card falls on the turn – such as an ace or king after a flop of low cards.

Tight Players

Against a tight player, you should play very loose-aggressive, but be quick to fold marginal hands when he shows strength. Your goal in the game will be to win many small and medium-sized pots uncontested and only give your tight opponent action in larger pots when you’re holding a very strong hand yourself. The best opponent to play against is one who is both tight and passive, as this is the weakest style in heads-up play.

Loose-passive Players

Against a loose-passive player, your goal is to aggressively value bet any hand you think is the best and almost never bluff. Do not make any fancy plays against a calling station; simply wait until you have an above-average hand and bet for value.

Loose-aggressive Players

Against a loose-aggressive player, you may have a challenge on your hands! Loose-aggressive is a very effective style in heads-up. You simply must play good poker and search for any weaknesses you can find and exploit, such as loose-aggressive players who defend with weak hands out of position.

Table Selection

Table selection is particularly crucial in heads-up. If you’re a very good player, you will still lose against a world-class player. Similarly, a weak player will have an advantage against a terrible player.

Your edge in the match depends on your skill level relative to your opponent.

If you’re playing micro-stakes games on a large site like PokerStars, new players may sit down so quickly that table selection becomes difficult. But when you do sit second, seek out weak players and avoid the regulars. Also: never rematch a good player.

SQL Server Backup

https://ola.hallengren.com/

SQL Server Backup, Integrity Check, and Index and Statistics Maintenance

The SQL Server Maintenance Solution comprises scripts for running backups, integrity checks, and index and statistics maintenance on all editions of Microsoft SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, and SQL Server 2014. The solution is based on stored procedures, the sqlcmd utility, and SQL Server Agent jobs. I designed the solution for the most mission-critical environments, and it is used in manyorganizations around the world. The SQL Server Maintenance Solution has been voted as Best Free Tool in the 2013, 2012, 2011, and 2010 SQL Server Magazine Awards, and a top session at PASS Summit 2014. The SQL Server Maintenance Solution is free.

“Ola Hallengren publishes a free set of database maintenance scripts that are like maintenance plans that went to college, married into a nice family, and went to training school afterwards.”Brent Ozar

Getting Started

Download MaintenanceSolution.sql. This script creates all the objects and jobs that you need.

Learn more about using the SQL Server Maintenance Solution:

Sign up for the newsletter to be alerted about updates to the solution.

Backup to Azure Blob Storage

You can now use the SQL Server Maintenance Solution to back up to Azure Blob Storage. Here is how it works:

EXECUTE dbo.DatabaseBackup @Databases = ‘USER_DATABASES’,
@URL = ‘https://myaccount.blob.core.windows.net/mycontainer’,
@Credential = ‘mycredential’,
@BackupType = ‘FULL’,
@Compress = ‘Y’,
@Verify = ‘Y’

You can also encrypt the backups. Then you do like this:

EXECUTE dbo.DatabaseBackup @Databases = ‘USER_DATABASES’,
@URL = ‘https://myaccount.blob.core.windows.net/mycontainer’,
@Credential = ‘MyCredential’,
@BackupType = ‘FULL’,
@Compress = ‘Y’,
@Encrypt = ‘Y’,
@EncryptionAlgorithm = ‘AES_256’,
@ServerCertificate = ‘MyCertificate’,
@Verify = ‘Y’

Mirrored Backup

One of the most requested features has been mirrored backup. I have added that now. You can combine it with striping of backups, and also specify a separate cleanup time for the mirror. Here is how it works:

EXECUTE dbo.DatabaseBackup @Databases = ‘USER_DATABASES’,
@Directory = ‘C:\Backup’,
@MirrorDirectory = ‘D:\Backup’,
@BackupType = ‘FULL’,
@Compress = ‘Y’,
@Verify = ‘Y’,
@CleanupTime = 24,
@MirrorCleanupTime = 48

SQL Server 2014

I have added support for backup encryption, lock priorities for online index rebuilds, online index rebuilds of partitions, and updating of statistics on memory-optimized tables in SQL Server 2014.

Here is how you can back up a database using encryption:

EXECUTE dbo.DatabaseBackup @Databases = ‘USER_DATABASES’,
@Directory = ‘C:\Backup’,
@BackupType = ‘FULL’,
@Compress = ‘Y’,
@Encrypt = ‘Y’,
@EncryptionAlgorithm = ‘AES_256’,
@ServerCertificate = ‘MyCertificate’

Here is how you can rebuild indexes online using low priority locks:

EXECUTE dbo.IndexOptimize @Databases = ‘USER_DATABASES’,
@FragmentationLow = NULL,
@FragmentationMedium = ‘INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE’,
@FragmentationHigh = ‘INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE’,
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 30,
@WaitAtLowPriorityMaxDuration = 1,
@WaitAtLowPriorityAbortAfterWait = ‘NONE’

Partitions will be rebuilt online by default.

Intelligent Index Maintenance

The SQL Server Maintenance Solution lets you intelligently rebuild or reorganize only the indexes that are fragmented. In the IndexOptimize procedure, you can define a preferred index maintenance operation for each fragmentation group. Take a look at this code:

EXECUTE dbo.IndexOptimize @Databases = ‘USER_DATABASES’,
@FragmentationLow = NULL,
@FragmentationMedium = ‘INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE’,
@FragmentationHigh = ‘INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE’,
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 30

In this example, indexes that have a high fragmentation level will be rebuilt, online if possible. Indexes that have a medium fragmentation level will be reorganized. Indexes that have a low fragmentation level will remain untouched.

Update Statistics

The IndexOptimize procedure can also be used to update statistics. You can choose to update all statistics, statistics on indexes only, or statistics on columns only. You can also choose to update the statistics only if any rows have been modified since the most recent statistics update.

EXECUTE dbo.IndexOptimize @Databases = ‘USER_DATABASES’,
@FragmentationLow = NULL,
@FragmentationMedium = ‘INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE’,
@FragmentationHigh = ‘INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE’,
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 30,
@UpdateStatistics = ‘ALL’,
@OnlyModifiedStatistics = ‘Y’

Solve “No Current Database” Issues

Most DBAs have experienced the error message “BACKUP LOG cannot be performed because there is no current database backup” or “Cannot perform a differential backup for database, because a current database backup does not exist”. These errors usually occur when you have created a new database or changed the database recovery model from Simple to Full. The answer is to determine, before you run the backup, whether a differential or transaction log backup can be performed. You can use the DatabaseBackup procedure’s @ChangeBackupType option to change the backup type dynamically if a differential or transaction log backup cannot be performed.

Here’s an example of how to use the @ChangeBackupType option:

EXECUTE dbo.DatabaseBackup
@Databases = ‘USER_DATABASES’,
@Directory = ‘C:\Backup’,
@BackupType = ‘LOG’,
@Verify = ‘Y’,
@ChangeBackupType = ‘Y’,
@CleanupTime = 24

Back up to Multiple Files

Databases are becoming larger and larger. You can tune the performance of SQL Server backup compression, by using multiple backup files, and the BUFFERCOUNT and MAXTRANSFERSIZE options. The DatabaseBackupprocedure supports these options:

EXECUTE dbo.DatabaseBackup
@Databases = ‘USER_DATABASES’,
@Directory = ‘C:\Backup, D:\Backup, E:\Backup, F:\Backup’,
@BackupType = ‘FULL’,
@Compress = ‘Y’,
@BufferCount = 50,
@MaxTransferSize = 4194304,
@NumberOfFiles = 4,
@CleanupTime = 24

Run Integrity Checks of Very Large Databases

The SQL Server Maintenance Solution has been designed to do integrity checks of very large databases. In the DatabaseIntegrityCheck procedure you can choose do the checks on the database level, the filegroup level, or the table level. It also supports limiting the checks to the physical structures of the database:

EXECUTE dbo.DatabaseIntegrityCheck
@Databases = ‘USER_DATABASES’,
@CheckCommands = ‘CHECKDB’,
@PhysicalOnly = ‘Y’

SQL Server Community Awards

For the past four years, the SQL Server Maintenance Solution has been voted as Best Free Tool in the SQL Server Magazine Awards:

  • 2014 – 2015 Microsoft Most Valuable Professional (MVP) – SQL Server
  • 2014 Simple-Talk and SQL Server Central Tribal Awards: Best Free Script
  • 2013 SQL Server Magazine Community Choice: Best Free Tool, Gold award
  • 2012 SQL Server Magazine Community Choice: Best Free Tool, Gold award
  • 2011 SQL Server Magazine Editors’ Best: Best Free Tool, Silver award
  • 2011 SQL Server Magazine Community Choice: Best Free Tool, Gold award
    “Hands down, one of the best tools out there! If you’re responsible for a database, you should be using Ola’s scripts. It’s very comprehensive, is efficient with resources, has numerous options, and is a brilliant piece of SQL coding!”
  • 2010 SQL Server Magazine Editors’ Best: Best Free Tool, Bronze award
  • 2010 SQL Server Magazine Community Choice: Best Free Tool, Gold award

The Solution in the News and on the Web

I had a session about the SQL Server Maintenance Solution on PASS Summit in November 2014 (PDF version and demo scripts).

SQL PASS had a session about the SQL Server Maintenance Solution during the 24 Hours of PASS 2010 online conference.

SimpleTalk featured an article about the SQL Server Maintenance Solution in July 2010.

SQL Server Magazine featured an article about the SQL Server Maintenance Solution in its November 2008 issue (PDF version).

Feel free to contact me if you have any questions. Thank you for trying out the solution.

加密html5 mobile app

http://www.justbeck.com/three-ways-to-encrypt-phonegap-and-cordova-mobile-applications/

Cordova (and the associated PhoneGap project) is a great way for mobile phone developers to quickly develop applications that work across mobile devices. Using Cordova, developers can write the core of their application in simple HTML and Javascript. Cordova then provides Javascript API to access native capabilities on the phone. Once the code is ready, it can easily be distributed as native applications for iOS, Android, Blackberry and Windows mobile devices.

The Cordova Platform

However, the ease-of-development comes at a cost. Since the core of the application is simple HTML and Javascript files, it makes it easy for a nefarious competitor to reverse the application. This is easiest to do with the Android version where all you need to do is unzip the APK file to recover the original HTML and Javascript for the application.

In this blog post we’ll take a look at three different ways you can protect your code from prying eyes. No method is perfect but the goal is to make it as hard as possible.

Traditional Javascript Obfuscation

The simplest way to protect your code is to use traditional Javascript and HTML obfuscation techniques. There’s a large number of websites online that provide Javascript obfuscation but what they all essentially do it to take code like this:

1
2
var message = "Hello World";
alert(message);

and turn it in to code like this:

1
2
var _0xc2f9=["\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64"];
var a=_0xc2f9[0];var b=alert;b(a);

This doesn’t make the code impossible to reverse but it can provide light to medium headaches for your adversary.

Pros: Free tools available for obfuscation, provides some headaches for adversaries

Cons: Code can still be reversed without too much difficulty

Online Asset Hosting

Another method you can use to hide the code of your Cordova application is to host most of the resources on another server. In the main HTML page for your application you can include the bulk of your source code from a while sitting on a webserver:

In this way the HTML page just becomes a holder for the actual application which is hosted elsewhere. A competitor could still access your source code but it requires them to scan the HTML and determine where your assets are hosted. To prevent them from directly downloading your source code you could implement User-Agent checking on your web-server. Again, not perfect, but every little bit can help.

Pros: Most of your source code is not actually distributed with application. You can make minor updates to your application without requiring users to download updates.

Cons: Applications only work with internet connection. Requires a webserver to host your HTML and Javascript files.

Modifying the Core Cordova Libraries

This is probably the most secure method but requires the most work. It works as follows:

  1. All HTML pages are encrypted using the same algorithm and key (AES 256 for example)
  2. For each platform you want to deploy to you need to modify the Cordova Libraries. Intercept requests for new HTML pages and add a decryption function before they get sent to the mobile browser.
  3. Distribute the application

This way all the assets packaged with your mobile application are encrypted. The only possible way for an attacker to retrieve your pages is for them to decompile your application to retrieve the encryption key.

An example implementation for this technique on iOS is available at http://oleksiy.pro/2012/12/27/cordova-ios-security/.

Pros: Most secure method to protect your code

Cons: Highest work effort, core libraries need to be modified

Conclusion

There’s no perfect way to prevent competitors from seeing the source code of your Cordova applications but using one or more of these methods can significantly increase the level of effort on their part. If you have any further questions about these techniques please leave a comment or contact me.

用ionic 整合 facebook 登录

Module 9: Facebook Integration

In this module, you add Facebook integration to your application. You allow users to login with Facebook, view their profile, and share their favorite sessions on their feed.

In this tutorial, you use OpenFB to perform the integration. OpenFB is a micro-library that lets you integrate your JavaScript applications with Facebook. It works for both browser-based and Cordova/PhoneGap apps. It also doesn’t have any dependency: You don’t need the Facebook plugin when running in Cordova. You also don’t need the Facebook SDK. More information here.

Step 1: Create a Facebook application

  1. Login to Facebook
  2. Access https://developers.facebook.com/apps, and click Add New App
  3. Select www as the platform
  4. Type a unique name for your app and click Create New Facebook App ID
  5. Specify a Category, and click Create App ID
  6. Click My Apps in the menu and select the app you just created
  7. Click Settings in the left navigation
  8. Click the Advanced Tab
  9. In the OAuth Settings section, add the following URLs in the Valid OAuth redirect URIs field:
  10. Click Save Changes

Step 2: Initialize OpenFB

  1. Add the OpenFB files to your application
    • Copy openfb.js and ngopenfb.js from ionic-tutorial/resources to conference/www/js.
    • Copy oauthcallback.html and logoutcallback.html from ionic-tutorial/resources toconference/www.
    • In conference/www/index.html, add script tags to include openfb.js and ngopenfb.js (before app.js):

      ngOpenFB is just an Angular wrapper around the OpenFB library. It lets you use OpenFB “the Angular way”: as an Angular service (called ngFB) instead of a global object, and using promises instead of callbacks.

  2. Open conference/www/js/app.js, and add ngOpenFB as a dependency to the starter module:
    angular.module('starter', ['ionic', 'starter.controllers', 'ngOpenFB'])
    
  3. Inject ngFB in the run() function declaration:
    .run(function ($ionicPlatform, ngFB) {
    
  4. Initialize OpenFB on the first line of the run() function. Replace YOUR_FB_APP_ID with the App ID of your Facebook application.
    ngFB.init({appId: 'YOUR_FB_APP_ID'});
    

Step 3: Add Facebook login

  1. Open login.html in the conference/www/templates directory. Add a Login with Facebook button right after the existing Log In button:
    <label class="item">
        <button class="button button-block button-positive" ng-click="fbLogin()">
        Login with Facebook
        </button>
    </label>
    

    Notice that fbLogin() is called on ng-click. You define the fbLogin() function in the next step.

  2. Open conference/www/js/controllers.js, and add ngOpenFB as a dependency to the starter.controllersmodule:
    angular.module('starter.controllers', ['starter.services', 'ngOpenFB'])
    
  3. Inject ngFB in the AppCtrl controller:
    .controller('AppCtrl', function ($scope, $ionicModal, $timeout, ngFB) {
    
  4. Add the fbLogin function in the AppCtrl controller (right after the doLogin function):
    $scope.fbLogin = function () {
        ngFB.login({scope: 'email,read_stream,publish_actions'}).then(
            function (response) {
                if (response.status === 'connected') {
                    console.log('Facebook login succeeded');
                    $scope.closeLogin();
                } else {
                    alert('Facebook login failed');
                }
            });
    };
    
  5. Test the application.
    • Make sure ionic serve (your local web server) is still running. If it’s running but you closed your app page in the browser, you can reload the app by accessing the following URL: http://localhost:8100. If it’s not running, open a command prompt, navigate (cd) to the ionic-tutorial directory and type:
      ionic serve
      
    • In the application, open the side menu and select Login
    • Click the Login with Facebook button
    • Enter your Facebook credentials on the Facebook login screen, and authorize the application
    • Open the browser console: you should see the Facebook login succeeded message

    The next time you login, you won’t be asked for your credentials again since you already have a valid token. To test the login process again, simply logout from Facebook. The OpenFB library has additional methods to logout and revoke permissions that are beyond the scope of this tutorial.

Step 4: Display the User Profile

  1. Create a template for the user profile view. In the conference/www/templates directory, create a new file named profile.html and implement it as follows:
    <ion-view view-title="Profile">
        <ion-content class="has-header">
            

    {{user.name}}

    {{user.city}}

    </div> </ion-content> </ion-view>
  2. Create a controller for the user profile view. Open controllers.js, and add the following controller:
    .controller('ProfileCtrl', function ($scope, ngFB) {
        ngFB.api({
            path: '/me',
            params: {fields: 'id,name'}
        }).then(
            function (user) {
                $scope.user = user;
            },
            function (error) {
                alert('Facebook error: ' + error.error_description);
            });
    });
    
  3. Create a route for the user profile view. Open app.js, and add the following route:
    .state('app.profile', {
        url: "/profile",
        views: {
            'menuContent': {
                templateUrl: "templates/profile.html",
                controller: "ProfileCtrl"
            }
        }
    })
    
  4. Open www/templates/menu.html, and add the following menu item:
    <ion-item menu-close href="#/app/profile">
        Profile
    </ion-item>
    
  5. Test the application:
    • Make sure ionic serve (your local web server) is still running. If it’s running but you closed your app page in the browser, you can reload the app by accessing the following URL: http://localhost:8100. If it’s not running, open a command prompt, navigate (cd) to the ionic-tutorial directory and type:
      ionic serve
      
    • Open the side menu and select Login
    • Login with Facebook
    • Open the side menu and select Profile

Step 5: Publish to your feed

  1. Open controllers.js, and inject ngFB in the SessionCtrl definition:
    .controller('SessionCtrl', function ($scope, $stateParams, Session, ngFB) {
    
  2. Add a share() function to the SessionCtrl controller:
    $scope.share = function (event) {
        ngFB.api({
            method: 'POST',
            path: '/me/feed',
            params: {
                message: "I'll be attending: '" + $scope.session.title + "' by " +
                $scope.session.speaker
            }
        }).then(
            function () {
                alert('The session was shared on Facebook');
            },
            function () {
                alert('An error occurred while sharing this session on Facebook');
            });
    };
    
  3. Open session.html in the templates directory and add an ng-click handler to the Share button: invoke the share function:
    <a class="tab-item" ng-click="share()">
        <i class="icon ion-share"></i>
        Share
    </a>
    
  4. Test the application:
    • Make sure ionic serve (your local web server) is still running. If it’s running but you closed your app page in the browser, you can reload the app by accessing the following URL: http://localhost:8100. If it’s not running, open a command prompt, navigate (cd) to the ionic-tutorial directory and type:
      ionic serve
      
    • Open the side menu and select Login
    • Login with Facebook
    • Open the side menu, select Sessions, and select a session in the list
    • Click/Tap the Share button
    • Check your feed on Facebook

Step 6: Test Facebook integration on device (optional)

  1. Add the InAppBrowser plugin used by OpenFB when running in Cordova. On the command line, navigate to the ionic-tutorial/conference directory and type:
    cordova plugins add org.apache.cordova.inappbrowser
    
  2. Build your application for a specific platform following the steps described in module 8:
    ionic build ios
    

    and/or

    ionic build android
    

    If the build fails after adding the plugin, try removing and re-adding the platform. For example:

    ionic platform remove ios
    ionic platform add ios
    ionic build ios
    
  3. Run and test your application on an iOS or Android device or emulator

https://ccoenraets.github.io/ionic-tutorial/ionic-facebook-integration.html

ionic framework note 1

From http://mclspace.com/2015/05/28/ionic-steup/

前言

最近用ionic做hybrid app的开发,这篇文章用来记录探索过程中遇到的方方面面。
声明:在开始这个项目之前没有接触过任何web开发相关的知识,所以下面的内容是从一个初学者的角度出发。

注:以下许多笔记为边开发边整理,没有调整格式,请见谅。


前端

总体

首先对ionic有所了解,直接看官网即可,跟着例子走一遍,有个直观的感觉。
然后前端要学的东西很多,html5,css,js等,这些可以在w3school上学习,另外可以看看知乎上的这个回答
另外ionic的逻辑是用angularJS写的,因此必须要对其有比较好的理解:

更新(2015-8-31):w3school只能用作参考,实际学习知识请阅读书籍,参看教程,推荐《Head First Html & Css》《javascript语言精粹》
廖大大的javascript教程

编写ionic代码时的一些坑

  1. 模块记得填写依赖,如下面代码中如果你的controller放在zlyc.controllers模块中,记得填写
    1
    angular.module('zlyc', ['ionic', 'zlyc.controllers'])
  2. 在js文件夹中的js文件需要初始化,默认只有app.js会初始化,初始化的方法是在index.html的 tag 中用script加载,如下:
    1
    2
    3
    4
    5
    <!-- your app's js -->
       <script src="js/app.js"></script>
       <script src="js/controllers.js"></script>
       <script src="js/services.js"></script>
       <script src="js/utils.js"></script>
  3. 如果某个界面上不想要导航栏,可以简单地在最顶端的标签中添加hide-nav-bar=”true”
  4. onclick方法后面调用函数要加括号,如:
    1
    <div class="padding signup-opt" ng-click="goToSign()">
  5. 这篇文章生成各尺寸的图片.
  6. app的icon和splash的处理
  7. 对于css文件夹中的样式文件中如果要调用本地的图片的话要加../ 否则在浏览器中可以正常显示,在设备上不行,结构如下所示:
    1
    2
    3
    4
    5
    .login-page {
      background:url(../img/signup_bg.png);
      background-size: cover;
      background-repeat: no-repeat;
    }

但是对于在页面中定义的图片路径,从www路径开始算,否则浏览器中可显示,但设备上不行,如

1
<img src="img/commander.jpg">
  1. 如果要使用ionic的图标,可以到ionicons上查找名字,然后通过icon=”“使用
  2. angularJS 的router功能的state中的abstrcat变量设为true是指其自身不能被调用,但可以有自己的子状态。
  3. 可以指定名字,然后在子状态中使用该名字,ionic就知道该把该状态的template渲染到哪边了。例如:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     // signup page
     .state('auth.signup', {
       url: '/signup',
       views: {
           'auth-signup': {
               templateUrl: 'templates/auth-signup.html',
               controller: 'SignUpCtrl'
           }
       }
     })
    
     另有一个tabs中声明该auth-signup:
     <ion-tab title="Sign Up" icon-on="ion-ios-personadd"
       icon-off="ion-ios-personadd-outline" href="#/auth/signup">
       <ion-nav-view name="auth-signup"></ion-nav-view>
    </ion-tab>
  4. ionic serve命令时,ionic报错如下:
    1
    ionic $ An uncaught exception occured and has been reported to Ionic

看看你是不还有一个终端在运行着serve呢?

  1. 注意.state中的url中不能有url,否则定位不到,如
    1
    2
    .state('sidemenu.userManage',{
      url: "/user_manage",

注意不要加下划线

  1. ionic 在用docker跑的时候,因为暂时不能把地址绑定到0.0.0.0,可以用ionic serve -all的方法解决
  2. 加载页面的时候会看到双括号一闪而过?

    angularjs 在使用双括号的时候,第一个加载的页面,也就是应用中的index.html,其未被渲染好的模版可能会被用户看到。
    用ng-bind就不会遇到这个问题。造成这种现象的原因是,浏览器需要首先加载HTML页面,渲染它,然后Angular才有机会把它解释成
    你期望看到的内容。不过好消息是,在大多数的模版中你依然可以使用双括号.但是对于index.html页面中的数据绑定操作,建议使用
    ng-bind。

ng-bind使用方式如下: <p ng-bind="greeting"></p>

  1. 如何更新列表?
    下拉刷新,或者用广播
  2. list 有延迟?
    在ion-content处使用 overflow-scroll=”true”
  3. 上用ng-click上是没效果的
  4. 标签内的事件会在整个label内被触发,点哪都触发
  5. 直接在ion-list中的ion-item中并不能触发ng-click事件,可以在item中的元素上再套一层div
  6. 如何改背景色 :
    1
    style="background-color: #212326;"
  7. 能用ng-if就用ng-if,ng-if的效率比ng-show和ng-hide高
  8. 如何实现card上面有一列分割线的效果?
    在css里定义

    1
    2
    3
    #info-up {
      border-top: 4px solid #f06336;
    }
  9. 所有的控制器不必都放在controllers.js这一个文件中,可以新建controllers文件夹,
    然后把每个controller都建一个.js文件,同理services和utils等都是.但注意要在index.js中head部分声明.但是为了避免他们相互覆盖,第一个加载的js中模块中要加[…],其他都不需要。如:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    // File : /js/directives/mainDirective.js
    angular.module('app.directives',[]);
    
    // File : /js/directives/myGreatDirective.js
    angular.module('app.directives')  
        .directive('myGreatDirective', function(){
            return {
                //...
            }
        });
    
    // File : /js/directives/myBetterDirective.js
    angular.module('app.directives')  
        .directive('myBetterDirective', function(){
            return {
                //...
            }
        });
    
    ...

这篇文章了解更多,
嗯这篇文章写的还不是best practice,因为你还得记着自己把[]写到那个模块里了,统一地写在app.js中即可,
在app.js最下面加上类似:

1
2
angular.module('fcws.controllers',['ionic', 'fcws.services']);
angular.module('fcws.services', []);

可以达到和上面一样的效果,而且可以统一管理.

  1. 话说ionic 的app似乎暂时无法进行代码混淆,至少ionic官方的ionic view没有进行代码混淆,下载他们的app,文件名改成zip,解压,所有的 www文件都在assets文件夹中,相当于开源了有木有,看看那些最优秀的practice,
    看中哪些优秀的app,下下来,如何在googleplay上下载?把googleplay应用的地址贴到这个网址
  2. 可以用ng-class="{'important': post.important}"配合css 根据列表元素显示不同的效果
  3. js列表中的元素不能写成 id : 4,应写成 id : “4”,注意在创建id变量的时候也需要
    1
    var id = InfoListService.getListLength()+1+"";
  4. 获取日期用$filter
    1
    var postdate = $filter('date')(date, 'yyyy-MM-dd HH:mm:ss');
  5. 为什么用$log而不是console.log呢?可以看看这个
  6. 更新了数据,如何让界面更新呢?可以用广播,注意$broadcast 和 $emit的区别
  7. 在安卓上的体验比较差,动画有延迟?可以试试ionic集成的crosswalk
  8. 如何显示相对时间? 可以用momentjs,看这篇教程
  9. 发布应用的时候如果遇到翻译错误,暂时的解决方法是,不进行翻译校正, 在 /platforms/android/build.gradle 中的android {}节中加入:
    1
    2
    3
    4
    lintOptions {
    						 disable 'MissingTranslation'
    							disable 'ExtraTranslation'
    }
  10. span 可以用来将时间之类的附加信息显示到列表右边,如下面会将创建时间显示在name的右边:
    1
    2
    3
    4
    5
    6
    <ion-item class="item item-avatar-left " ng-repeat="message in messages">
    	<img src="../../img/commander.jpg">
    	<span class="item-note">{{message.create_at}}</span>
    	<h2 >{{message.name}}</h2>
    	<p >  {{message.content}}</p>
    </ion-item >
  11. controllers 和services 的文件名可能会重合,但是他们意义差不多,
    可以将controllers中的文件名小写,对应的services中的文件名大写进行区分.
  12. ng-bind-html这个类可能会过滤原始html的标签,我们可以引入$sce模块,用$sce.trustAsHtml()方法信任我们获取的网页
  13. 如何完成邮箱修改重设密码的流程?
    整个流程:
  • 注册时要求每个用户使用唯一的邮箱,注册后向用户的邮箱发一封邮件
  • 找回密码时要求用户填写邮箱地址,提示用户如果不记得地址请在邮箱中搜索
  • 找回密码功能限制每帐号每天只能使用三次(只能发三次邮件), 使用缓存来完成这个计数
  • 找回密码时向缓存中写入一个随机的字符串作为 Token, 有效期为一天,向用户的邮箱发送包含 Token 的链接
  • 用户从链接点回来先验证 Token 的有效性,然后提示填写新密码,然后将新密码和 Token 一起提交给后端完成修改密码的操作
  • 删除掉 Token 的缓存
  1. 如何回到上一页面?
    $ionicHistory这个模块,引入该模块后使用goBack([backCount]),backCount指定回去多少个页面(-1代表回去一个页面),默认为-1
  2. 如何关闭应用?
    1
    ionic.Platform.exitApp();
  3. 在安卓设备上如何让title居中(安卓设计规范上推荐title居左)? 在headerbar中添加align-title="center",如
    1
    2
    3
    <ion-header-bar class="bar-positive" align-title="center">
    	 <h1 class="title">{{username}}</h1>
    </ion-header-bar>

不过这个设置对ion-view无效,亲测,如果要统一让所有navbar上的title居中(包括上面的headerbar),可以在config里设置,如:

1
2
.config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {
  $ionicConfigProvider.navBar.alignTitle('center');

如果要让某一个view title居中,可以用$ionicNavBarDelegate,参考ionic官方文档

  1. 如何让在sidemenu中的headerbar能够显示头像等其他信息? 解决方案是去掉headerbar,添加一个avatar到sidemenu content中,如:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <ion-side-menu side="left">
    	<ion-content class="bar-positive">
    		<ion-list>
    			<ion-item class="item item-avatar item-positive" href="#">
    				<img src="img/commander.jpg">
    				<h2 class=" light">
    					<i class="icon ion-ios-star"></i>{{title}}
    				</h2>
    				<a>{{username}}</a>
    			</ion-item>
Follow

Get every new post delivered to your Inbox.