问:
Add spaces before Capital Letters
Given the string "ThisStringHasNoSpacesButItDoesHaveCapitals" what is the best way to add spaces before the capital letters. So the end string would be "This String Has No Spaces But It Does Have Capitals"

Here is my attempt with a RegEx

```<code>System.Text.RegularExpressions.Regex.Replace(value, "[A-Z]", " $0")
</code>```

答:
```<code>    private string GetProperName(string Header)
    {
        if (Header.ToCharArray().Where(c => Char.IsUpper(c)).Count() == 1)
        {
            return Header;
        }
        else
        {
            string ReturnHeader = Header[0].ToString();
            for(int i=1; i<Header.Length;i++)
            {
                if (char.IsLower(Header[i-1]) && char.IsUpper(Header[i]))
                {
                    ReturnHeader += " " + Header[i].ToString();
                }
                else
                {
                    ReturnHeader += Header[i].ToString();
                }
            }

            return ReturnHeader;
        }

        return Header;
    }
</code>```

OwnerDisplayName: Bob

Title: Add spaces before Capital Letters

Body:
Given the string "ThisStringHasNoSpacesButItDoesHaveCapitals" what is the best way to add spaces before the capital letters. So the end string would be "This String Has No Spaces But It Does Have Capitals"

Here is my attempt with a RegEx

System.Text.RegularExpressions.Regex.Replace(value, "[A-Z]", " $0")

LastEditorDisplayName: Blair Conrad


来源: stackexchange

问:
Cursor flashing on the non-client area when using IDirect3DDevice9::SetCursorProperties
I have an application running under Direct3D9. The application is using the Direct3D HW cursor API (IDirect3DDevice9::SetCursorProperties et al.) to control the cursor. Almost everything works fine:

when inside of the application window, the cursor specified by SetCursorProperties is shown

when outside of the application window, normal OS cursor is displayed as needed by desktop or other windows

The problem is with the non-client area of my window (the title bar, screen edges). When moving in the non-client area, the cursor corresponding to the function of the area is breifly shown, but once I stop moving, the cursor set in SetCursorProperties is shown again.

What is the correct way to use IDirect3DDevice9::SetCursorProperties so that I get the default OS cursors on my window non-client area?

答:
After experimenting with various things, a following change in the application has solved the issue for me:

In a window procedure, when a WM_SETCURSOR is received, remember a result of a condition  (lParam&0xffff)==HTCLIENT in a global variable CursorInClient

When the global variable CursorInClient is false, avoid calling IDirect3DDevice9::ShowCursor

ContentLicense: CC BY-SA 2.5


问:
Django Rest Framework Authentication Issues
I am a newbie in Django. I had created REST API using DRF. My Django has 3 apps. So now I want to apply authentication. I have seen much help but I am not to apply the authentication properly. I also want that the model should be attached to the user. So that one user can't see another user entries. Can anyone help me in telling how to implement this a little detailed?

Thanks in advance. Will be a great help if someone answers.

答:
You could add custom permissions,

```<code>class IsOwnerOnlyAllowed(permissions.BasePermission):

    def has_object_permission(self, request, view, obj):
        return obj.owner == request.user
</code>```

You may add permission_classes = (IsOwnerOnlyAllowed,)

Also, you could override the queryset attribute of your view to provide only entries which are related to the logged in users.

Edit your views,

```<code>from rest_framework import generics
from .models import DatasetModel
from .serializer import DatasetSerializer

class DatasetView(generics.ListCreateAPIView):
    queryset = DatasetModel.objects.all()
    serializer_class = DatasetSerializer

    def get_queryset(self):
        return self.queryset.filter(owner=self.request.user)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
You could add custom permissions,

class IsOwnerOnlyAllowed(permissions.BasePermission):

    def has_object_permission(self, request, view, obj):
        return obj.owner == request.user

You may add permission_classes = (IsOwnerOnlyAllowed,)

Also, you could override the queryset attribute of your view to provide only entries which are related to the logged in users.

Edit your views,

from rest_framework import generics
from .models import DatasetModel
from .serializer import DatasetSerializer

class DatasetView(generics.ListCreateAPIView):
    queryset = DatasetModel.objects.all()
    serializer_class = DatasetSerializer

    def get_queryset(self):
        return self.queryset.filter(owner=self.request.user)


问:
VSTS externalnugetfeed is either disabled or uninstalled
I have two VSTS collections and I'd like to publish NuGet packages to feeds in each collection. I thought I'd be able to accomplish this with the NuGet Publisher task with a feed type of External. When I try to configure the Nuget Server Endpoint I selected External VSTS, entered my PAT, clicked verify connection and it was confirmed. However upon saving my endpoint I noticed the following under the type information:

Type: The endpoint type extension externalnugetfeed is either disabled or uninstalled which may lead to issues in using this endpoint.

I cannot select the endpoint in my NuGet Publisher task. I looked in the marketplace and I don't see any relevant extensions. I also looked under extensions and don't see any disabled extensions in either collection.

答:
The same issue in my VSTS, there is the feedback that you can follow. Cannot use external NuGet service

Update: The issue has been fixed now.


问:
Time difference in years with lubridate?
I would like to use lubridate to calculate age in years given their date of birth and today's date. Right now I have this:

```<code>library(lubridate)
today<-mdy(08312015)
dob<-mdy(09071982)
today-dob
</code>```

which gives me their age in days.

答:
```<code>as.duration(interval(dob,today)) %/% as.duration(years(1))
</code>```

<p>should do the job without errors. </p>

Body:
I would like to use lubridate to calculate age in years given their date of birth and today's date. Right now I have this:

library(lubridate)
today<-mdy(08312015)
dob<-mdy(09071982)
today-dob

which gives me their age in days.

Body:
as.duration(interval(dob,today)) %/% as.duration(years(1))

should do the job without errors.


问:
Function mcrypt_get_iv_size() is deprecated - Heroku
I just deploy my laravel

5.0

site to Heroku.
I believe Heroku is using PHP 7.1 by default.

I did everything, and finally got it to deployed, but I see error on my page

Function mcrypt_get_iv_size() is deprecated

config/app.php

'cipher' => 'AES-256-CBC',

I've already run php artisan key:generate.

Any hints on how I prevent that ?

答:
This method worked for me:

```<code>$iv_size = openssl_cipher_iv_length('AES-256-CBC');//16
</code>```

Or

else you can use other git repository "defuse/php-encrption" for existing version to work

Body:
This method worked for me:

$iv_size = openssl_cipher_iv_length('AES-256-CBC');//16

Or

else you can use other git repository "defuse/php-encrption" for existing version to work


问:
how to display data from database into an option tag html?
any one can help me with this?
i want to displaying my database data into a option tag but it not showing anything. i have try to make a code for that but that code not work to display my data into html option tag. someone please help me to solve my problem.

this is my code that i make

// JavaScript Document
// for make the option tag
$(function() {

$('#chkveg').multiselect({

includeSelectAllOption: true

});
});

// for call the data from my database
$(document).on('click','#nama_check',function(e){
    $.ajax({
        type:"POST",
        url:"../php/absen/absen_karyawan_autocomplete.php",
        success: function(data){
            var list = JSON.parse(data);
            for(var i=0; i < list.length; i++){
                $('#chkveg').val((list[i]['bagian']));

            }
            return false;
        }
    });
});
```

<pre class="lang-html prettyprint-override"><code><script src="https://davidstutz.github.io/bootstrap-multiselect/docs/js/bootstrap-3.3.2.min.js"></script>
<link href="https://davidstutz.github.io/bootstrap-multiselect/docs/css/bootstrap-3.3.2.min.css" rel="stylesheet"/>
<link href="https://davidstutz.github.io/bootstrap-multiselect/dist/css/bootstrap-multiselect.css" rel="stylesheet"/>
<script src="https://davidstutz.github.io/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>

<form id="form1" method="post">

        <div style="padding:20px">

        <select id="chkveg" multiple="multiple">
        </select>

        </div>

        </form>
</code>```

答:
Use .append().
Try to check this documentataion: http://api.jquery.com/append/</p>

```<code>dataType: 'json',
success: function(data){
        var list = JSON.parse(data);
        for(var i=0; i < list.length; i++){
            $('#chkveg').append($('<option>'+ list[i]['bagian']  +'</option>'));

        }
        return false;
    }
</code>```

Body:
any one can help me with this?
i want to displaying my database data into a option tag but it not showing anything. i have try to make a code for that but that code not work to display my data into html option tag. someone please help me to solve my problem.

this is my code that i make

// JavaScript Document
// for make the option tag
$(function() {

$('#chkveg').multiselect({

includeSelectAllOption: true

});
});

// for call the data from my database
$(document).on('click','#nama_check',function(e){
    $.ajax({
        type:"POST",
        url:"../php/absen/absen_karyawan_autocomplete.php",
        success: function(data){
            var list = JSON.parse(data);
            for(var i=0; i < list.length; i++){
                $('#chkveg').val((list[i]['bagian']));

            }
            return false;
        }
    });
});

<link href="https://davidstutz.github.io/bootstrap-multiselect/docs/css/bootstrap-3.3.2.min.css" rel="stylesheet"/>
<link href="https://davidstutz.github.io/bootstrap-multiselect/dist/css/bootstrap-multiselect.css" rel="stylesheet"/>

<form id="form1" method="post">

        <select id="chkveg" multiple="multiple">
        </select>

        </form>

Body:
Use .append().
Try to check this documentataion: http://api.jquery.com/append/

dataType: 'json',
success: function(data){
        var list = JSON.parse(data);
        for(var i=0; i < list.length; i++){
            $('#chkveg').append($('<option>'+ list[i]['bagian']  +'</option>'));

        }
        return false;
    }


问:
product catalog api fail
need help.
I tried to start with https://developers.facebook.com/docs/marketing-api/dynamic-product-ads/ads-management/v2.3
created account. Approved it by phone.
created a business account, an ad account, an app, and so on.
linked app to ad accont like this https://developers.facebook.com/docs/marketing-api/access#standard_accounts.
Now i tried to create product catalog. i am getting same error all the time:

```<code> The app is not whitelisted to use this API
</code>```

i tried to call api to cteate/list/managment product catalog.
when i did, the same by UI - i can create product catalog & feed.
but by API - all time error.
i do not understand what it need?

now try to create product set:

```<code>GET /<product_catalog ID>/product_sets/?
access_token=<my access token from app with full rights get from exploer>
{
  "error": {
    "message": "(#200) The app is not whitelisted to use this API",
    "type": "OAuthException",
    "code": 200
  }
}
</code>```

try to create the same:

```<code>POST : /v2.3/<product_catalog ID>/product_sets/?access_token=<my access token from app with full rights get from exploer>&name=my new prod set
{
  "error": {
    "message": "(#275) Ad account cannot be determined for this request",
    "type": "OAuthException",
    "code": 275
  }
}
</code>```

So what Are the changes i needed to make it work?

is it any way to made api calls work correctly?

p.s.
  i guess something wrong in settings - i run unit tests in SDK - have the same situation. i have read about that problems with game app - but my app - is not a game, so i cant use solution in my situation.
  if some body understand what whitelist API want  - please help!
Thanks.

答: This happens also when the access token used is not from your app which has Standard Access. Also, note the dev version of the same app will not work.</p>

Title: product catalog api fail

Body:
need help.
I tried to start with https://developers.facebook.com/docs/marketing-api/dynamic-product-ads/ads-management/v2.3
created account. Approved it by phone.
created a business account, an ad account, an app, and so on.
linked app to ad accont like this https://developers.facebook.com/docs/marketing-api/access#standard_accounts.
Now i tried to create product catalog. i am getting same error all the time:

 The app is not whitelisted to use this API

i tried to call api to cteate/list/managment product catalog.
when i did, the same by UI - i can create product catalog & feed.
but by API - all time error.
i do not understand what it need?

now try to create product set:

GET /<product_catalog ID>/product_sets/?
access_token=<my access token from app with full rights get from exploer>
{
  "error": {
    "message": "(#200) The app is not whitelisted to use this API",
    "type": "OAuthException",
    "code": 200
  }
}

try to create the same:

POST : /v2.3/<product_catalog ID>/product_sets/?access_token=<my access token from app with full rights get from exploer>&name=my new prod set
{
  "error": {
    "message": "(#275) Ad account cannot be determined for this request",
    "type": "OAuthException",
    "code": 275
  }
}

So what Are the changes i needed to make it work?

is it any way to made api calls work correctly?

p.s.
  i guess something wrong in settings - i run unit tests in SDK - have the same situation. i have read about that problems with game app - but my app - is not a game, so i cant use solution in my situation.
  if some body understand what whitelist API want  - please help!
Thanks.


问:
In Microsoft Bot Framework How can restrict the number of characters to a particular number?
(EX: I want add give phone number in the text box so only 10 numbers has to added there. More than ten should not be allowed) </p>

答:
Adaptive cards could solve this issue - you need to respond with a card which has a text input. Just set up maxLength property in the card's markup explicitly. Below is an example of the markup you need:

```<code>{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "0.5",
  "body": [
    {
      "type": "Input.Text",
      "id": "phone",
      "placeholder": "Enter a phone number",
      "speak": "Enter a phone number",
      "maxLength": 10
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "title": "Action.Submit data",
    }
  ]
}
</code>```

Body:
Adaptive cards could solve this issue - you need to respond with a card which has a text input. Just set up maxLength property in the card's markup explicitly. Below is an example of the markup you need:

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "0.5",
  "body": [
    {
      "type": "Input.Text",
      "id": "phone",
      "placeholder": "Enter a phone number",
      "speak": "Enter a phone number",
      "maxLength": 10
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "title": "Action.Submit data",
    }
  ]
}


问:
Overlapping java-like interfaces in C++
I've read on many places that Java's interface can be 100% emulated using C++'s abstract class with all pure virtual methods.

I'm trying to convert this piece of java code:

```<code>interface A {
    void a();
}

interface B extends A {
    void b();
}

class C implements A {
    public void a() {
    }
}

class D extends C implements B {
    public void b() {
    }
}

D d = new D();
d.a();
d.b();
</code>```

into something like this in C++:

```<code>class A {
public:
    virtual void a() const = 0;
protected:
    virtual ~A() {
    }
};

class B : public A {
public:
    virtual void b() const = 0;
protected:
    virtual ~B() {
    }
};

class C : public /*implements*/ A {
public:
    virtual void a() const override {
    }
};

class D : public /*extends*/ C, public /*implements*/ B {
public:
    virtual void b() const override {
    }
};

D d;
d.a();
d.b();
</code>```

but no matter how hard I try, I always end up with C++ complaining about ambiguity and/or missing body definitions.

The idea is that I want to derive from "C" which contains some shared code for all classes (here: "D" but there's more of them) and yet maintain the promise that "D" is 100% interchangeable with any class implementing "B" (incl. the parts from "A").

The errors I'm getting with C++ code above is:

```<code>../untitled1/main.cpp: In function ‘int main(int, char**)’:
../untitled1/main.cpp:39:7: error: cannot declare variable ‘d’ to be of abstract type ‘D’
     D d;
       ^
../untitled1/main.cpp:28:7: note:   because the following virtual functions are pure within ‘D’:
 class D : public /*extends*/ C, public /*implements*/ B {
       ^
../untitled1/main.cpp:7:18: note:   virtual void A::a() const
     virtual void a() const = 0;
                  ^
../untitled1/main.cpp:40:7: error: request for member ‘a’ is ambiguous
     d.a();
       ^
../untitled1/main.cpp:7:18: note: candidates are: virtual void A::a() const
     virtual void a() const = 0;
                  ^
../untitled1/main.cpp:23:18: note:                 virtual void C::a() const
     virtual void a() const override {
                  ^
</code>```

答:
All what you need is implementation of a() in D class:</p>

```<code>class A {
public:
    virtual void a() const = 0;
protected:
    virtual ~A() {
    }
};

class B : public A {
public:
    virtual void b() const = 0;
protected:
    virtual ~B() {
    }
};

class C : public /*implements*/ A {
public:
    virtual void a() const override {
    }
};

class D : public /*extends*/ C, public /*implements*/ B {
public:
    void b() const override {
    }
    void a() const {
        C::a();
    }
};

int main()
{
    D d;
    d.a();
    d.b();
    return 0;
}
</code>```

Title: Overlapping java-like interfaces in C++

Body:
I've read on many places that Java's interface can be 100% emulated using C++'s abstract class with all pure virtual methods.

I'm trying to convert this piece of java code:

interface A {
    void a();
}

interface B extends A {
    void b();
}

class C implements A {
    public void a() {
    }
}

class D extends C implements B {
    public void b() {
    }
}

D d = new D();
d.a();
d.b();

into something like this in C++:

class A {
public:
    virtual void a() const = 0;
protected:
    virtual ~A() {
    }
};

class B : public A {
public:
    virtual void b() const = 0;
protected:
    virtual ~B() {
    }
};

class C : public /*implements*/ A {
public:
    virtual void a() const override {
    }
};

class D : public /*extends*/ C, public /*implements*/ B {
public:
    virtual void b() const override {
    }
};

D d;
d.a();
d.b();

but no matter how hard I try, I always end up with C++ complaining about ambiguity and/or missing body definitions.

The idea is that I want to derive from "C" which contains some shared code for all classes (here: "D" but there's more of them) and yet maintain the promise that "D" is 100% interchangeable with any class implementing "B" (incl. the parts from "A").

The errors I'm getting with C++ code above is:

../untitled1/main.cpp: In function ‘int main(int, char**)’:
../untitled1/main.cpp:39:7: error: cannot declare variable ‘d’ to be of abstract type ‘D’
     D d;
       ^
../untitled1/main.cpp:28:7: note:   because the following virtual functions are pure within ‘D’:
 class D : public /*extends*/ C, public /*implements*/ B {
       ^
../untitled1/main.cpp:7:18: note:   virtual void A::a() const
     virtual void a() const = 0;
                  ^
../untitled1/main.cpp:40:7: error: request for member ‘a’ is ambiguous
     d.a();
       ^
../untitled1/main.cpp:7:18: note: candidates are: virtual void A::a() const
     virtual void a() const = 0;
                  ^
../untitled1/main.cpp:23:18: note:                 virtual void C::a() const
     virtual void a() const override {
                  ^

Body:
All what you need is implementation of a() in D class:

class A {
public:
    virtual void a() const = 0;
protected:
    virtual ~A() {
    }
};

class B : public A {
public:
    virtual void b() const = 0;
protected:
    virtual ~B() {
    }
};

class C : public /*implements*/ A {
public:
    virtual void a() const override {
    }
};

class D : public /*extends*/ C, public /*implements*/ B {
public:
    void b() const override {
    }
    void a() const {
        C::a();
    }
};

int main()
{
    D d;
    d.a();
    d.b();
    return 0;
}


问:
2 Different ComboBox Styles with 2 Different ComboBoxItem Styles
I have 2 ComboBox-Styles in my WPF-Application. They're look both like this:

```<code><Style TargetType="{x:Type local:MyComboBox1}">
    <Style.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                ...
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Style.Resources>
    <Setter Property="SnapsToDevicePixels" Value="true" />
    ...
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:MyComboBox1}">
             ...
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Style.Triggers />
</Style>
</code>```

Now I want to style the ComboBoxItems for each ComboBox in a different way. How can i do this?

答:
You can use the ItemContainerStyle property

```<code><Style TargetType="Combobox" x:Key="myStyleOne">
    <Setter Property="ItemContainerStyle">
        <Setter.Value>
            <Style TargetType="ComboBoxItem">

                <!-- put your style here -->

            </Style>
        </Setter.Value>
    </Setter>
</Style>
</code>```

And then you can use your style like the following.

```<code><ComboBox Style="{StaticResource myStyleOne}" />
</code>```

Body:
I have 2 ComboBox-Styles in my WPF-Application. They're look both like this:

    <Setter Property="SnapsToDevicePixels" Value="true" />
    ...
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:MyComboBox1}">
             ...
            </ControlTemplate>
        </Setter.Value>
    </Setter>

Now I want to style the ComboBoxItems for each ComboBox in a different way. How can i do this?

Body:
You can use the ItemContainerStyle property

<Style TargetType="Combobox" x:Key="myStyleOne">
    <Setter Property="ItemContainerStyle">
        <Setter.Value>
            <Style TargetType="ComboBoxItem">

                <!-- put your style here -->

            </Style>
        </Setter.Value>
    </Setter>
</Style>

And then you can use your style like the following.

<ComboBox Style="{StaticResource myStyleOne}" />


问:
Changing the Trashcan icon in the dock
Is it possible to write a program for Mac OS X that monitors the trashcan and changes the icon dynamically when you fill the can?</p>

答: Panic's Candybar lets you customize system icons (including the trash), so it must be possible.</p>

Title: Changing the Trashcan icon in the dock


问:
Terse way to get remainder of an iterable (like an array)
I want to get the remainder of an iterable like an array. Like so:

```<code>var arr = ['a', 'b', 'c'];
var brr = arr.slice(1);
</code>```

But is there a terser way (maybe using destructuring assignment?).

答:
Yes there is:

```<code>var [,...brr] = arr; // ['b', 'c']
</code>```

Multiple elision also works:

```<code>var [,,...brr] = arr; // ['c']
</code>```

Body:
I want to get the remainder of an iterable like an array. Like so:

var arr = ['a', 'b', 'c'];
var brr = arr.slice(1);

But is there a terser way (maybe using destructuring assignment?).

Body:
Yes there is:

var [,...brr] = arr; // ['b', 'c']

Multiple elision also works:

var [,,...brr] = arr; // ['c']


问:
Issue playing slow-mo AVAsset in AVPlayer
I'm trying to play an slow motion video (filmed by the user's iPhone) in an AVPlayer.

I am retrieving the AVAsset with a request on a PHAsset from a picker:

```<code>   [manager requestAVAssetForVideo:PHAsset
                           options:videoRequestOptions
                     resultHandler:^(AVAsset * avasset, AVAudioMix * audioMix, NSDictionary * info) {}];
</code>```

The problem is once it plays, I get this error:

```<code> -[AVComposition URL]: unrecognized selector sent to instance 0x138d17f40
</code>```

However, if I set this option on the manager request, it will play as normal speed video at 120/240fps and no crashes:

```<code>  videoRequestOptions.version = PHVideoRequestOptionsVersionOriginal;
</code>```

Whats going on? The default version property is PHVideoRequestOptionsVersionCurrent which incorporates slow motion, user edits and trims, etc.

I would like to play that video version. Thanks

答:
For those coming here looking for a swift answer, this is the swift translation, which I use in my project, where I need the url of the slow-motion Video to play it with the AVPlayerViewController:

```<code>else if asset is AVComposition {
//Slow-Motion Assets are passed as AVComposition
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let documentsDirectory: NSString? = paths.first as NSString?
if documentsDirectory != nil {
    let random = Int(arc4random() % 1000)
    let pathToAppend = String(format: "mergeSlowMoVideo-%d.mov", random)
    let myPathDocs = documentsDirectory!.strings(byAppendingPaths: [pathToAppend])
    let myPath = myPathDocs.first
    if myPath != nil {
        let url = URL(fileURLWithPath: myPath!)
        let exporter = AVAssetExportSession(asset: asset!, presetName: AVAssetExportPresetHighestQuality)
        if exporter != nil {
        exporter!.outputURL = url
        exporter!.outputFileType = AVFileTypeQuickTimeMovie
        exporter!.shouldOptimizeForNetworkUse = true
        exporter!.exportAsynchronously(completionHandler: {
            AsyncUtil.asyncMain {
                let url = exporter!.outputURL
                if url != nil {
                    let player = AVPlayer(url: url!)
                    let playerViewController = AVPlayerViewController()
                    playerViewController.player = player
                    playerViewController.modalTransitionStyle = .crossDissolve
                    view.present(playerViewController, animated: true) {
                        playerViewController.player!.play()
                    }
                }
            }
        })
    }
}
</code>```

Body:
I'm trying to play an slow motion video (filmed by the user's iPhone) in an AVPlayer.

I am retrieving the AVAsset with a request on a PHAsset from a picker:

   [manager requestAVAssetForVideo:PHAsset
                           options:videoRequestOptions
                     resultHandler:^(AVAsset * avasset, AVAudioMix * audioMix, NSDictionary * info) {}];

The problem is once it plays, I get this error:

 -[AVComposition URL]: unrecognized selector sent to instance 0x138d17f40

However, if I set this option on the manager request, it will play as normal speed video at 120/240fps and no crashes:

  videoRequestOptions.version = PHVideoRequestOptionsVersionOriginal;

Whats going on? The default version property is PHVideoRequestOptionsVersionCurrent which incorporates slow motion, user edits and trims, etc.

I would like to play that video version. Thanks

Body:
For those coming here looking for a swift answer, this is the swift translation, which I use in my project, where I need the url of the slow-motion Video to play it with the AVPlayerViewController:

else if asset is AVComposition {
//Slow-Motion Assets are passed as AVComposition
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let documentsDirectory: NSString? = paths.first as NSString?
if documentsDirectory != nil {
    let random = Int(arc4random() % 1000)
    let pathToAppend = String(format: "mergeSlowMoVideo-%d.mov", random)
    let myPathDocs = documentsDirectory!.strings(byAppendingPaths: [pathToAppend])
    let myPath = myPathDocs.first
    if myPath != nil {
        let url = URL(fileURLWithPath: myPath!)
        let exporter = AVAssetExportSession(asset: asset!, presetName: AVAssetExportPresetHighestQuality)
        if exporter != nil {
        exporter!.outputURL = url
        exporter!.outputFileType = AVFileTypeQuickTimeMovie
        exporter!.shouldOptimizeForNetworkUse = true
        exporter!.exportAsynchronously(completionHandler: {
            AsyncUtil.asyncMain {
                let url = exporter!.outputURL
                if url != nil {
                    let player = AVPlayer(url: url!)
                    let playerViewController = AVPlayerViewController()
                    playerViewController.player = player
                    playerViewController.modalTransitionStyle = .crossDissolve
                    view.present(playerViewController, animated: true) {
                        playerViewController.player!.play()
                    }
                }
            }
        })
    }
}


问:
How to add DELETE method inside 'do' keyword in config/routes.rb?
I know I can add a new DELETE method on http://localhost:3000/students by editing config/routes.rb:

```<code>resources :students
delete '/students',:to => 'students#destroymany'
</code>```

Note: it is different from DELETE http://localhost:3000/students/1 because  the default DELETE supports deleting 1 student only, while I also want to support DELETE on http://localhost:3000/students/ (without specific student id)

but it has a disadvantage: I need to repeat typing 'students'. Is there any syntax that changes the routing statement to become

```<code>resources :students do
    xxx
end
</code>```

but have the same effect as the beginning version? I tried:

```<code>resources :students do
  delete '',:to => 'students#destroymany'
end
</code>```

but the error occurs:

```<code>No route matches [DELETE] "/students"
</code>```

because it adds the routing to

```<code>/students/:student_id
</code>```

instead of

```<code>/students
</code>```

答:
Make use of singular resource. Singular resource will give you delete route without any ID

```<code>resource :students
</code>```

DELETE /students students#destroy
please refer singular resource

Body:
I know I can add a new DELETE method on http://localhost:3000/students by editing config/routes.rb:

resources :students
delete '/students',:to => 'students#destroymany'

Note: it is different from DELETE http://localhost:3000/students/1 because  the default DELETE supports deleting 1 student only, while I also want to support DELETE on http://localhost:3000/students/ (without specific student id)

but it has a disadvantage: I need to repeat typing 'students'. Is there any syntax that changes the routing statement to become

resources :students do
    xxx
end

but have the same effect as the beginning version? I tried:

resources :students do
  delete '',:to => 'students#destroymany'
end

but the error occurs:

No route matches [DELETE] "/students"

because it adds the routing to

/students/:student_id

instead of

/students

Body:
Make use of singular resource. Singular resource will give you delete route without any ID

resource :students

DELETE /students students#destroy
please refer singular resource


问:
How to get a reverse DNS?
all my mails to GMX and WEB come back with the response of spam potential. I'm searching in google and I found, that I need a reverse DNS.

My DNS configuration:

```<code>$TTL 86400
@   IN SOA ns1.first-ns.de. postmaster.robot.first-ns.de. (
    2016110200   ; serial
    14400        ; refresh
    1800         ; retry
    604800       ; expire
    86400 )      ; minimum

@                        IN NS      robotns3.second-ns.com.
@                        IN NS      robotns2.second-ns.de.
@                        IN NS      ns1.first-ns.de.

@                        IN A       999.999.999.999
localhost                IN A       127.0.0.1
mail                     IN A       999.999.999.999
www                      IN A       999.999.999.999
ftp                      IN CNAME   www
imap                     IN CNAME   www
loopback                 IN CNAME   localhost
pop                      IN CNAME   www
relay                    IN CNAME   www
smtp                     IN CNAME   www
@                        IN MX 10   mail
</code>```

What I have to change for a reverse DNS?

答:
You need  to create a ptr record which enables dns to lookup your hostname rather than ip address.

example:

100.0.168.192.in-addr.arpa. 6230    IN  PTR mailserver.example.com.

Title: How to get a reverse DNS?

Body:
all my mails to GMX and WEB come back with the response of spam potential. I'm searching in google and I found, that I need a reverse DNS.

My DNS configuration:

$TTL 86400
@   IN SOA ns1.first-ns.de. postmaster.robot.first-ns.de. (
    2016110200   ; serial
    14400        ; refresh
    1800         ; retry
    604800       ; expire
    86400 )      ; minimum

@                        IN NS      robotns3.second-ns.com.
@                        IN NS      robotns2.second-ns.de.
@                        IN NS      ns1.first-ns.de.

@                        IN A       999.999.999.999
localhost                IN A       127.0.0.1
mail                     IN A       999.999.999.999
www                      IN A       999.999.999.999
ftp                      IN CNAME   www
imap                     IN CNAME   www
loopback                 IN CNAME   localhost
pop                      IN CNAME   www
relay                    IN CNAME   www
smtp                     IN CNAME   www
@                        IN MX 10   mail

What I have to change for a reverse DNS?


问:
trigger update value before insert pl/sql-oracle
```<code>PL/SQL: SQL Statement ignored
21/25    PL/SQL: ORA-00927: missing equal sign
22/2     PL/SQL: SQL Statement ignored
22/31    PL/SQL: ORA-00927: missing equal sign
26/1     PL/SQL: SQL Statement ignored
27/13    PL/SQL: ORA-00927: missing equal sign
32/1     PL/SQL: SQL Statement ignored
33/13    PL/SQL: ORA-00927: missing equal sign
38/1     PL/SQL: SQL Statement ignored
39/13    PL/SQL: ORA-00927: missing equal sign
44/1     PL/SQL: SQL Statement ignored
</code>```

I want to create a trigger when I insert into the table the value of 4 subject it will calculate automatically percentage and set scholarship discount like if student got 60% then set some rupees discount and if 80% than set some rupee discount

答:
You need to write simple BEFORE INSERT Trigger. You don't even need to have a cursor. Try below trigger.

```<code>CREATE OR REPLACE TRIGGER stud_percent_disc
BEFORE INSERT
ON student
FOR EACH ROW
  DECLARE
    v_total student.total%type;
    v_percent student.percentage%type;
    v_discount student.discount%type;
  BEGIN
    -- calculate total
    v_total := ( :new.s1 + :new.s2 + :new.s3 + :new.s4 );
    -- calculate percentage
    v_percent := ( v_total * 0.25 );
    -- calculate discount value
    if (v_percent >= 95) then
      v_discount := 25000;
    elsif (v_percent >= 90) then
      v_discount := 20000;
    elsif (v_percent >= 80) then
      v_discount := 15000;
    elsif (v_percent >= 75) then
      v_discount := 10000;
    else
      v_discount := 0;
    end if;
    :new.total := v_total;
    :new.percentage := v_percent;
    :new.discount := v_discount;
  END;
/
</code>```

User below syntax for insertion:

```<code>insert into student(s1,s2,s3,s4,total,percentage,discount) values(88,88,88,88,0,0,0);
</code>```

Body:
PL/SQL: SQL Statement ignored
21/25    PL/SQL: ORA-00927: missing equal sign
22/2     PL/SQL: SQL Statement ignored
22/31    PL/SQL: ORA-00927: missing equal sign
26/1     PL/SQL: SQL Statement ignored
27/13    PL/SQL: ORA-00927: missing equal sign
32/1     PL/SQL: SQL Statement ignored
33/13    PL/SQL: ORA-00927: missing equal sign
38/1     PL/SQL: SQL Statement ignored
39/13    PL/SQL: ORA-00927: missing equal sign
44/1     PL/SQL: SQL Statement ignored

I want to create a trigger when I insert into the table the value of 4 subject it will calculate automatically percentage and set scholarship discount like if student got 60% then set some rupees discount and if 80% than set some rupee discount

Body:
You need to write simple BEFORE INSERT Trigger. You don't even need to have a cursor. Try below trigger.

CREATE OR REPLACE TRIGGER stud_percent_disc
BEFORE INSERT
ON student
FOR EACH ROW
  DECLARE
    v_total student.total%type;
    v_percent student.percentage%type;
    v_discount student.discount%type;
  BEGIN
    -- calculate total
    v_total := ( :new.s1 + :new.s2 + :new.s3 + :new.s4 );
    -- calculate percentage
    v_percent := ( v_total * 0.25 );
    -- calculate discount value
    if (v_percent >= 95) then
      v_discount := 25000;
    elsif (v_percent >= 90) then
      v_discount := 20000;
    elsif (v_percent >= 80) then
      v_discount := 15000;
    elsif (v_percent >= 75) then
      v_discount := 10000;
    else
      v_discount := 0;
    end if;
    :new.total := v_total;
    :new.percentage := v_percent;
    :new.discount := v_discount;
  END;
/

User below syntax for insertion:

insert into student(s1,s2,s3,s4,total,percentage,discount) values(88,88,88,88,0,0,0);


问:
python regex find text with digits
I have text like:

```<code>sometext...one=1290...sometext...two=12985...sometext...three=1233...
</code>```

How can I find one=1290 and two=12985 but not three or four or five? There are can be from 4 to 5 digits after =. I tried this:

```<code>import re
pattern = r"(one|two)+=+(\d{4,5})+\D"
found = re.findall(pattern, sometext, flags=re.IGNORECASE)
print(found)
</code>```

It gives me results like: [('one', '1290')].
If i use pattern = r"((one|two)+=+(\d{4,5})+\D)" it gives me [('one=1290', 'one', '1290')]. How can I get just one=1290?

答:
You were close. You need to use  a single capture group (or none for that matter):

```<code>((?:one|two)+=+\d{4,5})+
</code>```

Full code:

```<code>import re

string = 'sometext...one=1290...sometext...two=12985...sometext...three=1233...'

pattern = r"((?:one|two)+=+\d{4,5})+"
found = re.findall(pattern, string, flags=re.IGNORECASE)
print(found)
# ['one=1290', 'two=12985']
</code>```

Title: python regex find text with digits

Body:
I have text like:

sometext...one=1290...sometext...two=12985...sometext...three=1233...

How can I find one=1290 and two=12985 but not three or four or five? There are can be from 4 to 5 digits after =. I tried this:

import re
pattern = r"(one|two)+=+(\d{4,5})+\D"
found = re.findall(pattern, sometext, flags=re.IGNORECASE)
print(found)

It gives me results like: [('one', '1290')].
If i use pattern = r"((one|two)+=+(\d{4,5})+\D)" it gives me [('one=1290', 'one', '1290')]. How can I get just one=1290?

Body:
You were close. You need to use  a single capture group (or none for that matter):

((?:one|two)+=+\d{4,5})+

Full code:

import re

string = 'sometext...one=1290...sometext...two=12985...sometext...three=1233...'

pattern = r"((?:one|two)+=+\d{4,5})+"
found = re.findall(pattern, string, flags=re.IGNORECASE)
print(found)
# ['one=1290', 'two=12985']


问:
DNS Round Robin very slow requests in failover scenario
Currently i'm configuring a server pool with AWS. It is a simple setup with two database servers an scalable server array and two load balancers in front of it all. Every machine has a failover standing by and it should all be pretty robust.

The load balancers should be able to failover through Round Robin DNS. So in a happy day scenario both machines get hit and distribute the traffic over the array. When one of these machines is down Round Robin DNS in combination with client browser retry should make it so that browsers should shift their target host to the machine which is still up once they hit a timeout. This is not something I came up with but seems like a very good solution.

The problem i'm experiencing is as following. The shift does actually happen but not just once for the failed request but for each and every subsequent request from the same browser. So a simple page request takes 21 seconds to load after which all images also take 21 seconds to load. All the following page request also takes this long. So the failover works but is a the same time completely useless.

Output from a dig:

; <<>> DiG 9.6.1-P2 <<>> example.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45224

;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:

;example.com.             IN      A

;; ANSWER SECTION:

www.example.com.      86400   IN      A       1.2.3.4

www.example.com.      86400   IN      A       1.2.3.4

;; Query time: 31 msec

;; SERVER: 172.16.0.23#53(172.16.0.23)

;; WHEN: Mon Dec 20 12:21:25 2010

;; MSG SIZE  rcvd: 67

Thanks in advance!

Maarten Hoekstra

Kingsquare Information Services

答:
When the DNS server gives a list of IP addresses to the client, this list will be ordered (possibly in a rotating manner, i.e. subsequent DNS might return them in a different order). It is likely that the browser caches the DNS response, i.e. the list it originally received. It then does not assume that a failed connection means that the server is down, but will retry the list in the same order every time.

So round-robin DNS is for load balancing at best; it is not very well suited to support fault tolerance.


问:
i just want to leave the message if the List from Json is empty...so how should i do it...getting lots of conflits at recyclerview
i just want to leave the message if the List from Json is empty...so how should i do it...getting lots of conflits at recyclerview

A simple {@link Fragment} subclass.

```<code>public class TodayFragment extends Fragment implements ViewPager.OnPageChangeListener {

    public static final String URL_DATA =Url.GET_TODAY_UPDATE;
    private RecyclerView recyclerView;
    private RecyclerView.Adapter adapter;
    String currentDate="2017-06-29";
    private List<TodayList> listViews;
    private TextView totalPaidFees;

    public TodayFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/mm/dd");
        loadRecyclerViewData();
        return view;
    }

    private void loadRecyclerViewData() {

        final ProgressDialog progressDialog = new ProgressDialog(getActivity());
        progressDialog.setMessage("Loading...");
        progressDialog.show();

        SingletoneRequst.q(getContext()).add(new StringRequest(Request.Method.GET, URL_DATA+currentDate , new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                progressDialog.dismiss();
                Log.i("@url_T","url--"+URL_DATA);
                Log.i("@today", "Json--"+response.toString());
                Gson gson = new Gson();
                TodayFees list = (gson.fromJson(response, TodayFees.class));

                List<TodayList> lists = list.getTodayList();
                for (TodayList todayList : lists) {
                    Log.i("today", "" + todayList);

                }
                totalPaidFees.setText(list.getTotalFees().toString());
                adapter = new Adapter_TodayFees(lists, getContext());
                recyclerView.setAdapter(adapter);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                progressDialog.dismiss();
                Toast.makeText(getActivity(), "Network problem!! Check your internet connection", Toast.LENGTH_LONG).show();
            }
        }));

    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {

    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}
</code>```

答:
Just check if the Todayfees List has any data. If yes then set the adapter:

```<code>if(list != null){
    if(list.size() > 0){
        totalPaidFees.setText(list.getTotalFees().toString());
        adapter = new Adapter_TodayFees(lists, getContext());
        recyclerView.setAdapter(adapter);

    }
    else{
        Toast.makeText(getActivity(), "Data couldn't be fetched properly!", Toast.LENGTH_LONG).show();
    }
}
</code>```

Hope it helps.

Body:
i just want to leave the message if the List from Json is empty...so how should i do it...getting lots of conflits at recyclerview

A simple {@link Fragment} subclass.

public class TodayFragment extends Fragment implements ViewPager.OnPageChangeListener {

    public static final String URL_DATA =Url.GET_TODAY_UPDATE;
    private RecyclerView recyclerView;
    private RecyclerView.Adapter adapter;
    String currentDate="2017-06-29";
    private List<TodayList> listViews;
    private TextView totalPaidFees;

    public TodayFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/mm/dd");
        loadRecyclerViewData();
        return view;
    }

    private void loadRecyclerViewData() {

        final ProgressDialog progressDialog = new ProgressDialog(getActivity());
        progressDialog.setMessage("Loading...");
        progressDialog.show();

        SingletoneRequst.q(getContext()).add(new StringRequest(Request.Method.GET, URL_DATA+currentDate , new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                progressDialog.dismiss();
                Log.i("@url_T","url--"+URL_DATA);
                Log.i("@today", "Json--"+response.toString());
                Gson gson = new Gson();
                TodayFees list = (gson.fromJson(response, TodayFees.class));

                List<TodayList> lists = list.getTodayList();
                for (TodayList todayList : lists) {
                    Log.i("today", "" + todayList);

                }
                totalPaidFees.setText(list.getTotalFees().toString());
                adapter = new Adapter_TodayFees(lists, getContext());
                recyclerView.setAdapter(adapter);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                progressDialog.dismiss();
                Toast.makeText(getActivity(), "Network problem!! Check your internet connection", Toast.LENGTH_LONG).show();
            }
        }));

    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {

    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}

Body:
Just check if the Todayfees List has any data. If yes then set the adapter:

if(list != null){
    if(list.size() > 0){
        totalPaidFees.setText(list.getTotalFees().toString());
        adapter = new Adapter_TodayFees(lists, getContext());
        recyclerView.setAdapter(adapter);

    }
    else{
        Toast.makeText(getActivity(), "Data couldn't be fetched properly!", Toast.LENGTH_LONG).show();
    }
}

Hope it helps.


答: Make the inner groups non capturing: ((?:one|two)+=+(?:\d{4,5})+\D)

Title: python regex find text with digits


问:
How to change python version in apache toree pyspark notebook?
I am running Apache Toree for Pyspark Notebook. I had anaconda 3.5 and jupyter hub installed on unix machines. When I am invoking pyspark from Jupyter notebook it's starting with Python 2.7 instead of Anaconda 3.5.

Requesting your help in changing python version.

Please see I had already tried changing python version via os.environ but it didn't worked.

答:
Followed Below steps for configuring Toree with Python-3:

Installed a new kernel with spark home and python path.

jupyter toree install --spark_home="spark_path" --kernel_name=tanveer_kernel1 --interpreters=PySpark,SQL --python="python_path"

After doing above there were issues with Driver Python version and Executor Python version. Corrected Python Version in spark-env.sh by adding

export PYSPARK_PYTHON="/usr/lib/anaconda3/bin/python"
export PYSPARK_DRIVER_PYTHON="/usr/lib/anaconda3/bin/python"

Restarted spark services.


答:
The reason that you are getting results like [('one', '1290')] rather than one=1290 is because you are using capture groups. Use:

```<code>r"(?:one|two)=(?:\d{4,5})(?=\D)"
</code>```

I have removed the additional + repeaters, as they were (I think?) unnecessary. You don't want to match things like oneonetwo===1234, right?

Using (?:...) rather than (...) defines a non-capture group. This prevents the result of the capture from being returned, and you instead get the whole match.

Similarly, using (?=\D) defines a look-ahead - so this is excluded from the match result.

Title: python regex find text with digits

Body:
The reason that you are getting results like [('one', '1290')] rather than one=1290 is because you are using capture groups. Use:

r"(?:one|two)=(?:\d{4,5})(?=\D)"

I have removed the additional + repeaters, as they were (I think?) unnecessary. You don't want to match things like oneonetwo===1234, right?

Using (?:...) rather than (...) defines a non-capture group. This prevents the result of the capture from being returned, and you instead get the whole match.

Similarly, using (?=\D) defines a look-ahead - so this is excluded from the match result.


问:
not able to run maven project
I have a maven project, where in src/test/java i have a java file which have @Test method, which basically initiates the entire test suite and when i run through TestNG or jUnit everything works fine.

But when i run this by Maven Test, i am getting below message and nothing executes. Can someone help me in this?

```<code>[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for MavenHybridFramework:MavenHybridFramework:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.relevantcodes:extentreports:jar should use a variable instead of a hard-coded path D:\UD\jars\extentreports_Updated.jar @ line 36, column 18
[WARNING] 'dependencies.dependency.systemPath' for org.monte:media:jar should use a variable instead of a hard-coded path D:\UD\jars\MonteScreenRecorder.jar @ line 43, column 18
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenHybridFramework 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenHybridFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ MavenHybridFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenHybridFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ MavenHybridFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenHybridFramework ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.491 s
[INFO] Finished at: 2015-09-23T09:35:28+05:30
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------
</code>```

Following is my pom.xml

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>MavenHybridFramework</groupId>
  <artifactId>MavenHybridFramework</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
  <dependencies>
      <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.47.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.relevantcodes</groupId>
        <artifactId>extentreports</artifactId>
        <version>1.41</version>
        <scope>system</scope>
        <systemPath>D:\UD\jars\extentreports_Updated.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>org.monte</groupId>
        <artifactId>media</artifactId>
        <version>0.7.7</version>
        <scope>system</scope>
        <systemPath>D:\UD\jars\MonteScreenRecorder.jar</systemPath>
    </dependency>
  </dependencies>
</project>
</code>```

Following is my TestNG test

```<code>package TestSuite;

import org.testng.annotations.Test;

import FrameworkLibraries.FunctionLibraries.CommonFunctionLibrary;
import FrameworkLibraries.FunctionLibraries.FrameworkFunctionLibrary;

public class AutomationDriver
{

    @Test
    public void runTestSuite()
    {
        FrameworkFunctionLibrary frameworkFuncLib=new FrameworkFunctionLibrary();

        //The below method initilizes the framework to make sure required configurations exists
        frameworkFuncLib.frameworkInit();

        //The below loads the required Test Data configurations and execute test cases
        frameworkFuncLib.frameworkExecuteTestCases();
    }
}
</code>```

答:
Try adding the below to pom.xml. It should enhance the compiler version to JDK 1.8 . For me, it worked.</p>

```<code><project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>
</code>```

Title: not able to run maven project

Body:
I have a maven project, where in src/test/java i have a java file which have @Test method, which basically initiates the entire test suite and when i run through TestNG or jUnit everything works fine.

But when i run this by Maven Test, i am getting below message and nothing executes. Can someone help me in this?

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for MavenHybridFramework:MavenHybridFramework:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.relevantcodes:extentreports:jar should use a variable instead of a hard-coded path D:\UD\jars\extentreports_Updated.jar @ line 36, column 18
[WARNING] 'dependencies.dependency.systemPath' for org.monte:media:jar should use a variable instead of a hard-coded path D:\UD\jars\MonteScreenRecorder.jar @ line 43, column 18
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenHybridFramework 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenHybridFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ MavenHybridFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenHybridFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ MavenHybridFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenHybridFramework ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.491 s
[INFO] Finished at: 2015-09-23T09:35:28+05:30
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------

Following is my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>MavenHybridFramework</groupId>
  <artifactId>MavenHybridFramework</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
  <dependencies>
      <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.47.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.relevantcodes</groupId>
        <artifactId>extentreports</artifactId>
        <version>1.41</version>
        <scope>system</scope>
        <systemPath>D:\UD\jars\extentreports_Updated.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>org.monte</groupId>
        <artifactId>media</artifactId>
        <version>0.7.7</version>
        <scope>system</scope>
        <systemPath>D:\UD\jars\MonteScreenRecorder.jar</systemPath>
    </dependency>
  </dependencies>
</project>

Following is my TestNG test

package TestSuite;

import org.testng.annotations.Test;

import FrameworkLibraries.FunctionLibraries.CommonFunctionLibrary;
import FrameworkLibraries.FunctionLibraries.FrameworkFunctionLibrary;

public class AutomationDriver
{

    @Test
    public void runTestSuite()
    {
        FrameworkFunctionLibrary frameworkFuncLib=new FrameworkFunctionLibrary();

        //The below method initilizes the framework to make sure required configurations exists
        frameworkFuncLib.frameworkInit();

        //The below loads the required Test Data configurations and execute test cases
        frameworkFuncLib.frameworkExecuteTestCases();
    }
}

Body:
Try adding the below to pom.xml. It should enhance the compiler version to JDK 1.8 . For me, it worked.

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>


问:
I want only the authorized users to view their images on Akamai. Can this be achieved?
Currently in my system, all the private images which are behind authentication are being served from my backend application server. All other non-private images are being served directly from CDN (Akamai).

Flow to serve private images is like this

Client browser -> Application Server -> Authorization -> Return Image bitmap to browser

I want to use CDN for private images also since it is putting heavy load on my application servers. Please suggest how it can be achieved?

答:
Another option is to use Akamai's EdgeAuth tokens to do a form of authorisation at their edge server. This allows you to specify an ACL within the token to provide clients with appropriate access, e.g.

```<code>"/public/*"
</code>```

would allow access to all images that you serve up under /public

```<code>/client123/*
</code>```

Would allow only access to images served up under /client123

You can also combine these and build up any combination:

```<code>/client/*|/public/*
</code>```

etc.

This does mean you need to be able to segment your images by route in this way, it can get complex if there is a lot of unpredictable crossover in terms of what clients can access.

The flow for serving this to your client depends a bit on how your client works, you can tab the token onto the image URL itself or serve it up in a cookie (the name of which you configure with Akamai). Tokens are secured via a HMAC signature so they can't be tampered with and you can set as small a window as you like for their validity.

Latest info/code/samples are linked from this article, this can be used from .NET and other tech as well as Java. There's also this node library.

If the above doesn't work for you, it's also possible to have Akamai always validate (i.e. authorise) with your backend, but serve up the asset from the CDN. This obviously removes some of the benefit of using the CDN but it can be beneficial in special cases for a small percentage of your traffic if necessary.

Body:
Another option is to use Akamai's EdgeAuth tokens to do a form of authorisation at their edge server. This allows you to specify an ACL within the token to provide clients with appropriate access, e.g.

"/public/*"

would allow access to all images that you serve up under /public

/client123/*

Would allow only access to images served up under /client123

You can also combine these and build up any combination:

/client/*|/public/*

etc.

This does mean you need to be able to segment your images by route in this way, it can get complex if there is a lot of unpredictable crossover in terms of what clients can access.

The flow for serving this to your client depends a bit on how your client works, you can tab the token onto the image URL itself or serve it up in a cookie (the name of which you configure with Akamai). Tokens are secured via a HMAC signature so they can't be tampered with and you can set as small a window as you like for their validity.

Latest info/code/samples are linked from this article, this can be used from .NET and other tech as well as Java. There's also this node library.

If the above doesn't work for you, it's also possible to have Akamai always validate (i.e. authorise) with your backend, but serve up the asset from the CDN. This obviously removes some of the benefit of using the CDN but it can be beneficial in special cases for a small percentage of your traffic if necessary.


问:
Excel Formula/SQL to get calculated value in Access
I had tables in MS Access.

Due to the size of the tables in Access, it is practically impossible to 'export' it into Excel.

Thus, am wondering if there's a way to "LINK" from Excel to Access.

In a sense, given the condition in Excel, it's able to 'calculate' tables/data that's in Access and spit out the result.

答:
I think you can try the ADO objects. They are a way to link Excel to Access database in the VBA environment.
You can turn them on from "Tools">"Reference" in the VBA editor, named "Microsoft Office/Excel 16.0 Object Library. See
How to turn on ADO for VBA here.

Once you turn it on, you can use a particular set of objects such as ADODB.Recordset or ADODB.Connection to access your Access database, retrieve and calculate data from it, and eventually getting the data outputted just like any other VBA macros. Microsoft's site offers detailed explanation on how to explore. Good luck!


问:
Pause Video Recording Using AVFoundation
I created a custom camera that works perfectly so far. I can record a video and stop recording with no errors or bugs. A feature i would like to add to this camera is the ability to pause a recording.

After a lot of research online, i see the solution is to actually stop the recording when the pause button is clicked, and to begin another recording when the resume button is clicked. After that you are supposed to merge the videos together.

I am not sure how to merge videos, i looked a lot of things up online and have not been able to find a solution.

Thank you!

This is my recording button function

```<code>@IBAction func recordVideoButtonPressed(sender:AnyObject) {

    if self.movieFileOutput.isRecording {
        isRecording = false
        self.movieFileOutput.stopRecording()
    } else {
        isRecording = true
        self.movieFileOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = self.videoOrientation()
        self.movieFileOutput.maxRecordedDuration = self.maxRecordedDuration()
        self.movieFileOutput.startRecording(toOutputFileURL: URL(fileURLWithPath: self.videoFileLocation()), recordingDelegate: self)
    }

    self.updateRecordButtonTitle()

}
</code>```

This is my pause button function

```<code> func pauseVideo() {
    if isRecording {
        if isPaused == false {
            isPaused = true
            recordButton.isEnabled = false
            recordButton.backgroundColor = UIColor.wetAsphalt
            recordButton.setTitle("Paused", for: .normal)
        } else {
            isPaused = false
            recordButton.isEnabled = true
            recordButton.backgroundColor = UIColor.red
            updateRecordButtonTitle()
        }
    } else {
        return
    }
}
</code>```

答:
You can write all frames with AVAssetWriter. You need to use AVCaptureVideoDataOutput to get frames from camera. Here You can find an exmaple.

Or if you want to merge  videos checkout this tutorial.

Body:
I created a custom camera that works perfectly so far. I can record a video and stop recording with no errors or bugs. A feature i would like to add to this camera is the ability to pause a recording.

After a lot of research online, i see the solution is to actually stop the recording when the pause button is clicked, and to begin another recording when the resume button is clicked. After that you are supposed to merge the videos together.

I am not sure how to merge videos, i looked a lot of things up online and have not been able to find a solution.

Thank you!

This is my recording button function

@IBAction func recordVideoButtonPressed(sender:AnyObject) {

    if self.movieFileOutput.isRecording {
        isRecording = false
        self.movieFileOutput.stopRecording()
    } else {
        isRecording = true
        self.movieFileOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = self.videoOrientation()
        self.movieFileOutput.maxRecordedDuration = self.maxRecordedDuration()
        self.movieFileOutput.startRecording(toOutputFileURL: URL(fileURLWithPath: self.videoFileLocation()), recordingDelegate: self)
    }

    self.updateRecordButtonTitle()

}

This is my pause button function

 func pauseVideo() {
    if isRecording {
        if isPaused == false {
            isPaused = true
            recordButton.isEnabled = false
            recordButton.backgroundColor = UIColor.wetAsphalt
            recordButton.setTitle("Paused", for: .normal)
        } else {
            isPaused = false
            recordButton.isEnabled = true
            recordButton.backgroundColor = UIColor.red
            updateRecordButtonTitle()
        }
    } else {
        return
    }
}


问:
React CSS Transition Group
Can someone help me with slide up/down transition that I am trying to create for a
fullscreen popup.
I am unable to get the desired ease in slide up effect using CSSTransitionGroup.
The code example can be found here

Any help would be much appreciated.
Thanks

答:
I could achieve the same with react-motion.
Example:

Title: React CSS Transition Group


问:
Bootstrap 4: get the last card in card column
I'm using Bootstrap 4 to build a masonry card deck.
Now I have 3 columns with 3 cards in it.
Is it possible to adress the last card of every column?

I could adress the last card of the deck with the following code:

```<code>card-columns div.card:last-of-type
</code>```

But is this also possible for every column?

This is the code of the card deck:

Card title that wraps to a new line

This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

          Someone famous in Source Title

Card title

This card has supporting text below as a natural lead-in to additional content.

Last updated 3 mins ago

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.

          Someone famous in Source Title

Card title

This card has supporting text below as a natural lead-in to additional content.

Last updated 3 mins ago

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

          Someone famous in Source Title

Card title

This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.

Last updated 3 mins ago

```

答:
I found a solution:

```<code>.card-columns div.card:nth-child(3n)
</code>```

this gets the last card of every column

Body:
I'm using Bootstrap 4 to build a masonry card deck.
Now I have 3 columns with 3 cards in it.
Is it possible to adress the last card of every column?

I could adress the last card of the deck with the following code:

card-columns div.card:last-of-type

But is this also possible for every column?

This is the code of the card deck:

Card title that wraps to a new line

This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

          Someone famous in Source Title

Card title

This card has supporting text below as a natural lead-in to additional content.

Last updated 3 mins ago

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.

          Someone famous in Source Title

Card title

This card has supporting text below as a natural lead-in to additional content.

Last updated 3 mins ago

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

          Someone famous in Source Title

Card title

This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.

Last updated 3 mins ago

Body:
I found a solution:

.card-columns div.card:nth-child(3n)

this gets the last card of every column


问:
Solutions for testing entire features of an app
EDIT: to clarify - I am asking for advice on both unit testing and user interface testing.

Currently, I don't use TDD. While I am developing an application I am constantly testing what I am working on. Testing iteration could be anything from minor function changes to entire models. I try not to code too much before I test. I like instant feedback.

Of course, with experience I can see potential problems or bugs occurring as I'm coding.

BUT, after an application is complete I will usually go through the entire app on the frontend and ensure all functions are working as expected. This means literally everything. Every add/edit/delete, sort, filter, even broken links and such.

This can take a lot of time sometimes but it does ensure my work hardly ever contains bugs after deployment.

However, I'm looking for a more standard solution. What do experienced developers do? Assume for a moment I am a single developer and so do not have a testing department etc

Do you hire beta testers (no good if app is sensitive to public use)?

Is it viable to build a series of 'general' unit tests which can for example test ALL sorting, filter functions. One for testing ALL add/edit/delete functions.

Love to hear your feedback. Will be changing the way I develop based on suggestions.

答:
Of course as David said : Unit-testing for models and helpers, of course.

and I need to add Selenium

```<code>Selenium is a robust set of tools that supports rapid development of
</code>```

test automation for web-based
  applications. Selenium provides a rich
  set of testing functions specifically
  geared to the needs of testing of a
  web application. These operations are
  highly flexible, allowing many options
  for locating UI elements and comparing
  expected test results against actual
  application behavior.

which is amazing  :

watch the 2 min intro
http://seleniumhq.org/movies/intro.mov

How Selenium Works

Testing with PHPUnit and Selenium

Body:
Of course as David said : Unit-testing for models and helpers, of course.

and I need to add Selenium

Selenium is a robust set of tools that supports rapid development of

test automation for web-based
  applications. Selenium provides a rich
  set of testing functions specifically
  geared to the needs of testing of a
  web application. These operations are
  highly flexible, allowing many options
  for locating UI elements and comparing
  expected test results against actual
  application behavior.

which is amazing  :

watch the 2 min intro
http://seleniumhq.org/movies/intro.mov

How Selenium Works

Testing with PHPUnit and Selenium


答:
Do like that...</p>

```<code>List<TodayList> lists = list.getTodayList();
if(lists!=null && lists.size>0){
        for (TodayList todayList : lists) {
            Log.i("today", "" + todayList);

        }
        totalPaidFees.setText(list.getTotalFees().toString());
        adapter = new Adapter_TodayFees(lists, getContext());
        recyclerView.setAdapter(adapter);
}
else{
   //Show the message here
 }
</code>```

Title: i just want to leave the message if the List from Json is empty...so how should i do it...getting lots of conflits at recyclerview

Body:
Do like that...

List<TodayList> lists = list.getTodayList();
if(lists!=null && lists.size>0){
        for (TodayList todayList : lists) {
            Log.i("today", "" + todayList);

        }
        totalPaidFees.setText(list.getTotalFees().toString());
        adapter = new Adapter_TodayFees(lists, getContext());
        recyclerView.setAdapter(adapter);
}
else{
   //Show the message here
 }


问:
download weblogic install package from oracle website via curl
I'd like to download the installation package from the oracle website (as a part of my CI build). So requirement is to have it done without any user interaction, using the linux command line toolset.

I've tried the following script:

```<code>#!/bin/sh

ORCL_USER='top'
ORCL_PWD='secret'
rm -rf cookies.txt

curl -H "Cookie: oraclelicense=accept-weblogicserver-cookie" -b cookies.txt -c cookies.txt -L -v http://download.oracle.com/otn/nt/middleware/12c/12212/fmw_12.2.1.2.0_wls_Disk1_1of1.zip
curl -H "Cookie: oraclelicense=accept-weblogicserver-cookie" --data "sso_username=${ORCL_USER}&ssopassword=${ORCL_PWD}&v=v1.4&locale=&" -b cookies.txt -c cookies.txt -L -v https://login.oracle.com/mysso/signon.jsp
</code>```

(where ORCL_USER and ORCL_PWD are replaced with valid values)

However after 2.nd curl command I end up with response like this:

```<code>...
<div class="cb41 cb41v0">
<input type="hidden" name="request_id" value="">
<div class="cb41w1">
<span id="errormsg" class="error-show">
Error! Do not use bookmarked URL. Please type the URL you are trying to reach directly into your browser.
</span>
</code>```

...

Any ideas on how to proceed/what am I missing here?

答:
based on the @Bertrand answer I introduced the github project: https://github.com/typekpb/oradown</p>

```<code>Usage: oradown.sh [OPTION]... URL
oradown enables download of the SSO protected files (specified by URL) from the Oracle website.

Functional arguments:
  -C, --cookie=LICENSE_COOKIE  name of the license cookie (mandatory)
  -O, --output=FILE            output FILE (optional)
  -P, --password=PASSWORD      set the Oracle PASSWORD (mandatory)
  -U, --username=USERNAME      set the Oracle USERNAME (mandatory)

Logging and info arguments:
  -H, --help                   print this help and exit
  -V, --version                display the version of oradown and exit.

Examples:

  Downloads weblogic 12c (oradown downloaded via wget):
    wget -O - -q https://raw.githubusercontent.com/typekpb/oradown/master/oradown.sh  | \
    bash -s -- --cookie=accept-weblogicserver-server \
        --username=foo --password=bar \
        http://download.oracle.com/otn/nt/middleware/12c/12212/fmw_12.2.1.2.0_wls_Disk1_1of1.zip

    Downloads weblogic 12c (oradown downloaded via curl):
    curl -s https://raw.githubusercontent.com/typekpb/oradown/master/oradown.sh  | \
    bash -s -- --cookie=accept-weblogicserver-server \
        --username=foo --password=bar \
        http://download.oracle.com/otn/nt/middleware/12c/12212/fmw_12.2.1.2.0_wls_Disk1_1of1.zip
</code>```

Body:
I'd like to download the installation package from the oracle website (as a part of my CI build). So requirement is to have it done without any user interaction, using the linux command line toolset.

I've tried the following script:

#!/bin/sh

ORCL_USER='top'
ORCL_PWD='secret'
rm -rf cookies.txt

curl -H "Cookie: oraclelicense=accept-weblogicserver-cookie" -b cookies.txt -c cookies.txt -L -v http://download.oracle.com/otn/nt/middleware/12c/12212/fmw_12.2.1.2.0_wls_Disk1_1of1.zip
curl -H "Cookie: oraclelicense=accept-weblogicserver-cookie" --data "sso_username=${ORCL_USER}&ssopassword=${ORCL_PWD}&v=v1.4&locale=&" -b cookies.txt -c cookies.txt -L -v https://login.oracle.com/mysso/signon.jsp

(where ORCL_USER and ORCL_PWD are replaced with valid values)

However after 2.nd curl command I end up with response like this:

...

<input type="hidden" name="request_id" value="">

Error! Do not use bookmarked URL. Please type the URL you are trying to reach directly into your browser.

...

Any ideas on how to proceed/what am I missing here?

Body:
based on the @Bertrand answer I introduced the github project: https://github.com/typekpb/oradown

Usage: oradown.sh [OPTION]... URL
oradown enables download of the SSO protected files (specified by URL) from the Oracle website.

Functional arguments:
  -C, --cookie=LICENSE_COOKIE  name of the license cookie (mandatory)
  -O, --output=FILE            output FILE (optional)
  -P, --password=PASSWORD      set the Oracle PASSWORD (mandatory)
  -U, --username=USERNAME      set the Oracle USERNAME (mandatory)

Logging and info arguments:
  -H, --help                   print this help and exit
  -V, --version                display the version of oradown and exit.

Examples:

  Downloads weblogic 12c (oradown downloaded via wget):
    wget -O - -q https://raw.githubusercontent.com/typekpb/oradown/master/oradown.sh  | \
    bash -s -- --cookie=accept-weblogicserver-server \
        --username=foo --password=bar \
        http://download.oracle.com/otn/nt/middleware/12c/12212/fmw_12.2.1.2.0_wls_Disk1_1of1.zip

    Downloads weblogic 12c (oradown downloaded via curl):
    curl -s https://raw.githubusercontent.com/typekpb/oradown/master/oradown.sh  | \
    bash -s -- --cookie=accept-weblogicserver-server \
        --username=foo --password=bar \
        http://download.oracle.com/otn/nt/middleware/12c/12212/fmw_12.2.1.2.0_wls_Disk1_1of1.zip


问:
retrieving data in Indian language from MySql database using php shows unusual character set
I am retrieving data in Indian language and I am getting output as ??????????????????????????

NOTE : - I used this 2 line in my php script

```<code>header('Content-type: text/plain; charset=utf-8');
mysqli_set_charset($conn,'utf-8');
</code>```

and also I used utf8_general_ci encoding in databse and table.

my php script is

```<code><?php

require 'init.php';

header('Content-type: text/plain; charset=utf-8');
mysqli_set_charset($conn,'utf-8');

$table = $_GET['table_name'];

$sql = "SELECT * FROM ".$table;

$response = array();

$result = mysqli_query($conn,$sql);

if(mysqli_num_rows($result)>0) {
        while($row = mysqli_fetch_array($result)) {
        array_push($response, array('id'=>$row['id'],'text'=>$row['text']));
    }
    echo json_encode($response);
} else {
    echo "error";
}

mysqli_close($conn);

?>
</code>```

You can check the link http://www.sharefb.com/statusApp/readStatus.php?table_name=gujrati_attitude

答:
Add this meta tag in header and try

```<code><META HTTP-EQUIV="Content-Type" CONTENT="text/html"; charset="utf-8" />
</code>```

Note : If the result shows like the ???? then u may need to install the external language support tool by enabling the following options,

Control Panel -> Regional and Language Option -> Languages -> Install files for complex script and right-to-left languages (including Thai).

Body:
I am retrieving data in Indian language and I am getting output as ??????????????????????????

NOTE : - I used this 2 line in my php script

header('Content-type: text/plain; charset=utf-8');
mysqli_set_charset($conn,'utf-8');

and also I used utf8_general_ci encoding in databse and table.

my php script is

<?php

require 'init.php';

header('Content-type: text/plain; charset=utf-8');
mysqli_set_charset($conn,'utf-8');

$table = $_GET['table_name'];

$sql = "SELECT * FROM ".$table;

$response = array();

$result = mysqli_query($conn,$sql);

if(mysqli_num_rows($result)>0) {
        while($row = mysqli_fetch_array($result)) {
        array_push($response, array('id'=>$row['id'],'text'=>$row['text']));
    }
    echo json_encode($response);
} else {
    echo "error";
}

mysqli_close($conn);

?>

You can check the link http://www.sharefb.com/statusApp/readStatus.php?table_name=gujrati_attitude

Body:
Add this meta tag in header and try

<META HTTP-EQUIV="Content-Type" CONTENT="text/html"; charset="utf-8" />

Note : If the result shows like the ???? then u may need to install the external language support tool by enabling the following options,

Control Panel -> Regional and Language Option -> Languages -> Install files for complex script and right-to-left languages (including Thai).


问:
How to make a diference of money with respect to currency rate movements
I want to make a diffrence of currency rate movements between May and June expressed in total amount of loan people borrowed in CZK (Czech Koruna) with relation to EUR.
e.g.: People have borrowed from my company money in a amount of 27M CZK (corresponding to 1M EUR) in May, which is only 0.89M EUR in June due to the currency rate movements.

I've come with:

```<code>    SELECT
    SUM((
       SELECT Rate
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=5)
       ) * t.ApprovedLoanAmount)
      -
    SUM((
       SELECT Rate
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=6)
       ) * t.ApprovedLoanAmount)
    AS currChange
FROM(
        SELECT ApprovedLoanAmount
       FROM dim.Contract con
          JOIN dim.Calendar cal ON con.CreateDateID = cal.DateId
       WHERE (cal.CalendarYear = 2017) AND (cal.MonthOfYear = 5)
      ) t
</code>```

which returns:

Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

Any help would be aprreciated.

答:
There is few options to change you query.
You can calculate current rates in subqueries and use left join on 1=1.
You can also change your sum statements to:</p>

```<code>SELECT
((
       SELECT SUM(Rate)
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=5)
       ) * t.ApprovedLoanAmount)
     -
    ((
       SELECT SUM(Rate)
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=6)
       ) * t.ApprovedLoanAmount)
    AS currChange
FROM(
        SELECT ApprovedLoanAmount
       FROM dim.Contract con
          JOIN dim.Calendar cal ON con.CreateDateID = cal.DateId
       WHERE (cal.CalendarYear = 2017) AND (cal.MonthOfYear = 5)
      ) t
</code>```

Body:
I want to make a diffrence of currency rate movements between May and June expressed in total amount of loan people borrowed in CZK (Czech Koruna) with relation to EUR.
e.g.: People have borrowed from my company money in a amount of 27M CZK (corresponding to 1M EUR) in May, which is only 0.89M EUR in June due to the currency rate movements.

I've come with:

    SELECT
    SUM((
       SELECT Rate
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=5)
       ) * t.ApprovedLoanAmount)
      -
    SUM((
       SELECT Rate
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=6)
       ) * t.ApprovedLoanAmount)
    AS currChange
FROM(
        SELECT ApprovedLoanAmount
       FROM dim.Contract con
          JOIN dim.Calendar cal ON con.CreateDateID = cal.DateId
       WHERE (cal.CalendarYear = 2017) AND (cal.MonthOfYear = 5)
      ) t

which returns:

Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

Any help would be aprreciated.

Body:
There is few options to change you query.
You can calculate current rates in subqueries and use left join on 1=1.
You can also change your sum statements to:

SELECT
((
       SELECT SUM(Rate)
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=5)
       ) * t.ApprovedLoanAmount)
     -
    ((
       SELECT SUM(Rate)
       FROM s96.CurrencyRates
       WHERE (YEAR(Date)=2017) AND (MONTH(Date)=6)
       ) * t.ApprovedLoanAmount)
    AS currChange
FROM(
        SELECT ApprovedLoanAmount
       FROM dim.Contract con
          JOIN dim.Calendar cal ON con.CreateDateID = cal.DateId
       WHERE (cal.CalendarYear = 2017) AND (cal.MonthOfYear = 5)
      ) t


问:
jQuery: using live() with each()
I have this function here:

```<code>$("a.fancybox_vid").each(function(){
   $(this).fancybox({
    titleShow     : false,
    width:    640,
    height:   395,
    autoDimensions: false,
    overlayOpacity: 0.6,
    href: "misc/mc.php?v="+$(this).attr('id')
  });
});
</code>```

Now a link with c lass .fancybox_vid gets appended, and then this will not work. Only if it is there from the beginning. How can I have live() in this each().

答:
What about doing a live event, that calls the fancybox:</p>

```<code>$("a.fancybox_vid:not(.fancy)").live('click', function(){
 $(this).addClass('fancy').fancybox({
  titleShow     : false,
  width:    640,
  height:   395,
  autoDimensions: false,
  overlayOpacity: 0.6,
  href: "misc/mc.php?v="+$(this).attr('id')
 });
});
</code>```

Title: jQuery: using live() with each()

Body:
I have this function here:

$("a.fancybox_vid").each(function(){
   $(this).fancybox({
    titleShow     : false,
    width:    640,
    height:   395,
    autoDimensions: false,
    overlayOpacity: 0.6,
    href: "misc/mc.php?v="+$(this).attr('id')
  });
});

Now a link with c lass .fancybox_vid gets appended, and then this will not work. Only if it is there from the beginning. How can I have live() in this each().

Body:
What about doing a live event, that calls the fancybox:

$("a.fancybox_vid:not(.fancy)").live('click', function(){
 $(this).addClass('fancy').fancybox({
  titleShow     : false,
  width:    640,
  height:   395,
  autoDimensions: false,
  overlayOpacity: 0.6,
  href: "misc/mc.php?v="+$(this).attr('id')
 });
});


问:
Encrypt database connection .env in laravel
When we put laravel project to localhost. Anyone can view our project .env file and they can view our database password DB_USERNAME= DB_PASSWORD= how can we encrypt it??

答: You can just set a encrypted string as password in the '.env' file and decrypt it in your code. But I dont think that it will increase the security level on your system. Much more important is set the right configuration on the server (permissions, file locations, etc.).</p>


问:
Should I use Core Data or SQLite to have better App Size
I have a requirement to keep the app size under 3MB. There will be small amount of offline data storage in the app. I would like to know if I should use SQLite or Core Data (Which I personally prefer) to have better app size.

I will be coding the app in SWIFT3. I found out that we would require to use a wrapper to use SQLite anyway, which is basically what Core Data offers.

P.S.: I would personally like to stick to SWIFT3 rather than switching to objectiveC. Any additional tips for better app size and, opinions on if I should switch to objectiveC would be much appreciated.

答:
The answer is the usual "it depends".

If you are using it to store a minimal amount of data, like in this case, it really does not matter, but for ease of use and the easy methods of dealing with objects, I think that Core Data is a better choice. Nonetheless, it has its downsides (don't even get me started on thread concurrencies), but it's a useful extension for storing, especially if you are dealing with objects.


问:
amp project form submit
I'm currently testing a landing page made with amp.
There's a lot of information on how to make forms but,
nothing on how the form is process.

Where we insert the recipient email?
Do we need to make a submiter.php?

Thank you!

答:
Yes, you need to create a server endpoint to handle the form submission. If you use method="POST" then you should also add action-xhr="submitter.php" and then submitter.php should collect the values in the form, and return JSON to the AMP page.

If you use method="GET" then you can use action="submitter.php" or action-xhr="submitter.php. If you use action and not action-xhr then submitter.php doesn't need to return JSON, it can just be a normal PHP/AMP page that takes the values of the form and sends an email or whatever you want

Title: amp project form submit


问:
Choice of backend technologies to be used to build a full fledged blogging application with front end being of Vue2 js
I am building a full fledged blogging application .As I am primarily into front end development I have almost decided what front end technologies I will be using for my app.(decided on using Vue js) .But now confused which technology stack technology goes well with VueJs .the database choice also not decided upon
yet.Any help will be appreciated</p>

答:
Don't really understand why you get point-reductions..

Actually, you already did the hard part, deciding the front end development technology.

If you had decided to go with angular or ember, it would have been quit hard to integrate a Server side technology (i'm not talking about database only). If you need some server side rendering or a CMS, vue integrates very good with these technologies.

I've used vuejs2 with .Net MVC, .net ASP, Umbraco CMS and Sitecore CMS (based on .nets ASPX) and works very well, (also laracast works very well for php, but I haven't used it).

You can find some samples of integrating vuejs with server side technologies in my  github account

Hope it helps


问:
SNAPSHOT Artifacts not visible in eclipse after mvn install

from proj-a folder: run mvn install proj-a

from proj-b folder: (proj-b depends on proj-a) run mvn clean eclipse:clean eclipse:eclipse

refresh proj-b in eclipse.

jars that proj-a depends on are in the proj-b classpath, but proj-a-0.0.1-SNAPSHOT.jar is missing. proj-a-0.0.1-SNAPSHOT.jar is in the local repository.

run mvn deploy for proj-a

delete proj-a folder from local repository

run mvn eclipse:eclipse from proj-b folder - all jars are visible.

what can cause this problem? all artifacts should be available right after install operation. mvn does not complains about nothing....

thanks.

答: For me handling maven projects in eclipse becomes easier using m2eclipse. After you have installed the plugin, right click on your project > Maven > Enable Dependency Management so that it becomes a maven eclipse project. Then, given you have run your mvn install and you can see your SNAPSHOT jar in your local repository, right click on your maven project > Maven > Update Snapshots or in general Maven > Update Dependencies.


问:
.net core Web API and Firebase Auth
I am developing a web application using .net Core Web API. So far I have used Identity to authenticate and manage users. Is it often the case and suggested to use an auth service like Google Firebase Auth while still having an own server backend?

I am thinking about using Google Firebase Auth so that users can login in different ways (using Facebook, Google, etc.).
However, I want to have a self hosted backend application and database.
Now I am asking myself:

How do I store user data on my server: Should I use the uid (returned from Firebase) as foreign key to save user related data in my database?

How can I make use of Roles (Identity)? How can I add/remove a Role from a particular user?

Should I store additional user data (like email, name, etc.) in my database or should I always retrieve those infos from the token!? Are those infos provided by Firebase Auth at all?

Thank you for bringing light into the darkness!

答:
You have your own user database. You can verify the Firebase ID token when a user signs in and get your internal users Firebase custom token.

docs/auth/users

You store them in you own database and add them to you Firebase custom token.

That depends on how much data you need and if the data can differ from the Firebase base data.

Title: .net core Web API and Firebase Auth


问:
sockettimeOutexception when app goes in background
I have set an Alarm when app goes background which working fine, but inside the service I have api which is calling every 5 minutes interval for sending location to server, after app goes in background, service works continue but due network my api is not called and getting socckettimeOutException though network is available.</p>

答:
SocketTimeoutException happens when socket read or accept times out. eg: Reading bytes from socket input stream. Network may be available but you are not receiving data on the socket, so after the amount of time passing and not receiving any data, this exception is thrown.

you can set socket timeout value using socket.setSoTimeout(0) for no timeout.


问:
Error installing Caffe on Ubuntu - CPU only
I followed the instructions for installing Caffe on Ubuntu without using the GPU:
https://stackoverflow.com/a/31396229/3198732

The "make all" command finished successfully.
I get the following error when running "make test":

CXX/LD -o .build_release/test/test_all.testbin src/caffe/test/test_caffe_main.cpp
/usr/bin/ld: /usr/local/lib/libcaffe.a(common.o): undefined reference to symbol '_ZN6google21ParseCommandLineFlagsEPiPPPcb'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libgflags.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [.build_release/test/test_all.testbin] Error 1

Any idea on how to solve this?

答:
you need to install gflags.
Follow this link https://github.com/google/python-gflags</p>


问:
No module named 'geopy' but works in terminal
I'm trying to run a python program within pyCharm but I get this error:

Traceback (most recent call last):   File
  "/Users/amywang/Documents/latLong/main.py", line 3, in
      from geopy.geocoders import Nominatim ImportError: No module named 'geopy'

However, when I run the same import statement in terminal I don't get an error.

Any ideas on how I can resolve this? Thanks!

答:
It sounds like you need to update the preferences of the PyCharm project to point to the correct python interpreter.

Preferences -> Project:SomeProject -> Project Interpreter.


问:
Creating an App that Contains a Group of Applications
Hello and thanks in advance for the help

I have a series of Android apps that I am using.  Whenever I recommend these apps to someone, I have to go over each one individually.

I wanted to know if it was possible to create a single application that will:

Download all of the individual apps all at once and install them

Create an app icon that when launched creates a submenu with all of the related apps and a help file to walk the user through each one.

Is this possible?  If so, how difficult is it to do?

Thanks again for your help

Dave

答:
For the download and installation, it's not difficult. You'll just have to get the market URL of all the apps you want to include, and then use a custom Intent to download and install them (something using ACTION_VIEW should do the trick

For the second part, you could create your launcher, and then have a screen with some buttons and an help screen. It shouldn't be too hard to do.