问:
How can I get a value of an action class from another
I have two action classes

```<code>public class TokenAction extends Action {
    private ActionForward getToken(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        String token = generateToken();
        response.setContentType("text/plain");
        response.getWriter().print(token);

        return null;
    }
</code>```

and

```<code>public class ActionTwo extends Action{
    private ActionForward doSomething(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response)  {
        token = ???
        return actionMapping.findForward("page");
    }

}
</code>```

How can I get in ActionTwo from TokenAction?

答:
Basically, in Java there are multiple ways to pass objects across contexts, the most popular being likely:

through static variables (not recommended)

through shared parameter maps

through a controller object

In your case, since the parameters passed to the methods seem to have a lifetime that encompasses both calls (although it's hard to say without the specifics), you should probably store them in the parameters (HttpServletResponse isn't very useful for that purpose, but the ActionMapping and ActionForm likely are). If your Actions are created in the context of some controller, you could use the controller to pass the parameter instead.

Body:
I have two action classes

public class TokenAction extends Action {
    private ActionForward getToken(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        String token = generateToken();
        response.setContentType("text/plain");
        response.getWriter().print(token);

        return null;
    }

and

public class ActionTwo extends Action{
    private ActionForward doSomething(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response)  {
        token = ???
        return actionMapping.findForward("page");
    }

}

How can I get in ActionTwo from TokenAction?


来源: stackexchange

问:
Keeping pages inside an iframe
I am trying to put a website inside an iframe, but this code on the site keeps changing the window of the page. Is there anyway I can get around this? Or better yet, can I disable javascript in an iframe?</p>

```<code>if(top!=self){
  if(top.location)
    top.location=self.location;
  else
    top.location='http://example.com/not_subframe.html';
}
</code>```

答: iFrames have a variety of security features to try to block what you're doing.</p>

ContentLicense: CC BY-SA 2.5

Title: Keeping pages inside an iframe

Body:
I am trying to put a website inside an iframe, but this code on the site keeps changing the window of the page. Is there anyway I can get around this? Or better yet, can I disable javascript in an iframe?

if(top!=self){
  if(top.location)
    top.location=self.location;
  else
    top.location='http://example.com/not_subframe.html';
}


问:
How to color EXTJS 6.2 modern grid row

I'm facing an issue. I'm building an EXTJ 6.2 modern app with Sencha architect 4.1. I'm using the grid component in my panel with a server loaded store. I'd like to color rows according to the data I have.

In classic, this is doable with

```<code>viewConfig: {
  forceFit: true,
  getRowClass: function(record, rowIndex, p, store) {
     //some if statement here
}
</code>```

I tried this in modern but it doesn't work. Does anyone know of another way or a hack that I could do color the rows? Or at best at least change the one-color background.

I'd really like to avoid using the list component if possible.

答:
In modern you can use itemConfig to configure Ext.grid.Row.

Add the code bellow to a Sencha Fiddle:

```<code> Ext.application({
name : 'Fiddle',

launch : function() {
    var store = Ext.create('Ext.data.Store', {
fields: ['name', 'email', 'phone'],
data: [
    { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224", color: "blue"  },
    { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234", color: "green" },
    { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244", color: "yellow" },
    { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254", color: "red" }
]
});

Ext.create('Ext.grid.Grid', {
title: 'Simpsons',

variableHeights: true,

store: store,

itemConfig: {
    listeners: {
        painted: function (row) {
            var record = row.getRecord();
            var color = record.get('color');

            row.setStyle('background: '+color)

            //if (color == 'red')
                //row.setStyle('background: red');
        }
    }
},

columns: [
    {
        text: 'Name',
        dataIndex: 'name',
        minWidth: 200,
        //flex: 1,
        //cellWrap: true,
        cell: {
            bodyStyle: {
                whiteSpace: 'normal'
            }
        }
    },
    {
        text: 'Email',
        dataIndex: 'email',
        flex: 2,
        minWidth: 250

    },
    {
        text: 'Phone',
        dataIndex: 'phone',
        flex: 1,
        minWidth: 120
    },
    {
        text: 'Color',
        dataIndex: 'color',
        flex: 1
    }
],

//height: 200,
//layout: 'fit',
fullscreen: true
});
}
});
</code>```

the itemConfig part is what will do the trick.

After @Gwynge's comment i've created another example setting the color to each cell using the renderer config:

```<code>Ext.application({
name : 'Fiddle',

launch : function() {
    var store = Ext.create('Ext.data.Store', {
fields: ['name', 'email', 'phone'],
data: [
    { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224", color: "blue"  },
    { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234", color: "green" },
    { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244", color: "yellow" },
    { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254", color: "red" }
]
});

Ext.create('Ext.grid.Grid', {
title: 'Simpsons',

variableHeights: true,

store: store,

columns: [
    {
        text: 'Name',
        dataIndex: 'name',
        minWidth: 200,
        //flex: 1,
        //cellWrap: true,
        cell: {
            bodyStyle: {
                whiteSpace: 'normal'
            }
        },
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    },
    {
        text: 'Email',
        dataIndex: 'email',
        flex: 2,
        minWidth: 250,
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    },
    {
        text: 'Phone',
        dataIndex: 'phone',
        flex: 1,
        minWidth: 120,
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    },
    {
        text: 'Color',
        dataIndex: 'color',
        flex: 1,
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    }
],

//height: 200,
//layout: 'fit',
fullscreen: true
});
}
});
</code>```

I hope this will help.

ContentLicense: CC BY-SA 4.0

Title: How to color EXTJS 6.2 modern grid row

Body:
I'm facing an issue. I'm building an EXTJ 6.2 modern app with Sencha architect 4.1. I'm using the grid component in my panel with a server loaded store. I'd like to color rows according to the data I have.

In classic, this is doable with

viewConfig: {
  forceFit: true,
  getRowClass: function(record, rowIndex, p, store) {
     //some if statement here
}

I tried this in modern but it doesn't work. Does anyone know of another way or a hack that I could do color the rows? Or at best at least change the one-color background.

I'd really like to avoid using the list component if possible.

Body:
In modern you can use itemConfig to configure Ext.grid.Row.

Add the code bellow to a Sencha Fiddle:

 Ext.application({
name : 'Fiddle',

launch : function() {
    var store = Ext.create('Ext.data.Store', {
fields: ['name', 'email', 'phone'],
data: [
    { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224", color: "blue"  },
    { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234", color: "green" },
    { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244", color: "yellow" },
    { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254", color: "red" }
]
});

Ext.create('Ext.grid.Grid', {
title: 'Simpsons',

variableHeights: true,

store: store,

itemConfig: {
    listeners: {
        painted: function (row) {
            var record = row.getRecord();
            var color = record.get('color');

            row.setStyle('background: '+color)

            //if (color == 'red')
                //row.setStyle('background: red');
        }
    }
},

columns: [
    {
        text: 'Name',
        dataIndex: 'name',
        minWidth: 200,
        //flex: 1,
        //cellWrap: true,
        cell: {
            bodyStyle: {
                whiteSpace: 'normal'
            }
        }
    },
    {
        text: 'Email',
        dataIndex: 'email',
        flex: 2,
        minWidth: 250

    },
    {
        text: 'Phone',
        dataIndex: 'phone',
        flex: 1,
        minWidth: 120
    },
    {
        text: 'Color',
        dataIndex: 'color',
        flex: 1
    }
],

//height: 200,
//layout: 'fit',
fullscreen: true
});
}
});

the itemConfig part is what will do the trick.

After @Gwynge's comment i've created another example setting the color to each cell using the renderer config:

Ext.application({
name : 'Fiddle',

launch : function() {
    var store = Ext.create('Ext.data.Store', {
fields: ['name', 'email', 'phone'],
data: [
    { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224", color: "blue"  },
    { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234", color: "green" },
    { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244", color: "yellow" },
    { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254", color: "red" }
]
});

Ext.create('Ext.grid.Grid', {
title: 'Simpsons',

variableHeights: true,

store: store,

columns: [
    {
        text: 'Name',
        dataIndex: 'name',
        minWidth: 200,
        //flex: 1,
        //cellWrap: true,
        cell: {
            bodyStyle: {
                whiteSpace: 'normal'
            }
        },
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    },
    {
        text: 'Email',
        dataIndex: 'email',
        flex: 2,
        minWidth: 250,
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    },
    {
        text: 'Phone',
        dataIndex: 'phone',
        flex: 1,
        minWidth: 120,
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    },
    {
        text: 'Color',
        dataIndex: 'color',
        flex: 1,
        renderer: function(value, record, dataIndex, cell) {
           cell.setStyle('background: '+record.get('color')+';')
           return value;
        }
    }
],

//height: 200,
//layout: 'fit',
fullscreen: true
});
}
});

I hope this will help.


问:
how to disable direct access to a web site by ip address
I have a website on a VPS.

The issue I am having is that when I enter the IP of the server, it links to the website.

Even when entering mail.domain.com, it does the same thing.

How do I disable that, so a visitor would get a message or be directed to the domain?

I tried disabling the IP and mail a record on cloud flare but it didn't work.

My setup is:

```<code>VPS on Linux Debian
Nginx
no control panel just command line
Cloudflare
DNS setup with BIND
</code>```

答:
you can return any error you find suitable. A list of errors can be found here List_of_HTTP_status_codes</p>

```<code>server {
    listen      x.x.x.x:80;
    server_name x.x.x.x;
    return      404;
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a website on a VPS.

The issue I am having is that when I enter the IP of the server, it links to the website.

Even when entering mail.domain.com, it does the same thing.

How do I disable that, so a visitor would get a message or be directed to the domain?

I tried disabling the IP and mail a record on cloud flare but it didn't work.

My setup is:

VPS on Linux Debian
Nginx
no control panel just command line
Cloudflare
DNS setup with BIND

Body:
you can return any error you find suitable. A list of errors can be found here List_of_HTTP_status_codes

server {
    listen      x.x.x.x:80;
    server_name x.x.x.x;
    return      404;
}


问:
TornadoFx: Which performs better FXML or type-CSS
I wanted to know if there is any performance benefit of using one over the other with TornadoFx ? </p>

答:
Type safe CSS can be used with both FXML and type safe builders. You need to compare FXML with the type safe builders. The builders are both faster to execute and faster to write due to the lower noise level of the syntax. It's far more expressive and definitely the preferred way of writing TornadoFX Applications.

That said, you won't notice a speed issue with either approach.


问:
How to create a content element in typoscript?
Is there a possible way to create a content element just using typoscript?

I need something like this:

```<code>ce = CONTENTELEMENT
ce {
    type = textmedia
    header = Hello World
    bodytext = Lorem ipsum
}
</code>```

答:
The easiest way is to create your content element in a storage folder in the backend and then retrieve it with :

```<code>lib.ce = RECORDS
lib.ce {
    source = theIDOfTheContentElement
    tables = tt_content
}
</code>```

Then you can call your lib in a fluid template with :

```<code><f:cObject typoscriptObjectPath="lib.ce"/>
</code>```

Body:
Is there a possible way to create a content element just using typoscript?

I need something like this:

ce = CONTENTELEMENT
ce {
    type = textmedia
    header = Hello World
    bodytext = Lorem ipsum
}

Body:
The easiest way is to create your content element in a storage folder in the backend and then retrieve it with :

lib.ce = RECORDS
lib.ce {
    source = theIDOfTheContentElement
    tables = tt_content
}

Then you can call your lib in a fluid template with :

<f:cObject typoscriptObjectPath="lib.ce"/>


问:
How to "clear" an object?
What's the better way to clear an object:

Write a method inside the class that clears all the members of the class: MyObject.Clear();

Inside my code, in the business logic, null the object: MyObject = null;

答:
Second one.
Be careful not to persist any references to your object. Any bound event handlers, references in collections make your instance "unfreeable".

If you come from C++, don't bother with Garbage Collector. I'm aware that the obsession of memory performance may lead to manipulating memory collection process. In fact you should not ever have the need to use it. Just unbind any references.

Title: How to "clear" an object?


问:
How to webscrape with Selenium when URL remains static after click
I am new to Selenium/Firefox.  My goal is to go to my URL, fill in basic input, select a few items, let browser change the content and download a PDF from there.  Ideally, I would love to do it repeatedly later by looping a number of new items. As a first step, I manage to get the browser to work and change content once.  But I am stuck in getting the content out as find_elements_by_tag_name() seem to get me something funny rather than some usual HTML tag like what Beautifulsoup .find_all() would do.   Appreciate very much any help here.

Here is my code:

```<code>from selenium import webdriver
from selenium.webdriver.support.ui import Select

url ='http://www.hkexnews.hk/listedco/listconews/advancedsearch/search_active_main.aspx'

browser = webdriver.Firefox(executable_path = 'C:\Program Files\Mozilla
Firefox\geckodriver.exe')
browser.get(url)

StockElem = browser.find_element_by_id('ctl00_txt_stock_code')
StockElem.send_keys('00772')
StockElem.click()

select = Select(browser.find_element_by_id('ctl00_sel_tier_1'))
select.select_by_value('3')

select = Select(browser.find_element_by_id('ctl00_sel_tier_2'))
select.select_by_value('153')

select = Select(browser.find_element_by_id('ctl00_sel_DateOfReleaseFrom_d'))
select.select_by_value('01')

select = Select(browser.find_element_by_id('ctl00_sel_DateOfReleaseFrom_m'))
select.select_by_value('01')

select = Select(browser.find_element_by_id('ctl00_sel_DateOfReleaseFrom_y'))
select.select_by_value('2000')

#  select the search button
browser.execute_script("document.forms[0].submit()")

element = browser.find_elements_by_tag_name("a")

print(element)
</code>```

答:
After clicking on the Search button -- you have 5 links to download PDF files.

You should find those links by CSS selector: .news.

Then go through the list of links by index and click on each link to Download:

elements[0].click() -- by clicking on the first link.

Body:
I am new to Selenium/Firefox.  My goal is to go to my URL, fill in basic input, select a few items, let browser change the content and download a PDF from there.  Ideally, I would love to do it repeatedly later by looping a number of new items. As a first step, I manage to get the browser to work and change content once.  But I am stuck in getting the content out as find_elements_by_tag_name() seem to get me something funny rather than some usual HTML tag like what Beautifulsoup .find_all() would do.   Appreciate very much any help here.

Here is my code:

from selenium import webdriver
from selenium.webdriver.support.ui import Select

url ='http://www.hkexnews.hk/listedco/listconews/advancedsearch/search_active_main.aspx'

browser = webdriver.Firefox(executable_path = 'C:\Program Files\Mozilla
Firefox\geckodriver.exe')
browser.get(url)

StockElem = browser.find_element_by_id('ctl00_txt_stock_code')
StockElem.send_keys('00772')
StockElem.click()

select = Select(browser.find_element_by_id('ctl00_sel_tier_1'))
select.select_by_value('3')

select = Select(browser.find_element_by_id('ctl00_sel_tier_2'))
select.select_by_value('153')

select = Select(browser.find_element_by_id('ctl00_sel_DateOfReleaseFrom_d'))
select.select_by_value('01')

select = Select(browser.find_element_by_id('ctl00_sel_DateOfReleaseFrom_m'))
select.select_by_value('01')

select = Select(browser.find_element_by_id('ctl00_sel_DateOfReleaseFrom_y'))
select.select_by_value('2000')

#  select the search button
browser.execute_script("document.forms[0].submit()")

element = browser.find_elements_by_tag_name("a")

print(element)


问:
Extend native interface for element
I want to make a "semi-customized" button. Basically, I want it to extend the <button> tag's initial properties. Here's a minimal example of what I am doing:

```<code>export default class Button extends React.Component<Props, State> {
  public render() {
    const { size, ...buttonProps } = this.props;
    return (
      <button
        {...buttonProps}
        className={classnames({
          [styles.small]: size === 'small',
          [styles.medium]: size === 'medium',
          [styles.large]: size === 'large',
        })}
      />
    );
  }
}
</code>```

However, what I can't figure out is how to create an interface which inherits all of the native HTMLButton's proptypes.

I imagine it would be something like:

```<code>interface Props extends <(Something)> {
  size: 'small' | 'medium' | 'large',
}
</code>```

How would you extend native HTML element properties in typescript?

答:
Interfaces in TypeScript are open and multiple declarations within the same common root are merged. Example:

```<code>interface HTMLButtonElement {
    customThing(): string;
}

const button = document.getElementsByTagName('button')[0];

const customValue = button.customThing();
</code>```

The HTMLButtonElement interface needs to be declared in the same common root as the original interface (i.e. it is in the global scope). Once you add your customThing, your HTMLButtonElement will have all the members of the original HTMLButtonElement and your customThing.

Title: Extend native interface for element

Body:
I want to make a "semi-customized" button. Basically, I want it to extend the <button> tag's initial properties. Here's a minimal example of what I am doing:

export default class Button extends React.Component<Props, State> {
  public render() {
    const { size, ...buttonProps } = this.props;
    return (
      <button
        {...buttonProps}
        className={classnames({
          [styles.small]: size === 'small',
          [styles.medium]: size === 'medium',
          [styles.large]: size === 'large',
        })}
      />
    );
  }
}

However, what I can't figure out is how to create an interface which inherits all of the native HTMLButton's proptypes.

I imagine it would be something like:

interface Props extends <(Something)> {
  size: 'small' | 'medium' | 'large',
}

How would you extend native HTML element properties in typescript?

Body:
Interfaces in TypeScript are open and multiple declarations within the same common root are merged. Example:

interface HTMLButtonElement {
    customThing(): string;
}

const button = document.getElementsByTagName('button')[0];

const customValue = button.customThing();

The HTMLButtonElement interface needs to be declared in the same common root as the original interface (i.e. it is in the global scope). Once you add your customThing, your HTMLButtonElement will have all the members of the original HTMLButtonElement and your customThing.


问:
Filtering audio in AudioKit
What i need to do:

record audio file;

as it's record from iPhone/iPad microphone it can be quiet, so i need to filter it to make it louder;

save filtered record;

I'm new in audio programming, but as I understand so far I need "All Pass" filter (if not please correct me).

For this task I've found two libs: Novocaine and AudioKit, but Novocaine written in C, so it's harder to implement it in swift, and I decided to use AudioKit, but I didn't found "All Pass" filter there.

Does anybody know how to implement it in AudioKit and save filtered file? Thank you!

答:
You have a few choices, for musical recordings I recommend AKBooster as it purely boosts the audio, you have to be careful how much you boost, otherwise you might cause clipping.

For spoken word audio I recommend AKPeakLimiter.  It will give you the maximum volume without clipping.  Set the attackTime and decayTime to lower values to hear a more pronounced effect.

The values of the sliders won't represent the values of the parameters until you move them.

```<code>import UIKit
import AudioKit

class ViewController: UIViewController {

    let mic = AKMicrophone()
    let boost = AKBooster()
    let limiter = AKPeakLimiter()

    override func viewDidLoad() {
        super.viewDidLoad()

        mic >>> boost >>> limiter
        AudioKit.output = limiter
        AudioKit.start()

        let inset: CGFloat = 10.0
        let width = view.bounds.width - inset * 2

        for i in 0..<4 {
            let y = CGFloat(100 + i * 50)
            let slider = UISlider(frame: CGRect(x: inset, y: y, width: width, height: 30))
            slider.tag = i
            slider.addTarget(self, action: #selector(sliderAction(slider:)), for: .valueChanged)
            view.addSubview(slider)
        }

        boost.gain = 1

    }

    @objc func sliderAction(slider: UISlider) {
        switch slider.tag {
        case 0:
            boost.gain = slider.value * 40
        case 1:
            limiter.preGain = slider.value * 40
        case 2:
            limiter.attackTime = max(0.001, slider.value * 0.03)
        case 4:
            limiter.decayTime = max(0.001, slider.value * 0.06)
        default: break

        }
    }

}
</code>```

Title: Filtering audio in AudioKit

Body:
You have a few choices, for musical recordings I recommend AKBooster as it purely boosts the audio, you have to be careful how much you boost, otherwise you might cause clipping.

For spoken word audio I recommend AKPeakLimiter.  It will give you the maximum volume without clipping.  Set the attackTime and decayTime to lower values to hear a more pronounced effect.

The values of the sliders won't represent the values of the parameters until you move them.

import UIKit
import AudioKit

class ViewController: UIViewController {

    let mic = AKMicrophone()
    let boost = AKBooster()
    let limiter = AKPeakLimiter()

    override func viewDidLoad() {
        super.viewDidLoad()

        mic >>> boost >>> limiter
        AudioKit.output = limiter
        AudioKit.start()

        let inset: CGFloat = 10.0
        let width = view.bounds.width - inset * 2

        for i in 0..<4 {
            let y = CGFloat(100 + i * 50)
            let slider = UISlider(frame: CGRect(x: inset, y: y, width: width, height: 30))
            slider.tag = i
            slider.addTarget(self, action: #selector(sliderAction(slider:)), for: .valueChanged)
            view.addSubview(slider)
        }

        boost.gain = 1

    }

    @objc func sliderAction(slider: UISlider) {
        switch slider.tag {
        case 0:
            boost.gain = slider.value * 40
        case 1:
            limiter.preGain = slider.value * 40
        case 2:
            limiter.attackTime = max(0.001, slider.value * 0.03)
        case 4:
            limiter.decayTime = max(0.001, slider.value * 0.06)
        default: break

        }
    }

}


问:
export datasets into multiple sheets of one excel file in sas
I'm use this code

```<code>proc export data=goldsheet_invalid outfile="C:\Documents and Settings\sasadm\Desktop\gold.xls" dbms=xls replace;
sheet="gold";
run;

proc export data=platinumsheet_invalid outfile="C:\Documents and Settings\sasadm\Desktop\gold.xls" dbms=xls replace;
sheet="platinum";
run;

proc export data=titaniumsheet_invalid outfile="C:\Documents and Settings\sasadm\Desktop\gold.xls" dbms=xls replace;
sheet="titanium";
run;
</code>```

Error:Statement is not valid or it is used out of proper order

Note:- already try dbms=xlsx or dbms=EXCELCS but not work

答:
Instead of using a PROC EXPORT this can be accomplished with older versions of SAS using ODS (Output Delivery System) statements.  Going this route is not as clean as the PROC EXPORT but if all you want is to get the data from these data sets to a single Excel workbook and have the results of each proc statement on a different worksheet this will do it.

In this case the code to accomplish what you are looking for would be:

```<code>ods tagsets.excelxp file='C:\temp\gold.xml' options(sheet_name = 'Gold' sheet_interval='proc');
proc print data=goldsheet_invalid;
run;
ods tagsets.excelxp options(sheet_name = 'Platinum');
proc print data=platinumsheet_invalid;
run;
ods tagsets.excelxp options(sheet_name = 'Titanium');
proc print data=titaniumsheet_invalid;
run;
ods tagsets.excelxp close;
</code>```

You will notice that the file extension created is XML, this is a necessity.  When you load the file in Excel is would appear as expected and feel free to update the file extension from there.

More details about SAS and ODS can be found at:  https://support.sas.com/rnd/base/ods/odsmarkup/TipSheet_ods_xl_xp.pdf

Body:
I'm use this code

proc export data=goldsheet_invalid outfile="C:\Documents and Settings\sasadm\Desktop\gold.xls" dbms=xls replace;
sheet="gold";
run;

proc export data=platinumsheet_invalid outfile="C:\Documents and Settings\sasadm\Desktop\gold.xls" dbms=xls replace;
sheet="platinum";
run;

proc export data=titaniumsheet_invalid outfile="C:\Documents and Settings\sasadm\Desktop\gold.xls" dbms=xls replace;
sheet="titanium";
run;

Error:Statement is not valid or it is used out of proper order

Note:- already try dbms=xlsx or dbms=EXCELCS but not work

Body:
Instead of using a PROC EXPORT this can be accomplished with older versions of SAS using ODS (Output Delivery System) statements.  Going this route is not as clean as the PROC EXPORT but if all you want is to get the data from these data sets to a single Excel workbook and have the results of each proc statement on a different worksheet this will do it.

In this case the code to accomplish what you are looking for would be:

ods tagsets.excelxp file='C:\temp\gold.xml' options(sheet_name = 'Gold' sheet_interval='proc');
proc print data=goldsheet_invalid;
run;
ods tagsets.excelxp options(sheet_name = 'Platinum');
proc print data=platinumsheet_invalid;
run;
ods tagsets.excelxp options(sheet_name = 'Titanium');
proc print data=titaniumsheet_invalid;
run;
ods tagsets.excelxp close;

You will notice that the file extension created is XML, this is a necessity.  When you load the file in Excel is would appear as expected and feel free to update the file extension from there.

More details about SAS and ODS can be found at:  https://support.sas.com/rnd/base/ods/odsmarkup/TipSheet_ods_xl_xp.pdf


问:
How to make an image clickable to run a function
How do I make an image clickable to run the displayScore function?</p>

```<code>$(function(){
   $(".Image").on('click',function(){
      displayScore();
   });
});

function addMole(){
   $("#gamespace").append('<img class= 'Image' img
   src="img/mole.png"/>');
   moreMoles = setTimeout("addMole()", 2000);
 };
</code>```

答:
```<code>$(function(){
   $(document).on('click','.Image',function(){
      displayScore();
   });
});
</code>```

Body:
How do I make an image clickable to run the displayScore function?

$(function(){
   $(".Image").on('click',function(){
      displayScore();
   });
});

function addMole(){
   $("#gamespace").append('');
   moreMoles = setTimeout("addMole()", 2000);
 };


问:
Printing the exception message in an Ada Last_Chance_Handler
I'm in the process of learning Ada using the GNAT compiler using the AdaCore GPS (GPL) IDE, aimed at ARM "bare board" hardware (STM32F4 using a Ravenscar SFP runtime).

For my ARM based embedded work I've come from a C/C++ background.

Anyway, I've implemented a "last chance handler" that's defined as follows,

```<code>procedure Last_Chance_Handler (Msg : System.Address; Line : Integer);
pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler");
</code>```

Here's the actual procedure (a snippet from the .adb file),

```<code>procedure Last_Chance_Handler (Msg : System.Address; Line : Integer) is
begin
   LEDs_All_On;
   -- Put_Line("Detail :" & Address_To_String(Msg));
   Put_Line("Line   :" & Line'Image);

   loop
      null;
   end loop;
end Last_Chance_Handler;
</code>```

The Msg argument is documented as follows,

The Msg parameter is a C null-terminated string representing the
  source location of the raise statement, as generated by the compiler,
  or a zero-length string if pragma Suppress_Exception_Locations is
  used.

I've been trying to figure out how to convert the null terminated Msg bytes to an Ada string so that I can display it using a Put_Line() call (when debugging I can access this type of output via the semihosting mechanism).

I've previously mapped Ada records (representing device registers etc.) to physical memory addresses by setting their 'Address attribute to a constant value. However, this is the first time I've tried access memory via a System.Address value held in a variable.

Can anyone suggest how I might go about implementing the Address_To_String() procedure?

I have experimented with Ada byte arrays and unchecked conversions between them and System.Address, also with Ada pointers, but so far I've not had any success.

Any help or suggestions would be greatly appreciated!

Many thanks,

...Max

答:
Just in case it wasn’t clear from Jacob’s answer, you’re perfectly at liberty to declare

```<code>with Interfaces.C.Strings;
procedure Last_Chance_Handler
  (Msg : Interfaces.C.Strings.chars_ptr; Line : Integer);
</code>```

bearing in mind the documented description of Msg.

Body:
I'm in the process of learning Ada using the GNAT compiler using the AdaCore GPS (GPL) IDE, aimed at ARM "bare board" hardware (STM32F4 using a Ravenscar SFP runtime).

For my ARM based embedded work I've come from a C/C++ background.

Anyway, I've implemented a "last chance handler" that's defined as follows,

procedure Last_Chance_Handler (Msg : System.Address; Line : Integer);
pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler");

Here's the actual procedure (a snippet from the .adb file),

procedure Last_Chance_Handler (Msg : System.Address; Line : Integer) is
begin
   LEDs_All_On;
   -- Put_Line("Detail :" & Address_To_String(Msg));
   Put_Line("Line   :" & Line'Image);

   loop
      null;
   end loop;
end Last_Chance_Handler;

The Msg argument is documented as follows,

The Msg parameter is a C null-terminated string representing the
  source location of the raise statement, as generated by the compiler,
  or a zero-length string if pragma Suppress_Exception_Locations is
  used.

I've been trying to figure out how to convert the null terminated Msg bytes to an Ada string so that I can display it using a Put_Line() call (when debugging I can access this type of output via the semihosting mechanism).

I've previously mapped Ada records (representing device registers etc.) to physical memory addresses by setting their 'Address attribute to a constant value. However, this is the first time I've tried access memory via a System.Address value held in a variable.

Can anyone suggest how I might go about implementing the Address_To_String() procedure?

I have experimented with Ada byte arrays and unchecked conversions between them and System.Address, also with Ada pointers, but so far I've not had any success.

Any help or suggestions would be greatly appreciated!

Many thanks,

...Max

Body:
Just in case it wasn’t clear from Jacob’s answer, you’re perfectly at liberty to declare

with Interfaces.C.Strings;
procedure Last_Chance_Handler
  (Msg : Interfaces.C.Strings.chars_ptr; Line : Integer);

bearing in mind the documented description of Msg.


问:
Import inbound security group rules on AWS
I have a security group which has quite a few inbound rules. Can I reference to this group from another group so that the referencing group inherits all the rules from its parent?

For example:

Group A

Port 3306. Traffic from X.X.X.X allowed.

Port 3306. Traffic from X.X.X.Y allowed.

Port 3306. Traffic from X.X.X.Z allowed.

Group B

Traffic from Group A

The tooltip of the Source column in the inbound rules table says that I can do that:

However it doesn't work. The connections from the sources listed in the Group A are blocked on the instance assigned with the Group B

答:
There is no security group inheritance. Referencing a security group in the source field does not provide rule inheritance. Referencing a group in this way allows inbound access to group B from resources in A.

Note that you can assign multiple security groups to a single instance. So you should create a third security group with all the common rules, and assign that to all the instances that need those common rules.


问:
Docker secrets and RSA keys
I have a Docker swarm and I would like to use a secret RSA key in a service to connect via SSH to another container.

My security policy is that all the secrets (passwords, keys, etc.) are stored on a different machine than the destination servers (the Swarm).

Actually (and I don't like it), in my Dockerfile I create a temporary directory /run/secrets:

```<code>mkdir -p /run/secrets
</code>```

Then I create fake id_rsa and id_rsa.pub files:

```<code>touch /run/secrets/id_rsa
touch /run/secrets/id_rsa.pub
</code>```

And now I create a symbolic link:

```<code>ln -s /run/secrets/id_rsa /root/.ssh/id_rsa
ln -s /run/secrets/id_rsa.pub /root/.ssh/id_rsa.pub
</code>```

I'm doing this because I didn't find a way to copy the secrets in my docker-entrypoint.sh: in the entrypoint I'm not root so I can't copy in the /root directory.

So, I'm already using Docker secrets but the problem here is that the secrets inside the containers are in read-only. That impacts the usage of SSH:

```<code>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0444 for '/root/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
</code>```

I can't modify the permissions of my id_rsa file since it's read-only.

Is there a workaround or just a really better way to do it ?

Thanks

EDIT 1:

I'm trying to change the way I build my Docker image in order to copy keys in the /root/.ssh directory.

答:
Consider creating a stack with a compose file.
This gives you the option to alter the file permissions of your secrets.

```<code>version: "3.1"
services:
  redis:
    image: redis:latest
    deploy:
      replicas: 1
    secrets:
      - source: my_secret
        target: redis_secret
        uid: '103'
        gid: '103'
        mode: 0440
secrets:
  my_secret:
    file: ./my_secret.txt
  my_other_secret:
    external: true
</code>```

More info can be found here: https://docs.docker.com/compose/compose-file/#long-syntax-2

Title: Docker secrets and RSA keys

Body:
I have a Docker swarm and I would like to use a secret RSA key in a service to connect via SSH to another container.

My security policy is that all the secrets (passwords, keys, etc.) are stored on a different machine than the destination servers (the Swarm).

Actually (and I don't like it), in my Dockerfile I create a temporary directory /run/secrets:

mkdir -p /run/secrets

Then I create fake id_rsa and id_rsa.pub files:

touch /run/secrets/id_rsa
touch /run/secrets/id_rsa.pub

And now I create a symbolic link:

ln -s /run/secrets/id_rsa /root/.ssh/id_rsa
ln -s /run/secrets/id_rsa.pub /root/.ssh/id_rsa.pub

I'm doing this because I didn't find a way to copy the secrets in my docker-entrypoint.sh: in the entrypoint I'm not root so I can't copy in the /root directory.

So, I'm already using Docker secrets but the problem here is that the secrets inside the containers are in read-only. That impacts the usage of SSH:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0444 for '/root/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.

I can't modify the permissions of my id_rsa file since it's read-only.

Is there a workaround or just a really better way to do it ?

Thanks

EDIT 1:

I'm trying to change the way I build my Docker image in order to copy keys in the /root/.ssh directory.

Body:
Consider creating a stack with a compose file.
This gives you the option to alter the file permissions of your secrets.

version: "3.1"
services:
  redis:
    image: redis:latest
    deploy:
      replicas: 1
    secrets:
      - source: my_secret
        target: redis_secret
        uid: '103'
        gid: '103'
        mode: 0440
secrets:
  my_secret:
    file: ./my_secret.txt
  my_other_secret:
    external: true

More info can be found here: https://docs.docker.com/compose/compose-file/#long-syntax-2


问:
cant see my post in my list .html
i created a blog
this is my models.py configurations:

```<code>from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
# Create your models here.
class PublishedManager(models.Manager):

    def get_queryset(self):
        return super(PublishedManager, self).get_queryset()\
                .filter(status='published')
class post(models.Model):
    STATUS_CHOICE=(
        ('draft','DRAFT'),
        ('published','Published'),
        ('admin','admin'),
    )

    title=models.CharField(max_length=250,null=True)
    author=models.ForeignKey(User,related_name='blog_posts',null=True)
    slug=models.SlugField(max_length=250,unique_for_date='publish',null=True)
    body=models.TextField(default='')
    publish=models.DateTimeField(default=timezone.now)
    created = models.DateTimeField(auto_now_add=True,null=True)
    updated =models.DateTimeField(auto_now=True)
    status = models.CharField(max_length=10,
                            choices =STATUS_CHOICE,
                                default='draft')
    objects = models.Manager()
    published = PublishedManager()
    class Meta:
        ordering = ('-publish',)
    def __str__(self):
        return self.title
    def get_absolute_url(self):
        return reverse('blog:post_detail',args=[self.publish.year,
                                                self.publish.strftime('%m'),
                                                self.publish.strftime('%dz'),
                                                self.slug])
</code>```

and this is my views.py:

```<code>from django.shortcuts import render
from .models import post
# Create your views here.
def post_list(request):
    posts= post.published.all()
    return render(request,'blog/post/list.html',{posts:posts})

def post_detail(request,year,month,day,post):
    post=get_object_or_404(post,slug=post,
                                status = 'published',
                                publish__year=year,
                                publish__month=month,
                                publish__day=day)
    return render(request,'blog/post/index.html',{'post':post})
</code>```

and this is my base.html:

```<code>{%load staticfiles%}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{% block title %}
      <link rel="stylesheet" href={% static "/css/blog.css"%}>
      {% endblock %}
    </title>
  </head>
  <body>
<div id="content">
  {% block content %}
  {% endblock %}

</div>
<div id="sidebar">
  <h2>my blog</h2>
  <h3>this blog</h3>

</div>
  </body>
</html>
</code>```

and my list.html file:

```<code>{% extends "blog/base.html" %}

{% block title  %}My blog{% endblock %}
{% block content %}

  <h1>My Blog</h1>

  {% for post in posts %}
    <h2>
      <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
    </h2>
    <p class="date">
      Published {{ post.publish }} by {{ post.author }}
    </p>
    {{ post.body|truncatewords:30|linebreaks }}
  {% endfor %}
{% endblock %}
</code>```

and this is my urls.py (app folder)

```<code>from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$',views.post_list,name = 'post_list'),
    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<post>[-\W]+)/$',
    views.post_detail,
    name='post_detail'),
]
</code>```

and this is my urls.py file of my project folder:

```<code>from django.conf.urls import url,include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^blog/', include('myblog.urls',namespace='blog',app_name='blog')),
]
</code>```

and i have added some post objects using admin user but when i tried to access the page  the expected output according to the tutorial looks like this:
enter image description here

but instead my output was :
enter image description here

答:
Firstly, the key in your context dictionary should be the string 'posts', not the variable posts, as @ABDUL pointed out in the comments.

```<code>return render(request,'blog/post/list.html',{'posts':posts})
</code>```

Then you need to fix the NoReverseMatch error. In your get_absolute_url method, you have %dz. It should be '%d'. Remove the z.

```<code>def get_absolute_url(self):
    return reverse('blog:post_detail',args=[self.publish.year,
                                            self.publish.strftime('%m'),
                                            self.publish.strftime('%d'),
                                            self.slug])
</code>```

Title: cant see my post in my list .html

Body:
i created a blog
this is my models.py configurations:

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
# Create your models here.
class PublishedManager(models.Manager):

    def get_queryset(self):
        return super(PublishedManager, self).get_queryset()\
                .filter(status='published')
class post(models.Model):
    STATUS_CHOICE=(
        ('draft','DRAFT'),
        ('published','Published'),
        ('admin','admin'),
    )

    title=models.CharField(max_length=250,null=True)
    author=models.ForeignKey(User,related_name='blog_posts',null=True)
    slug=models.SlugField(max_length=250,unique_for_date='publish',null=True)
    body=models.TextField(default='')
    publish=models.DateTimeField(default=timezone.now)
    created = models.DateTimeField(auto_now_add=True,null=True)
    updated =models.DateTimeField(auto_now=True)
    status = models.CharField(max_length=10,
                            choices =STATUS_CHOICE,
                                default='draft')
    objects = models.Manager()
    published = PublishedManager()
    class Meta:
        ordering = ('-publish',)
    def __str__(self):
        return self.title
    def get_absolute_url(self):
        return reverse('blog:post_detail',args=[self.publish.year,
                                                self.publish.strftime('%m'),
                                                self.publish.strftime('%dz'),
                                                self.slug])

and this is my views.py:

from django.shortcuts import render
from .models import post
# Create your views here.
def post_list(request):
    posts= post.published.all()
    return render(request,'blog/post/list.html',{posts:posts})

def post_detail(request,year,month,day,post):
    post=get_object_or_404(post,slug=post,
                                status = 'published',
                                publish__year=year,
                                publish__month=month,
                                publish__day=day)
    return render(request,'blog/post/index.html',{'post':post})

and this is my base.html:

{%load staticfiles%}
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>{% block title %}
      <link rel="stylesheet" href={% static "/css/blog.css"%}>
      {% endblock %}
    </title>

  {% block content %}
  {% endblock %}

my blog

this blog

and my list.html file:

{% extends "blog/base.html" %}

{% block title  %}My blog{% endblock %}
{% block content %}

My Blog

  {% for post in posts %}

      {{ post.title }}

      Published {{ post.publish }} by {{ post.author }}

    {{ post.body|truncatewords:30|linebreaks }}
  {% endfor %}
{% endblock %}

and this is my urls.py (app folder)

from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$',views.post_list,name = 'post_list'),
    url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<post>[-\W]+)/$',
    views.post_detail,
    name='post_detail'),
]

and this is my urls.py file of my project folder:

from django.conf.urls import url,include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^blog/', include('myblog.urls',namespace='blog',app_name='blog')),
]

and i have added some post objects using admin user but when i tried to access the page  the expected output according to the tutorial looks like this:
enter image description here

but instead my output was :
enter image description here

Body:
Firstly, the key in your context dictionary should be the string 'posts', not the variable posts, as @ABDUL pointed out in the comments.

return render(request,'blog/post/list.html',{'posts':posts})

Then you need to fix the NoReverseMatch error. In your get_absolute_url method, you have %dz. It should be '%d'. Remove the z.

def get_absolute_url(self):
    return reverse('blog:post_detail',args=[self.publish.year,
                                            self.publish.strftime('%m'),
                                            self.publish.strftime('%d'),
                                            self.slug])


问:
Multiple triggers for a jquery-click-event
Sorry for that simple question, but how do I add multiple triggers to a jquery-click-event?

I tried that one here

```<code>$("#trigger1","#trigger2").click(function() {
    //something
});
</code>```

But that doesn't work. What is the correct syntax there?

答:
Should be like :

```<code>$("#trigger1, #trigger2").click(function() {
    //Put your logic here
});
</code>```

Just remove the extra quotes.

Hope this helps.

Body:
Sorry for that simple question, but how do I add multiple triggers to a jquery-click-event?

I tried that one here

$("#trigger1","#trigger2").click(function() {
    //something
});

But that doesn't work. What is the correct syntax there?

Body:
Should be like :

$("#trigger1, #trigger2").click(function() {
    //Put your logic here
});

Just remove the extra quotes.

Hope this helps.


问:
How to Generate Controller in Symfony 3.0?
Hope you are all fine, I am a beginner trying to learn Symfony 3.0, so I want to generate my controller in a folder called Bundles, but it is not created, here is the command I taped :

```<code>php bin/console generate:controller
</code>```

And this is fine, when I tape the controller name, that was what I wrote :

```<code>?[32mController name?[39m: Bundles/FrontBundle
</code>```

But their answer is :

```<code>?[37;41m The controller name must contain a : ("Bundles/FrontBundle"
given, expecting something like AcmeBlogBundle:Post) ?[39;49m
</code>```

I don't know if I have to do something before this to noy have such error.
Any Help would be much appreciated.

答:
According to his doc you should use the shortcut notation when you are declaring a controller, entity, etc.

also you need to read the output of the command.

Welcome to the Symfony controller generator

Every page, and even sections of a page, are rendered by a controller.
  This command helps you generate them easily.

First, you need to give the controller name you want to generate. You
  must use the shortcut notation like AcmeBlogBundle:Post

Controller name: BundleNameEndingBundle:ControllerName

Body:
Hope you are all fine, I am a beginner trying to learn Symfony 3.0, so I want to generate my controller in a folder called Bundles, but it is not created, here is the command I taped :

php bin/console generate:controller

And this is fine, when I tape the controller name, that was what I wrote :

?[32mController name?[39m: Bundles/FrontBundle

But their answer is :

?[37;41m The controller name must contain a : ("Bundles/FrontBundle"
given, expecting something like AcmeBlogBundle:Post) ?[39;49m

I don't know if I have to do something before this to noy have such error.
Any Help would be much appreciated.


问:
Problems with migrations in Laravel 5.5
Something really weird is going on with my Laravel setup. I create some migration files and, when running php artisan migrate after creating each of them, they were successfully run and the tables were created in the database. Now, if I want to run php artisan migrate:refresh --seed, it cannot rollback one of the migrations because it says that migration file doesn't exist.
This is the error:

And this is my migration file:

```<code><?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAssessmentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('assessments', function (Blueprint $table) {
            $table->increments('id');
            //TODO - Complete information for this table
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('assessments');
    }
}
</code>```

What's even weirder is that I had to re-create all migrations because it was randomly not creating some of the tables listed on the migrations.

Did anyone face this issue before? Any help is really appreciated.

[UPDATE]

After a while, I realized this is not something from Laravel. For some reason, my Homestead is not viewing those files despite there are there. If I access that folder via SSH (the one inside the vagrant box), the file is not there. If I go to the real folder, it is there. For some reason the box is not synching files properly.
What's even weirder is that I can access and edit the file inside the VMB but it won't list it and won't take into account when running migrations. Here I created a screen-recording showing the problem.

[UPDATE 2]

Just recorded 2 more videos. This is really strange (unless I am missing something).

Video 1.

Video 2.

答:
It seems to be a problem with MacOS High Sierra and Vagrant. In order to fix it, I had to apply this workaround.

Hopefully this will save some time to the ones having the same problem I was having.

Title: Problems with migrations in Laravel 5.5

Body:
Something really weird is going on with my Laravel setup. I create some migration files and, when running php artisan migrate after creating each of them, they were successfully run and the tables were created in the database. Now, if I want to run php artisan migrate:refresh --seed, it cannot rollback one of the migrations because it says that migration file doesn't exist.
This is the error:

And this is my migration file:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAssessmentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('assessments', function (Blueprint $table) {
            $table->increments('id');
            //TODO - Complete information for this table
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('assessments');
    }
}

What's even weirder is that I had to re-create all migrations because it was randomly not creating some of the tables listed on the migrations.

Did anyone face this issue before? Any help is really appreciated.

[UPDATE]

After a while, I realized this is not something from Laravel. For some reason, my Homestead is not viewing those files despite there are there. If I access that folder via SSH (the one inside the vagrant box), the file is not there. If I go to the real folder, it is there. For some reason the box is not synching files properly.
What's even weirder is that I can access and edit the file inside the VMB but it won't list it and won't take into account when running migrations. Here I created a screen-recording showing the problem.

[UPDATE 2]

Just recorded 2 more videos. This is really strange (unless I am missing something).

Video 1.

Video 2.


答:
No that will not work. The reference of an SG by its ID only refers to any instance that uses that SG, and does not import its rules.  Each security group needs to have explict rules for the traffic you want to allow.

Again, using an SG for the source only serves to reference instances that use that SG.

Title: Import inbound security group rules on AWS

Body:
I have a security group which has quite a few inbound rules. Can I reference to this group from another group so that the referencing group inherits all the rules from its parent?

For example:

Group A

Port 3306. Traffic from X.X.X.X allowed.

Port 3306. Traffic from X.X.X.Y allowed.

Port 3306. Traffic from X.X.X.Z allowed.

Group B

Traffic from Group A

The tooltip of the Source column in the inbound rules table says that I can do that:

However it doesn't work. The connections from the sources listed in the Group A are blocked on the instance assigned with the Group B


问:
Make Nivo Slider fade-in on load
Hey, I want to load the Nivo Slider in this order:

Before the slides appear, a loading.gif is shown.

Once the slides are ready to appear, they fadeIn.

The Nivo Slider's call function looks like this:

```<code>$(window).load(function() { /* ///// start WINDOW load ///// */
$('#slider').nivoSlider({
    effect:'random', //Specify sets like: 'fold,fade,sliceDown'
    slices:12,
    animSpeed:500, //Slide transition speed
    pauseTime:3000,
    startSlide:0, //Set starting Slide (0 index)
    directionNav:false, //Next & Prev
    directionNavHide:true, //Only show on hover
    controlNav:false, //1,2,3...
    controlNavThumbs:false, //Use thumbnails for Control Nav
    controlNavThumbsFromRel:false, //Use image rel for thumbs
    controlNavThumbsSearch: '.jpg', //Replace this with...
    controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
    keyboardNav:true, //Use left & right arrows
    pauseOnHover:true, //Stop animation while hovering
    manualAdvance:false, //Force manual transitions
    captionOpacity:0.8, //Universal caption opacity
    beforeChange: function(){},
    afterChange: function(){},
    slideshowEnd: function(){}, //Triggers after all slides have been shown
    lastSlide: function(){}, //Triggers when last slide is shown
    afterLoad: function(){} //Triggers when slider has loaded
});
</code>```

});

The loading.gif is shown with this CSS statement that is located within the nivo-slider.css file:

```<code>#slider {
 background: #eee url(../images/nivo-loader.gif) no-repeat 50% 50%;
 position: relative;
 width: 960px; height: 328px;
}
#slider img {
 position: absolute;
 top: 0px;
 left: 0px;
 display: none;
}
</code>```

I thought the way to do this was to use the built-in afterLoad parameter, like this: afterLoad(function() { $(this).fadeIn(); }); but that didn't work out.

So I'd really appreciate any ideas!
Thank you!

UPDATE:

The HTML is very simple (as most Nivo slider's layouts):

```<code><div id="slider" class="box"> <!-- Image/video top box (cinema) -->
            <img src="assets/images/cinema/slide1.jpg" />
            <img src="assets/images/cinema/slide2.jpg" />
            <img src="assets/images/cinema/slide3.jpg" />
            <img src="assets/images/cinema/slide4.jpg" />
        </div>
</code>```

When I use the afterLoad parameter nothing happens; the loading.gif appears but then the images show up harshly (without the fadeIn() I'd like). So basically, everything works, but I'd just like these images to fade in once the show is ready to start. Then, they should simply slide with their random transitions (as they do now).

答:
What I'd do is overlay the slider with the loader and use nivo's afterLoad function to do the animation you want on the contained images, not the slider holder.  Here's how I'd do it:

```<code><div id="wrapper">
    <div id="slider" class="box">
        <img src="assets/images/cinema/slide1.jpg" />
        <img src="assets/images/cinema/slide2.jpg" />
        <img src="assets/images/cinema/slide3.jpg" />
        <img src="assets/images/cinema/slide4.jpg" />
    </div>
    <div id="preloader">
        <img src="assets/images/nivo-loader.gif" />
    </div>
</div>
</code>```

Now with the CSS you'll overlay the preloader over the slider using absolute position in relation to the relative position of the wrapper:

```<code>#wrapper { position:relative; }
#preloader {
 background:#eee;
 position:absolute; top:0; left:0; z-index:51; /* z-index greater than #slider */
 width:960px; height:328px;
}
#preloader img {
 padding:150px 0 0 470px; /* unknown img size, but adjust so centered */
}
#slider {
 background: #eee url(../images/nivo-loader.gif) no-repeat 50% 50%;
 position: relative; z-index:50; /* set z-index as appropriate to your site */
 width: 960px; height: 328px;
}
#slider img {
 position: absolute;
 top: 0px;
 left: 0px;
 display: none;
}
</code>```

Then, the nivo slider will have all appropriate calls, then the afterLoad will contain your fade animation on the images within the slider:

```<code>$('#slider').nivoSlider({
    ...lots of properties then...
    afterLoad: function(){
        var $slider = $('#slider img');
        $slider.css('opacity',0);
        $('#preloader').fadeOut(500, function(){
           $slider.animate({'opacity':1}, 500);
        });
    }
});
</code>```

If you want a cross-fade instead, then your afterLoad can look simply like:

```<code>$('#slider').nivoSlider({
    ...lots of properties then...
    afterLoad: function(){
        $('#preloader').fadeOut(500);
    }
});
</code>```

This will avoid any problems you had with images popping in.

Title: Make Nivo Slider fade-in on load

Body:
Hey, I want to load the Nivo Slider in this order:

Before the slides appear, a loading.gif is shown.

Once the slides are ready to appear, they fadeIn.

The Nivo Slider's call function looks like this:

$(window).load(function() { /* ///// start WINDOW load ///// */
$('#slider').nivoSlider({
    effect:'random', //Specify sets like: 'fold,fade,sliceDown'
    slices:12,
    animSpeed:500, //Slide transition speed
    pauseTime:3000,
    startSlide:0, //Set starting Slide (0 index)
    directionNav:false, //Next & Prev
    directionNavHide:true, //Only show on hover
    controlNav:false, //1,2,3...
    controlNavThumbs:false, //Use thumbnails for Control Nav
    controlNavThumbsFromRel:false, //Use image rel for thumbs
    controlNavThumbsSearch: '.jpg', //Replace this with...
    controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
    keyboardNav:true, //Use left & right arrows
    pauseOnHover:true, //Stop animation while hovering
    manualAdvance:false, //Force manual transitions
    captionOpacity:0.8, //Universal caption opacity
    beforeChange: function(){},
    afterChange: function(){},
    slideshowEnd: function(){}, //Triggers after all slides have been shown
    lastSlide: function(){}, //Triggers when last slide is shown
    afterLoad: function(){} //Triggers when slider has loaded
});

});

The loading.gif is shown with this CSS statement that is located within the nivo-slider.css file:

#slider {
 background: #eee url(../images/nivo-loader.gif) no-repeat 50% 50%;
 position: relative;
 width: 960px; height: 328px;
}
#slider img {
 position: absolute;
 top: 0px;
 left: 0px;
 display: none;
}

I thought the way to do this was to use the built-in afterLoad parameter, like this: afterLoad(function() { $(this).fadeIn(); }); but that didn't work out.

So I'd really appreciate any ideas!
Thank you!

UPDATE:

The HTML is very simple (as most Nivo slider's layouts):

When I use the afterLoad parameter nothing happens; the loading.gif appears but then the images show up harshly (without the fadeIn() I'd like). So basically, everything works, but I'd just like these images to fade in once the show is ready to start. Then, they should simply slide with their random transitions (as they do now).

Body:
What I'd do is overlay the slider with the loader and use nivo's afterLoad function to do the animation you want on the contained images, not the slider holder.  Here's how I'd do it:

<div id="wrapper">
    <div id="slider" class="box">
        <img src="assets/images/cinema/slide1.jpg" />
        <img src="assets/images/cinema/slide2.jpg" />
        <img src="assets/images/cinema/slide3.jpg" />
        <img src="assets/images/cinema/slide4.jpg" />
    </div>
    <div id="preloader">
        <img src="assets/images/nivo-loader.gif" />
    </div>
</div>

Now with the CSS you'll overlay the preloader over the slider using absolute position in relation to the relative position of the wrapper:

#wrapper { position:relative; }
#preloader {
 background:#eee;
 position:absolute; top:0; left:0; z-index:51; /* z-index greater than #slider */
 width:960px; height:328px;
}
#preloader img {
 padding:150px 0 0 470px; /* unknown img size, but adjust so centered */
}
#slider {
 background: #eee url(../images/nivo-loader.gif) no-repeat 50% 50%;
 position: relative; z-index:50; /* set z-index as appropriate to your site */
 width: 960px; height: 328px;
}
#slider img {
 position: absolute;
 top: 0px;
 left: 0px;
 display: none;
}

Then, the nivo slider will have all appropriate calls, then the afterLoad will contain your fade animation on the images within the slider:

$('#slider').nivoSlider({
    ...lots of properties then...
    afterLoad: function(){
        var $slider = $('#slider img');
        $slider.css('opacity',0);
        $('#preloader').fadeOut(500, function(){
           $slider.animate({'opacity':1}, 500);
        });
    }
});

If you want a cross-fade instead, then your afterLoad can look simply like:

$('#slider').nivoSlider({
    ...lots of properties then...
    afterLoad: function(){
        $('#preloader').fadeOut(500);
    }
});

This will avoid any problems you had with images popping in.


问:
Matlab unique cell combinations
I have a list as given below:

```<code>A= {[1 2], [2 1], [2 1 3],[3 4],[4 3]}
</code>```

I need to simplify the matrix. For example, [3 4] and [4 3] form the same combination, only one of them is enough. Also, [1 2] and [2 1] is the same combinations, so I should be left with

```<code>newA= {[1 2],[2 1 3],[3 4]}
</code>```

How do I do that?

答:
The most efficient way is probably to sort each vector and use two nested loops as follows:</p>

```<code>As = cellfun(@sort, A, 'UniformOutput', false); % sort each vector
remove = false(size(A)); % initiallize. Entries to be removed will be marked true
for ii = 1:numel(A)
    for jj = ii+1:numel(A)
        remove(jj) = remove(jj) || isequal(As{jj}, A{ii}); % short-circuit OR
    end
end
result = A(~remove);
</code>```

Title: Matlab unique cell combinations

Body:
I have a list as given below:

A= {[1 2], [2 1], [2 1 3],[3 4],[4 3]}

I need to simplify the matrix. For example, [3 4] and [4 3] form the same combination, only one of them is enough. Also, [1 2] and [2 1] is the same combinations, so I should be left with

newA= {[1 2],[2 1 3],[3 4]}

How do I do that?

Body:
The most efficient way is probably to sort each vector and use two nested loops as follows:

As = cellfun(@sort, A, 'UniformOutput', false); % sort each vector
remove = false(size(A)); % initiallize. Entries to be removed will be marked true
for ii = 1:numel(A)
    for jj = ii+1:numel(A)
        remove(jj) = remove(jj) || isequal(As{jj}, A{ii}); % short-circuit OR
    end
end
result = A(~remove);


问:
Multibranch pipeline - Jenkins - How to execute one branch at a time?
Merry xmas guys,

I have got a very basic question that I didn't find out there:

How to build branches one at a time?

I actually have two branches to be built set in my multi-branch pipeline Jenkins process.  However, when I hit run, if no changes, both are built at the same time which is a problem due to the unit tests that are using the same port.

This is why I would need to run one branch at a time.

Is there any way in which I can do this?

答:
You cannot limit branches being built with the Multibranch Pipeline. But you can limit that only one step/stage is being run at a time, even across branches, with a lock

```<code>stage("Unit Test") {
  lock("unit_test_lock") {

    //Unit tests here

  } // resource is unlocked.
}
</code>```

If two branches A and B build concurrently, A will first acquire the lock, while B will wait for the lock to be released. So the branches will never execute this locked stage concurrently.

Body:
You cannot limit branches being built with the Multibranch Pipeline. But you can limit that only one step/stage is being run at a time, even across branches, with a lock

stage("Unit Test") {
  lock("unit_test_lock") {

    //Unit tests here

  } // resource is unlocked.
}

If two branches A and B build concurrently, A will first acquire the lock, while B will wait for the lock to be released. So the branches will never execute this locked stage concurrently.


问:
React - On click, modal loads faster than the API response defined in an action, resulting in an empty modal
Good evening everybody!

I'm a total beginner in React and Redux so please bear with me if this sounds stupid.

I'm trying to perform an API call using axios whose response data I need to print onto a modal.

So, if I define the axios.get within a function in the same component it gets the response and I store it to a state and then I display the state in the modal and everything works fine.

But if I do the same using actions and reducers I get an empty the modal the first time I click it.

Without Actions and Reducers

```<code>handleImageClick() {
    axios.get(`http://demoapiwebsite`)
        .then(response => {
            response = JSON.stringify(response.data,null,"\t");
            this.setState({ imageDetails: response })  //Modal applies the data from the state imageDetails.
            this.setState({ selectedReceiptDetails: true }); // Toggles the modal.
        });
}
</code>```

With Actions and Reducers

ACTION CREATOR

```<code>export function getImageDetails() {
    return function (dispatch) {
        axios.get(`http://demoapiwebsite`)
            .then(response => {
                dispatch({
                    type: IMAGE_DETAILS,
                    payload: response.data
                });
                console.log(response.data);
            })
    }
}
</code>```

REDUCER

```<code>import {
    IMAGE_DETAILS,
} from '../actions/types';

export default function (state = {imageDetails:''}, action) {
    switch (action.type) {
        case (IMAGE_DETAILS):
            return { ...state, imageDetails: action.payload };
        default:
            return state;
    }
}
</code>```

COMPONENT

```<code> handleImageClick() {
        this.setState({ imageDetails : JSON.stringify(this.props.imageDetails,null,"\t")});
        console.log(this.state.imageDetails)
        this.setState({ selectedReceiptDetails: true }); //Toggles the modal.
    }

//Modal that sets this.state.selectedReceiptDetails to the body

function mapStateToProps(state) {
    return {
        receiptDetails: state.services.receiptDetails,
        imageDetails: state.services.imageDetails
    }
};

export default connect(mapStateToProps, { getImageDetails })(ReceiptService);
</code>```

Please Help!

答:
If you are handling async operation then you must have some Loading block of code before data is available to redux store. Important point about component is it always render with initial state/once after calling fetch action and before async data arrive.

componentWillReceiveProps(nextProps){
 //change the loading state to false if next props is data.
}```

Body:
Good evening everybody!

I'm a total beginner in React and Redux so please bear with me if this sounds stupid.

I'm trying to perform an API call using axios whose response data I need to print onto a modal.

So, if I define the axios.get within a function in the same component it gets the response and I store it to a state and then I display the state in the modal and everything works fine.

But if I do the same using actions and reducers I get an empty the modal the first time I click it.

Without Actions and Reducers

handleImageClick() {
    axios.get(`http://demoapiwebsite`)
        .then(response => {
            response = JSON.stringify(response.data,null,"\t");
            this.setState({ imageDetails: response })  //Modal applies the data from the state imageDetails.
            this.setState({ selectedReceiptDetails: true }); // Toggles the modal.
        });
}

With Actions and Reducers

ACTION CREATOR

export function getImageDetails() {
    return function (dispatch) {
        axios.get(`http://demoapiwebsite`)
            .then(response => {
                dispatch({
                    type: IMAGE_DETAILS,
                    payload: response.data
                });
                console.log(response.data);
            })
    }
}

REDUCER

import {
    IMAGE_DETAILS,
} from '../actions/types';

export default function (state = {imageDetails:''}, action) {
    switch (action.type) {
        case (IMAGE_DETAILS):
            return { ...state, imageDetails: action.payload };
        default:
            return state;
    }
}

COMPONENT

 handleImageClick() {
        this.setState({ imageDetails : JSON.stringify(this.props.imageDetails,null,"\t")});
        console.log(this.state.imageDetails)
        this.setState({ selectedReceiptDetails: true }); //Toggles the modal.
    }

//Modal that sets this.state.selectedReceiptDetails to the body

function mapStateToProps(state) {
    return {
        receiptDetails: state.services.receiptDetails,
        imageDetails: state.services.imageDetails
    }
};

export default connect(mapStateToProps, { getImageDetails })(ReceiptService);

Please Help!


问:
How to get the user logged in
I'm having an issue with trying to set the value to the user that logged in to the website. This is what I have so far but I'm getting this error
Error   CS0200  Property or indexer 'Employee.getName' cannot be assigned to -- it is read only. What changes would I make to set the user that logged in the view

Employee Model

```<code> public class Employee
{
    [Required]
    [Display(Name="Employee Number")]
    public int employeeNum { get; set; }

    [Display(Name = "Employee First Name")]
    public string firstName { get; set; }

    [Display(Name = "Employee Last Name")]
    public string lastName { get; set; }

    [Display(Name = "Employee Department")]
    public string department { get; set; }

    [Display(Name = "Employee Name")]
    public string Name
    {
        get
        {

            return string.Concat(firstName, " ", lastName);
        }
    }

    public string getName
    {
        get {
            IssueDAO dbObj = new IssueDAO();
            dbObj.connectionString = "Server=tw-testdb-04;Database=TWCL_OPERATIONS;uid=sa;password=P@ssw0rd";
            var emp= dbObj.getEmployee(employeeNum);
            return emp;
        }
    }

}
</code>```

}

Controller

```<code>private Requisition getRequisition
    {
        get
        {
            Requisition requisition = (Requisition)Session["Requisition"];
            if (requisition == null)
            {
                requisition = new Requisition();
                Session["Requisition"] = requisition;
            }
            return requisition;

        }

    }

 public ActionResult RequisitionItem()
    {
        //Session.Clear();
        //Set the document number and type to autoamtic values
        IssueDAO dbData = new IssueDAO();
        getRequisition.reqDate= DateTime.Now;
        getRequisition.reqNumber= string.Concat("RN", DateTime.Now.ToString("yyyyMMddhhmmssms"));
        getRequisition.count = 0;
        getRequisition.inventory_account = 5520;
        getRequisition.employeeDetails.getName = System.Web.HttpContext.Current.User.Identity.Name;

        getRequisition.item = new Item();

        return View(getRequisition);
    }
</code>```

答:
Property or indexer 'Employee.getName' cannot be assigned to -- it is
  read only.

The error is self explanatory. In your Employee class, you have defined getName with only get accessor method for this property. That means, the value of it can only read by some other code. You are trying to set the value to this property and hence the compiler is complaining about it.

If you want the value of this property to be settable by some other code, you should have a set access modifier on this property.

IMHO, you should keep your view models lean and simple. There should not be any data access code to get data inside a view model properties ( that is mixing 2 concerns ,UI and Data access together!)

I suggest you have a settable and gettable property in your view model to pass the logged in user name

```<code>public class Employee
{
   // Your other properties
   public string LoggedInUserName { set;get;}
}
</code>```

Now you can set this as needed

```<code>var emp=new Employee();
emp.LoggedInUserName = "Any username value here";
</code>```

or

```<code>emp.LoggedInUserName = System.Web.HttpContext.Current.User.Identity.Name;
</code>```

Title: How to get the user logged in

Body:
I'm having an issue with trying to set the value to the user that logged in to the website. This is what I have so far but I'm getting this error
Error   CS0200  Property or indexer 'Employee.getName' cannot be assigned to -- it is read only. What changes would I make to set the user that logged in the view

Employee Model

 public class Employee
{
    [Required]
    [Display(Name="Employee Number")]
    public int employeeNum { get; set; }

    [Display(Name = "Employee First Name")]
    public string firstName { get; set; }

    [Display(Name = "Employee Last Name")]
    public string lastName { get; set; }

    [Display(Name = "Employee Department")]
    public string department { get; set; }

    [Display(Name = "Employee Name")]
    public string Name
    {
        get
        {

            return string.Concat(firstName, " ", lastName);
        }
    }

    public string getName
    {
        get {
            IssueDAO dbObj = new IssueDAO();
            dbObj.connectionString = "Server=tw-testdb-04;Database=TWCL_OPERATIONS;uid=sa;password=P@ssw0rd";
            var emp= dbObj.getEmployee(employeeNum);
            return emp;
        }
    }

}

}

Controller

private Requisition getRequisition
    {
        get
        {
            Requisition requisition = (Requisition)Session["Requisition"];
            if (requisition == null)
            {
                requisition = new Requisition();
                Session["Requisition"] = requisition;
            }
            return requisition;

        }

    }

 public ActionResult RequisitionItem()
    {
        //Session.Clear();
        //Set the document number and type to autoamtic values
        IssueDAO dbData = new IssueDAO();
        getRequisition.reqDate= DateTime.Now;
        getRequisition.reqNumber= string.Concat("RN", DateTime.Now.ToString("yyyyMMddhhmmssms"));
        getRequisition.count = 0;
        getRequisition.inventory_account = 5520;
        getRequisition.employeeDetails.getName = System.Web.HttpContext.Current.User.Identity.Name;

        getRequisition.item = new Item();

        return View(getRequisition);
    }

Body:
Property or indexer 'Employee.getName' cannot be assigned to -- it is
  read only.

The error is self explanatory. In your Employee class, you have defined getName with only get accessor method for this property. That means, the value of it can only read by some other code. You are trying to set the value to this property and hence the compiler is complaining about it.

If you want the value of this property to be settable by some other code, you should have a set access modifier on this property.

IMHO, you should keep your view models lean and simple. There should not be any data access code to get data inside a view model properties ( that is mixing 2 concerns ,UI and Data access together!)

I suggest you have a settable and gettable property in your view model to pass the logged in user name

public class Employee
{
   // Your other properties
   public string LoggedInUserName { set;get;}
}

Now you can set this as needed

var emp=new Employee();
emp.LoggedInUserName = "Any username value here";

or

emp.LoggedInUserName = System.Web.HttpContext.Current.User.Identity.Name;


问:
Clarify the working of add and printNodes functions in this code
In this code I can able to understand the use of X for dynamic type casting. But I can't able to understand how add function really loads the data.

anyone please help me to understand step by step execution of add and printNodes method in detail. Thanks

```<code>class UsingGenericsForLinkedList[X] {
  private class Node[X](elem: X) {
    var next: Node[X] = _
    override def toString = elem.toString
  }
  private var head: Node[X] = _

  def add(elem: X) { //Add element in the linekd list
    val value = new Node(elem)
    value.next = head
    head = value
  }

  private def printNodes(value: Node[X]) { // prining value of the nodes
    if (value != null) {
      println(value)
      printNodes(value.next)
    }
  }
  def printAll() { printNodes(head) } //print all the node values at a time
}
</code>```

答:
In a (singly) linked list, one maintains cells (here the Node class) that carry an element payload and a pointer to the next cell. Here you have a mutable linked list, so the next pointers can be updated (are mutable vars). The outer structure keeps a pointer to head, the first node of the list, which is initially null to indicate an empty list. When you traverse, you find the first node in head, then do something with its payload (the payload is elem in Node which is only made available here through toString), then repeat the procedure by looking at the next pointer, until that becomes null.

Note that add replaces head, and puts the previous value of head into the next field of the newly inserted node. So technically, this prepends an element to the list, it will become the first element to be found. So if you do add(1), add(2), add(3), you get the traversal 3, 2, 1. This is equivalent to :: in Scala's default List class.

Here is a tutorial on Scala's (immutable) List type; the only difference there is that you never replace next or head pointers, but return a new head cell when you prepend.

Body:
In this code I can able to understand the use of X for dynamic type casting. But I can't able to understand how add function really loads the data.

anyone please help me to understand step by step execution of add and printNodes method in detail. Thanks

class UsingGenericsForLinkedList[X] {
  private class Node[X](elem: X) {
    var next: Node[X] = _
    override def toString = elem.toString
  }
  private var head: Node[X] = _

  def add(elem: X) { //Add element in the linekd list
    val value = new Node(elem)
    value.next = head
    head = value
  }

  private def printNodes(value: Node[X]) { // prining value of the nodes
    if (value != null) {
      println(value)
      printNodes(value.next)
    }
  }
  def printAll() { printNodes(head) } //print all the node values at a time
}


问:
Can't delete a Stateful Set in Kubernetes
I can't delete this Stateful Set in Kubernetes, even with --cascade=false so it doesn't delete the Pods managed by it.

```<code>kubectl get statefulsets

NAME                        DESIRED   CURRENT   AGE
assets-elasticsearch-data   0         1         31m
</code>```

Then:

```<code>kubectl delete statefulsets assets-elasticsearch-data
^C
</code>```

... hangs for minutes until I give up, then:

```<code>kubectl delete statefulsets assets-elasticsearch-data --cascade=false
statefulset "assets-elasticsearch-data" deleted
kubectl get statefulsets
NAME                        DESIRED   CURRENT   AGE
assets-elasticsearch-data   0         1         32m
</code>```

I'm using Google's GKE.

答:
Had a similar issue with k8s 1.8. Tried many times and it timedout.
Eventually I tried,

```<code>kubectl delete statefulsets mariadb -n openstack --force
</code>```

error: timed out waiting for "mariadb" to be synced

This appears to work :

```<code>kubectl delete statefulsets mariadb -n openstack --force --grace-period=0 --cascade=false
</code>```

warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.

statefulset "mariadb" deleted

Body:
I can't delete this Stateful Set in Kubernetes, even with --cascade=false so it doesn't delete the Pods managed by it.

kubectl get statefulsets

NAME                        DESIRED   CURRENT   AGE
assets-elasticsearch-data   0         1         31m

Then:

kubectl delete statefulsets assets-elasticsearch-data
^C

... hangs for minutes until I give up, then:

kubectl delete statefulsets assets-elasticsearch-data --cascade=false
statefulset "assets-elasticsearch-data" deleted
kubectl get statefulsets
NAME                        DESIRED   CURRENT   AGE
assets-elasticsearch-data   0         1         32m

I'm using Google's GKE.

Body:
Had a similar issue with k8s 1.8. Tried many times and it timedout.
Eventually I tried,

kubectl delete statefulsets mariadb -n openstack --force

error: timed out waiting for "mariadb" to be synced

This appears to work :

kubectl delete statefulsets mariadb -n openstack --force --grace-period=0 --cascade=false

warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.

statefulset "mariadb" deleted


问:
How to specify my databases name into JDBC -> MySQL connection?
What is the way to connect with JDBC to a mySql database that is online?

mysql.info.mi.us:3006 = corresponds to the server of the database

mydatabases_2 = my databases

my try returning this error:

java.lang.NullPointerException

```<code>Class.forName("com.mysql.jdbc.Driver")
connexion = DriverManager.getConnection("jdbc:mysql://mysql.info.mi.us:3306", "user", "password");
</code>```

答:
Just a question: are you sure about the port?
The default port of mysql is 3306, while you're using 3006. Are you sure the port is right?</p>

Body:
What is the way to connect with JDBC to a mySql database that is online?

mysql.info.mi.us:3006 = corresponds to the server of the database

mydatabases_2 = my databases

my try returning this error:

java.lang.NullPointerException

Class.forName("com.mysql.jdbc.Driver")
connexion = DriverManager.getConnection("jdbc:mysql://mysql.info.mi.us:3306", "user", "password");


问:
How to partition a list in Rebol 2
How does one partition a listin Rebol 2?  I don't care about final order of partitions.

e.g. I imagined there would be a function something like this:

```<code>lst: [1 5 6 5 5 2 1 3]

probe partition lst  ; Assuming identity function by default
[[1 1] [5 5 5] [6] [2] [3]]

probe partition/by lst even?
[[6 2] [1 5 5 5 1 3]]
</code>```

If there is no such inbuilt function, what is the idiomatic way of constructing it in Rebol?

答:
Here's an idiomatic attempt:

partition-unique: func [
    s [block!]
    /local got more
][
    collect [
        parse sort copy s [
            any [
                copy got [
                    set more skip
                    any more
                ] (keep/only got)
            ]
        ]
    ]
]

partition-by: func [
    s [block!]
    f [any-function!]
    /local result
][
    result: reduce [make block! 0 make block! 0]
    forall s [append pick result f s/1 s/1]
    result
]
```

<p>Usage example:</p>

```>> lst: [1 5 6 5 5 2 1 3]
== [1 5 6 5 5 2 1 3]

>> partition-unique lst
== [[1 1] [2] [3] [5 5 5] [6]]

>> partition-by lst :even?
== [[6 2] [1 5 5 5 1 3]]
```

<p>It's easy to combine these into one function.  Here's something to give you the basic idea:</p>

<pre class="lang-lisp prettyprint-override"><code>partition: func [
    s [block!]
    /by f [any-function!]
][
    either by [partition-by s :f] [partition-unique s]
]
</code>```

Title: How to partition a list in Rebol 2

Body:
How does one partition a listin Rebol 2?  I don't care about final order of partitions.

e.g. I imagined there would be a function something like this:

lst: [1 5 6 5 5 2 1 3]

probe partition lst  ; Assuming identity function by default
[[1 1] [5 5 5] [6] [2] [3]]

probe partition/by lst even?
[[6 2] [1 5 5 5 1 3]]

If there is no such inbuilt function, what is the idiomatic way of constructing it in Rebol?

Body:
Here's an idiomatic attempt:

partition-unique: func [
    s [block!]
    /local got more
][
    collect [
        parse sort copy s [
            any [
                copy got [
                    set more skip
                    any more
                ] (keep/only got)
            ]
        ]
    ]
]

partition-by: func [
    s [block!]
    f [any-function!]
    /local result
][
    result: reduce [make block! 0 make block! 0]
    forall s [append pick result f s/1 s/1]
    result
]

Usage example:

>> lst: [1 5 6 5 5 2 1 3]
== [1 5 6 5 5 2 1 3]

>> partition-unique lst
== [[1 1] [2] [3] [5 5 5] [6]]

>> partition-by lst :even?
== [[6 2] [1 5 5 5 1 3]]

It's easy to combine these into one function.  Here's something to give you the basic idea:

partition: func [
    s [block!]
    /by f [any-function!]
][
    either by [partition-by s :f] [partition-unique s]
]


问:
Define macro to log error with file and line in android
I want to make a Error Log that throw in what file and line the problem is using . But I didn't find a good reference. All code is using JNI, C++ side.

This Try fail:

```<code>#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR  , LOG_TAG,"%s %s %s",__VA_ARGS__, __FILE__, __LINE__)
</code>```

This one only show the msg, no the file and line

```<code>#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR  , LOG_TAG,__VA_ARGS__, __FILE__, __LINE__)
</code>```

How could I print all the info clearly?
Is possible to print only some arguments from __VA_ARGS__, something like __VA_NARG__ ?
Extra info or useful references for this kind of things?

答:
This is ancient, but I came across it when searching for the same thing. However, I managed to put together a better solution from multiple sources.

```<code>#define LOGV(fmt, ...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "Your Tag", "%s: " fmt, __FUNCTION__, ## __VA_ARGS__))
</code>```

You should note that ## __VA_ARGS__ is not standard though. Works on GCC and clang though, so no issues with Android.

Body:
I want to make a Error Log that throw in what file and line the problem is using . But I didn't find a good reference. All code is using JNI, C++ side.

This Try fail:

#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR  , LOG_TAG,"%s %s %s",__VA_ARGS__, __FILE__, __LINE__)

This one only show the msg, no the file and line

#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR  , LOG_TAG,__VA_ARGS__, __FILE__, __LINE__)

How could I print all the info clearly?
Is possible to print only some arguments from __VA_ARGS__, something like __VA_NARG__ ?
Extra info or useful references for this kind of things?

Body:
This is ancient, but I came across it when searching for the same thing. However, I managed to put together a better solution from multiple sources.

#define LOGV(fmt, ...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "Your Tag", "%s: " fmt, __FUNCTION__, ## __VA_ARGS__))

You should note that ## __VA_ARGS__ is not standard though. Works on GCC and clang though, so no issues with Android.


问:
How to prevent "force-attribute-nesting" Sass-Lint warnings when applying CSS properties to specific input elements, along with selects and textarea?
I'm using Sass-Lint in my build system and am getting the warning Attribute-selector should be nested within its parent Type-selector when using the following selector:

```<code>input[type='text'],
input[type='number'],
input[type='email'],
input[type='password'],
select,
textarea {
    color: gray;
}
</code>```

How can this be updated to prevent the warning messages, but also apply the CSS properties to all of these elements? (I obviously don't want to apply the attribute selectors to select and textarea, but not sure how else to do it without having two separate selectors with duplicate properies?)

答:
try this one, hope will be helpfull.</p>

```<code>// sass-lint:disable-block no-qualifying-elements force-attribute-nesting
input[type='text'],
input[type='number'],
input[type='email'],
input[type='password'],
select,
textarea {
    color: gray;
}
</code>```

Body:
I'm using Sass-Lint in my build system and am getting the warning Attribute-selector should be nested within its parent Type-selector when using the following selector:

input[type='text'],
input[type='number'],
input[type='email'],
input[type='password'],
select,
textarea {
    color: gray;
}

How can this be updated to prevent the warning messages, but also apply the CSS properties to all of these elements? (I obviously don't want to apply the attribute selectors to select and textarea, but not sure how else to do it without having two separate selectors with duplicate properies?)

Body:
try this one, hope will be helpfull.

// sass-lint:disable-block no-qualifying-elements force-attribute-nesting
input[type='text'],
input[type='number'],
input[type='email'],
input[type='password'],
select,
textarea {
    color: gray;
}