问:
Rails select_tag with i18n translation
I have the following select_tag and would like to have the labels translated. I am using Rails Internationalization (I18n) API

Now, this code works how ever I need to translate the option label.

```<code><%=  select_tag "object",
 "<option value=address>Address</option>
  <option value=Orden>Orden</option>".html_safe %>
</code>```

I have tried:

```<code><%=  select_tag "object",
 "<option value=address><%= t('address').capitalize %></option>
  <option value=Orden>Orden</option>".html_safe %>
</code>```

But I get a syntax error. I have also tried:

```<code><%=  select_tag "object",
 "<option value=address> t('address').capitalize </option>
  <option value=Orden>Orden</option>".html_safe %>
</code>```

The last one will not translate and just put the string 't('address').capitalize'

Any advice?

答:
You should look into options_for_select(args)

http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-options_for_select

```<code>options_for_select([[t('address'), "address"], ["orden", "orden"]], params[:the_selected_one])
</code>```

you would do:

```<code><%=  select_tag("object", options_for_select([[t('address'), "address"], ["orden", "orden"]], param[:the_selected_one])) %>
</code>```

Title: Rails select_tag with i18n translation

Body:
I have the following select_tag and would like to have the labels translated. I am using Rails Internationalization (I18n) API

Now, this code works how ever I need to translate the option label.

<%=  select_tag "object",
 "<option value=address>Address</option>
  <option value=Orden>Orden</option>".html_safe %>

I have tried:

<%=  select_tag "object",
 "<option value=address><%= t('address').capitalize %></option>
  <option value=Orden>Orden</option>".html_safe %>

But I get a syntax error. I have also tried:

<%=  select_tag "object",
 "<option value=address> t('address').capitalize </option>
  <option value=Orden>Orden</option>".html_safe %>

The last one will not translate and just put the string 't('address').capitalize'

Any advice?

Body:
You should look into options_for_select(args)

http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-options_for_select

options_for_select([[t('address'), "address"], ["orden", "orden"]], params[:the_selected_one])

you would do:

<%=  select_tag("object", options_for_select([[t('address'), "address"], ["orden", "orden"]], param[:the_selected_one])) %>


来源: stackexchange

问:
How to make full screen java applets?
I am designing a psychology experiment with java applets. I have to make my java applets full screen. What is the best way of doing this and how can I do this.

Since I haven't been using java applets for 3 years(The last time I've used it was for a course homework :) ) I have forgotten most of the concepts. I googled and found that link:
Dani web

But in the method described in above link you have to put a JFrame inside the applet which I have no idea how to do it.

Whatever I need a quick and dirty method b'cause I don't have much time and this is the reason why I asked it here.

Thanx in advance

答:
The obvious answer is don't use applets.  Write an application that uses a JFrame or JWindow as its top-level container.  It's not a huge amount of work to convert an applet into an application.  Applets are designed to be embedded in something else, usually a web page.

If you already have an applet and want to make it full screen, there's two quick and dirty hacks:

1).  If you know the screen resolution, just set the applet parameters to be that size in the HTML and then run the browser in full screen mode.

2).  Run the applet in appletviewer, rather than a web page, and maximise the appletviewer window.

OwnerDisplayName: holydiver

ContentLicense: CC BY-SA 2.5

Title: How to make full screen java applets?

LastEditorDisplayName: cletus

OwnerDisplayName: Dan Dyer


问:
Can't set focus() on a text field
This is just the weirdest thing. I've got a Sammy.js app, and I want to set focus on a text field right after the HTML loads. I've got this CoffeeScript here:

```<code>this.partial('templates/my-template.jqt').then ->
  i = $('#item')
  debugger
  i.focus()
</code>```

While I'm in the debugger, right on that line, I can inspect "i" and see that it's a JQuery object. I can even call i.val("HI THERE!") and see my text field update. But, calling i.focus() does absolutely nothing. Is there some security feature I'm missing that doesn't let you focus on a text element that was dynamically loaded?

答:
If you are sure that you are getting $('#item') object.You can try out few things.

Make sure that you have only one input box with <input type="text" id="item" />.Same id should not be repeated.

Next thing is why dont you try $('#item').focus().

Thanks.
with regards,

Wasim

Title: Can't set focus() on a text field

Body:
This is just the weirdest thing. I've got a Sammy.js app, and I want to set focus on a text field right after the HTML loads. I've got this CoffeeScript here:

this.partial('templates/my-template.jqt').then ->
  i = $('#item')
  debugger
  i.focus()

While I'm in the debugger, right on that line, I can inspect "i" and see that it's a JQuery object. I can even call i.val("HI THERE!") and see my text field update. But, calling i.focus() does absolutely nothing. Is there some security feature I'm missing that doesn't let you focus on a text element that was dynamically loaded?


答:
Try using options_for_select instead raw HTML options.

Check code below.

```<code>select_tag "object", options_for_select([t('address').capitalize, "address"], [t('order').capitalize, "order"])
</code>```

Also you can use a Model to build the Select options. Please, check the documentation below for more information.

http://apidock.com/rails/ActionView/Helpers/FormTagHelper/select_tag

ContentLicense: CC BY-SA 3.0

Title: Rails select_tag with i18n translation

Body:
Try using options_for_select instead raw HTML options.

Check code below.

select_tag "object", options_for_select([t('address').capitalize, "address"], [t('order').capitalize, "order"])

Also you can use a Model to build the Select options. Please, check the documentation below for more information.

http://apidock.com/rails/ActionView/Helpers/FormTagHelper/select_tag


问:
Function that adds equal amount of whitespace to both ends of string
```<code>function space(str,numSpace){
     str = "";
     numSpace = (" " + " ");
     document.write(numSpace + str + numSpace);
}
console.log(space("hi", " "));
</code>```

This is not working out, I'm not too sure how I can add whitespace to both ends of a string.

答:
Don't overwrite you're function's parameters with constants, and don't use document.write but return the result:

```<code>function space(str, numSpace) {
    return numSpace + str + numSpace;
}
console.log(space("hi", " "));
</code>```

Also I would suggest renaming numSpace to spaces, as the former suggests to be used with an integer count, not a string of spaces.

Body:
function space(str,numSpace){
     str = "";
     numSpace = (" " + " ");
     document.write(numSpace + str + numSpace);
}
console.log(space("hi", " "));

This is not working out, I'm not too sure how I can add whitespace to both ends of a string.

Body:
Don't overwrite you're function's parameters with constants, and don't use document.write but return the result:

function space(str, numSpace) {
    return numSpace + str + numSpace;
}
console.log(space("hi", " "));

Also I would suggest renaming numSpace to spaces, as the former suggests to be used with an integer count, not a string of spaces.


答:
This is not working out, i'm not too sure how I can add whitespace to
  both ends of a string.

you're always resetting the parameter str to empty string hence the unexpected behaviour.

there are two ways you could solve the issue at hand.

1) you could use console.log() inside the method, example:

```<code>function space(str, numSpace) {
    var result = numSpace + str + numSpace;
    console.log(result);
}
space("hi", " ");
</code>```

2) you could return the value then use console.log():

```<code>function space(str, numSpace) {
    return numSpace + str + numSpace;
}
var result = space("hi", " ");
console.log(result);
</code>```

Title: Function that adds equal amount of whitespace to both ends of string

Body:
This is not working out, i'm not too sure how I can add whitespace to
  both ends of a string.

you're always resetting the parameter str to empty string hence the unexpected behaviour.

there are two ways you could solve the issue at hand.

1) you could use console.log() inside the method, example:

function space(str, numSpace) {
    var result = numSpace + str + numSpace;
    console.log(result);
}
space("hi", " ");

2) you could return the value then use console.log():

function space(str, numSpace) {
    return numSpace + str + numSpace;
}
var result = space("hi", " ");
console.log(result);


问:
Display an image in real device from a computer in Android Application
I want to load an image from an external folder of my system to my android application. I use the following code, but the image is not displaying. When I debugged it, the Bitmap object 'bitmap' is shown as null. How can I solve this problem?

```<code>      ImageView img=(ImageView)findViewById(R.id.myImage);
      String fname="C:/Users/Public/Pictures/Garden.jpg";
      Bitmap bitmap = BitmapFactory.decodeFile(fname);
      img.setImageBitmap(bitmap);
</code>```

My actual need is my andorid application (on real device) should display some images which is stored into one computer. The admin of this application will upload some images to a specific folder in that computer. And the android application will access these images using IP address, and will display these images. If these images should be pushed to sdcard path, then how can i do it at runtime?

Please help me..

Thank you to all..

答:
You cannot access you system file. Check this link<br>
 If you are trying to access SDcard you can use the following </p>

```<code>ImageView img=(ImageView)findViewById(R.id.myImage);
 File imgFile = new  File(“/sdcard/Images/image.jpg”);
        if(imgFile.exists()){

            Bitmap bitmap = BitmapFactory.decodeFile(imgFile);
            myImage.setImageBitmap(bitmap );

        }
</code>```

Body:
I want to load an image from an external folder of my system to my android application. I use the following code, but the image is not displaying. When I debugged it, the Bitmap object 'bitmap' is shown as null. How can I solve this problem?

      ImageView img=(ImageView)findViewById(R.id.myImage);
      String fname="C:/Users/Public/Pictures/Garden.jpg";
      Bitmap bitmap = BitmapFactory.decodeFile(fname);
      img.setImageBitmap(bitmap);

My actual need is my andorid application (on real device) should display some images which is stored into one computer. The admin of this application will upload some images to a specific folder in that computer. And the android application will access these images using IP address, and will display these images. If these images should be pushed to sdcard path, then how can i do it at runtime?

Please help me..

Thank you to all..

Body:
You cannot access you system file. Check this link

 If you are trying to access SDcard you can use the following

ImageView img=(ImageView)findViewById(R.id.myImage);
 File imgFile = new  File(“/sdcard/Images/image.jpg”);
        if(imgFile.exists()){

            Bitmap bitmap = BitmapFactory.decodeFile(imgFile);
            myImage.setImageBitmap(bitmap );

        }


问:
Error when creating a new user account
I'm trying to insert a new collection into the database when a user creates their account for the first time, however, I'm getting an error.

Exception while invoking method 'createUser' TypeError: Cannot read property 'insert' of undefined

I've used similar code in the past and not had this problem.

Path: imports/startup/server/newUser.js

```<code>import { Meteor } from 'meteor/meteor';
import { Roles } from 'meteor/alanning:roles';
import { Accounts } from 'meteor/accounts-base';
import { Documents } from '../../api/documents/documents.js';

Accounts.onCreateUser((options, user) => {
      if (options.profile) {
        user.profile = options.profile;
      }

      Documents.insert({
        title: "Test Title",
        body: "Test Body"
      })

      return user;
    });
</code>```

Path: imports/api/documents/documents.js

```<code>import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Factory } from 'meteor/dburles:factory';

const Documents = new Mongo.Collection('Documents');
export default Documents;

Documents.allow({
  insert: () => false,
  update: () => false,
  remove: () => false,
});

Documents.deny({
  insert: () => true,
  update: () => true,
  remove: () => true,
});

Documents.schema = new SimpleSchema({
  title: {
    type: String,
    label: 'The title of the document.',
  },
  body: {
    type: String,
    label: 'The body of the document.',
  },
});

Documents.attachSchema(Documents.schema);
</code>```

答:
If you are using MongoDB, you must first declare your documents collection as it follows:

```<code>var Documents = new Mongo.Collection('documents');
</code>```

Then you should be able to use the usual MongoDB operations.

Title: Error when creating a new user account

Body:
I'm trying to insert a new collection into the database when a user creates their account for the first time, however, I'm getting an error.

Exception while invoking method 'createUser' TypeError: Cannot read property 'insert' of undefined

I've used similar code in the past and not had this problem.

Path: imports/startup/server/newUser.js

import { Meteor } from 'meteor/meteor';
import { Roles } from 'meteor/alanning:roles';
import { Accounts } from 'meteor/accounts-base';
import { Documents } from '../../api/documents/documents.js';

Accounts.onCreateUser((options, user) => {
      if (options.profile) {
        user.profile = options.profile;
      }

      Documents.insert({
        title: "Test Title",
        body: "Test Body"
      })

      return user;
    });

Path: imports/api/documents/documents.js

import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Factory } from 'meteor/dburles:factory';

const Documents = new Mongo.Collection('Documents');
export default Documents;

Documents.allow({
  insert: () => false,
  update: () => false,
  remove: () => false,
});

Documents.deny({
  insert: () => true,
  update: () => true,
  remove: () => true,
});

Documents.schema = new SimpleSchema({
  title: {
    type: String,
    label: 'The title of the document.',
  },
  body: {
    type: String,
    label: 'The body of the document.',
  },
});

Documents.attachSchema(Documents.schema);

Body:
If you are using MongoDB, you must first declare your documents collection as it follows:

var Documents = new Mongo.Collection('documents');

Then you should be able to use the usual MongoDB operations.


问:
Python print bytes without terminator
I am trying to print shell code with python but it adds a \x0a terminator. Is there a way to print without the terminator?

```<code># cat test.py
print(b'\x41\x41\x41\x41')

# python test.py |xxd -g1
0000000: 41 41 41 41 0a                                   AAAA.

# python test.py | wc
  1       1       5
</code>```

答:
0x0A is a newline (LF, \n) which Python adds automatically to print statements.

For Python 3, use print(..., end="").

In Python 2, end the print statement with a comma like so:

```<code>print "abc",
</code>```

However, Python will still try to print a newline when it exits. You may be better off using sys.stdout.write().

Title: Python print bytes without terminator

Body:
I am trying to print shell code with python but it adds a \x0a terminator. Is there a way to print without the terminator?

# cat test.py
print(b'\x41\x41\x41\x41')

# python test.py |xxd -g1
0000000: 41 41 41 41 0a                                   AAAA.

# python test.py | wc
  1       1       5

Body:
0x0A is a newline (LF, \n) which Python adds automatically to print statements.

For Python 3, use print(..., end="").

In Python 2, end the print statement with a comma like so:

print "abc",

However, Python will still try to print a newline when it exits. You may be better off using sys.stdout.write().


问:
How to pass down a callback from a parent component to a nested routed component?
I have the following format where I have a global component that has 3 nested components that are activated based on a given route:

```<code>  $stateProvider
    .state('create-goal', {
      url: '/create-goal',
      component: 'createGoal',
      redirectTo: 'create-goal.step-1'
    })
    .state('create-goal.step-1', {
      url: '/step-1',
      component: 'step1'
    })
    .state('create-goal.step-2', {
      url: '/step-2',
      component: 'step2'
    })
    .state('create-goal.step-3', {
      url: '/step-3',
      component: 'step3'
    });
</code>```

Inside of the main create-goal html file, I have the following:

```<code>  <ui-view goal="$ctrl.goal"
           goalInfo="$ctrl.goalInfo"
           processStep1="$ctrl.processStep1">
  </ui-view>
</code>```

The goal and goalInfo work great as they are data that is one way data bound. However, when I want to pass down a function, such as processStep1 to compute some action on step-1 and so forth, that function does not show up in the step-1 component even though the goal and goalInfo do.

```<code>export default {
  name: 'step1',
  restrict: 'E',
  bindings: {
    goal: '<',
    processStep1: '&'
  },
  template,
  controller
};
</code>```

Thoughts?

答:
There a few ways you could go about doing this.

Access the function using $parent (I recommend against this, as it is relative and can cause problems

Pass it down using attributes to inject it into each child function using the '=function' or '&function' depending on your use case

Set the function in a helper service that can be injected anywhere.  This is great if you plan on using this a lot and if it is just for data manipulation it really belongs in a service anyways to avoid bloated controllers.

The last way would be use models.  This would be good for if it is a function to be run on a certain type of object like users that can easily be modeled.  Such as a .save or .update function.

https://docs.angularjs.org/guide/directive
http://fdietz.github.io/recipes-with-angular-js/controllers/sharing-code-between-controllers-using-services.html
https://www.sitepoint.com/tidy-angular-controllers-factories-services/
http://www.webdeveasy.com/angularjs-data-model/

Body:
I have the following format where I have a global component that has 3 nested components that are activated based on a given route:

  $stateProvider
    .state('create-goal', {
      url: '/create-goal',
      component: 'createGoal',
      redirectTo: 'create-goal.step-1'
    })
    .state('create-goal.step-1', {
      url: '/step-1',
      component: 'step1'
    })
    .state('create-goal.step-2', {
      url: '/step-2',
      component: 'step2'
    })
    .state('create-goal.step-3', {
      url: '/step-3',
      component: 'step3'
    });

Inside of the main create-goal html file, I have the following:

  <ui-view goal="$ctrl.goal"
           goalInfo="$ctrl.goalInfo"
           processStep1="$ctrl.processStep1">
  </ui-view>

The goal and goalInfo work great as they are data that is one way data bound. However, when I want to pass down a function, such as processStep1 to compute some action on step-1 and so forth, that function does not show up in the step-1 component even though the goal and goalInfo do.

export default {
  name: 'step1',
  restrict: 'E',
  bindings: {
    goal: '<',
    processStep1: '&'
  },
  template,
  controller
};

Thoughts?


问:
Batch file - extract variables to build complex query
I've got a batch file I'm trying to modify which builds a wireshark capture, but specifically excludes IP traffic from a selection of IP addresses

As you can see from the original filter below, I'm trying to capture traffic from 2 subnets, but what I'd really like to do for each IP that I add to a list if build a 'ip src not %%IP%% and ip dst not %%IP%%' for each IP (which might be 15-20 IP addresses) rather than having to break it out by device type and iterate each one in turn.
I'm having trouble, as I'm trying to expand and concatenate strings in different ways.
My for loop isn't expanding the string of the IP list, and net1 and net2 aren't being expanded either - I'd like to make this really quite generic, as it's something I would want a number of different sites to use, all with different subnets and exclusion IPs

```<code>SETLOCAL EnableExtensions EnableDelayedExpansion
set TSHARK="C:\Program Files (x86)\Wireshark\tshark"
set LOCATION = "E:\ISA_CAPTURE\"
set NAME = "ISA.pcapng"
set NET1 = 10.198.64
set NET2 = 10.198.63
set IP_LIST = 10.198.64.30 10.198.64 31,10.198.64.20 10.198.64.81
set "FILTER = net %NET1% and net %NET2% and not udp portrange 2530-2550 and"
for /f "tokens=* delims= " %%i in (%%IP_LIST%%) do set "FILTER=!FILTER! and   ip src not %%i and ip dst not %%i"
if not exist %LOCATION% mkdir %LOCATION%
%TSHARK% -i 1 -b filesize:50000 -b files:16000 -f %%FILTER%%" -w %LOCATION%%NAME%
</code>```

The original version looked a bit like this - which is horrible to maintain.

```<code>if not exist %LOCATION% mkdir %LOCATION%
%TSHARK% -i 1 -b filesize:50000 -b files:16000 -f "net 10.28.57 and net 10.28.132 and ip src not 10.28.57.30 and ip dst not 10.28.57.30 and ip src not 10.28.57.32 and ip dst not 10.28.57.32 and ip src not 10.28.57.132 and ip dst not 10.28.57.132 and ip src not 10.28.57.133 and ip dst not 10.28.57.133 and ip src not 10.28.57.144 and ip dst not 10.28.57.144 and ip src not 10.28.57.146 and ip dst not 10.28.57.146 and ip src not 10.28.57.180 and ip dst not 10.28.57.180 and ip src not 10.28.57.183 and ip dst not 10.28.57.183 and ip src not 10.28.57.185 and ip dst not 10.28.57.185 and ip src not 10.28.206.26 and ip dst not 10.28.206.26 and not udp portrange 2530-2550" -w %LOCATION%%NAME%
</code>```

答:
undone by formatting - I'd retyped the variables and forgotten which language I was using.</p>

```<code>SETLOCAL  EnableDelayedExpansion
set TSHARK="C:\Program Files (x86)\Wireshark\tshark"
set LOCATION=E:\ISA_CAPTURE\
set NAME=ISA.pcapng
set net1=net 10.198.64
set net2=net 10.198.63
set net3=net 10.198.1
set ip_list= 10.198.64.30 10.198.64.31,10.198.64.20 10.198.64.81
set "FILTER=(%net1% or %net2% or %net3%) and not udp portrange 2530-2550"
for %%i in (%ip_list%) do set "FILTER=!FILTER! and ip src not %%i and ip dst not %%i"
if not exist %LOCATION% mkdir %LOCATION%
%TSHARK% -i 5 -b filesize:50000 -b files:16000 -f "%FILTER%" -w %LOCATION%%NAME%
</code>```

Body:
I've got a batch file I'm trying to modify which builds a wireshark capture, but specifically excludes IP traffic from a selection of IP addresses

As you can see from the original filter below, I'm trying to capture traffic from 2 subnets, but what I'd really like to do for each IP that I add to a list if build a 'ip src not %%IP%% and ip dst not %%IP%%' for each IP (which might be 15-20 IP addresses) rather than having to break it out by device type and iterate each one in turn.
I'm having trouble, as I'm trying to expand and concatenate strings in different ways.
My for loop isn't expanding the string of the IP list, and net1 and net2 aren't being expanded either - I'd like to make this really quite generic, as it's something I would want a number of different sites to use, all with different subnets and exclusion IPs

SETLOCAL EnableExtensions EnableDelayedExpansion
set TSHARK="C:\Program Files (x86)\Wireshark\tshark"
set LOCATION = "E:\ISA_CAPTURE\"
set NAME = "ISA.pcapng"
set NET1 = 10.198.64
set NET2 = 10.198.63
set IP_LIST = 10.198.64.30 10.198.64 31,10.198.64.20 10.198.64.81
set "FILTER = net %NET1% and net %NET2% and not udp portrange 2530-2550 and"
for /f "tokens=* delims= " %%i in (%%IP_LIST%%) do set "FILTER=!FILTER! and   ip src not %%i and ip dst not %%i"
if not exist %LOCATION% mkdir %LOCATION%
%TSHARK% -i 1 -b filesize:50000 -b files:16000 -f %%FILTER%%" -w %LOCATION%%NAME%

The original version looked a bit like this - which is horrible to maintain.

if not exist %LOCATION% mkdir %LOCATION%
%TSHARK% -i 1 -b filesize:50000 -b files:16000 -f "net 10.28.57 and net 10.28.132 and ip src not 10.28.57.30 and ip dst not 10.28.57.30 and ip src not 10.28.57.32 and ip dst not 10.28.57.32 and ip src not 10.28.57.132 and ip dst not 10.28.57.132 and ip src not 10.28.57.133 and ip dst not 10.28.57.133 and ip src not 10.28.57.144 and ip dst not 10.28.57.144 and ip src not 10.28.57.146 and ip dst not 10.28.57.146 and ip src not 10.28.57.180 and ip dst not 10.28.57.180 and ip src not 10.28.57.183 and ip dst not 10.28.57.183 and ip src not 10.28.57.185 and ip dst not 10.28.57.185 and ip src not 10.28.206.26 and ip dst not 10.28.206.26 and not udp portrange 2530-2550" -w %LOCATION%%NAME%

Body:
undone by formatting - I'd retyped the variables and forgotten which language I was using.

SETLOCAL  EnableDelayedExpansion
set TSHARK="C:\Program Files (x86)\Wireshark\tshark"
set LOCATION=E:\ISA_CAPTURE\
set NAME=ISA.pcapng
set net1=net 10.198.64
set net2=net 10.198.63
set net3=net 10.198.1
set ip_list= 10.198.64.30 10.198.64.31,10.198.64.20 10.198.64.81
set "FILTER=(%net1% or %net2% or %net3%) and not udp portrange 2530-2550"
for %%i in (%ip_list%) do set "FILTER=!FILTER! and ip src not %%i and ip dst not %%i"
if not exist %LOCATION% mkdir %LOCATION%
%TSHARK% -i 5 -b filesize:50000 -b files:16000 -f "%FILTER%" -w %LOCATION%%NAME%


问:
PHP - url-address for send-script
I'm creating pagging for some data.
For example, I have a page:

```<code>http://example.com/news.php?type=bla&smth=bla
</code>```

There are I have a list of news with links to another pages. Link to the first page is:

```
http://example.com/news.php?type=bla&smth=bla&<b>page=1</b>
```

Here is script, which creates pages links:

```<code>print '<a href="?'.$_SERVER['QUERY_STRING'].'&page=1"><<</a>';
</code>```

But after clicking to another pages the link URL is very large and it looks like:

```<code>http://example.com/news.php?type=bla&smth=bla&page=1&page=2&page=1&page=3
</code>```

How can I change that?

答:
The alternative http_build_str does not handle inner arrays,
therefor, i suggest the following:

```<code>function http_build_str_inner($query, $prefix, $arg_separator,&$args) {
    if (!is_array($query)) {
        return null;
    }
    foreach ($query as $key => $val) {
        $name = $prefix."[".$key."]";
        if (!is_numeric($name)) {
            if(is_array($val)){
                http_build_str_inner($val,$name,$arg_separator,$args);
            }else{
                $args[] = rawurlencode($name).'='.urlencode($val);
            }
        }
    }
}

function http_build_str($query, $prefix='', $arg_separator='') {
    if (!is_array($query)) {
        return null;
    }
    if ($arg_separator == '') {
        $arg_separator = ini_get('arg_separator.output');
    }
    $args = array();
    foreach ($query as $key => $val) {
        $name = $prefix.$key;
        if (!is_numeric($name)) {
            if(is_array($val)){
                http_build_str_inner($val,$name,$arg_separator,$args);
            }else{
                $args[] = rawurlencode($name).'='.urlencode($val);
            }
        }
    }
    return implode($arg_separator, $args);
}
</code>```

Enjoy...

Title: PHP - url-address for send-script

Body:
I'm creating pagging for some data.
For example, I have a page:

http://example.com/news.php?type=bla&smth=bla

There are I have a list of news with links to another pages. Link to the first page is:

http://example.com/news.php?type=bla&smth=bla&page=1

Here is script, which creates pages links:

print '<<';

But after clicking to another pages the link URL is very large and it looks like:

http://example.com/news.php?type=bla&smth=bla&page=1&page=2&page=1&page=3

How can I change that?

Body:
The alternative http_build_str does not handle inner arrays,
therefor, i suggest the following:

function http_build_str_inner($query, $prefix, $arg_separator,&$args) {
    if (!is_array($query)) {
        return null;
    }
    foreach ($query as $key => $val) {
        $name = $prefix."[".$key."]";
        if (!is_numeric($name)) {
            if(is_array($val)){
                http_build_str_inner($val,$name,$arg_separator,$args);
            }else{
                $args[] = rawurlencode($name).'='.urlencode($val);
            }
        }
    }
}

function http_build_str($query, $prefix='', $arg_separator='') {
    if (!is_array($query)) {
        return null;
    }
    if ($arg_separator == '') {
        $arg_separator = ini_get('arg_separator.output');
    }
    $args = array();
    foreach ($query as $key => $val) {
        $name = $prefix.$key;
        if (!is_numeric($name)) {
            if(is_array($val)){
                http_build_str_inner($val,$name,$arg_separator,$args);
            }else{
                $args[] = rawurlencode($name).'='.urlencode($val);
            }
        }
    }
    return implode($arg_separator, $args);
}

Enjoy...


问:
Breaking changes in Angular-CLI 1.0.0
I updated my global Angular-CLI today to 1.0.0, and tried to run a project I've been working on, and I got this:

```<code>The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/index.js:14:11)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/tasks/eject.js:10:19)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
</code>```

I decided that trying to upgrade my local version of Angular-CLI would fix this, but then I got a ton of errors from things that have apparently been broken by the new CLI version. Most of this is project specific:

```<code>ERROR in /Users/bradley/Work/dashboard/dashboard/lib/layout/navbar/pg-dash-navbar.module.ts (3,10): Module '"/Users/bradley/Work/dashboard/dashboard/node_modules/ng2-bootstrap/index"' has no exported member 'DropdownModule'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/chart-test2-title-bottom/chart-test2-title-bottom.component.ts (3,10): Module '"/Users/bradley/Work/dashboard/dashboard/node_modules/ng2-bootstrap/index"' has no exported member 'DropdownModule'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/chart-test2.module.ts (7,10): Module '"/Users/bradley/Work/dashboard/dashboard/node_modules/ng2-bootstrap/index"' has no exported member 'DropdownModule'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test1/index.ts (1,15): Cannot find module './chart-test1-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test1/index.ts (2,15): Cannot find module './chart-test1-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/index.ts (1,15): Cannot find module './chart-test2-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/index.ts (2,15): Cannot find module './chart-test2-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/data-table1/index.ts (1,15): Cannot find module './data-table1-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/data-table1/index.ts (2,15): Cannot find module './data-table1-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/index.ts (1,15): Cannot find module './map-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/index.ts (2,15): Cannot find module './map-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/news/index.ts (1,15): Cannot find module './news-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/news/index.ts (2,15): Cannot find module './news-edit-widget.component'.

ERROR in ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css
Module not found: Error: Can't resolve './images/layers.png' in '/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/map-widget'
 @ ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css 6:7520-7550
 @ ./src/demo-app/widgets/map/map-widget/map-widget.component.ts
 @ ./src/demo-app/widgets/map/map.module.ts
 @ ./src/demo-app/core/demo-core.module.ts
 @ ./src/demo-app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

ERROR in ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css
Module not found: Error: Can't resolve './images/layers-2x.png' in '/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/map-widget'
 @ ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css 6:7674-7707
 @ ./src/demo-app/widgets/map/map-widget/map-widget.component.ts
 @ ./src/demo-app/widgets/map/map.module.ts
 @ ./src/demo-app/core/demo-core.module.ts
 @ ./src/demo-app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

ERROR in ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css
Module not found: Error: Can't resolve './images/marker-icon.png' in '/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/map-widget'
 @ ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css 6:8648-8683
 @ ./src/demo-app/widgets/map/map-widget/map-widget.component.ts
 @ ./src/demo-app/widgets/map/map.module.ts
 @ ./src/demo-app/core/demo-core.module.ts
 @ ./src/demo-app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
</code>```

I could have tried to fix the bugs, but then I wouldn't be sure if my colleagues would be able to run my project without upgrading as well. So I tried to revert to an older version via:

```<code>npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@1.0.0-beta.28.3
</code>```

But then when I run any ng commands, I get:

```<code>Error: Cannot find module 'command'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/ember-cli/lib/models/project.js:17:26)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
</code>```

Going back to the most recent version of Angular-CLI fixes this, but then I'm back to that stack of errors with my project, where I'm not sure if the fixes will cause issues with older versions of Angular-CLI.

I'm really stuck here. Think I have to start all over maybe. Like uninstall Node? What should I do?

答: Try to do the migration guide again here and make sure you update your Node.js to 6.9.0 or higher.</p>

Title: Breaking changes in Angular-CLI 1.0.0

Body:
I updated my global Angular-CLI today to 1.0.0, and tried to run a project I've been working on, and I got this:

The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/index.js:14:11)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/tasks/eject.js:10:19)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

I decided that trying to upgrade my local version of Angular-CLI would fix this, but then I got a ton of errors from things that have apparently been broken by the new CLI version. Most of this is project specific:

ERROR in /Users/bradley/Work/dashboard/dashboard/lib/layout/navbar/pg-dash-navbar.module.ts (3,10): Module '"/Users/bradley/Work/dashboard/dashboard/node_modules/ng2-bootstrap/index"' has no exported member 'DropdownModule'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/chart-test2-title-bottom/chart-test2-title-bottom.component.ts (3,10): Module '"/Users/bradley/Work/dashboard/dashboard/node_modules/ng2-bootstrap/index"' has no exported member 'DropdownModule'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/chart-test2.module.ts (7,10): Module '"/Users/bradley/Work/dashboard/dashboard/node_modules/ng2-bootstrap/index"' has no exported member 'DropdownModule'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test1/index.ts (1,15): Cannot find module './chart-test1-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test1/index.ts (2,15): Cannot find module './chart-test1-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/index.ts (1,15): Cannot find module './chart-test2-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/chart-test2/index.ts (2,15): Cannot find module './chart-test2-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/data-table1/index.ts (1,15): Cannot find module './data-table1-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/data-table1/index.ts (2,15): Cannot find module './data-table1-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/index.ts (1,15): Cannot find module './map-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/index.ts (2,15): Cannot find module './map-edit-widget.component'.

ERROR in /Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/news/index.ts (1,15): Cannot find module './news-widget.component'.
/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/news/index.ts (2,15): Cannot find module './news-edit-widget.component'.

ERROR in ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css
Module not found: Error: Can't resolve './images/layers.png' in '/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/map-widget'
 @ ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css 6:7520-7550
 @ ./src/demo-app/widgets/map/map-widget/map-widget.component.ts
 @ ./src/demo-app/widgets/map/map.module.ts
 @ ./src/demo-app/core/demo-core.module.ts
 @ ./src/demo-app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

ERROR in ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css
Module not found: Error: Can't resolve './images/layers-2x.png' in '/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/map-widget'
 @ ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css 6:7674-7707
 @ ./src/demo-app/widgets/map/map-widget/map-widget.component.ts
 @ ./src/demo-app/widgets/map/map.module.ts
 @ ./src/demo-app/core/demo-core.module.ts
 @ ./src/demo-app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

ERROR in ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css
Module not found: Error: Can't resolve './images/marker-icon.png' in '/Users/bradley/Work/dashboard/dashboard/src/demo-app/widgets/map/map-widget'
 @ ./src/demo-app/widgets/map/map-widget/leaflet@1.0.3.css 6:8648-8683
 @ ./src/demo-app/widgets/map/map-widget/map-widget.component.ts
 @ ./src/demo-app/widgets/map/map.module.ts
 @ ./src/demo-app/core/demo-core.module.ts
 @ ./src/demo-app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

I could have tried to fix the bugs, but then I wouldn't be sure if my colleagues would be able to run my project without upgrading as well. So I tried to revert to an older version via:

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@1.0.0-beta.28.3

But then when I run any ng commands, I get:

Error: Cannot find module 'command'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/ember-cli/lib/models/project.js:17:26)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

Going back to the most recent version of Angular-CLI fixes this, but then I'm back to that stack of errors with my project, where I'm not sure if the fixes will cause issues with older versions of Angular-CLI.

I'm really stuck here. Think I have to start all over maybe. Like uninstall Node? What should I do?


问:
How to use array in batch file?
I'm trying to rename the NIC names on my PC. It has A LOT of NICs (they are virtual). I can get their names like so

```<code>for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnection id /value') do (
 echo %%A
)
</code>```

I'd like to use netsh inside that loop to rename them. Unfortunately, the target names aren't simple incrementing numbers. So I did

```<code>set names[0]=name1
set names[1]=name two
set names[2]=name test
set local ENABLEDELAYEDEXPANSION
set /a idx=0
for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnectionid /value') do (
 echo names[!idx!]
 set /a idx=!idx!+1
)
</code>```

This outputs

```<code>names[0]
names[1]
names[2]
</code>```

But if I try

```<code>set names[0]=name1
set names[1]=name two
set names[2]=name test
set local ENABLEDELAYEDEXPANSION
set /a idx=0
for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnectionid /value') do (
 echo %names[!idx!]%
 set /a idx=!idx!+1
)
</code>```

I just get garbage output. Is there some way I can evaluate the generated string in the previous example as a variable? Then I could pass that to netsh to do the renaming.

答:
In first place, your code have a couple errors. This line:

```<code>set local ENABLEDELAYEDEXPANSION
</code>```

... should be written this way:

```<code>setlocal ENABLEDELAYEDEXPANSION
</code>```

Otherwise the "setlocal" command becomes a "set" one, and don't works in the same way.

In this line:

```<code>for /f "tokens=2 delems==" %%A in (. . .
</code>```

... the option must be written "delims==" (NOT "delems=="), but in this case the FOR command issue an error.

After these errors were fixed, you should use the method to access array elements fully described at this answer, so I copy the relevant parts here:

To get the value of an element when the index changes inside FOR/IF,
  enclose the element in double percent symbols and precede the command
  with call:

```<code>call echo %%names[!idx!]%%
</code>```

Another way to achieve the previous process is to use an additional
  FOR command to change the delayed expansion of the index by an
  equivalent replaceable parameter, and then use the delayed expansion
  for the array element. This method runs faster than previous CALL:

```<code>for %%i in (!idx!) do echo !names[%%i]!
</code>```

Title: How to use array in batch file?

Body:
I'm trying to rename the NIC names on my PC. It has A LOT of NICs (they are virtual). I can get their names like so

for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnection id /value') do (
 echo %%A
)

I'd like to use netsh inside that loop to rename them. Unfortunately, the target names aren't simple incrementing numbers. So I did

set names[0]=name1
set names[1]=name two
set names[2]=name test
set local ENABLEDELAYEDEXPANSION
set /a idx=0
for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnectionid /value') do (
 echo names[!idx!]
 set /a idx=!idx!+1
)

This outputs

names[0]
names[1]
names[2]

But if I try

set names[0]=name1
set names[1]=name two
set names[2]=name test
set local ENABLEDELAYEDEXPANSION
set /a idx=0
for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnectionid /value') do (
 echo %names[!idx!]%
 set /a idx=!idx!+1
)

I just get garbage output. Is there some way I can evaluate the generated string in the previous example as a variable? Then I could pass that to netsh to do the renaming.

Body:
In first place, your code have a couple errors. This line:

set local ENABLEDELAYEDEXPANSION

... should be written this way:

setlocal ENABLEDELAYEDEXPANSION

Otherwise the "setlocal" command becomes a "set" one, and don't works in the same way.

In this line:

for /f "tokens=2 delems==" %%A in (. . .

... the option must be written "delims==" (NOT "delems=="), but in this case the FOR command issue an error.

After these errors were fixed, you should use the method to access array elements fully described at this answer, so I copy the relevant parts here:

To get the value of an element when the index changes inside FOR/IF,
  enclose the element in double percent symbols and precede the command
  with call:

call echo %%names[!idx!]%%

Another way to achieve the previous process is to use an additional
  FOR command to change the delayed expansion of the index by an
  equivalent replaceable parameter, and then use the delayed expansion
  for the array element. This method runs faster than previous CALL:

for %%i in (!idx!) do echo !names[%%i]!


问:
How to put a border-radius on a specific corner of a button
I have a modal that looks like this

As you can see, the modal has border-radius but the buttons at the footer dont. I want to put a border-radius at the bottom left of the purple button and a border-radius at the bottom right of the gray button. Ive tried border-bottom-left-radius and border-bottom-right-radius but it didnt work. Here`s my codes

Modal:

```<code><!--Notifier Modal-->
<div id="notifier-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
   <div class="modal-dialog modal-md" role="document">
       <div class="modal-content">
           <div class="modal-body">
               <div class="row">
                   <div class="col-md-12">
                       <div class="confirm-purchase-label">
                           Only {{size}} out of {{totalsize}} transactions have been loaded <br>
                           <h5>The complete list of transactions will be sent to your email after the process.</h5>
                       </div>
                   </div>
               </div>
           </div>

           <div class="modal-footer g-nopadding">
               <div class="col-md-6 g-nopadding">
                   <button type="button" class="btn btn-purple btn-block col-md-6" ng-click="proceedAction();">PROCEED</button>
               </div>
               <div class="col-md-6 g-nopadding">
                   <button type="button" class="btn btn-gray btn-block col-md-6" data-dismiss="modal">CANCEL</button>
               </div>
           </div>
       </div>
   </div>
</code>```

CSS:

```<code>#notifier-modal .btn,
{
    border: none!important;
    border-radius: 0px!important;
    font-family: 'AvenirMedium';
    height: 50px!important;
}

#notifier-modal .modal-md{
    width: 500px;
}

.modal-footer {
   padding: 15px;
   text-align: right;
   border-top: 1px solid #e5e5e5;
}

.modal-content{
   background:#f0f0f0;
   box-shadow:0px 0px 30px 0px rgba(101,101,101,0.50);
   border: none;
}

.btn-gray {
   color: #797979!important;
   background:#e0e0e0!important;
   font-size:14px!important;
   border: none!important;
}

.btn-purple {
   color: #f0f0f0!important;
   background-color: #9c82cd!important;
   font-size:14px!important;
   border: none!important;
}
</code>```

答:
Add the following CSS to your buttons and adjust for each accordingly</p>

```<code>-moz-border-radius-topleft: 0px;
-moz-border-radius-topright:0px;
-moz-border-radius-bottomleft:5px;
-moz-border-radius-bottomright:5px;
-webkit-border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-webkit-border-bottom-left-radius:5px;
-webkit-border-bottom-right-radius:5px;
border-top-left-radius:0px;
border-top-right-radius:0px;
border-bottom-left-radius:5px;
border-bottom-right-radius:5px;
</code>```

Body:
I have a modal that looks like this

As you can see, the modal has border-radius but the buttons at the footer dont. I want to put a border-radius at the bottom left of the purple button and a border-radius at the bottom right of the gray button. Ive tried border-bottom-left-radius and border-bottom-right-radius but it didnt work. Here`s my codes

Modal:

                           Only {{size}} out of {{totalsize}} transactions have been loaded

The complete list of transactions will be sent to your email after the process.

                   <button type="button" class="btn btn-purple btn-block col-md-6" ng-click="proceedAction();">PROCEED</button>

                   <button type="button" class="btn btn-gray btn-block col-md-6" data-dismiss="modal">CANCEL</button>

CSS:

#notifier-modal .btn,
{
    border: none!important;
    border-radius: 0px!important;
    font-family: 'AvenirMedium';
    height: 50px!important;
}

#notifier-modal .modal-md{
    width: 500px;
}

.modal-footer {
   padding: 15px;
   text-align: right;
   border-top: 1px solid #e5e5e5;
}

.modal-content{
   background:#f0f0f0;
   box-shadow:0px 0px 30px 0px rgba(101,101,101,0.50);
   border: none;
}

.btn-gray {
   color: #797979!important;
   background:#e0e0e0!important;
   font-size:14px!important;
   border: none!important;
}

.btn-purple {
   color: #f0f0f0!important;
   background-color: #9c82cd!important;
   font-size:14px!important;
   border: none!important;
}

Body:
Add the following CSS to your buttons and adjust for each accordingly

-moz-border-radius-topleft: 0px;
-moz-border-radius-topright:0px;
-moz-border-radius-bottomleft:5px;
-moz-border-radius-bottomright:5px;
-webkit-border-top-left-radius:0px;
-webkit-border-top-right-radius:0px;
-webkit-border-bottom-left-radius:5px;
-webkit-border-bottom-right-radius:5px;
border-top-left-radius:0px;
border-top-right-radius:0px;
border-bottom-left-radius:5px;
border-bottom-right-radius:5px;


问:
How do I set a UITextField's borderColor?
I am trying to set a UITextField's borderColor in iOS 8 in Swift. I tried using this code:

```<code>myTextField.layer.borderColor = UIColor( red: 0.5, green: 0.5, blue:0, alpha: 1.0 )
</code>```

I got this error:

UIColor not convertible to CGColor

答:
I found that the simplest way to set the border color using Swift 3 is to do

```<code>myTextField.layer.borderColor = UIColor.gray.cgColor
</code>```

or

```<code>myTextView.layer.borderColor = UIColor.gray.cgColor
</code>```

Hope this works!
Good luck.

Body:
I am trying to set a UITextField's borderColor in iOS 8 in Swift. I tried using this code:

myTextField.layer.borderColor = UIColor( red: 0.5, green: 0.5, blue:0, alpha: 1.0 )

I got this error:

UIColor not convertible to CGColor

Body:
I found that the simplest way to set the border color using Swift 3 is to do

myTextField.layer.borderColor = UIColor.gray.cgColor

or

myTextView.layer.borderColor = UIColor.gray.cgColor

Hope this works!
Good luck.


问:
Neo4j OGM 3.0.0-M1 Failed to instantiate [org.neo4j.ogm.session.SessionFactory]
In my Spring Boot 1.5.2 / Neo4j 3.1.2 / SDN 4 application I'm trying to use Neo4j OGM 3.0.0-M1

Right now the application fails with a following exception:

```<code>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.neo4j.transaction.SharedSessionCreator#0': Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.example.domain.configuration.Neo4jTestConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:448)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659)
    ... 56 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.example.domain.configuration.Neo4jTestConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 71 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    ... 80 common frames omitted
Caused by: java.lang.NullPointerException: null
    at org.neo4j.ogm.config.Configuration.equals(Configuration.java:159)
    at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:72)
    at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:52)
    at com.example.domain.configuration.Neo4jTestConfig.sessionFactory(Neo4jTestConfig.java:22)
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$a7edbc94.CGLIB$sessionFactory$0(<generated>)
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$a7edbc94$$FastClassBySpringCGLIB$$ffac7974.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$a7edbc94.sessionFactory(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 81 common frames omitted
</code>```

This is my Neo4jConfig:

```<code>@Configuration
@EnableNeo4jRepositories(basePackages = "com.example.domain.repository.neo4j")
@EnableTransactionManagement
public class Neo4jTestConfig {

    @Bean
    public Neo4jTransactionManager transactionManager() throws Exception {
        return new Neo4jTransactionManager(sessionFactory());
    }

    @Bean
    public SessionFactory sessionFactory() {
        return new SessionFactory("com.example");
    }

}
</code>```

What can be a reason of this issue and how to solve it ?

答:
There are significant changes in OGM 3.0 that are not backwards compatible with the Spring 4.x, Spring Boot 1.x and Spring Data Neo4J 4.x family.

If you want to use the new OGM 3.0 please use the Spring 5.x, Spring Boot 2.x and Spring Data Neo4J 5.x family. Note that all these projects are currently under active development and may not be 100% stable.

Body:
In my Spring Boot 1.5.2 / Neo4j 3.1.2 / SDN 4 application I'm trying to use Neo4j OGM 3.0.0-M1

Right now the application fails with a following exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.neo4j.transaction.SharedSessionCreator#0': Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.example.domain.configuration.Neo4jTestConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:634)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:448)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659)
    ... 56 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.example.domain.configuration.Neo4jTestConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 71 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    ... 80 common frames omitted
Caused by: java.lang.NullPointerException: null
    at org.neo4j.ogm.config.Configuration.equals(Configuration.java:159)
    at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:72)
    at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:52)
    at com.example.domain.configuration.Neo4jTestConfig.sessionFactory(Neo4jTestConfig.java:22)
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$a7edbc94.CGLIB$sessionFactory$0(<generated>)
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$a7edbc94$$FastClassBySpringCGLIB$$ffac7974.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at com.example.domain.configuration.Neo4jTestConfig$$EnhancerBySpringCGLIB$$a7edbc94.sessionFactory(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 81 common frames omitted

This is my Neo4jConfig:

@Configuration
@EnableNeo4jRepositories(basePackages = "com.example.domain.repository.neo4j")
@EnableTransactionManagement
public class Neo4jTestConfig {

    @Bean
    public Neo4jTransactionManager transactionManager() throws Exception {
        return new Neo4jTransactionManager(sessionFactory());
    }

    @Bean
    public SessionFactory sessionFactory() {
        return new SessionFactory("com.example");
    }

}

What can be a reason of this issue and how to solve it ?


问:
C Makefile error: ld returned 1 exit
My teacher is not the best at explain C so I'm having a bit of trouble understanding the connection of makefiles. I have already added the code for complex.c, complex.h, and main.c. I'm just having trouble compiling it all using the make command. I followed the example on the powerpoint he handed up and I don't understand why its failing to get to complex.

makefile

```<code>complex: main.o complex.o
    gcc -o complex main.o complex.o
main.o: main.c complex.h
    gcc -c main.c -lm
complex.o: complex.c complex.h
    gcc -c complex.c -lm
clean:
    rm*.o complex
    ls
</code>```

main.o

```<code>main.o: complex.h
    gcc -c main.c
</code>```

complex.o

```<code>complex.o: complex.h
    gcc -c complex.c
</code>```

Error

```<code>mason% make
gcc -o complex main.o complex.o
ld: fatal: file main.o: unknown file type
ld: fatal: file processing errors. No output written to complex
collect2: error: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `complex'
</code>```

答:
It looks like you have put Makefile fragments inside main.o and complex.o. These should be generated by the compiler, not by you.

Delete these files, and make again.

Additionally, your make clean rule is missing a space.

```<code>clean:
    rm *.o complex
    ls
</code>```

One more thing. No need for -lm in the compile lines.

```<code>main.o: main.c complex.h
    gcc -c main.c
complex.o: complex.c complex.h
    gcc -c complex.c
</code>```

You should add -lm at the linking phase.

```<code>complex: main.o complex.o
    gcc -o complex main.o complex.o -lm
</code>```

Title: C Makefile error: ld returned 1 exit

Body:
My teacher is not the best at explain C so I'm having a bit of trouble understanding the connection of makefiles. I have already added the code for complex.c, complex.h, and main.c. I'm just having trouble compiling it all using the make command. I followed the example on the powerpoint he handed up and I don't understand why its failing to get to complex.

makefile

complex: main.o complex.o
    gcc -o complex main.o complex.o
main.o: main.c complex.h
    gcc -c main.c -lm
complex.o: complex.c complex.h
    gcc -c complex.c -lm
clean:
    rm*.o complex
    ls

main.o

main.o: complex.h
    gcc -c main.c

complex.o

complex.o: complex.h
    gcc -c complex.c

Error

mason% make
gcc -o complex main.o complex.o
ld: fatal: file main.o: unknown file type
ld: fatal: file processing errors. No output written to complex
collect2: error: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `complex'

Body:
It looks like you have put Makefile fragments inside main.o and complex.o. These should be generated by the compiler, not by you.

Delete these files, and make again.

Additionally, your make clean rule is missing a space.

clean:
    rm *.o complex
    ls

One more thing. No need for -lm in the compile lines.

main.o: main.c complex.h
    gcc -c main.c
complex.o: complex.c complex.h
    gcc -c complex.c

You should add -lm at the linking phase.

complex: main.o complex.o
    gcc -o complex main.o complex.o -lm


问:
HAProxy - Add response header to indicate the server that was chosen
Consider the following HAProxy Config:

```<code>frontend front
        default_backend default

backend default
        balance roundrobin
        http-response set-header X-RGN us-east-1
        server app-1a app.us-east-1a.example.com:443 ssl verify none check
        server app-1c app.us-east-1c.example.com:443 ssl verify none check
        server app-1b app.us-east-1b.example.com:443 ssl verify none check
</code>```

I would like to return a response header the indicates the server that was chosen. For example, if the frontend receives a request, it will balance roundrobin and forward the request to a backend server, when it responds, I would like to see in my browser which server was used.

The config might look something like this:

```<code>frontend front
        default_backend default

backend default
        balance roundrobin
        http-response set-header X-RGN us-east-1
        server app-1a app.us-east-1a.example.com:443 ssl verify none check
        server app-1c app.us-east-1c.example.com:443 ssl verify none check
        server app-1b app.us-east-1b.example.com:443 ssl verify none check
        http-response set-header X-Server app-1a if server -i app-1a
        http-response set-header X-Server app-1b if server -i app-1b
        http-response set-header X-Server app-1c if server -i app-1c
</code>```

Has anyone tried this before?

答:
Assuming HAProxy 1.5 or later:</p>

```<code>http-response set-header X-Server %s
</code>```

Body:
Consider the following HAProxy Config:

frontend front
        default_backend default

backend default
        balance roundrobin
        http-response set-header X-RGN us-east-1
        server app-1a app.us-east-1a.example.com:443 ssl verify none check
        server app-1c app.us-east-1c.example.com:443 ssl verify none check
        server app-1b app.us-east-1b.example.com:443 ssl verify none check

I would like to return a response header the indicates the server that was chosen. For example, if the frontend receives a request, it will balance roundrobin and forward the request to a backend server, when it responds, I would like to see in my browser which server was used.

The config might look something like this:

frontend front
        default_backend default

backend default
        balance roundrobin
        http-response set-header X-RGN us-east-1
        server app-1a app.us-east-1a.example.com:443 ssl verify none check
        server app-1c app.us-east-1c.example.com:443 ssl verify none check
        server app-1b app.us-east-1b.example.com:443 ssl verify none check
        http-response set-header X-Server app-1a if server -i app-1a
        http-response set-header X-Server app-1b if server -i app-1b
        http-response set-header X-Server app-1c if server -i app-1c

Has anyone tried this before?

Body:
Assuming HAProxy 1.5 or later:

http-response set-header X-Server %s

ContentLicense: CC BY-SA 4.0


问:
Django excluding one queryset from another
I have the following two models:

```<code>class DeliveryTime(models.Model):
   delivery_time = models.CharField(max_length=15)

class BlockedDeliveryTime(models.Model):
   delivery_date = models.DateField()
   delivery_time = models.ForeignKey(DeliveryTime)
</code>```

I want to return all the available delivery times for a day i.e. all DeliveryTime excluding the BlockedDeliveryTime.

```<code> blocked_delivery_times = BlockedDeliveryTime.objects.filter(delivery_date=delivery_date)
 delivery_times = DeliveryTime.objects.all()
</code>```

From delivery_times queryset I want to remove all blocked_delivery_times.delivery_time

How can I do that? Any suggestions?

答:
For newer version of Django (I use 1.10) you should not use .objects for the second line.</p>

```<code>blocked_delivery_times = BlockedDeliveryTime.objects.filter(delivery_date=delivery_date) \
    .values('delivery_time')
delivery_times = DeliveryTime.exclude(id__in=blocked_delivery_times)
</code>```

Body:
I have the following two models:

class DeliveryTime(models.Model):
   delivery_time = models.CharField(max_length=15)

class BlockedDeliveryTime(models.Model):
   delivery_date = models.DateField()
   delivery_time = models.ForeignKey(DeliveryTime)

I want to return all the available delivery times for a day i.e. all DeliveryTime excluding the BlockedDeliveryTime.

 blocked_delivery_times = BlockedDeliveryTime.objects.filter(delivery_date=delivery_date)
 delivery_times = DeliveryTime.objects.all()

From delivery_times queryset I want to remove all blocked_delivery_times.delivery_time

How can I do that? Any suggestions?

Body:
For newer version of Django (I use 1.10) you should not use .objects for the second line.

blocked_delivery_times = BlockedDeliveryTime.objects.filter(delivery_date=delivery_date) \
    .values('delivery_time')
delivery_times = DeliveryTime.exclude(id__in=blocked_delivery_times)


答:
As discussed you have border radius set to zero important in css

```<code>#notifier-modal .btn,
{
border: none!important;
border-radius: 0px!important;
font-family: 'AvenirMedium';
height: 50px!important;
}
</code>```

Try commenting it out and then adding in the bottom ones.

There are many resources online but the best one i have found is

Border radius

it lets you set border radius seperatly or all at once. It also give you the CSS to use.

Cheers

Title: How to put a border-radius on a specific corner of a button

Body:
As discussed you have border radius set to zero important in css

#notifier-modal .btn,
{
border: none!important;
border-radius: 0px!important;
font-family: 'AvenirMedium';
height: 50px!important;
}

Try commenting it out and then adding in the bottom ones.

There are many resources online but the best one i have found is

Border radius

it lets you set border radius seperatly or all at once. It also give you the CSS to use.

Cheers


问:
Cannot call methods on dialog prior to initialization; attempted to call method 'open'
I am using this script to open a dialog. But, it throws an error :

Error: cannot call methods on dialog prior to initialization; attempted to call method 'open'

Here is the HTML code:

```<code><div class="content-wrapper" style="display:none">
    <div id="dialog-error" title="LIST ERROR">
        <div class="row">
            <div class="">
                <div class="col-md-4">
                    <span class="text text-green"><b>FIELD</b></span>
                    <div id="container-field">
                        <table class="table table-condensed table-bordered table-hover" >
                            <tbody id="container-field-error">

                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="col-md-8">
                    <div class="row">
                        <span class="text text-green"><b>ERROR MESSAGE</b></span>
                        <div id="container-message" style="min-height: 150px">

                        </div>
                    </div>
                    <div class="row">
                        <span class="text text-green"><b>TYPE</b></span>
                        <div id="container-type" style="min-height: 150px">

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</code>```

and here is the script:

```<code>$("#dialog-error").dialog({
        autoOpen: false,
        width: '700px',
        resizeable: false,
        position: {
            my: 'top',
            at: 'top+150',
            of: window
        }
    });
$('.btn-list-error').live('click', function () {
        $('#dialog-error').dialog('open');
    });
</code>```

And here is the jQuery versions in my code:

```<code><script src="<?php echo Yii::app()->theme->baseUrl ?>/js/jQuery/jQuery-2.1.4.min.js"></script>
<script src="<?php echo Yii::app()->theme->baseUrl ?>/js/jQuery/jQuery-migrate-1.2.1.min.js"></script>
<script src="<?php echo Yii::app()->theme->baseUrl ?>/js/jquery-ui-1.11.4/jquery-ui.min.js"></script>
<script src="<?php echo Yii::app()->theme->baseUrl ?>/js/bootstrap.min.js"></script>
<!--<script src="<?php echo Yii::app()->theme->baseUrl ?>/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="<?php echo Yii::app()->theme->baseUrl ?>/js/jquery.ui.touch-punch.min.js"></script>-->
<script class="include" type="text/javascript" src="<?php echo Yii::app()->theme->baseUrl ?>/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="<?php echo Yii::app()->theme->baseUrl ?>/js/common-scripts.js"></script>
</code>```

Anyone can help me what is the problem here? Is the jQuery conflict?

答: I figured out what is the matter here. In my case, the problem is in html code. There is an error in my html code. I was wrong in using css class. Once i fixed the error, the code runs well.</p>

Body:
I am using this script to open a dialog. But, it throws an error :

Error: cannot call methods on dialog prior to initialization; attempted to call method 'open'

Here is the HTML code:

                    FIELD

                        ERROR MESSAGE

                        TYPE

and here is the script:

$("#dialog-error").dialog({
        autoOpen: false,
        width: '700px',
        resizeable: false,
        position: {
            my: 'top',
            at: 'top+150',
            of: window
        }
    });
$('.btn-list-error').live('click', function () {
        $('#dialog-error').dialog('open');
    });

And here is the jQuery versions in my code:

Anyone can help me what is the problem here? Is the jQuery conflict?


问:
The app crashes when start when using cursorloader
The app is crashes when first lanuched and give me those error when using the CursorLoaders callback methods(before that I was loading the DB table in the main UI and nothing happen in this situation but when change to CursorLoader to load and change the UI in Background this problem occured), I didn't know the line of code that makes the app crashes but I think the imports has a hand on it, please help?

```<code>   03-30 02:10:06.441    1564-1591/android.process.acore E/DatabaseUtils﹕   Writing exception to parcel
   java.lang.IllegalArgumentException: Invalid column name
        at    android.database.sqlite.SQLiteQueryBuilder.computeProjection(SQLiteQueryBuilder.java:632)
        at android.database.sqlite.SQLiteQueryBuilder.buildQuery(SQLiteQueryBuilder.java:447)
        at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:393)
        at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:6493)
        at com.android.providers.contacts.ContactsProvider2.queryLocal(ContactsProvider2.java:6443)
        at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:5038)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:211)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
        at android.os.Binder.execTransact(Binder.java:446)
03-30 02:10:06.446  24098-24122/com.example.android.pets E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.example.android.pets, PID: 24098
java.lang.RuntimeException: An error occured while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:304)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)
 Caused by: java.lang.IllegalArgumentException: Invalid column name
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
        at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
        at android.content.ContentResolver.query(ContentResolver.java:478)
        at android.content.CursorLoader.loadInBackground(CursorLoader.java:64)
        at android.content.CursorLoader.loadInBackground(CursorLoader.java:42)
        at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:312)
        at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:69)
        at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:57)
        at android.os.AsyncTask$2.call(AsyncTask.java:292)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)
</code>```

this is a link to entire link of the app on https://github.com/NayirMicheal/petsapp , this app creating database of pets and saving those pets into database and then retriving them back from database and displaying the data retrieved into UI using listview throught CursorLoader and CursorAdapter
and here is the code of the mainActivity

```<code>package com.example.android.pets;

import android.content.ContentValues;
import android.app.LoaderManager;
import android.content.CursorLoader;
import android.content.Loader;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

import com.example.android.pets.data.PetContract;
import com.example.android.pets.data.PetDbHelper;

public class CatalogActivity extends AppCompatActivity implements     LoaderManager.LoaderCallbacks<Cursor> {
private static final int URI_LOADER = 0;
private PetDbHelper mDbHelper;
SQLiteDatabase db;
ListView lvItems;
PetCursorAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_catalog);
 lvItems = (ListView) findViewById(R.id.lstview);
View emptyView = findViewById(R.id.empty_view);
lvItems.setEmptyView(emptyView);

adapter = new PetCursorAdapter(this, null);
lvItems.setAdapter(adapter);

// Setup FAB to open EditorActivity
FloatingActionButton fab = (FloatingActionButton)  findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent = new Intent(CatalogActivity.this,      EditorActivity.class);
        startActivity(intent);
    }
  });
mDbHelper = new PetDbHelper(this);
db=mDbHelper.getWritableDatabase();
getLoaderManager().initLoader(URI_LOADER, null, this);

 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
 // Inflate the menu options from the res/menu/menu_catalog.xml file.
 // This adds menu items to the app bar.
 getMenuInflater().inflate(R.menu.menu_catalog, menu);
 return true;
 }

 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
 // User clicked on a menu option in the app bar overflow menu
 switch (item.getItemId()) {
    // Respond to a click on the "Insert dummy data" menu option
    case R.id.action_insert_dummy_data:
        insertdummy();
        return true;
    // Respond to a click on the "Delete all entries" menu option
    case R.id.action_delete_all_entries:
        // Do nothing for now
        return true;
    }
  return super.onOptionsItemSelected(item);
  }

 private void insertdummy() {
 ContentValues values=new ContentValues();
 values.put(PetContract.PetEntry.COLUMN_PET_NAME, "toto");
 values.put(PetContract.PetEntry.COLUMN_PET_BREED,"terrier");
 values.put(PetContract.PetEntry.COLUMN_PET_GENDER,     PetContract.PetEntry.GENDER_MALE);
 values.put(PetContract.PetEntry.COLUMN_PET_WEIGHT, 7);
 Uri URI_ID=   getContentResolver().insert(PetContract.PetEntry.CONTENT_URI, values);
 if(URI_ID==null)
  Toast.makeText(getApplicationContext(),  R.string.fail_save,Toast.LENGTH_LONG).show();
 else
    Toast.makeText(getApplicationContext(), R.string.success_save,   Toast.LENGTH_LONG).show();

  }

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
String[] projection = {PetContract.PetEntry._ID,
        PetContract.PetEntry.COLUMN_PET_NAME,
        PetContract.PetEntry.COLUMN_PET_BREED};
String selection = null;
String selectionArgs[] =null;
return new CursorLoader(getApplicationContext(),     ContactsContract.Data.CONTENT_URI,
        projection, selection, selectionArgs, null);
 }

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
adapter.swapCursor(cursor);
}

@Override
public void onLoaderReset(Loader<Cursor> loader) {
adapter.swapCursor(null);
 }
 }
</code>```

答:
I think you have to use the PetContract here :

```<code>@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    String[] projection = {PetContract.PetEntry._ID,
    PetContract.PetEntry.COLUMN_PET_NAME,PetContract.PetEntry.COLUMN_PET_BREED};
    String selection = null;
    String selectionArgs[] =null;
    return new CursorLoader(this, PetContract.CONTENT_URI,
    projection, selection, selectionArgs, null);
}
</code>```

I also changed the getApplicationContext() to this in order to get the Activity Context. I'm not sure with that but that's what I do in my loaders.  Try it and see if it works but I think the main error would be on the Contract part.

Body:
The app is crashes when first lanuched and give me those error when using the CursorLoaders callback methods(before that I was loading the DB table in the main UI and nothing happen in this situation but when change to CursorLoader to load and change the UI in Background this problem occured), I didn't know the line of code that makes the app crashes but I think the imports has a hand on it, please help?

   03-30 02:10:06.441    1564-1591/android.process.acore E/DatabaseUtils﹕   Writing exception to parcel
   java.lang.IllegalArgumentException: Invalid column name
        at    android.database.sqlite.SQLiteQueryBuilder.computeProjection(SQLiteQueryBuilder.java:632)
        at android.database.sqlite.SQLiteQueryBuilder.buildQuery(SQLiteQueryBuilder.java:447)
        at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:393)
        at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:6493)
        at com.android.providers.contacts.ContactsProvider2.queryLocal(ContactsProvider2.java:6443)
        at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:5038)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:211)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
        at android.os.Binder.execTransact(Binder.java:446)
03-30 02:10:06.446  24098-24122/com.example.android.pets E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.example.android.pets, PID: 24098
java.lang.RuntimeException: An error occured while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:304)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)
 Caused by: java.lang.IllegalArgumentException: Invalid column name
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
        at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
        at android.content.ContentResolver.query(ContentResolver.java:478)
        at android.content.CursorLoader.loadInBackground(CursorLoader.java:64)
        at android.content.CursorLoader.loadInBackground(CursorLoader.java:42)
        at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:312)
        at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:69)
        at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:57)
        at android.os.AsyncTask$2.call(AsyncTask.java:292)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)

this is a link to entire link of the app on https://github.com/NayirMicheal/petsapp , this app creating database of pets and saving those pets into database and then retriving them back from database and displaying the data retrieved into UI using listview throught CursorLoader and CursorAdapter
and here is the code of the mainActivity

package com.example.android.pets;

import android.content.ContentValues;
import android.app.LoaderManager;
import android.content.CursorLoader;
import android.content.Loader;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

import com.example.android.pets.data.PetContract;
import com.example.android.pets.data.PetDbHelper;

public class CatalogActivity extends AppCompatActivity implements     LoaderManager.LoaderCallbacks<Cursor> {
private static final int URI_LOADER = 0;
private PetDbHelper mDbHelper;
SQLiteDatabase db;
ListView lvItems;
PetCursorAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_catalog);
 lvItems = (ListView) findViewById(R.id.lstview);
View emptyView = findViewById(R.id.empty_view);
lvItems.setEmptyView(emptyView);

adapter = new PetCursorAdapter(this, null);
lvItems.setAdapter(adapter);

// Setup FAB to open EditorActivity
FloatingActionButton fab = (FloatingActionButton)  findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent = new Intent(CatalogActivity.this,      EditorActivity.class);
        startActivity(intent);
    }
  });
mDbHelper = new PetDbHelper(this);
db=mDbHelper.getWritableDatabase();
getLoaderManager().initLoader(URI_LOADER, null, this);

 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
 // Inflate the menu options from the res/menu/menu_catalog.xml file.
 // This adds menu items to the app bar.
 getMenuInflater().inflate(R.menu.menu_catalog, menu);
 return true;
 }

 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
 // User clicked on a menu option in the app bar overflow menu
 switch (item.getItemId()) {
    // Respond to a click on the "Insert dummy data" menu option
    case R.id.action_insert_dummy_data:
        insertdummy();
        return true;
    // Respond to a click on the "Delete all entries" menu option
    case R.id.action_delete_all_entries:
        // Do nothing for now
        return true;
    }
  return super.onOptionsItemSelected(item);
  }

 private void insertdummy() {
 ContentValues values=new ContentValues();
 values.put(PetContract.PetEntry.COLUMN_PET_NAME, "toto");
 values.put(PetContract.PetEntry.COLUMN_PET_BREED,"terrier");
 values.put(PetContract.PetEntry.COLUMN_PET_GENDER,     PetContract.PetEntry.GENDER_MALE);
 values.put(PetContract.PetEntry.COLUMN_PET_WEIGHT, 7);
 Uri URI_ID=   getContentResolver().insert(PetContract.PetEntry.CONTENT_URI, values);
 if(URI_ID==null)
  Toast.makeText(getApplicationContext(),  R.string.fail_save,Toast.LENGTH_LONG).show();
 else
    Toast.makeText(getApplicationContext(), R.string.success_save,   Toast.LENGTH_LONG).show();

  }

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
String[] projection = {PetContract.PetEntry._ID,
        PetContract.PetEntry.COLUMN_PET_NAME,
        PetContract.PetEntry.COLUMN_PET_BREED};
String selection = null;
String selectionArgs[] =null;
return new CursorLoader(getApplicationContext(),     ContactsContract.Data.CONTENT_URI,
        projection, selection, selectionArgs, null);
 }

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
adapter.swapCursor(cursor);
}

@Override
public void onLoaderReset(Loader<Cursor> loader) {
adapter.swapCursor(null);
 }
 }

Body:
I think you have to use the PetContract here :

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    String[] projection = {PetContract.PetEntry._ID,
    PetContract.PetEntry.COLUMN_PET_NAME,PetContract.PetEntry.COLUMN_PET_BREED};
    String selection = null;
    String selectionArgs[] =null;
    return new CursorLoader(this, PetContract.CONTENT_URI,
    projection, selection, selectionArgs, null);
}

I also changed the getApplicationContext() to this in order to get the Activity Context. I'm not sure with that but that's what I do in my loaders.  Try it and see if it works but I think the main error would be on the Contract part.


问:
Added class unable to be selected for a new XIB
I added a new class to solution (iOS), together with XIB and its designer.cs.

Problem is I cannot select this newly created class (NewAccountView.cs) in the XIB NewAccountView.xib properties (see the drop down list does not include my added class NewAccountView.cs.)

I am new to Xamarin and I am sure I am missing a crucial step here. Pls help.

答:
Did you use the View or the View Controller template?

If you used the View template, then only the .xib is created and you would have had to create the View class separately, in which case it probably did not automatically add the class inheritance and the Register attribute to your class. Make sure your NewAccountView inherits from UIView (or some subclass of UIView as appropriate) and also that you register it. E.g.:

```<code>using Foundation;
using UIKit;
...

[Register("NewAccountView")]
public class NewAccountView : UIView
{
    ...
}
</code>```

Body:
Did you use the View or the View Controller template?

If you used the View template, then only the .xib is created and you would have had to create the View class separately, in which case it probably did not automatically add the class inheritance and the Register attribute to your class. Make sure your NewAccountView inherits from UIView (or some subclass of UIView as appropriate) and also that you register it. E.g.:

using Foundation;
using UIKit;
...

[Register("NewAccountView")]
public class NewAccountView : UIView
{
    ...
}


答:
The issue is simply a word-ordering one :)

Instead of border-radius-bottom-left and border-radius-bottom-right, the attributes you're looking for are border-bottom-left-radius and border-bottom-right-radius:

```<code>.modal-footer {
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
}
</code>```

Hope this helps! :)

Body:
The issue is simply a word-ordering one :)

Instead of border-radius-bottom-left and border-radius-bottom-right, the attributes you're looking for are border-bottom-left-radius and border-bottom-right-radius:

.modal-footer {
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
}

Hope this helps! :)