问:
Symfony FOSUser Hash algorithm in java
hey everyone am trying to find out which algorithm of hash is used my symfony FOS User Bundle I've done some research , and it's mentioned that FOSUser Bundle default security config uses Sha512() and itirate it over 5000 times + salt then bas64 encoding i'm actually new with these hash algorithms ,however this is the algorithm in php

```<code>$password = 'toto';
$salt = '1234';
$salted = $password.'{'.$salt.'}';
$digest = hash('sha512', $salted, true);

for ($i=1; $i<5000; $i++) {
  $digest = hash('sha512', $digest.$salted, true);
}

$encodedPassword = base64_encode($digest);
}
</code>```

taking from this post How do I generate a SALT in Java for Salted-Hash?

since am not familiar with java hash libraries can anyone help me how to translated  this code into Java !

答:
Symfony default setting for password encryption is Bcrypt this code mentioned in your security.yml config file

```<code>encoders:
    Symfony\Component\Security\Core\User\User:
        algorithm: bcrypt
        cost:      15
</code>```

in my case i used a trick since all my password start with 13 am assuming that the salt equals to 13
so i tried translating it into java by using the java BCrypt library

```<code>public boolean checkPassword(String passwordText, String DbHash) {
    boolean password_verified = false;
    if (null == DbHash || !DbHash.startsWith("$2a$")) {
        throw new java.lang.IllegalArgumentException("Invalid hash provided for comparison");
    }
    password_verified = BCrypt.checkpw(passwordText, DbHash);
    return (password_verified);
 }
</code>```

passwordText you actual password  , DbHash stored hash

This code check a password hash if password match or not

 there's a trick symfony hashed password start with $2y$ so to make this work you need to need change $2y$ to $2a$

for exemple i have password with a hash value that is stored in my database

```<code>String passwordText = "admin";
String DbHash  = "$2y$13$VVmaKXzaS2QWgU1S4I8h5eJgC/DduF2fXmnhvcynro004GCUAQfr2";
</code>```

change this :

```<code>String DbHash  = "$2y$13$VVmaKXzaS2QWgU1S4I8h5eJgC/DduF2fXmnhvcynro004GCUAQfr2";
</code>```

to this :

```<code>String DbHash  = "$2a$13$VVmaKXzaS2QWgU1S4I8h5eJgC/DduF2fXmnhvcynro004GCUAQfr2";
</code>```

Title: Symfony FOSUser Hash algorithm in java

Body:
hey everyone am trying to find out which algorithm of hash is used my symfony FOS User Bundle I've done some research , and it's mentioned that FOSUser Bundle default security config uses Sha512() and itirate it over 5000 times + salt then bas64 encoding i'm actually new with these hash algorithms ,however this is the algorithm in php

$password = 'toto';
$salt = '1234';
$salted = $password.'{'.$salt.'}';
$digest = hash('sha512', $salted, true);

for ($i=1; $i<5000; $i++) {
  $digest = hash('sha512', $digest.$salted, true);
}

$encodedPassword = base64_encode($digest);
}

taking from this post How do I generate a SALT in Java for Salted-Hash?

since am not familiar with java hash libraries can anyone help me how to translated  this code into Java !

Body:
Symfony default setting for password encryption is Bcrypt this code mentioned in your security.yml config file

encoders:
    Symfony\Component\Security\Core\User\User:
        algorithm: bcrypt
        cost:      15

in my case i used a trick since all my password start with 13 am assuming that the salt equals to 13
so i tried translating it into java by using the java BCrypt library

public boolean checkPassword(String passwordText, String DbHash) {
    boolean password_verified = false;
    if (null == DbHash || !DbHash.startsWith("$2a$")) {
        throw new java.lang.IllegalArgumentException("Invalid hash provided for comparison");
    }
    password_verified = BCrypt.checkpw(passwordText, DbHash);
    return (password_verified);
 }

passwordText you actual password  , DbHash stored hash

This code check a password hash if password match or not

 there's a trick symfony hashed password start with $2y$ so to make this work you need to need change $2y$ to $2a$

for exemple i have password with a hash value that is stored in my database

String passwordText = "admin";
String DbHash  = "$2y$13$VVmaKXzaS2QWgU1S4I8h5eJgC/DduF2fXmnhvcynro004GCUAQfr2";

change this :

String DbHash  = "$2y$13$VVmaKXzaS2QWgU1S4I8h5eJgC/DduF2fXmnhvcynro004GCUAQfr2";

to this :

String DbHash  = "$2a$13$VVmaKXzaS2QWgU1S4I8h5eJgC/DduF2fXmnhvcynro004GCUAQfr2";


来源: stackexchange

问:
Hide other recipients while sending mail phpmailer
I know this question is asked many times. I have few queries regarding sending mail to multiple recipients.

I have an array with multiple email addresses  $mail_address[]. I don't want to make each recipients to know the other recipients address. So I think I cannot use addAddress() method. So can I use AddBCC() method  without addAddress() method if I am sending mail to all recipients at once.

If the above solution is not possible, I need to add each recipients inside the foreach loop and will use addAddress() method. But each time whole code should run which I fear it can affect the optimization of my system.

So what can be a better solution for me.

答:
If you want to send same email layout after processing lots of data then you should first process data once and should make email layout and store in one variable.

After that you can write foreach loop to send an email to individual which wont affect your execution time.

```<code>//Process all data and make layout variable with value.

$layout = '<email template>';

foreach($mail_address as $mail_item) {
//Send an email to $mail_item with $layout variable.
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
If you want to send same email layout after processing lots of data then you should first process data once and should make email layout and store in one variable.

After that you can write foreach loop to send an email to individual which wont affect your execution time.

//Process all data and make layout variable with value.

$layout = '<email template>';

foreach($mail_address as $mail_item) {
//Send an email to $mail_item with $layout variable.
}


问:
Load balancer for Azure Service Fabric Cluster on-premises
As developers we wrote microservices on Azure Service Fabric and we can run them in Azure in some sort of PaaS concept for many customers. But some of our customers do not want to run in the cloud, as databases are on-premises and not going to be available from the outside, not even through a DMZ. It's ok, we promised to support it as Azure Service Fabric can be installed as a cluster on-premises.

We have an API-gateway microservice running inside the cluster on every virtual machine, which uses the name resolver, and requests are routed and distributed accordingly, but the API that the API gateway microservice provides is the entrance for another piece of client software which our customers use, that software runs outside of the cluster and have to send requests to the API.

I suggested to use an Load Balancer like HA-Proxy or Nginx on a seperate machine (or machines) where the client software send their requests to and then the reverse proxy would forward it to an available machine inside the cluster.

It seems that is not what our customer want, another machine as load balancer is not an option. They suggest: make the client software smarter to figure out which host to go to, in other words: we should write our own fail-over/load balancer inside the client software.

What other options do we have?

Install Network Load Balancer Feature on each of the virtual machine to give the cluster a single IP address, is this even possible? Something like https://www.poweradmin.com/blog/configuring-network-load-balancing-in-windows-server/

Suggest an API gateway outside the cluster, like KONG https://getkong.org/

Something else ?

PS: The client applications do not send many requests per second, maybe a few per minute.

答:
We have also faced the same situation when started working with service fabric cluster. We configured Application Gateway as Proxy but it would not provide the function like HTTP to HTTPS redirection.

For that, we configured Nginx Instead of Azure Application Gateway as Proxy to Service Fabric Application.


问:
sql -changing column attribute to Unique
I have a column of "email" in my table "user". I forget to make email as Unique in starting. Now I have lot of entries in my database and when I tries to change "email" as Unique, it show error "#1062 - Duplicate entry '' for key 'email'".

I do have some users with no email entry which means there are many Null value in column 'email'. How can I make 'email' unique now.

Question: Did unique means it can't contain any null value? Did I need to recreate a new table?

答:
Create a backup table. Then clean your backup table by removing duplicate email and place dummy emails for null records.

Run an Update sql from backup table to your original table.


问:
UIButton titleLabel frame size returning CGSize with zero width & height
For iOS7, I used the UIButton titleLabel.frame.size.width property to determine the width of my button title under different localisations so I could position the title correctly using contentInset on the UIButton.

My UIButton is setup with an image and title and I always want the combination of these two to be centred horizontally in the UIButton for example:

```<code>[space-x (image) space-y (titleLabel) space-x]
</code>```

Under iOS 7 and Xcode 5.1, the following code works perfectly (even running on iOS 8 GM when built in XCode 5.1):

```<code>CGSize buttonSize = button.frame.size;
CGSize titleSize = button.titleLabel.frame.size;
float contentInset =((buttonSize.width - (titleSize.width + 18 + 3)) / 2 );
float contentInsetRounded = roundf(contentInset);
[button setContentEdgeInsets:(UIEdgeInsetsMake(0, contentInsetRounded, 0, 0))];
</code>```

(18 is the width of the image, and 3 is the number of points spacing between the image and titleLabel or space-y in my example above)

Under iOS 8 and Xcode 6 GM, button.titleLabel.frame.size is returning a CGSize with zero width & height so my contentInset ends up centring the UIImage in the UIButton, causing the titleLabel to truncate.

Any ideas? I tried setting the titleLabel text immediately before this code in case it thought it was empty but that didn't help either.

Thanks in advance!

答:
If you are then setting an image next to a button after getting the frame, you can use

```<code>[theButton setTitle: @"theTitle" forState:UIControlStateNormal];
[theButton setImage: theImage forState:UIControlStateNormal];
[theButton setNeedsLayout];
[theButton layoutIfNeeded];
[theButton setImageEdgeInsets: UIEdgeInsetsMake(6, transactionsButton.titleLabel.frame.size.width + 40.0, 0, 0)];
</code>```

And in Swift 3, this will do.

```<code>self.view.layoutIfNeeded()
</code>```

Body:
For iOS7, I used the UIButton titleLabel.frame.size.width property to determine the width of my button title under different localisations so I could position the title correctly using contentInset on the UIButton.

My UIButton is setup with an image and title and I always want the combination of these two to be centred horizontally in the UIButton for example:

[space-x (image) space-y (titleLabel) space-x]

Under iOS 7 and Xcode 5.1, the following code works perfectly (even running on iOS 8 GM when built in XCode 5.1):

CGSize buttonSize = button.frame.size;
CGSize titleSize = button.titleLabel.frame.size;
float contentInset =((buttonSize.width - (titleSize.width + 18 + 3)) / 2 );
float contentInsetRounded = roundf(contentInset);
[button setContentEdgeInsets:(UIEdgeInsetsMake(0, contentInsetRounded, 0, 0))];

(18 is the width of the image, and 3 is the number of points spacing between the image and titleLabel or space-y in my example above)

Under iOS 8 and Xcode 6 GM, button.titleLabel.frame.size is returning a CGSize with zero width & height so my contentInset ends up centring the UIImage in the UIButton, causing the titleLabel to truncate.

Any ideas? I tried setting the titleLabel text immediately before this code in case it thought it was empty but that didn't help either.

Thanks in advance!

Body:
If you are then setting an image next to a button after getting the frame, you can use

[theButton setTitle: @"theTitle" forState:UIControlStateNormal];
[theButton setImage: theImage forState:UIControlStateNormal];
[theButton setNeedsLayout];
[theButton layoutIfNeeded];
[theButton setImageEdgeInsets: UIEdgeInsetsMake(6, transactionsButton.titleLabel.frame.size.width + 40.0, 0, 0)];

And in Swift 3, this will do.

self.view.layoutIfNeeded()


问:
Displaying related data in Web API 2 Entity Framework
Im having some issues with the Web API part of my asp.net MVC-application. The application works fine when using MVC-controllers and views, but when trying to return a Order and its OrderItem's through my web api 2-controller I get this error message:

The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.

I gather there is something wrong with the serialization of the MenuItems. I have tried removing the Virtual-keyword from the classes and using Include to manually include the MenuItems but still get the same error.

Do I need to make a ViewModel for this just to return the data? I have also tried JSON.NET and get the same errors.

I have the following classes:

```<code>public class Order
{
    public int Id { get; set; }
    public DateTime OrderDate { get; set; }

    public virtual ICollection<OrderItem> OrderItems { get; set; }
}

public class OrderItem
{
    public int Id { get; set; }
    public decimal UnitPrice { get; set; }
    public int Quantity { get; set; }
    public int Discount { get; set; }

    public virtual Order Order { get; set; }
    public virtual MenueItem MenueItem { get; set; }
}

public class MenueItem
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
    public string Description { get; set; }
    public DateTime CreateDate { get; set; }
    public DateTime LastChanged { get; set; }
    public bool IsActive { get; set; }

    public virtual ICollection<OrderItem> OrderItems { get; set; }
}
</code>```

And the controller method:

```<code>    // GET: api/Orders
    public IQueryable<Order> GetOrders()
    {
        var orders = db.Orders.Include(c => c.OrderItems);
        return orders;
    }
</code>```

答:
You can specify the converter to ignore the loop reference like:  </p>

```<code>var orders = JsonConvert.SerializeObject(db.GetOrders(), new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
</code>```

Body:
Im having some issues with the Web API part of my asp.net MVC-application. The application works fine when using MVC-controllers and views, but when trying to return a Order and its OrderItem's through my web api 2-controller I get this error message:

The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.

I gather there is something wrong with the serialization of the MenuItems. I have tried removing the Virtual-keyword from the classes and using Include to manually include the MenuItems but still get the same error.

Do I need to make a ViewModel for this just to return the data? I have also tried JSON.NET and get the same errors.

I have the following classes:

public class Order
{
    public int Id { get; set; }
    public DateTime OrderDate { get; set; }

    public virtual ICollection<OrderItem> OrderItems { get; set; }
}

public class OrderItem
{
    public int Id { get; set; }
    public decimal UnitPrice { get; set; }
    public int Quantity { get; set; }
    public int Discount { get; set; }

    public virtual Order Order { get; set; }
    public virtual MenueItem MenueItem { get; set; }
}

public class MenueItem
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
    public string Description { get; set; }
    public DateTime CreateDate { get; set; }
    public DateTime LastChanged { get; set; }
    public bool IsActive { get; set; }

    public virtual ICollection<OrderItem> OrderItems { get; set; }
}

And the controller method:

    // GET: api/Orders
    public IQueryable<Order> GetOrders()
    {
        var orders = db.Orders.Include(c => c.OrderItems);
        return orders;
    }

Body:
You can specify the converter to ignore the loop reference like:

var orders = JsonConvert.SerializeObject(db.GetOrders(), new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });


问:
how to create an invoice in pdf with barcode in django
i want to create an invoice in pdf format with barcode,
first mybarcode.py file to create barcode using reportlab

# mybarcode.py file to create barecode

```<code>    from reportlab.lib.units import mm
    from reportlab.graphics.barcode import createBarcodeDrawing
    from reportlab.graphics.shapes import Drawing, String
    from reportlab.graphics.charts.barcharts import HorizontalBarChart

    class MyBarcodeDrawing(Drawing):
            def __init__(self, text_value, *args, **kw):
                barcode = createBarcodeDrawing('Code128', value=text_value,  barHeight=19*mm, humanReadable=True)
                Drawing.__init__(self,barcode.width,barcode.height,*args,**kw)
                self.add(barcode, name='barcode')
</code>```

views function to generate pdf with barcode.

# views.py

```<code>from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus.tables import Table
cm = 2.54

def print_pdf(request):

  import mybarcode
  product = Product.objects.get(id = id)
  d = mybarcode.MyBarcodeDrawing(product.code)
  binaryStuff = d.asString('jpg')

  response = HttpResponse(content_type='application/pdf')
  filename=somefilename.pdf'
  elements = []
  doc = SimpleDocTemplate(response, rightMargin=0, leftMargin=6.5 * cm, topMargin=0.3 * cm, bottomMargin=0)

  data=[("barcode", binaryStuff),("name", "some_name")]
  table = Table(data)
  elements.append(table)
  doc.build(elements)
  return response
</code>```

and getting this error : 'utf8' codec can't decode byte 0xff in position 0: invalid start byte

答:
This might solve your issues:

```<code>    import codecs

    f = codecs.open(dir+location, 'r', encoding='utf-8')
    txt = f.read()
</code>```

from that moment txt is in unicode format and you can use it everywhere in your code.

If you want to generate UTF-8 files after your processing do:

```<code>    f.write(txt.encode('utf-8'))
</code>```

Body:
i want to create an invoice in pdf format with barcode,
first mybarcode.py file to create barcode using reportlab

# mybarcode.py file to create barecode

    from reportlab.lib.units import mm
    from reportlab.graphics.barcode import createBarcodeDrawing
    from reportlab.graphics.shapes import Drawing, String
    from reportlab.graphics.charts.barcharts import HorizontalBarChart

    class MyBarcodeDrawing(Drawing):
            def __init__(self, text_value, *args, **kw):
                barcode = createBarcodeDrawing('Code128', value=text_value,  barHeight=19*mm, humanReadable=True)
                Drawing.__init__(self,barcode.width,barcode.height,*args,**kw)
                self.add(barcode, name='barcode')

views function to generate pdf with barcode.

# views.py

from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus.tables import Table
cm = 2.54

def print_pdf(request):

  import mybarcode
  product = Product.objects.get(id = id)
  d = mybarcode.MyBarcodeDrawing(product.code)
  binaryStuff = d.asString('jpg')

  response = HttpResponse(content_type='application/pdf')
  filename=somefilename.pdf'
  elements = []
  doc = SimpleDocTemplate(response, rightMargin=0, leftMargin=6.5 * cm, topMargin=0.3 * cm, bottomMargin=0)

  data=[("barcode", binaryStuff),("name", "some_name")]
  table = Table(data)
  elements.append(table)
  doc.build(elements)
  return response

and getting this error : 'utf8' codec can't decode byte 0xff in position 0: invalid start byte

Body:
This might solve your issues:

    import codecs

    f = codecs.open(dir+location, 'r', encoding='utf-8')
    txt = f.read()

from that moment txt is in unicode format and you can use it everywhere in your code.

If you want to generate UTF-8 files after your processing do:

    f.write(txt.encode('utf-8'))


问:
time difference betweern varchar field and timestamp field
I have two dates fields as below (I know they are incorrectly design but DBA will not changed it)

```<code>   order_tag varchar(2)    dt_changed timestamp(6)
   06:35:13                27-MAR-17 06.10.31.036561
</code>```

And I know to find the time difference between the timestamp_field and the varchar(2) field.

I tried the below sql and get an ora error:

ORA-01850: hour must be between 0 and 23

```<code>select orq.order_tag,
       rt.dt_changed,
       (to_date(rt.dt_changed,'hh24:mi:ss') -
         (to_date (orq.order_tag, 'hh24:mi:ss'))) time_differ
from   order_request orq,route rt
where  orq.rt_id = rt.rt_id
</code>```

ORA-01850: hour must be between 0 and 23

答:
TO_DATE( date_string, format_mask ) takes a string as the first value and you are passing in a DATE datatype. To solve this, Oracle will implicitly call TO_CHAR( date_value, format_mask ) on the date to convert it to a string and will use your NLS_DATE_FORMAT session parameter as the format mask.

If you do:

```<code>SELECT * FROM NLS_SESSION_PARAMETERS WHERE PARAMETER = 'NLS_DATE_FORMAT';
</code>```

You will see the format mask that Oracle is using and it almost certainly does not match the HH24:MI:SS mask you are using in TO_DATE.

Instead, you can try explicitly calling TO_CHAR and specifying the format mask:

```<code>select orq.order_tag,
       rt.dt_changed,
       to_date( TO_CHAR( rt.dt_changed, 'HH24:MI:SS' ),'hh24:mi:ss') -
         to_date (orq.order_tag, 'hh24:mi:ss') time_differ
from   order_request orq,route rt
where  orq.rt_id = rt.rt_id
</code>```

Body:
I have two dates fields as below (I know they are incorrectly design but DBA will not changed it)

   order_tag varchar(2)    dt_changed timestamp(6)
   06:35:13                27-MAR-17 06.10.31.036561

And I know to find the time difference between the timestamp_field and the varchar(2) field.

I tried the below sql and get an ora error:

ORA-01850: hour must be between 0 and 23

select orq.order_tag,
       rt.dt_changed,
       (to_date(rt.dt_changed,'hh24:mi:ss') -
         (to_date (orq.order_tag, 'hh24:mi:ss'))) time_differ
from   order_request orq,route rt
where  orq.rt_id = rt.rt_id

ORA-01850: hour must be between 0 and 23

Body:
TO_DATE( date_string, format_mask ) takes a string as the first value and you are passing in a DATE datatype. To solve this, Oracle will implicitly call TO_CHAR( date_value, format_mask ) on the date to convert it to a string and will use your NLS_DATE_FORMAT session parameter as the format mask.

If you do:

SELECT * FROM NLS_SESSION_PARAMETERS WHERE PARAMETER = 'NLS_DATE_FORMAT';

You will see the format mask that Oracle is using and it almost certainly does not match the HH24:MI:SS mask you are using in TO_DATE.

Instead, you can try explicitly calling TO_CHAR and specifying the format mask:

select orq.order_tag,
       rt.dt_changed,
       to_date( TO_CHAR( rt.dt_changed, 'HH24:MI:SS' ),'hh24:mi:ss') -
         to_date (orq.order_tag, 'hh24:mi:ss') time_differ
from   order_request orq,route rt
where  orq.rt_id = rt.rt_id


问:
How do I test for an empty JavaScript object?
After an AJAX request, sometimes my application may return an empty object, like:

```<code>var a = {};
</code>```

How can I check whether that's the case?

答:
The following example show how to test if a JavaScript object is empty, if by empty we means has no own properties to it.

The script works on ES6.

const isEmpty = (obj) => {
    if (obj === null ||
        obj === undefined ||
        Array.isArray(obj) ||
        typeof obj !== 'object'
    ) {
        return true;
    }
    return Object.getOwnPropertyNames(obj).length === 0;
};
console.clear();
console.log('-----');
console.log(isEmpty(''));           // true
console.log(isEmpty(33));           // true
console.log(isEmpty([]));           // true
console.log(isEmpty({}));           // true
console.log(isEmpty({ length: 0, custom_property: [] })); // false
console.log('-----');
console.log(isEmpty('Hello'));      // true
console.log(isEmpty([1, 2, 3]));    // true
console.log(isEmpty({ test: 1 }));  // false
console.log(isEmpty({ length: 3, custom_property: [1, 2, 3] })); // false
console.log('-----');
console.log(isEmpty(new Date()));   // true
console.log(isEmpty(Infinity));     // true
console.log(isEmpty(null));         // true
console.log(isEmpty(undefined));    // true```

OwnerDisplayName: falmp

Body:
After an AJAX request, sometimes my application may return an empty object, like:

var a = {};

How can I check whether that's the case?

ContentLicense: CC BY-SA 4.0


问:
How to use <md-error> in Angular Material 2?
I am trying to display an error message when a required input is not valid in Angular Material 2. There is an example in the Angular Material demo app :

```<code><form novalidate>
  <h4>Inside a form</h4>

  <md-input-container>
    <input mdInput name="example" placeholder="example"
      [(ngModel)]="errorMessageExample3" required>
    <md-error>This field is required</md-error>
  </md-input-container>

  <button color="primary" md-raised-button>Submit</button>
</form>
</code>```

Expected result

Unfortunately when I try to do the same, I get :

```<code>Unhandled Promise rejection: Template parse errors:
'md-error' is not a known element:
1. If 'md-error' is an Angular component, then verify that it is part
   of this module.
2. If 'md-error' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA'
   to the '@NgModule.schemas' of this component to suppress this message.
</code>```

What am I supposed to do to use <md-error>?

答:
Have you added MaterialModule to your appModule?

ie

```<code>@NgModule({
    imports: [
        ...
        MaterialModule
    ],
    ...
})
</code>```

Update:

md-error is a new directive that hasn't been released yet (as of beta.2) it will probably be part of the next release, I guess. More information can be found here: https://github.com/angular/material2/pull/3560

Meanwhile you can use md-hint.

Body:
I am trying to display an error message when a required input is not valid in Angular Material 2. There is an example in the Angular Material demo app :

<form novalidate>

Inside a form

  <md-input-container>
    <input mdInput name="example" placeholder="example"
      [(ngModel)]="errorMessageExample3" required>
    <md-error>This field is required</md-error>
  </md-input-container>

  <button color="primary" md-raised-button>Submit</button>
</form>

Expected result

Unfortunately when I try to do the same, I get :

Unhandled Promise rejection: Template parse errors:
'md-error' is not a known element:
1. If 'md-error' is an Angular component, then verify that it is part
   of this module.
2. If 'md-error' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA'
   to the '@NgModule.schemas' of this component to suppress this message.

What am I supposed to do to use <md-error>?

Body:
Have you added MaterialModule to your appModule?

ie

@NgModule({
    imports: [
        ...
        MaterialModule
    ],
    ...
})

Update:

md-error is a new directive that hasn't been released yet (as of beta.2) it will probably be part of the next release, I guess. More information can be found here: https://github.com/angular/material2/pull/3560

Meanwhile you can use md-hint.


问:
Resizing an using CSS is not working
Hi I am trying to achieve the desired look:

How it should look

However, when the text is longer or the screen is resized it can lead to this:

How it looks with more text

Any help would be greatly appreciated as I have spent hours trying to get this to work...Responsive is easy enough as it will appear under the text not side by side but the desktop preview is just killing me!

The HTML:

```<code><div class="container-combo white">
        <div class="row-2col-equal-ignore image-combo">
                <div class="column">
                <div class="content">
                <h2>Located at the heart of our community to serve our community</h2>
                <img src="images/bkg-swirl.png" alt="swirl divider" class="swirl">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
                <p>quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                </div>
                </div>
                <div class="column">
                <img src="images/bedroom-combo.jpg" class="combo-img">
                </div>
        </div>
</div>
</code>```

The SCSS/CSS:

```<code>.image-combo {

.column {
margin-bottom: -5px;

    .content {
        margin: 0 auto;
        text-align: center;
        max-width: 705px;
        padding-top: 61px;
        padding: 61px 10px 10px;

        h2 {
            color: $dark-grey;
            font-size: 34px;
            font-family: $minion;
            line-height: 40px;
            font-weight: normal;
            text-transform: none;
            padding-bottom: 32px;
        }

        p {
            font-size: 15px;
            line-height: 24px;
            text-align: left;
            padding-bottom: 32px;
        }

        .swirl {
            float: none;
            max-width: 456px;
            width: 100%;
            min-width: 1px;
        }
    }

    .flip {
        padding-right: 120px;
        padding-left: 40px;
    }

    .combo-img {
        width: 100%;
        min-height: 426px;
        height: 100%;
    }
}
</code>```

答:
If you use background-image and background-size: cover like this it will work

.image-combo {
  display: flex;
}

.column {
  margin-bottom: -5px;
}

.content {
  margin: 0 auto;
  text-align: center;
  max-width: 705px;
  padding-top: 61px;
  padding: 61px 10px 10px;
}

h2 {
  color: $dark-grey;
  font-size: 34px;
  font-family: $minion;
  line-height: 40px;
  font-weight: normal;
  text-transform: none;
  padding-bottom: 32px;
}

p {
  font-size: 15px;
  line-height: 24px;
  text-align: left;
  padding-bottom: 32px;
}

.swirl {
  float: none;
  max-width: 456px;
  width: 100%;
  min-width: 1px;
}

.flip {
  padding-right: 120px;
  padding-left: 40px;
}
.column {
  flex: 1;
  width: 50%;
}
.column.img {
  background-image: url(http://lorempixel.com/500/500/people/10/);
  background-size: cover;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container-combo white">
  <div class="row-2col-equal-ignore image-combo">
    <div class="column">
      <div class="content">
        <h2>Located at the heart of our community to serve our community</h2>
        <img src="http://placehold.it/200x20" alt="swirl divider" class="swirl">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
          dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        <p>quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
      </div>
    </div>
    <div class="column img">
    </div>
  </div>
</div></code>```

Title: Resizing an using CSS is not working

Body:
Hi I am trying to achieve the desired look:

How it should look

However, when the text is longer or the screen is resized it can lead to this:

How it looks with more text

Any help would be greatly appreciated as I have spent hours trying to get this to work...Responsive is easy enough as it will appear under the text not side by side but the desktop preview is just killing me!

The HTML:

Located at the heart of our community to serve our community

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

The SCSS/CSS:

.image-combo {

.column {
margin-bottom: -5px;

    .content {
        margin: 0 auto;
        text-align: center;
        max-width: 705px;
        padding-top: 61px;
        padding: 61px 10px 10px;

        h2 {
            color: $dark-grey;
            font-size: 34px;
            font-family: $minion;
            line-height: 40px;
            font-weight: normal;
            text-transform: none;
            padding-bottom: 32px;
        }

        p {
            font-size: 15px;
            line-height: 24px;
            text-align: left;
            padding-bottom: 32px;
        }

        .swirl {
            float: none;
            max-width: 456px;
            width: 100%;
            min-width: 1px;
        }
    }

    .flip {
        padding-right: 120px;
        padding-left: 40px;
    }

    .combo-img {
        width: 100%;
        min-height: 426px;
        height: 100%;
    }
}

Body:
If you use background-image and background-size: cover like this it will work

.image-combo {
  display: flex;
}

.column {
  margin-bottom: -5px;
}

.content {
  margin: 0 auto;
  text-align: center;
  max-width: 705px;
  padding-top: 61px;
  padding: 61px 10px 10px;
}

h2 {
  color: $dark-grey;
  font-size: 34px;
  font-family: $minion;
  line-height: 40px;
  font-weight: normal;
  text-transform: none;
  padding-bottom: 32px;
}

p {
  font-size: 15px;
  line-height: 24px;
  text-align: left;
  padding-bottom: 32px;
}

.swirl {
  float: none;
  max-width: 456px;
  width: 100%;
  min-width: 1px;
}

.flip {
  padding-right: 120px;
  padding-left: 40px;
}
.column {
  flex: 1;
  width: 50%;
}
.column.img {
  background-image: url(http://lorempixel.com/500/500/people/10/);
  background-size: cover;
}

<div class="container-combo white">
  <div class="row-2col-equal-ignore image-combo">
    <div class="column">
      <div class="content">
        <h2>Located at the heart of our community to serve our community</h2>
        <img src="http://placehold.it/200x20" alt="swirl divider" class="swirl">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
          dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        <p>quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
      </div>
    </div>
    <div class="column img">
    </div>
  </div>
</div>


问:
Inno Setup - verysilent yet still have to click next
So I cant get this to work as intended. I have 4 small programmes that need to be installed silently. However using the verysilent tag, each of the 4 programmes pops up asking me to click next a couple of times as they would normally.

Not sure how to auto click next or why silentinstall isnt working (probably not supported by my programmes?)

Any thing I can do?

答:
You don't need to implement the "/Verysilent" Flag.
As it means it will be executed as a parameter.
You need to identify which types of installers are you using and what parameters that they support..</p>


问:
download a list users from twitter
I have a list of "n" Twitter ID representing users I would like to download.
To retrieve their user profile info, should I use n times the api call get_user or there exist a method to pass the entire list and retrieve all the info within one single api call, within the twitter  rate time limit?

I tried something like
api.search_users(A)
api.search_users(id in A)

where A contains the list of id
but it does not work.
Anyone helping?

答:
You can use the Twitter API resource https://dev.twitter.com/rest/reference/get/users/lookup. It can return user objects for at most 100 users at a time.

You can use this in Tweepy like:

```<code>user_objects = api.lookup_users(user_ids=list_of_at_most_100_user_ids)
</code>```

Much of this answer first appeared as part of https://stackoverflow.com/a/42946854/1921546

Title: download a list users from twitter

Body:
You can use the Twitter API resource https://dev.twitter.com/rest/reference/get/users/lookup. It can return user objects for at most 100 users at a time.

You can use this in Tweepy like:

user_objects = api.lookup_users(user_ids=list_of_at_most_100_user_ids)

Much of this answer first appeared as part of https://stackoverflow.com/a/42946854/1921546


问:
anaconda/lib/libcurl.so.4 no version information available when i compile opencv at ubuntu14
When I compiled opencv on Ubuntu, I met this problem
"/usr/bin/cmake: /usr/home/anaconda/lib/libcurl.so.4: no version information available (required by cmake)".

I don't know the reason, I have found libcurl.so.4 at /usr/home/anaconda/lib/,  is it because I have other version of libcurl.so.4? or I should reinstall the anaconda?

答: How about add "su" before the command?</p>

Body: How about add "su" before the command?


问:
How to invoke a function and pass parameter when you have function name as string?
How to invoke a function when you have function name as string? e.g.</p>

```<code>$scope.ExecuteFunction = function (func,val) {
  // here func="GetActivityInfo" and val="ERF000000000A6543"
  // How to Invoke function named in variable func and pass val as parameter ?
  // GetActivityInfo(val) to be invoked.
}

var GetActivityInfo = function (elementId) {
  // some code
};
</code>```

答:
If the function is in scope of the window you can use this:

```<code>window[func](val);
</code>```

Body:
How to invoke a function when you have function name as string? e.g.

$scope.ExecuteFunction = function (func,val) {
  // here func="GetActivityInfo" and val="ERF000000000A6543"
  // How to Invoke function named in variable func and pass val as parameter ?
  // GetActivityInfo(val) to be invoked.
}

var GetActivityInfo = function (elementId) {
  // some code
};

Body:
If the function is in scope of the window you can use this:

window[func](val);


问:
How to make css for class in single page?
Here is my style:

```<code><style>
      ul {
          padding:0 0 0 0;
          margin:0 0 0 0;
      }
      ul li {
          list-style:none;
          margin-bottom:25px;
      }
      ul li img {
          cursor: pointer;
      }
      .modal-body {
          padding:5px !important;
      }
      .modal-content {
          border-radius:0;
      }
      .modal-dialog img {
          text-align:center;
          margin:0 auto;
      }
    .controls{
        width:50px;
        display:block;
        font-size:11px;
        padding-top:8px;
        font-weight:bold;
    }
    .next {
        float:right;
        text-align:right;
    }
      /*override modal for demo only*/
      .modal-dialog {
          max-width:500px;
          padding-top: 90px;
      }
      @media screen and (min-width: 768px){
          .modal-dialog {
              width:500px;
              padding-top: 90px;
          }
      }
      @media screen and (max-width:1500px){
          #ads {
              display:none;
          }
      }

        .dock {
            border: 4px dotted #cccccc;
            background-color: #ededed;
            width: 600px;
            height: 300px;
            color: #aaa;
            font-size: 18px;
            text-align: center;
            padding-top: 100px;
        }
        .dock_hover {
            border: 4px dotted #4d90fe;
            background-color: #e7f0ff;
            width: 600px;
            height: 300px;
            color: #4d90fe;
            font-size: 18px;
            text-align: center;
            padding-top: 100px;
        }
  </style>
</code>```

And I want to control

```<code>ul li {
          list-style:none;
          margin-bottom:25px;
      }
</code>```

without making change for my default page. margin-bottom must be 0px
And here is my ul li

```<code><ul class="row">
    <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-174908-rocking-the-night-away-xs.jpg">
    </li>
    <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-287182-blah-blah-blah-yellow-road-sign-xs.jpg">
    </li>
    <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-460760-colors-xs.jpg">
    </li>
</ul>
</code>```

Is it possible to change margin-bottom:0px through given class to ul li ? I've read the reference css style change just for one page but I don't know how to implement its code. That's why I ask a question for this.
Here is the page while margin-bottom:0px

Here is the page while margin-bottom:25px

I want to fix the picture with margin-bottom:25px but I don't want to change totally of the page.
Here's full of my script page:

```<!DOCTYPE html>
<?php include('akses.php'); ?>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Basarnas</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">

    <link href="../css/sb-admin.css" rel="stylesheet">

    <link href="../font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    Toggle navigation

                </button>
                Operator Komunikasi

                     <?php echo $_SESSION['operatorkomunikasi']; ?>

                             Settings

                             Log Out

                         Home

                         Informasi Bencana

                         Monitoring Operasi SAR

    Direktorat Operasi dan Latihan
                  BASARNAS

                            Data Informasi Bencana

                                  List Informasi Bencana

                                 Berita SAR

        <?php  if (isset($_POST['submit'])) {
        $key = md5('vxcygnusloiv');
        function encrypt($string, $key){
        $string = rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB)));
        return $string;
        }

        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');

        $id = $_POST['id'];
        $kategori = $_POST['kategoribencana'];
        $kepalaoperasi = $_POST['kepalaoperasi'];
        $kepalaoperasii = $_POST['kepalaoperasii'];

        $query = $db->informasi_bencana;
        $queryy = $db->user;
        $queryyy = $db->pegawai;
        if ($kategori == "Bencana Besar") {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasi.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasi, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasi.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasi.').

';
        }
        }
        }
        }
        } elseif ($kategori == "Bencana Kecil"){
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasii.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasii, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasii.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasii.').

';
        }
        }
        }
        }
        } else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim.

';
        }
        }
        $key = md5('vxcygnusloiv');
        function decrypt($string, $key){
        $string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB));
        return $string;
        }
        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');
        $query = $db->informasi_bencana;
        $cursor=$query->find(array("_id"=>new MongoId($_GET['id'])));
        foreach($cursor as $id=>$doc){
        if (decrypt($doc['jenis_kejadian'], $key) == "" || decrypt($doc['lokasi_kejadian'], $key) == "" || decrypt($doc['no_telp_lain'], $key) == "" || decrypt($doc['catatan'], $key) == "") {
        $status = "disabled";
        }else{
        $status = "";
        }
        ?>

 Form Pembuatan Berita SAR

                                <form class="form-signin" action="" method="post">

                                            Waktu Kejadian:<input type="hidden" name="id" value="<?php echo $doc['_id']; ?>"/>
                                            <input type="text" class="form-control" name="waktulaporan" value="<?php echo date('Y/m/d, H:i', $doc['waktu_laporan']->sec); ?>" disabled/>

                                            Nama Pelapor:
                                            <input type="text" class="form-control" name="namapelapor" value="<?php echo decrypt($doc['nama_pelapor'], $key); ?>" disabled/>

                                            No Telepon Pelapor:
                                            <input type="text" class="form-control" name="notelp" value="<?php echo decrypt($doc['no_telp'], $key); ?>" disabled/>

                                            Jenis Kejadian:
                                            <input type="text" class="form-control" name="jeniskejadian" value="<?php echo decrypt($doc['jenis_kejadian'], $key); ?>" disabled/>

                                            Lokasi Kejadian:
                                            <input type="text" class="form-control" name="lokasikejadian" value="<?php echo decrypt($doc['lokasi_kejadian'], $key); ?>" disabled/>

                                            No Telepon Lain Yang Bisa Dihubungi:
                                            <input type="text" class="form-control" name="notelplain" value="<?php echo decrypt($doc['no_telp_lain'], $key); ?>" disabled/>

                                            Catatan Tambahan:
                                            <textarea class="form-control" rows="3" name="catatan" disabled><?php echo decrypt($doc['catatan'], $key); ?></textarea>

                                            Kategori Bencana:
                                            <select class="form-control" name="kategoribencana" onchange="kategori(this);" required>
                                                <option value=""></option>
                                                <option value="Bencana Besar">Bencana Besar</option>
                                                <option value="Bencana Kecil">Bencana Kecil</option>
                                            </select>

<input type="hidden" name="kepalaoperasi" value="Kantor Pusat BASARNAS"/>
                                            <input type="text" class="form-control" value="Kantor Pusat BASARNAS" disabled/>

                                            Pilih Kantor SAR:
                                            <select class="form-control" name="kepalaoperasii" required>
                                                <option value="Kantor SAR Daerah Aceh">Kantor SAR Daerah Aceh</option>
                                                <option value="Kantor SAR Daerah Medan">Kantor SAR Daerah Medan</option>
                                                <option value="Kantor SAR Daerah Padang">Kantor SAR Daerah Padang</option>
                                                <option value="Kantor SAR Daerah Pekanbaru">Kantor SAR Daerah Pekanbaru</option>
                                                <option value="Kantor SAR Daerah Jambi">Kantor SAR Daerah Jambi</option>
                                                <option value="Kantor SAR Daerah Tanjung Pinang">Kantor SAR Daerah Tanjung Pinang</option>
                                                <option value="Kantor SAR Daerah Pangkal Pinang">Kantor SAR Daerah Pangkal Pinang</option>
                                                <option value="Kantor SAR Daerah Bengkulu">Kantor SAR Daerah Bengkulu</option>
                                                <option value="Kantor SAR Daerah Palembang">Kantor SAR Daerah Palembang</option>
                                                <option value="Kantor SAR Daerah Lampung">Kantor SAR Daerah Lampung</option>
                                                <option value="Kantor SAR Daerah Jakarta">Kantor SAR Daerah Jakarta</option>
                                                <option value="Kantor SAR Daerah Bandung">Kantor SAR Daerah Bandung</option>
                                                <option value="Kantor SAR Daerah Semarang">Kantor SAR Daerah Semarang</option>
                                                <option value="Kantor SAR Daerah Surabaya">Kantor SAR Daerah Surabaya</option>
                                                <option value="Kantor SAR Daerah Denpasar">Kantor SAR Daerah Denpasar</option>
                                                <option value="Kantor SAR Daerah Mataram">Kantor SAR Daerah Mataram</option>
                                                <option value="Kantor SAR Daerah Kupang">Kantor SAR Daerah Kupang</option>
                                                <option value="Kantor SAR Daerah Banjarmasin">Kantor SAR Daerah Banjarmasin</option>
                                                <option value="Kantor SAR Daerah Balikpapan">Kantor SAR Daerah Balikpapan</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                                <option value="Kantor SAR Daerah Pontianak">Kantor SAR Daerah Pontianak</option>
                                                <option value="Kantor SAR Daerah Palu">Kantor SAR Daerah Palu</option>
                                                <option value="Kantor SAR Daerah Makassar">Kantor SAR Daerah Makassar</option>
                                                <option value="Kantor SAR Daerah Kendari">Kantor SAR Daerah Kendari</option>
                                                <option value="Kantor SAR Daerah Ternate">Kantor SAR Daerah Ternate</option>
                                                <option value="Kantor SAR Daerah Ambon">Kantor SAR Daerah Ambon</option>
                                                <option value="Kantor SAR Daerah Jayapura">Kantor SAR Daerah Jayapura</option>
                                                <option value="Kantor SAR Daerah Sorong">Kantor SAR Daerah Sorong</option>
                                                <option value="Kantor SAR Daerah Biak">Kantor SAR Daerah Biak</option>
                                                <option value="Kantor SAR Daerah Timika">Kantor SAR Daerah Timika</option>
                                                <option value="Kantor SAR Daerah Manokwari">Kantor SAR Daerah Manokwari</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                            </select>

                                                    Upload Dokumen Foto Pendukung

0%

Drag & Drop Photos Here

                                    <button class="btn btn-primary" name="submit" <?php echo $status;?>>Kirim Berita </button>

                                </form>

                                <?php } ?>

 Informasi Pengiriman Berita SAR

Jika tombol (Kirim Berita) dalam keadaan "disabled" maka pastikan untuk mengisi semua kolom data informasi bencana secara lengkap. Karena syarat untuk pengiriman berita SAR diharuskan untuk mengisi
                                    form secara lengkap meskipun pada catatan tambahan tidak ada yang perlu untuk diisi tetapi usahakan untuk mengisinya seperti "Tidak ada". Untuk mengisi kolom data informasi bencana yang belum diisi dapat menuju link ini <?php echo "" ?>Edit Informasi Bencana

```

答:
If you observe in the page the body class throws a unique class for the page.
Taking the body class as your reference to the ul li that you are going to style the margin-bottom:0,
as for eg;

```<code><body class="page-class">
</code>```

you can take the page class of the body and style your ul li as per your desire.

```<code>.page-class ul li{
    margin-bottom:0;
 }
</code>```

Body:
Here is my style:

And I want to control

ul li {
          list-style:none;
          margin-bottom:25px;
      }

without making change for my default page. margin-bottom must be 0px
And here is my ul li

Is it possible to change margin-bottom:0px through given class to ul li ? I've read the reference css style change just for one page but I don't know how to implement its code. That's why I ask a question for this.
Here is the page while margin-bottom:0px

Here is the page while margin-bottom:25px

I want to fix the picture with margin-bottom:25px but I don't want to change totally of the page.
Here's full of my script page:

<!DOCTYPE html>
<?php include('akses.php'); ?>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Basarnas</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">

    <link href="../css/sb-admin.css" rel="stylesheet">

    <link href="../font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    Toggle navigation

                </button>
                Operator Komunikasi

                     <?php echo $_SESSION['operatorkomunikasi']; ?>

                             Settings

                             Log Out

                         Home

                         Informasi Bencana

                         Monitoring Operasi SAR

    Direktorat Operasi dan Latihan
                  BASARNAS

                            Data Informasi Bencana

                                  List Informasi Bencana

                                 Berita SAR

        <?php  if (isset($_POST['submit'])) {
        $key = md5('vxcygnusloiv');
        function encrypt($string, $key){
        $string = rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB)));
        return $string;
        }

        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');

        $id = $_POST['id'];
        $kategori = $_POST['kategoribencana'];
        $kepalaoperasi = $_POST['kepalaoperasi'];
        $kepalaoperasii = $_POST['kepalaoperasii'];

        $query = $db->informasi_bencana;
        $queryy = $db->user;
        $queryyy = $db->pegawai;
        if ($kategori == "Bencana Besar") {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasi.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasi, $key), "level"=>encrypt("Kepala Kantor Pusat BASARNAS", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasi, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasi.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasi.').

';
        }
        }
        }
        }
        } elseif ($kategori == "Bencana Kecil"){
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        $nResults = $cursor->count();
        if ($nResults == 0){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim karena tidak ada yang menjabat sebagai (Kepala '.$kepalaoperasii.').

';
        }else {
        $cursor=$queryy->find(array("kantor"=>encrypt($kepalaoperasii, $key), "level"=>encrypt("Kepala Kantor SAR Daerah", $key)));
        foreach($cursor as $doc){
        $selected = array('_id'=> new MongoId($doc['idpegawai']));
        $cursorr=$queryyy->find($selected);
        foreach($cursorr as $docc){
        $nip_kepala = decrypt($docc['nip'], $key);
        $nama_kepala = decrypt($docc['nama'], $key);
        $query->update(array("_id"=>new MongoId($id)), array('$set'=>array("status"=>encrypt("berita", $key), "status_berita"=>encrypt("Pending Berita SAR", $key), "kategori"=>encrypt($kategori, $key), "smc"=>encrypt($kepalaoperasii, $key), "nip_kepala"=>encrypt($nip_kepala, $key), "nama_kepala"=>encrypt($nama_kepala, $key), "chat_pusat_daerah"=>encrypt("", $key), "status_chat_pusat"=>0, "status_chat_daerah"=>0)));
        if ($query){
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR berhasil dikirim ke ('.$kepalaoperasii.').

';
        }else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim ke ('.$kepalaoperasii.').

';
        }
        }
        }
        }
        } else {
        echo '

              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
               Berita SAR gagal dikirim.

';
        }
        }
        $key = md5('vxcygnusloiv');
        function decrypt($string, $key){
        $string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB));
        return $string;
        }
        $conn = new Mongo();
        $db = $conn->selectDB('basarnas');
        $query = $db->informasi_bencana;
        $cursor=$query->find(array("_id"=>new MongoId($_GET['id'])));
        foreach($cursor as $id=>$doc){
        if (decrypt($doc['jenis_kejadian'], $key) == "" || decrypt($doc['lokasi_kejadian'], $key) == "" || decrypt($doc['no_telp_lain'], $key) == "" || decrypt($doc['catatan'], $key) == "") {
        $status = "disabled";
        }else{
        $status = "";
        }
        ?>

 Form Pembuatan Berita SAR

                                <form class="form-signin" action="" method="post">

                                            Waktu Kejadian:<input type="hidden" name="id" value="<?php echo $doc['_id']; ?>"/>
                                            <input type="text" class="form-control" name="waktulaporan" value="<?php echo date('Y/m/d, H:i', $doc['waktu_laporan']->sec); ?>" disabled/>

                                            Nama Pelapor:
                                            <input type="text" class="form-control" name="namapelapor" value="<?php echo decrypt($doc['nama_pelapor'], $key); ?>" disabled/>

                                            No Telepon Pelapor:
                                            <input type="text" class="form-control" name="notelp" value="<?php echo decrypt($doc['no_telp'], $key); ?>" disabled/>

                                            Jenis Kejadian:
                                            <input type="text" class="form-control" name="jeniskejadian" value="<?php echo decrypt($doc['jenis_kejadian'], $key); ?>" disabled/>

                                            Lokasi Kejadian:
                                            <input type="text" class="form-control" name="lokasikejadian" value="<?php echo decrypt($doc['lokasi_kejadian'], $key); ?>" disabled/>

                                            No Telepon Lain Yang Bisa Dihubungi:
                                            <input type="text" class="form-control" name="notelplain" value="<?php echo decrypt($doc['no_telp_lain'], $key); ?>" disabled/>

                                            Catatan Tambahan:
                                            <textarea class="form-control" rows="3" name="catatan" disabled><?php echo decrypt($doc['catatan'], $key); ?></textarea>

                                            Kategori Bencana:
                                            <select class="form-control" name="kategoribencana" onchange="kategori(this);" required>
                                                <option value=""></option>
                                                <option value="Bencana Besar">Bencana Besar</option>
                                                <option value="Bencana Kecil">Bencana Kecil</option>
                                            </select>

<input type="hidden" name="kepalaoperasi" value="Kantor Pusat BASARNAS"/>
                                            <input type="text" class="form-control" value="Kantor Pusat BASARNAS" disabled/>

                                            Pilih Kantor SAR:
                                            <select class="form-control" name="kepalaoperasii" required>
                                                <option value="Kantor SAR Daerah Aceh">Kantor SAR Daerah Aceh</option>
                                                <option value="Kantor SAR Daerah Medan">Kantor SAR Daerah Medan</option>
                                                <option value="Kantor SAR Daerah Padang">Kantor SAR Daerah Padang</option>
                                                <option value="Kantor SAR Daerah Pekanbaru">Kantor SAR Daerah Pekanbaru</option>
                                                <option value="Kantor SAR Daerah Jambi">Kantor SAR Daerah Jambi</option>
                                                <option value="Kantor SAR Daerah Tanjung Pinang">Kantor SAR Daerah Tanjung Pinang</option>
                                                <option value="Kantor SAR Daerah Pangkal Pinang">Kantor SAR Daerah Pangkal Pinang</option>
                                                <option value="Kantor SAR Daerah Bengkulu">Kantor SAR Daerah Bengkulu</option>
                                                <option value="Kantor SAR Daerah Palembang">Kantor SAR Daerah Palembang</option>
                                                <option value="Kantor SAR Daerah Lampung">Kantor SAR Daerah Lampung</option>
                                                <option value="Kantor SAR Daerah Jakarta">Kantor SAR Daerah Jakarta</option>
                                                <option value="Kantor SAR Daerah Bandung">Kantor SAR Daerah Bandung</option>
                                                <option value="Kantor SAR Daerah Semarang">Kantor SAR Daerah Semarang</option>
                                                <option value="Kantor SAR Daerah Surabaya">Kantor SAR Daerah Surabaya</option>
                                                <option value="Kantor SAR Daerah Denpasar">Kantor SAR Daerah Denpasar</option>
                                                <option value="Kantor SAR Daerah Mataram">Kantor SAR Daerah Mataram</option>
                                                <option value="Kantor SAR Daerah Kupang">Kantor SAR Daerah Kupang</option>
                                                <option value="Kantor SAR Daerah Banjarmasin">Kantor SAR Daerah Banjarmasin</option>
                                                <option value="Kantor SAR Daerah Balikpapan">Kantor SAR Daerah Balikpapan</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                                <option value="Kantor SAR Daerah Pontianak">Kantor SAR Daerah Pontianak</option>
                                                <option value="Kantor SAR Daerah Palu">Kantor SAR Daerah Palu</option>
                                                <option value="Kantor SAR Daerah Makassar">Kantor SAR Daerah Makassar</option>
                                                <option value="Kantor SAR Daerah Kendari">Kantor SAR Daerah Kendari</option>
                                                <option value="Kantor SAR Daerah Ternate">Kantor SAR Daerah Ternate</option>
                                                <option value="Kantor SAR Daerah Ambon">Kantor SAR Daerah Ambon</option>
                                                <option value="Kantor SAR Daerah Jayapura">Kantor SAR Daerah Jayapura</option>
                                                <option value="Kantor SAR Daerah Sorong">Kantor SAR Daerah Sorong</option>
                                                <option value="Kantor SAR Daerah Biak">Kantor SAR Daerah Biak</option>
                                                <option value="Kantor SAR Daerah Timika">Kantor SAR Daerah Timika</option>
                                                <option value="Kantor SAR Daerah Manokwari">Kantor SAR Daerah Manokwari</option>
                                                <option value="Kantor SAR Daerah Merauke">Kantor SAR Daerah Merauke</option>
                                            </select>

                                                    Upload Dokumen Foto Pendukung

0%

Drag & Drop Photos Here

                                    <button class="btn btn-primary" name="submit" <?php echo $status;?>>Kirim Berita </button>

                                </form>

                                <?php } ?>

 Informasi Pengiriman Berita SAR

Jika tombol (Kirim Berita) dalam keadaan "disabled" maka pastikan untuk mengisi semua kolom data informasi bencana secara lengkap. Karena syarat untuk pengiriman berita SAR diharuskan untuk mengisi
                                    form secara lengkap meskipun pada catatan tambahan tidak ada yang perlu untuk diisi tetapi usahakan untuk mengisinya seperti "Tidak ada". Untuk mengisi kolom data informasi bencana yang belum diisi dapat menuju link ini <?php echo "" ?>Edit Informasi Bencana

Body:
If you observe in the page the body class throws a unique class for the page.
Taking the body class as your reference to the ul li that you are going to style the margin-bottom:0,
as for eg;

<body class="page-class">

you can take the page class of the body and style your ul li as per your desire.

.page-class ul li{
    margin-bottom:0;
 }


问:
Multiple 'having' clauses blows up Rails 3 / Arel
I think I've found a bug in Rails 3 / Arel, but I'm hoping someone can clarify my problem before I try and fix it and/or submit a bug report.

On a very simple app, with a Question model: (submitter_id: integer, option_count: integer)

The code that I'm using:

```<code>q = Question.where(:submitter_id => 1)
q = q.having(['option_sum > ?', 5])
q = q.having(['option_sum < ?', 10])
q = q.select("#{Question.table_name}.*, MAX(#{Question.table_name}.option_count) AS option_sum")
q.to_sql
q
</code>```

This blows up with:

```<code>ArgumentError: wrong number of arguments (2 for 1)
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/arel-f092ae544f58/lib/arel/select_manager.rb:94:in `having'
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/rails-76053fe4d12b/activerecord/lib/active_record/relation/query_methods.rb:193:in `build_arel'
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/rails-76053fe4d12b/activerecord/lib/active_record/relation/query_methods.rb:162:in `arel'
</code>```

Taking out one of the 'having' clauses fixes the issue, and generates the proper SQL.

Any comments would be appreciated. Arel and Rails 3 are edge versions, with revisions as listed in the error above.

答:
Sometimes Arel gives similar error, when scope operators are not in SQL-like order, for example try to invoke select("..") before havings. Also, I'm not sure, that multiple havings are allowed in such requests, so try
q = q.having(['(option_sum > ? AND option_sum < ?)', 5, 10])</p>

ContentLicense: CC BY-SA 2.5

Body:
I think I've found a bug in Rails 3 / Arel, but I'm hoping someone can clarify my problem before I try and fix it and/or submit a bug report.

On a very simple app, with a Question model: (submitter_id: integer, option_count: integer)

The code that I'm using:

q = Question.where(:submitter_id => 1)
q = q.having(['option_sum > ?', 5])
q = q.having(['option_sum < ?', 10])
q = q.select("#{Question.table_name}.*, MAX(#{Question.table_name}.option_count) AS option_sum")
q.to_sql
q

This blows up with:

ArgumentError: wrong number of arguments (2 for 1)
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/arel-f092ae544f58/lib/arel/select_manager.rb:94:in `having'
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/rails-76053fe4d12b/activerecord/lib/active_record/relation/query_methods.rb:193:in `build_arel'
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/rails-76053fe4d12b/activerecord/lib/active_record/relation/query_methods.rb:162:in `arel'

Taking out one of the 'having' clauses fixes the issue, and generates the proper SQL.

Any comments would be appreciated. Arel and Rails 3 are edge versions, with revisions as listed in the error above.


Title: How to substring a given string with specific rules in java

Body:
This is my code and it is showing error at while.Index out of bound exception is coming.The substrings should be such that

Max 50 characters per string

No number should be broken - for example " 4318, 4466, 486," is acceptable but  " 4318, 4466, 48" is not

Substring should always start with one space and end with comma ","

can someone help me out with this please

 public class MyString {

/**
 * @param args

 */
static String input = " 4318, 4466, 486, 1698, 478, 590, 582, 1594, 486, 1690, 702, 378, 486, 586, 486, 1694, 486, 598, 538, 526, 486, 1694, 486, 622, 434, 630, 462, 1730, 422, 1754, 450, 586, 486, 1690, 498, 1682, 486, 586, 502, 606, 454, 1698, 478, 1694, 486, 1718, 458, 1686, 726, 1458, 646, 426, 486, 1694, 482, 1694, 486, 590, 482, 622, 490, 550, 490, 602, 450, 634, 466, 586, 486, 1730, 426, 1714, 494, 622, 446, 590, 494, 618, 450, 586, 490, 586, 486, 1730, 450, 586, 486, 590, 502, 1674, 530, 1650, 482, 1690, 558, 1622, 486, 1690, 486, 5298, 4306, 4466, 530, 1646, 486, 594, 650, 1502, 546, 1650, 490, 586, 486, 622, 522, 1622, 486, 602, 454, 634, 462, 1694, 482, 590, 486, 590, 486, 1694, 482, 1730, 450, 590, 498, 1638, 526, 1690, 498, 606, 458, 586, 486, 1698, 482, 1694, 482, 1690, 486, 1694, 486, 1698, 574, 494, 486, 1714, 462, 1690, 486, 626, 430, 610, 486, 590, 490, 622, 426, 610, 498, 618, 446, 1690, 486, 1734, 446, 590, 482, 590, 502, 606, 454, 590, 502, 582, 478, 1690, 486, 586, 506, 578, 482, 1686, 558, 1622, 674, 1506, 482, 1698, 590, 1606, 462, 1000";
char space=' ';
 static char comma=',';
public static void main(String[] args) {
    // TODO Auto-generated method stub
    int start=0, end=0;
    while (end-1 < input.length()){

    start=end;
    end= start+ 50;

    String output= input.substring(start,end);
    if(output.charAt(start)==' ' && output.charAt(end-1)==',')
    {
    System.out.println(output);
    }
    else
    {

    while(!(output.charAt(end-1)==','))
    {

    end--;

    }
    output= input.substring(start,end);
    System.out.println(output);

    }
    }
    }

}

Body:
I have made slight modification in your code.

class Ideone {

static String input = " 4318, 4466, 486, 1698, 478, 590, 582, 1594, 486, 1690, 702, 378, 486, 586, 486, 1694, 486, 598, 538, 526, 486, 1694, 486, 622, 434, 630, 462, 1730, 422, 1754, 450, 586, 486, 1690, 498, 1682, 486, 586, 502, 606, 454, 1698, 478, 1694, 486, 1718, 458, 1686, 726, 1458, 646, 426, 486, 1694, 482, 1694, 486, 590, 482, 622, 490, 550, 490, 602, 450, 634, 466, 586, 486, 1730, 426, 1714, 494, 622, 446, 590, 494, 618, 450, 586, 490, 586, 486, 1730, 450, 586, 486, 590, 502, 1674, 530, 1650, 482, 1690, 558, 1622, 486, 1690, 486, 5298, 4306, 4466, 530, 1646, 486, 594, 650, 1502, 546, 1650, 490, 586, 486, 622, 522, 1622, 486, 602, 454, 634, 462, 1694, 482, 590, 486, 590, 486, 1694, 482, 1730, 450, 590, 498, 1638, 526, 1690, 498, 606, 458, 586, 486, 1698, 482, 1694, 482, 1690, 486, 1694, 486, 1698, 574, 494, 486, 1714, 462, 1690, 486, 626, 430, 610, 486, 590, 490, 622, 426, 610, 498, 618, 446, 1690, 486, 1734, 446, 590, 482, 590, 502, 606, 454, 590, 502, 582, 478, 1690, 486, 586, 506, 578, 482, 1686, 558, 1622, 674, 1506, 482, 1698, 590, 1606, 462, 1000";
char space = ' ';
static char comma = ',';

public static void main(String[] args) {
    // TODO Auto-generated method stub
    int start = 0, end = 0;
    int temp = 0;
    while (end < input.length()) {

        start = end;
        end = Math.min(start + 50, input.length());

        String output = input.substring(start, end - 1);
        if (output.charAt(0) == ' ' && output.charAt(output.length() - 1) == ',') {
            System.out.println(output);
            end--;
        } else {
            temp = output.length() - 1;
            while (temp!=-1 && output.charAt(temp) != ',') {
                temp--;
            }
            if(temp==-1)break;
            output = input.substring(start, start + temp + 1);
            System.out.println(output);
            end = start + temp + 1;
        }

    }
}
}

Demo


问:
Jupyter Notebook time profiling
So I installed jupyter notebook through anaconda and I am working on python 3 kernel.

I am trying to do Time profiling using %time magic command as show here
The problem is that it only prints the Wall Time not the CPU Time

using %time or %%time does not help

%time prints the wall time for the first line only

%%time prints the wall time for the whole cell

I am not sure if there any specif config to print the CPU time

EDIT

To clarify using %%time should print two metrics for the whole cell

Metric 1: CPU Times

Metric 2: wall time

my problem is that I only get wall time not CPU time.

You may check this link on what is the expected output for %%time

答:
So it seems that my issue was in the environment itself.

Switching from Windows to Ubuntu actually helped me print the CPU times.

Title: Jupyter Notebook time profiling


问:
Write data on google sheets through android app form
I am new to android and I want to publish my form data which is created in an android app to google sheets. Can anyone help me out with this problem</p>

答: Check this http://codesmith.in/post-data-google-drive-sheet-through-mobile-app/ detailed step by step guide with image screen shot.</p>


问:
Visual studio breakpoint - can I set breakpoint that activate another breakpoint,
Lets say I set a breakpoint with condition, if this break point is hit I want to turn on another breakpoint . Is it possible ? </p>

答:
You can do that manually. If the first breakpoint is hit, the program stops at that breakpoint. Now you can go to Breakpoints Window (Alt-F9) and click on the breakpoint you now want to activate.

Below screenshot has both breakpoints enabled. Click on the checkbox on he left to disable a breakpoint. As an example I have added a condition. To add a condition, right-click on the breakpoint and choose Condition..

As suggested by George, you can have a boolean that is set at the frist breakpoint and use the condition at the 2nd breakpoint to have it break.


问:
What is the replacement of the Bash "source" command in the sh shell?
What is replacement of the source command of bash shell in sh shell?

I was getting an error while executing source in #!/bin/sh.

In #!/bin/bash, it is working well.

答:
It's just dot command .

You can see more here: https://ss64.com/bash/source.html
and even here: https://en.wikipedia.org/wiki/Dot_(command)


问:
sql -changing column attribute to Unique
I have a column of "email" in my table "user". I forget to make email as Unique in starting. Now I have lot of entries in my database and when I tries to change "email" as Unique, it show error "#1062 - Duplicate entry '' for key 'email'".

I do have some users with no email entry which means there are many Null value in column 'email'. How can I make 'email' unique now.

Question: Did unique means it can't contain any null value? Did I need to recreate a new table?

答: you cannot make "email" Unique if there is an email that exist more than one time in your table so first of all you must  delete the duplicated emails than generate dummy emails for the null values  </p>


问:
Smart association of graphs where one is faceted - ggplot2
I want to combine these two graphs :

```<code>p1 <- ggplot(iris, aes(Sepal.Length)) +
  geom_density() +
  facet_wrap(~ Species)

p2 <- ggplot(iris, aes(Sepal.Length)) +
  geom_density()
</code>```

To combine, I do :

```<code>multiplot(p1, p2, cols = 2)
</code>```

But it is not the desired shape.

I would like the graph p2 has the same dimensions than others and is situated just next to the last faceted graph.

Thanks for help

答:
This code should work:

```<code>p1 <- ggplot(iris, aes(Sepal.Length)) +
      geom_density() +
      ylim(limits = c(0, 1.25))+
      facet_wrap(~ Species)

p2 <- ggplot(iris, aes(Sepal.Length)) +
      geom_density() +
      ggtitle("") + # ad empty title as place holder
      labs(y = "", x = "") + # hide axis labels
      ylim(limits = c(0, 1.25)) + # y axis values should be fixed in both plots
      coord_fixed(ratio=20/1) + # ratio of x- and y-axis to reduce width of plot
      theme(axis.ticks.y = element_blank(), axis.text.y = element_blank(), axis.line.y = element_blank(),
      plot.margin=unit(c(0,0,0.65,-10), "lines")) # margin between plots = "0.65"
</code>```

I fiddled a bit and used just different styling options to produce this result. If you have more plots than this one I would recommend to use one theme for all.

You can use either the multiplot function that you are already using

```<code>multiplot(p1, p2, cols = 2)
</code>```

or you install the packages gridExtra and grid and use that one:

```<code>grid.arrange(p1, p2, ncol=2)
</code>```

Hope this helps!

Body:
I want to combine these two graphs :

p1 <- ggplot(iris, aes(Sepal.Length)) +
  geom_density() +
  facet_wrap(~ Species)

p2 <- ggplot(iris, aes(Sepal.Length)) +
  geom_density()

To combine, I do :

multiplot(p1, p2, cols = 2)

But it is not the desired shape.

I would like the graph p2 has the same dimensions than others and is situated just next to the last faceted graph.

Thanks for help

Body:
This code should work:

p1 <- ggplot(iris, aes(Sepal.Length)) +
      geom_density() +
      ylim(limits = c(0, 1.25))+
      facet_wrap(~ Species)

p2 <- ggplot(iris, aes(Sepal.Length)) +
      geom_density() +
      ggtitle("") + # ad empty title as place holder
      labs(y = "", x = "") + # hide axis labels
      ylim(limits = c(0, 1.25)) + # y axis values should be fixed in both plots
      coord_fixed(ratio=20/1) + # ratio of x- and y-axis to reduce width of plot
      theme(axis.ticks.y = element_blank(), axis.text.y = element_blank(), axis.line.y = element_blank(),
      plot.margin=unit(c(0,0,0.65,-10), "lines")) # margin between plots = "0.65"

I fiddled a bit and used just different styling options to produce this result. If you have more plots than this one I would recommend to use one theme for all.

You can use either the multiplot function that you are already using

multiplot(p1, p2, cols = 2)

or you install the packages gridExtra and grid and use that one:

grid.arrange(p1, p2, ncol=2)

Hope this helps!


问:
How to make a loop or "sum" formula in Microsoft Excel?
Say that I gain +5 coins from every room I complete. What I'm trying to do is to make a formula in Excel that gets the total coins I've gotten from the first room to the 100th room.

With C++, I guess it would be something like:

```<code>while (lastRoom > 0)
{
totalCoins = lastRoom*5;
lastRoom--;
}
</code>```

totalCoins, being an array so that you can just output the sum of the array.

So if ever, how do you put this code in excel and get it to work? Or is there any other way to get the total coins?

答:
If I understand you correctly you shouldn't need any special code, just a formula:

```<code>=(C2-A2+1)*B2
</code>```

Where C2 = Nth room, A2 = Previous Room, and B2 = coin reward. You can change A2, B2, or C2 and the formula in D2 will output the result.

Body:
Say that I gain +5 coins from every room I complete. What I'm trying to do is to make a formula in Excel that gets the total coins I've gotten from the first room to the 100th room.

With C++, I guess it would be something like:

while (lastRoom > 0)
{
totalCoins = lastRoom*5;
lastRoom--;
}

totalCoins, being an array so that you can just output the sum of the array.

So if ever, how do you put this code in excel and get it to work? Or is there any other way to get the total coins?

Body:
If I understand you correctly you shouldn't need any special code, just a formula:

=(C2-A2+1)*B2

Where C2 = Nth room, A2 = Previous Room, and B2 = coin reward. You can change A2, B2, or C2 and the formula in D2 will output the result.


问:
set back button title text in iOS Xamarin
I want to set the BackButton Title text to ""(means empty). I am using below code to set the Title but it is not working.

Try 1 :

```<code>this.NavigationItem.BackBarButtonItem = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, null);
</code>```

Try 2 :

```<code>this.NavigationItem.BackBarButtonItem.Title = "";
</code>```

it is give the object is not set to instance.

Is there any way to set the Back button title null in iOS.

Any Help Will be Appreciated.

答:
For the workaround I do simple trick.

before going to new UIViewController set the Title to "". and on Back button press when you come to ViewController inside the ViewDidAppearmethod set the Title again.

Body:
I want to set the BackButton Title text to ""(means empty). I am using below code to set the Title but it is not working.

Try 1 :

this.NavigationItem.BackBarButtonItem = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, null);

Try 2 :

this.NavigationItem.BackBarButtonItem.Title = "";

it is give the object is not set to instance.

Is there any way to set the Back button title null in iOS.

Any Help Will be Appreciated.


问:
How to enable filtering on an ObjectDataSource with FilterExpression when bound to a List<object>.
Does anyone know how to use FilterExpression with an ObjectDataSource when it is bound using a select method that returns a list of entity objects?

I get the following error when I attempt it:

"The data source 'testODS' only supports filtering when the SelectMethod returns a DataSet or a DataTable"

答:
According to MSDN

The ObjectDataSource control supports
  filtering data only when the Select
  method returns a DataSet or DataTable
  object.

So if you want to filter your result set of entities, perhaps you can use a LinqDataSource instead.

```<code><asp:LinqDataSource ID="LinqDataSource1" runat="server"
    ContextTypeName="MyNamespace.MyDataContext"

        Select="new (MyId, MyProperty1, MyCollection1.MyProperty2)"
        TableName="MyTable" Where="MyProperty1.Contains(@PropertyFilter)" >
        <WhereParameters>
            <asp:ControlParameter ControlID="txtPropertyFilter" Name="PropertyFilter"
                PropertyName="Text" Type="String" />
        </WhereParameters>
</asp:LinqDataSource>
</code>```

Body:
According to MSDN

The ObjectDataSource control supports
  filtering data only when the Select
  method returns a DataSet or DataTable
  object.

So if you want to filter your result set of entities, perhaps you can use a LinqDataSource instead.

<asp:LinqDataSource ID="LinqDataSource1" runat="server"
    ContextTypeName="MyNamespace.MyDataContext"

        Select="new (MyId, MyProperty1, MyCollection1.MyProperty2)"
        TableName="MyTable" Where="MyProperty1.Contains(@PropertyFilter)" >
        <WhereParameters>
            <asp:ControlParameter ControlID="txtPropertyFilter" Name="PropertyFilter"
                PropertyName="Text" Type="String" />
        </WhereParameters>
</asp:LinqDataSource>


问:
Cannot launch emulator on Linux (Ubuntu 15.10)
I try to launch emulator but it outputs into log:

```<code>libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
Major opcode of failed request:  155 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request:  47
Current serial number in output stream:  46
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
Major opcode of failed request:  155 (GLX)
Minor opcode of failed request:  6 (X_GLXIsDirect)
Serial number of failed request:  47
Current serial number in output stream:  46
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
Major opcode of failed request:  155 (GLX)
Minor opcode of failed request:  24 (X_GLXCreateNewContext)
Value in failed request:  0x0
Serial number of failed request:  33
Current serial number in output stream:  34
QObject::~QObject: Timers cannot be stopped from another thread emulator: WARNING: Increasing RAM size to 1GB
</code>```

How to fix it? I read topics with similar errors but it doesn't help me.

答:
In my case (Ubuntu 16.10 64-bit, Android Studio 2.3) libs were located in another place. So commands are:

```<code>/home/myusername/Android/Sdk/emulator/lib64/libstdc++

➜  libstdc++ ll
total 9,3M
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.0.18

➜  libstdc++ mv libstdc++.so.6 libstdc++.so.6.bak
➜  libstdc++ mv libstdc++.so.6.0.18 libstdc++.so.6.0.18.bak
➜  libstdc++ ln -s /usr/lib32/libstdc++.so.6 /home/myusername/Android/Sdk/emulator/lib64/libstdc++
➜  libstdc++ ln -s /usr/lib32/libstdc++.so.6.0.22 /home/myusername/Android/Sdk/emulator/lib64/libstdc++

➜  libstdc++ ll
total 9,3M
lrwxrwxrwx 1 myusername myusername   25 мар 29 13:18 libstdc++.so.6 -> /usr/lib32/libstdc++.so.6
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.0.18.bak
lrwxrwxrwx 1 myusername myusername   30 мар 29 13:19 libstdc++.so.6.0.22 -> /usr/lib32/libstdc++.so.6.0.22
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.bak
</code>```

And now emulator is launched from AVD manager normally.

Body:
I try to launch emulator but it outputs into log:

libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
Major opcode of failed request:  155 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request:  47
Current serial number in output stream:  46
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
Major opcode of failed request:  155 (GLX)
Minor opcode of failed request:  6 (X_GLXIsDirect)
Serial number of failed request:  47
Current serial number in output stream:  46
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
Major opcode of failed request:  155 (GLX)
Minor opcode of failed request:  24 (X_GLXCreateNewContext)
Value in failed request:  0x0
Serial number of failed request:  33
Current serial number in output stream:  34
QObject::~QObject: Timers cannot be stopped from another thread emulator: WARNING: Increasing RAM size to 1GB

How to fix it? I read topics with similar errors but it doesn't help me.

Body:
In my case (Ubuntu 16.10 64-bit, Android Studio 2.3) libs were located in another place. So commands are:

/home/myusername/Android/Sdk/emulator/lib64/libstdc++

➜  libstdc++ ll
total 9,3M
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.0.18

➜  libstdc++ mv libstdc++.so.6 libstdc++.so.6.bak
➜  libstdc++ mv libstdc++.so.6.0.18 libstdc++.so.6.0.18.bak
➜  libstdc++ ln -s /usr/lib32/libstdc++.so.6 /home/myusername/Android/Sdk/emulator/lib64/libstdc++
➜  libstdc++ ln -s /usr/lib32/libstdc++.so.6.0.22 /home/myusername/Android/Sdk/emulator/lib64/libstdc++

➜  libstdc++ ll
total 9,3M
lrwxrwxrwx 1 myusername myusername   25 мар 29 13:18 libstdc++.so.6 -> /usr/lib32/libstdc++.so.6
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.0.18.bak
lrwxrwxrwx 1 myusername myusername   30 мар 29 13:19 libstdc++.so.6.0.22 -> /usr/lib32/libstdc++.so.6.0.22
-rwxr-xr-x 1 myusername myusername 4,6M мар 21 00:09 libstdc++.so.6.bak

And now emulator is launched from AVD manager normally.


问:
How are Windows symbolic links treated by the apps?
I thought that symbolic links in Windows 10 behave similarly to Linux symlinks, i.e., they are transparent to the apps. However, I'm confused by the actual behavior.

As an example, I've both softlinked and hardlinked the same CSS file:

```<code>$ mklink softlinked.css Default.css
symbolic link created for softlinked.css <<===>> Default.css

$ mklink /H hardlinked.css Default.css
Hardlink created for hardlinked.css <<===>> Default.css
</code>```

The hardlink behaves predictably (is indistinguishable from the original file) but I don't understand the soft linked one. See for example this:

Also, when the CSS is consumed by the Caret editor, the hardlinked stylesheet works fine:

while the softlinked is broken:

The questions are:

How do the symbolic links actually behave on Windows?

Can soft links be made transparent to the apps? By transparent, I mean the app would always see the file as being on the symlinked path (...\symlinked.css) and never resolve to the original path (...\Default.css). Is there some Windows registry settings or something?

答:
A file is a pointer to a certain node.

When you create a hard link you are just making a new file that points to the same node as the original file.

When you create a soft link you are not making a pointer to a node, but to a file. Because of that soft link resolves it's path to the file it points to.

Since symlink contains both it's own path and path it points to it really depends on application developers to choose which path they want to put in their UI.

Body:
I thought that symbolic links in Windows 10 behave similarly to Linux symlinks, i.e., they are transparent to the apps. However, I'm confused by the actual behavior.

As an example, I've both softlinked and hardlinked the same CSS file:

$ mklink softlinked.css Default.css
symbolic link created for softlinked.css <<===>> Default.css

$ mklink /H hardlinked.css Default.css
Hardlink created for hardlinked.css <<===>> Default.css

The hardlink behaves predictably (is indistinguishable from the original file) but I don't understand the soft linked one. See for example this:

Also, when the CSS is consumed by the Caret editor, the hardlinked stylesheet works fine:

while the softlinked is broken:

The questions are:

How do the symbolic links actually behave on Windows?

Can soft links be made transparent to the apps? By transparent, I mean the app would always see the file as being on the symlinked path (...\symlinked.css) and never resolve to the original path (...\Default.css). Is there some Windows registry settings or something?


问:
r.js leads to: Evaluating ./lib/jquery.js as module "jquery" failed with error: TypeError: Cannot read property 'createElement' of undefined
I am trying to use r.js on my code which uses jQuery. But it fails while evaluating jQuery.

This is the error message I get:

$ r.js init-edx-machine.js
  /usr/local/lib/node_modules/requirejs/bin/r.js:393
          throw err;
          ^

Error: Evaluating ./lib/jquery.js as module "jquery" failed with error: TypeError: Cannot read property 'createElement' of undefined
      at Function.req.load (/usr/local/lib/node_modules/requirejs/bin/r.js:2571:23)
      at Object.load (/usr/local/lib/node_modules/requirejs/bin/r.js:1935:21)
      at Module.load (/usr/local/lib/node_modules/requirejs/bin/r.js:1084:29)
      at Module.fetch (/usr/local/lib/node_modules/requirejs/bin/r.js:1074:66)
      at Module.check (/usr/local/lib/node_modules/requirejs/bin/r.js:1106:30)
      at Module.enable (/usr/local/lib/node_modules/requirejs/bin/r.js:1426:22)
      at Object.enable (/usr/local/lib/node_modules/requirejs/bin/r.js:1807:39)
      at Module. (/usr/local/lib/node_modules/requirejs/bin/r.js:1411:33)
      at /usr/local/lib/node_modules/requirejs/bin/r.js:384:23
      at each (/usr/local/lib/node_modules/requirejs/bin/r.js:309:31)

I've searched for "createElement" in jquery.js. Most of the time it uses document. Sometimes it uses variables which are given through parameters.

The jQuery version is 2.1.4. I checked newer versions, they do it the same.

I really have no clue what is going on here. What can I do now?

答:
Using r.js without an option will make it want to execute your code, which is what happens here. You can an error because there's no document available globally by default in Node.js (contrarily to browsers), and thus the code fails.

To perform an optimization, you need to pass the -o argument: r.js -o ...