问:
What to do, Learn while Developing the app or Learn first and then develop the app
I am planning to develop a web and mobile application. Have a look on this Question on OnStartups

I have some PHP & MySql knowledge, however I didn't do any major projects so far.

My skills on a scale of 5

PHP&MySql 3/5,

Javascript 3/5

CSS 3/5

Android 1.5/5

IPhone    0/5

web development (2/5)

web    design(2/5)

Software Development &    management
(1.5/5)

My app, as said in one of the answers
in the question, is not much complex
as Mint. If the complexity of Mint is
rated 8. My app would be 5/8

I have lot of interest in programming. Only thing bothering and bogging me is the time to make the app live. I don't understand how to estimate the time as I am not so experienced.

Should I start developing the app and learn all the concepts on the way?

or

should I wait learn programming completely first and then develop the app.?

Edit: A small Edit based on below answers. How should I test myself to know whether I have the minimum web development knowledge to start developing the application.

答: I would strongly recommend getting hold of an MVC framework and figure out how to create applications with it. Without taking time out to "study" web application development, complying with the development pattern enforced by a framework is the best best to writing maintainable web applications. I have twice (in two different companies) come across projects that started as small hacks, didn't follow much structural organisation of code and ended up being extremely messy to enhance later on.</p>


来源: stackexchange

问:
make two side-by-side divs of equal heights
This is my final layout

I want to keep the left column height same as the right one. I am simplifying my html so would be easy for you.

```<code><div id="graphsWindow" style="height:100%; ">
<div class="table" style="height: 100%">
    <div class="row" style="margin-left:0px;margin-top:0px; padding-top:0px; padding-bottom:0px; height:100%;">

   <div style="border:groove; margin-left:10px; margin-bottom:0px; padding-bottom:0px; margin-right:2px; border:groove; height:100%" class="col-md-2">
   </div>
   <div class="col-md-9" style="padding-bottom:0px; padding-top:0px; margin-top:0px; margin-left:15px; height:100%">
   </div>

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

The div with class col-md-2 contains the picture, the prev/next buttons and the list with check boxes

The div with class col-md-9 contains the graphs and the buttons, labels at the bottom.

I have not specified a fixed height any where inside. How can I make the two divs of equal height?

UPDATES

Default Popup Window

Maximized Window

答:
There are a million ways to get this.

height:100% normally doesn't do much.

since you don't have any other divs(like nav or footer)

You could use:

min-height: 50vh; for each

You made need to play with it a bit, but I would remove the height: 100% everywhere, and add a min-height: 50vh; to each row div.

Hopefully this gets you started in the right direction.

If you need another strategy, let me know.

ContentLicense: CC BY-SA 3.0

Body:
This is my final layout

I want to keep the left column height same as the right one. I am simplifying my html so would be easy for you.

The div with class col-md-2 contains the picture, the prev/next buttons and the list with check boxes

The div with class col-md-9 contains the graphs and the buttons, labels at the bottom.

I have not specified a fixed height any where inside. How can I make the two divs of equal height?

UPDATES

Default Popup Window

Maximized Window


问:
Map on filter giving compilation issue
What could be the issue here ?

I get the following error on compilation:

```<code>error: cannot find symbol
                                .collect(toList())
                                         ^
  symbol:   method toList()
  location: class stocks
 error: invalid method reference
                                .map(Stock::getSymbol)
                                     ^
  cannot find symbol
    symbol:   method getSymbol()
    location: class Stock
</code>```

Class Stock does have a public method getSymbol

```<code>   static class StockUtil{

            public static Predicate<Stock> isLessThanLimit(Double limit){
                return s -> s.tick < limit;
            }

            public static String toUpperCase(String stock){
                return stock.toUpperCase();
            }
        }

        public static void main(String[] args) {
            // TODO Auto-generated method stub
            List<Stock> stocks = new ArrayList<>(Arrays.asList(new Stock("AMZ",312.0),
                new Stock("Yahoo",212.0),
                new Stock("ORCL",512.0),
                new Stock("SAP",112.0),
                new Stock("Google",412.0),
                new Stock("FB",12.0),
                new Stock("TWT",315.0)));

            //print list of stock names below 400 in uppercase
            System.out.println(stocks.stream().filter(StockUtil.isLessThanLimit(400.0))
                    .map(Stock::getSymbol)
                    .map(StockUtil::toUpperCase)
                    .collect(toList())
                    );
</code>```

答:
Either make sure you use the complete reference to the method as

```<code>Collectors.toList()
</code>```

or import statically

```<code>import static java.util.stream.Collectors.toList;
</code>```

along with a Stock class somewhat as :

```<code>class Stock {
    String symbol;
    ...
    public String getSymbol() {...} //getter for symbol
    ...
}
</code>```

Ideone it!

Title: Map on filter giving compilation issue

Body:
What could be the issue here ?

I get the following error on compilation:

error: cannot find symbol
                                .collect(toList())
                                         ^
  symbol:   method toList()
  location: class stocks
 error: invalid method reference
                                .map(Stock::getSymbol)
                                     ^
  cannot find symbol
    symbol:   method getSymbol()
    location: class Stock

Class Stock does have a public method getSymbol

   static class StockUtil{

            public static Predicate<Stock> isLessThanLimit(Double limit){
                return s -> s.tick < limit;
            }

            public static String toUpperCase(String stock){
                return stock.toUpperCase();
            }
        }

        public static void main(String[] args) {
            // TODO Auto-generated method stub
            List<Stock> stocks = new ArrayList<>(Arrays.asList(new Stock("AMZ",312.0),
                new Stock("Yahoo",212.0),
                new Stock("ORCL",512.0),
                new Stock("SAP",112.0),
                new Stock("Google",412.0),
                new Stock("FB",12.0),
                new Stock("TWT",315.0)));

            //print list of stock names below 400 in uppercase
            System.out.println(stocks.stream().filter(StockUtil.isLessThanLimit(400.0))
                    .map(Stock::getSymbol)
                    .map(StockUtil::toUpperCase)
                    .collect(toList())
                    );

Body:
Either make sure you use the complete reference to the method as

Collectors.toList()

or import statically

import static java.util.stream.Collectors.toList;

along with a Stock class somewhat as :

class Stock {
    String symbol;
    ...
    public String getSymbol() {...} //getter for symbol
    ...
}

Ideone it!


问:
on rotate mobile webview refresh hide menu
i have a problem i am create an app web view to get and website on play store.

the problem is that it have a dropdown Menu html5+jquery+css3. when i rotate the smartphone, the web are refreshed.

this my code Android Studio 3.0:

Activity xml

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.icarosnet.icarosnetsa.IcarosWeb">

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/wv"
    />

</android.support.constraint.ConstraintLayout>
</code>```

Main.Java

```<code>package com.icarosnet.icarosnetsa;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class IcarosWeb extends AppCompatActivity {
    WebView wv ;

    @Override
    public void onBackPressed(){
        if(wv.canGoBack()){
            wv.goBack();
        }else{
            super.onBackPressed();
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_icaros_web);
        wv= (WebView) findViewById(R.id.wv);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.setFocusable(true);
        wv.setFocusableInTouchMode(true);
        wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
        wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        wv.getSettings().setDomStorageEnabled(true);
        wv.getSettings().setDatabaseEnabled(true);
        wv.getSettings().setAppCacheEnabled(true);
        wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        wv.loadUrl("https://icarosnet.com");
        wv.setWebViewClient(new WebViewClient());
    }
    @Override
    protected void onSaveInstanceState(Bundle outState ){
        super.onSaveInstanceState(outState);
        wv= (WebView) findViewById(R.id.wv);
        wv.saveState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState){
        super.onRestoreInstanceState(savedInstanceState);
        wv= (WebView) findViewById(R.id.wv);
        wv.restoreState(savedInstanceState);
    }

}
</code>```

Xml Manifest

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.icarosnet.icarosnetsa">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".IcarosWeb">
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
</code>```

does not respect the content that was loaded by ajax.

how can i prevent refresh and resize the view; or how can i show it only portrait and block the view.

答:
```<code>@Override
    protected void onSaveInstanceState(Bundle outState )
    {
        super.onSaveInstanceState(outState);
        wv.saveState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState)
    {
        super.onRestoreInstanceState(savedInstanceState);
        wv.restoreState(savedInstanceState);
    }
</code>```

Body:
i have a problem i am create an app web view to get and website on play store.

the problem is that it have a dropdown Menu html5+jquery+css3. when i rotate the smartphone, the web are refreshed.

this my code Android Studio 3.0:

Activity xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.icarosnet.icarosnetsa.IcarosWeb">

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/wv"
    />

</android.support.constraint.ConstraintLayout>

Main.Java

package com.icarosnet.icarosnetsa;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class IcarosWeb extends AppCompatActivity {
    WebView wv ;

    @Override
    public void onBackPressed(){
        if(wv.canGoBack()){
            wv.goBack();
        }else{
            super.onBackPressed();
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_icaros_web);
        wv= (WebView) findViewById(R.id.wv);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.setFocusable(true);
        wv.setFocusableInTouchMode(true);
        wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
        wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        wv.getSettings().setDomStorageEnabled(true);
        wv.getSettings().setDatabaseEnabled(true);
        wv.getSettings().setAppCacheEnabled(true);
        wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        wv.loadUrl("https://icarosnet.com");
        wv.setWebViewClient(new WebViewClient());
    }
    @Override
    protected void onSaveInstanceState(Bundle outState ){
        super.onSaveInstanceState(outState);
        wv= (WebView) findViewById(R.id.wv);
        wv.saveState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState){
        super.onRestoreInstanceState(savedInstanceState);
        wv= (WebView) findViewById(R.id.wv);
        wv.restoreState(savedInstanceState);
    }

}

Xml Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.icarosnet.icarosnetsa">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".IcarosWeb">
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

does not respect the content that was loaded by ajax.

how can i prevent refresh and resize the view; or how can i show it only portrait and block the view.


问:
Filter dynamic table result using multiple dropdown
I have a stock table looks like this:

```<code> Supplier  |  Category  |  ItemID  |  Stock  |  SafetyLimit  |  Status
------------------------------------------------------------------------
   ABC     |  FOOD      |   001    |    200  |        140    |  Safe
   ABC     |  FOOD      |   004    |     50  |        100    |  Risky
   DEF     |  NON FOOD  |   002    |    150  |        100    |  Safe
   DEF     |  FOOD      |   006    |     32  |         50    |  Risky
</code>```

I'm trying to make 3 filters for that table based on Supplier (All, ABC, DEF), Category (All, Food, Non-Food), and Status (Safe, Risky). I found this script:

```<code>$('select').change(function () {
   var current = this.value;
   if (current == 'all') {
      $('#FilterContainer').find('div.all').show();
   } else {
      $('#FilterContainer').find('div').hide();
      $('#FilterContainer').find('div.all.' + current).show();
   }
   return false;
});
</code>```

working perfectly from this JS Fiddle, but in my case, my table isn't static. It's data get populated dynamically. Would anyone help me please with this? Thank you.

答:
I don't know your data structure, but if it is populated dynamically you can do something like this.

First, find unique values for each filters:

```<code>// Example for suppliers
const suppliers = ['ABC', 'ABC', 'DEF', 'DEF'];  // Your suppliers data
const uniqueSuppliers = Array.from(new Set(suppliers));  // ['ABC', 'DEF']
const supplierFilterValues = ['All', ...uniqueSuppliers];  // ['All', 'ABC', 'DEF']
</code>```

Now user can choose from supplierFilterValues to filter data, for example user want to show only rows with 'DEF' supplier:

```<code>const tableData = [{
    supplier: 'ABC',
    category: 'FOOD',
    itemID: '001',
    stock: '200',
    safetyLimit: '140',
    status: 'Safe',
}, {
    supplier: 'DEF',
    category: 'NON FOOD',
    itemID: '002',
    stock: '150',
    safetyLimit: '100',
    status: 'Safe',
}];
const dataToShow = tableData.filter((item) => item.supplier === 'DEF');
</code>```

Body:
I have a stock table looks like this:

 Supplier  |  Category  |  ItemID  |  Stock  |  SafetyLimit  |  Status
------------------------------------------------------------------------
   ABC     |  FOOD      |   001    |    200  |        140    |  Safe
   ABC     |  FOOD      |   004    |     50  |        100    |  Risky
   DEF     |  NON FOOD  |   002    |    150  |        100    |  Safe
   DEF     |  FOOD      |   006    |     32  |         50    |  Risky

I'm trying to make 3 filters for that table based on Supplier (All, ABC, DEF), Category (All, Food, Non-Food), and Status (Safe, Risky). I found this script:

$('select').change(function () {
   var current = this.value;
   if (current == 'all') {
      $('#FilterContainer').find('div.all').show();
   } else {
      $('#FilterContainer').find('div').hide();
      $('#FilterContainer').find('div.all.' + current).show();
   }
   return false;
});

working perfectly from this JS Fiddle, but in my case, my table isn't static. It's data get populated dynamically. Would anyone help me please with this? Thank you.

Body:
I don't know your data structure, but if it is populated dynamically you can do something like this.

First, find unique values for each filters:

// Example for suppliers
const suppliers = ['ABC', 'ABC', 'DEF', 'DEF'];  // Your suppliers data
const uniqueSuppliers = Array.from(new Set(suppliers));  // ['ABC', 'DEF']
const supplierFilterValues = ['All', ...uniqueSuppliers];  // ['All', 'ABC', 'DEF']

Now user can choose from supplierFilterValues to filter data, for example user want to show only rows with 'DEF' supplier:

const tableData = [{
    supplier: 'ABC',
    category: 'FOOD',
    itemID: '001',
    stock: '200',
    safetyLimit: '140',
    status: 'Safe',
}, {
    supplier: 'DEF',
    category: 'NON FOOD',
    itemID: '002',
    stock: '150',
    safetyLimit: '100',
    status: 'Safe',
}];
const dataToShow = tableData.filter((item) => item.supplier === 'DEF');


问:
remove characters before and after character in java
I need to delete all characters before and after a specific character using java programming
for example:

input: ab*cd output:ad

input: ab**cd output:ad

```<code>import java.util.Scanner;

public class Starstring {
    public static void main(String[] args) {
        String str1;
        String res="";
        int n,i=0;

        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the string");
        str1=sc.next();
        res=str1;
        StringBuffer a = new StringBuffer(str1);
        n=str1.length()-1;
        for(i=0;i<n;i++)
        {
            if(str1.charAt(i)=='*')
            {
                res=a.delete(i-1, i+2).toString();
            }
        }
        System.out.println("The final string is"+res);
    }

}
</code>```

I am getting expected output for case 1 but case 2 wrong output with ac as output.I don't know where I am going wrong.Someone please help me.Thanks in advance:)

答:
You can use regex to replace character group in your string. To remove * and 1 character before & after it:

```<code>Pattern pt = Pattern.compile(".\\*+.");
Matcher match = pt.matcher(input);
String output = match.replaceAll("");
//System.out.println(output);
</code>```

Body:
I need to delete all characters before and after a specific character using java programming
for example:

input: ab*cd output:ad

input: ab**cd output:ad

import java.util.Scanner;

public class Starstring {
    public static void main(String[] args) {
        String str1;
        String res="";
        int n,i=0;

        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the string");
        str1=sc.next();
        res=str1;
        StringBuffer a = new StringBuffer(str1);
        n=str1.length()-1;
        for(i=0;i<n;i++)
        {
            if(str1.charAt(i)=='*')
            {
                res=a.delete(i-1, i+2).toString();
            }
        }
        System.out.println("The final string is"+res);
    }

}

I am getting expected output for case 1 but case 2 wrong output with ac as output.I don't know where I am going wrong.Someone please help me.Thanks in advance:)

Body:
You can use regex to replace character group in your string. To remove * and 1 character before & after it:

Pattern pt = Pattern.compile(".\\*+.");
Matcher match = pt.matcher(input);
String output = match.replaceAll("");
//System.out.println(output);


问:
splinter: how to add chrome options?
I'm using splinter(v0.7.3) for web testing under linux, while on chrome, the default sample code can not running:

```<code>from splinter import Browser
from pyvirtualdisplay import Display

d = Display(visible=0, size=(800, 600))
d.start()

b = Browser('chrome')
b.visit('http://www.google.com')
b.quit()

d.stop()
</code>```

While running, I got the exception like this:

```<code>selenium.common.exceptions.WebDriverException: Message: chrome not reachable
</code>```

And I test the same function in selenium with some chrome option added:

```<code>from selenium import web driver
from selenium.webdriver.chrome.options import Options
from pyvirtualdisplay import Display

d = Display(visible=0, size=(800, 600))
d.start()

opt = Options()
opt.add_argument('--disable-setuid-sandbox')
b = webdriver.Chrome(chrome_options=opt)
b.get('http://www.google.com')
b.quit()

d.stop()
</code>```

This works ok, the difference is the --disable-setuid-sandbox option added to chrome driver, if the option not add, there would be a zombie chrome-sandbox process under chromium-browser.

The problem here is, I don't know how to pass a chrome.options.Option instance to splinter.Browser(), I browsed the implementation under splinter/driver/webdriver/chrome.py, it seems that there is no entry to pass such a instance to splinter.Browser(). Is there some other way to pass options to chrome driver?

答:
The only way I could ever do this was by using the add_argument method with selenium.webdriver.ChromeOptions like so:

```<code>from selenium.webdriver import ChromeOptions
from splinter import Browser

chrome_options = ChromeOptions()
chrome_options.add_argument(your_argument)

b=Browser("chrome", options=chrome_options)
b.visit('http://www.google.com')
b.quit()
</code>```

so in your code would be:

```<code>from splinter import Browser
from selenium.webdriver import ChromeOptions
from pyvirtualdisplay import Display #I'm not certain what this is...

d = Display(visible=0, size=(800, 600))
d.start()

chrome_options = ChromeOptions()
chrome_options.add_argument('disable-setuid-sandbox')

b = Browser('chrome')
b.visit('http://www.google.com')
b.quit()

d.stop()
</code>```

Note: I was unable to test this with your argument specifically because I recently broke my GRUB so I am stuck in windows, and the disable-setuid-sandbox option is linux-only. However, I have been using this method with the headless argument for a while.

Title: splinter: how to add chrome options?

Body:
I'm using splinter(v0.7.3) for web testing under linux, while on chrome, the default sample code can not running:

from splinter import Browser
from pyvirtualdisplay import Display

d = Display(visible=0, size=(800, 600))
d.start()

b = Browser('chrome')
b.visit('http://www.google.com')
b.quit()

d.stop()

While running, I got the exception like this:

selenium.common.exceptions.WebDriverException: Message: chrome not reachable

And I test the same function in selenium with some chrome option added:

from selenium import web driver
from selenium.webdriver.chrome.options import Options
from pyvirtualdisplay import Display

d = Display(visible=0, size=(800, 600))
d.start()

opt = Options()
opt.add_argument('--disable-setuid-sandbox')
b = webdriver.Chrome(chrome_options=opt)
b.get('http://www.google.com')
b.quit()

d.stop()

This works ok, the difference is the --disable-setuid-sandbox option added to chrome driver, if the option not add, there would be a zombie chrome-sandbox process under chromium-browser.

The problem here is, I don't know how to pass a chrome.options.Option instance to splinter.Browser(), I browsed the implementation under splinter/driver/webdriver/chrome.py, it seems that there is no entry to pass such a instance to splinter.Browser(). Is there some other way to pass options to chrome driver?

Body:
The only way I could ever do this was by using the add_argument method with selenium.webdriver.ChromeOptions like so:

from selenium.webdriver import ChromeOptions
from splinter import Browser

chrome_options = ChromeOptions()
chrome_options.add_argument(your_argument)

b=Browser("chrome", options=chrome_options)
b.visit('http://www.google.com')
b.quit()

so in your code would be:

from splinter import Browser
from selenium.webdriver import ChromeOptions
from pyvirtualdisplay import Display #I'm not certain what this is...

d = Display(visible=0, size=(800, 600))
d.start()

chrome_options = ChromeOptions()
chrome_options.add_argument('disable-setuid-sandbox')

b = Browser('chrome')
b.visit('http://www.google.com')
b.quit()

d.stop()

Note: I was unable to test this with your argument specifically because I recently broke my GRUB so I am stuck in windows, and the disable-setuid-sandbox option is linux-only. However, I have been using this method with the headless argument for a while.


问:
Developing CLDC or J2ME applications under Mac OSX?
I have noticed that Oracle now has released a Java Platform Micro Edition SDK for OSX. It works, it can compile the provided examples and the included phone emulator works too. But how do I compile my own J2ME project from Ant or Eclipse?

There are a lot of related jars but they are all inside the ".app" in the /Applications directory. Eclipse does not like it when I put a toolchain path to inside the ".app".

答:
Have you tried using the EclipseME plugin? It helps integrate JavaME (J2ME) development into Eclipse. Here's a guide for getting it working with Eclipse:

Eclipse ME / Configuration

You'll find plenty of documentation and how tos.

If you don't like EclipseME, I personally found Netbeans very good for mobile development:

Netbeans JavaME Page

Also, you weren't specific in your question, but the link you've provided seems to indicate you want to use MTJ. In that case, use this documentation to guide you through:

Eclipse MTJ - Getting Started

ContentLicense: CC BY-SA 2.5


答:
Use regex to replace more than one * with single *. Your code will be like below:

```<code>input:ab*cd output:ad
input ab**cd  ouput:ad
import java.util.Scanner;

public class Starstring {
    public static void main(String[] args) {
        String str1;
        String res="";
        int n,i=0;

        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the string");
        str1=sc.next();
        res=str1;
        str1 = str1.replaceAll("[*]+", "*");// add this line
        StringBuffer a = new StringBuffer(str1);
        n=str1.length()-1;
        for(i=0;i<n;i++)
        {
            if(str1.charAt(i)=='*')
            {
                res=a.delete(i-1, i+2).toString();
            }
        }
        System.out.println("The final string is"+res);
    }

}
</code>```

Title: remove characters before and after character in java

Body:
Use regex to replace more than one * with single *. Your code will be like below:

input:ab*cd output:ad
input ab**cd  ouput:ad
import java.util.Scanner;

public class Starstring {
    public static void main(String[] args) {
        String str1;
        String res="";
        int n,i=0;

        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the string");
        str1=sc.next();
        res=str1;
        str1 = str1.replaceAll("[*]+", "*");// add this line
        StringBuffer a = new StringBuffer(str1);
        n=str1.length()-1;
        for(i=0;i<n;i++)
        {
            if(str1.charAt(i)=='*')
            {
                res=a.delete(i-1, i+2).toString();
            }
        }
        System.out.println("The final string is"+res);
    }

}


问:
Boolean logic for validation is failing
```<code>public static boolean isValidReferenceCode(String rc) {
    boolean validCode = true;
    if (rc.length() != 6 ) {
        validCode = false;
    } else if ( !Character.isLetter(rc.charAt(0)) ||
                !Character.isLetter(rc.charAt(1)) ||
                !Character.isDigit(rc.charAt(2)) ||
                !Character.isDigit(rc.charAt(3)) ||
                !Character.isDigit(rc.charAt(4)) ||
                !Character.isLetter(rc.charAt(5))) {
        validCode = false;
    } else if ( (!rc.substring(5).matches("B")) || (!rc.substring(5).matches("N")) ) {
        validCode = false;
    }
    return validCode;
}
</code>```

<p>This is my validation method inside a big program, I need a validation that requires the user to input at least 6 characters, first two being letters, next three being digits, and the last character either a "B" or "N" right now it's not doing that. After some trial and error, the first two IF statements seem to be correct and work when I delete the 3rd if statement about substrings, am I using the correct Syntax here? Would really appreciate help! </p>

答:
Another way to solve it is to use the original code with:

} else if ( (rc.charAt(5) != 'B') && (rc.charAt(5) != 'N') ) {
```

You need both to be misses (i.e., use an && instead of an ||).

Title: Boolean logic for validation is failing

Body:
public static boolean isValidReferenceCode(String rc) {
    boolean validCode = true;
    if (rc.length() != 6 ) {
        validCode = false;
    } else if ( !Character.isLetter(rc.charAt(0)) ||
                !Character.isLetter(rc.charAt(1)) ||
                !Character.isDigit(rc.charAt(2)) ||
                !Character.isDigit(rc.charAt(3)) ||
                !Character.isDigit(rc.charAt(4)) ||
                !Character.isLetter(rc.charAt(5))) {
        validCode = false;
    } else if ( (!rc.substring(5).matches("B")) || (!rc.substring(5).matches("N")) ) {
        validCode = false;
    }
    return validCode;
}

This is my validation method inside a big program, I need a validation that requires the user to input at least 6 characters, first two being letters, next three being digits, and the last character either a "B" or "N" right now it's not doing that. After some trial and error, the first two IF statements seem to be correct and work when I delete the 3rd if statement about substrings, am I using the correct Syntax here? Would really appreciate help!

Body:
Another way to solve it is to use the original code with:

} else if ( (rc.charAt(5) != 'B') && (rc.charAt(5) != 'N') ) {

You need both to be misses (i.e., use an && instead of an ||).


问:
Can I depend on check constraint to ensure non-negative balance?
I currently have a table as follows:

```<code>CREATE TABLE Account (
 ID int NOT NULL,
 Balance int,
 CHECK (Balance>=0)
);
</code>```

I also have some application pseudo-code as follows:

```<code>function updateBalance(id Int, howMuch Int) {
 check howMuch is non zero (can be negative or positive)
 read balance for id as bal
 if bal + howMuch >= 0 update else throw error
}
</code>```

I feel that reading balance and checking >= 0 is unnecessary and time consuming, since the database I plan to use supports check constraints (most likely PostgreSQL or H2). Certain ones (such as MySQL) don't support check constraints and will silently ignore them in the create statement).

Should I rely on the database to ensure non-negative balance or do it also within my app?

答:
Use a CHECK constraint in the DB. It's absolutely reliable in PostgreSQL.

You may still want to check input in the app before writing to the DB to avoid raising an exception to begin with, additionally. But you never need to double-check data retrieved from the DB. That's what an RDBMS like Postgres is made for.

Body:
I currently have a table as follows:

CREATE TABLE Account (
 ID int NOT NULL,
 Balance int,
 CHECK (Balance>=0)
);

I also have some application pseudo-code as follows:

function updateBalance(id Int, howMuch Int) {
 check howMuch is non zero (can be negative or positive)
 read balance for id as bal
 if bal + howMuch >= 0 update else throw error
}

I feel that reading balance and checking >= 0 is unnecessary and time consuming, since the database I plan to use supports check constraints (most likely PostgreSQL or H2). Certain ones (such as MySQL) don't support check constraints and will silently ignore them in the create statement).

Should I rely on the database to ensure non-negative balance or do it also within my app?


问:
Edittext as spinner
I have a editext which I would like to show as drop down. SO for that I have background.xml file:

```<code><?xml version="1.0" encoding="utf-8" ?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

  <item>
    <layer-list>
      <item>
        <shape>
          <solid android:color="#ffffff" />
          <stroke android:width="1dp" android:color="#000000" />
          <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape>
      </item>
      <item>
        <bitmap android:gravity="right" android:src="@drawable/ic_arrow_drop_down" />
      </item>
    </layer-list>
  </item>

</selector>
</code>```

And added that as background for my edittext. This is what I get:

As you can see there is slight gap between the image and editext border. I would like to make my edittext like this:

How can I achieve this?

答:
Try this

```<code>  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bg"
        android:orientation="horizontal">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@android:color/transparent" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerInParent="true"
            android:background="@drawable/bgnew"
            android:src="@drawable/ic_android_black_24dp" />
    </LinearLayout>

</LinearLayout>
</code>```

Create bg.xml like this

```<code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Background Color -->
    <solid android:color="#ffffff" />

    <!-- Border Color -->
    <stroke android:width="1dp" android:color="#ff9900" />

</shape>
</code>```

create a bgnew.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Background Color -->
    <solid android:color="#ffffff" />

    <!-- Border Color -->
    <stroke android:width="1dp" android:color="@color/colorAccent" />

</shape>
</code>```

Output

Title: Edittext as spinner

Body:
I have a editext which I would like to show as drop down. SO for that I have background.xml file:

<?xml version="1.0" encoding="utf-8" ?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

  <item>
    <layer-list>
      <item>
        <shape>
          <solid android:color="#ffffff" />
          <stroke android:width="1dp" android:color="#000000" />
          <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape>
      </item>
      <item>
        <bitmap android:gravity="right" android:src="@drawable/ic_arrow_drop_down" />
      </item>
    </layer-list>
  </item>

</selector>

And added that as background for my edittext. This is what I get:

As you can see there is slight gap between the image and editext border. I would like to make my edittext like this:

How can I achieve this?

Body:
Try this

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bg"
        android:orientation="horizontal">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@android:color/transparent" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerInParent="true"
            android:background="@drawable/bgnew"
            android:src="@drawable/ic_android_black_24dp" />
    </LinearLayout>

</LinearLayout>

Create bg.xml like this

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Background Color -->
    <solid android:color="#ffffff" />

    <!-- Border Color -->
    <stroke android:width="1dp" android:color="#ff9900" />

</shape>

create a bgnew.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Background Color -->
    <solid android:color="#ffffff" />

    <!-- Border Color -->
    <stroke android:width="1dp" android:color="@color/colorAccent" />

</shape>

Output


问:
Remove all HTML tags *AND* content from json response
I am aware of this solution - str.replace(/<\/?[^>]+>/gi, '') - which removes the HTML tags from json response.

```<code>{"fdfd":4}<p>fdfdf</p> -> {"fdfd":4} fdfdf
</code>```

However i want to remove all content within the HTML, script tags as well for which i am seeking a solution.
Requirement -

```<code>{"fdfd":4}<p>fdfdf</p> -> {"fdfd":4}
</code>```

答:
To do that you have to use this regex

      var str='{"fdfd":4}
fdfdf
';
      console.log(str.replace(/<[^>]+>[^\n]+<\/?[^>]+>/gi, ''));
      ```

Body:
I am aware of this solution - str.replace(/<\/?[^>]+>/gi, '') - which removes the HTML tags from json response.

{"fdfd":4}
fdfdf
 -> {"fdfd":4} fdfdf

However i want to remove all content within the HTML, script tags as well for which i am seeking a solution.
Requirement -

{"fdfd":4}
fdfdf
 -> {"fdfd":4}

Body:
To do that you have to use this regex

      var str='{"fdfd":4}<p>fdfdf</p>';
      console.log(str.replace(/<[^>]+>[^\n]+<\/?[^>]+>/gi, ''));


问:
How to update a DataGridView
I have the following

IQueryable objs = 'some linq-to-entity query';

dataGridView1.DataSource = objs;

Which works fine. After the data is updated I need to refresh the dataGridView; I can't find anyway to refresh the grid, I have tried ReFresh(), Invalidate(). Looked at many questions/posts on this site and others but nothing happens.

Does anyone know a way to update a DataGridView?

Cheers

答:
You will have to assign the datasource again.
Once you know your data is updated, </p>

```<code>dataGridView1.DataSource = objs;
</code>```

Title: How to update a DataGridView

Body:
You will have to assign the datasource again.
Once you know your data is updated,

dataGridView1.DataSource = objs;


问:
How can I enable VoiceOver for webview content on tableview
Normally, VoiceOver correctly reads web contents loaded with WKWebView and it is possible to read buttons and links.

However,　when I added WKWebView on UITableViewCell and displayed in UITableVIew, VoiceOver could not recognize it.

According to the tableview document of apple, in order to make each content on UITableViewCell recognized by VoiceOver separately,
It is necessary to set isAccessibilityElement of cell to false and set isAccessibilityElement of view to be recognized to be true.

but if isAccesibilityElement ofWKWebView is set to true, view itself is focused and we can not recognize the inside web contents.

Also, when VoiceOver was enabled for the first time after loading the Web content, it performed strange behavior that Web content could be recognized.

I suspected the problem of VoiceOver content recognition timing, I tried running

```<code>UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil)
</code>```

or

```<code>UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil)
</code>```

after loading the web content, but it did not get a good result.

Is there a good way to handle contents in wkwebview on tableView to VoiceOver?

答:
So, I'll explain the behavior you're seeing.  Essentially, VoiceOver will only focus the first accessibility element in a tree. So any view that is an Accessibility Element will not have its children that are accessibility elements be focused.

Now as for your situation, I'm curious as to your scenario. I find it likely that you need to provide more detail. When I picture a tableview, I picture multiple WKWebViews in one view, which would be weird indeed.

The typical markup for a webview would be to just have NOTHING set as an accessibility element, and let the WebView determine which elements within are accessible. WKWebView should take care of reporting HTML content as proper native accessibility elements for you. To do anything else is going to corrupt what WKWebView is going. HOWEVER, if you have multiple webviews in one app, this may muck things up.  Ultimately, if it didn't work the way I outlined (just by leaving things alone, and marking everything as "not" an accessibility element), this would be a bug, but a bug that you would have to deal with.

The solution THEN becomes overriding the UIAccessibilityContainer protocol for your webview, and providing custom feedback for it. Not ideal, would be painful. More details would help, but at least now you can understand a little more about what is going on.

Another simple solution would be, if the content in your webview is very simple, you could set accessibility element to true, and provide a description of the content for the entire webview through the accessibilityLabel, accessibilityValue and accessibilityTraits. Just be sure you catch all of the information, and that any actions are still actionable!

Body:
Normally, VoiceOver correctly reads web contents loaded with WKWebView and it is possible to read buttons and links.

However,　when I added WKWebView on UITableViewCell and displayed in UITableVIew, VoiceOver could not recognize it.

According to the tableview document of apple, in order to make each content on UITableViewCell recognized by VoiceOver separately,
It is necessary to set isAccessibilityElement of cell to false and set isAccessibilityElement of view to be recognized to be true.

but if isAccesibilityElement ofWKWebView is set to true, view itself is focused and we can not recognize the inside web contents.

Also, when VoiceOver was enabled for the first time after loading the Web content, it performed strange behavior that Web content could be recognized.

I suspected the problem of VoiceOver content recognition timing, I tried running

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil)

or

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil)

after loading the web content, but it did not get a good result.

Is there a good way to handle contents in wkwebview on tableView to VoiceOver?


问:
Scala groupBy for a list
I'd like to create a map on which the key is the string and the value is the number of how many times the string appears on the list. I tried the groupBy method, but have been unsuccessful with that.

答:
Suppose you have a list as

```<code>scala> val list = List("abc", "abc", "bc", "b", "abc")
list: List[String] = List(abc, abc, bc, b, abc)
</code>```

You can write a function

```<code>scala> def generateMap(list: List[String], map:Map[String, Int]) : Map[String, Int] = list match {
     |       case x :: y => if(map.keySet.contains(x)) generateMap(y, map ++ Map(x -> (map(x)+1))) else generateMap(y, map ++ Map(x -> 1))
     |       case Nil => map
     |     }
generateMap: (list: List[String], map: Map[String,Int])Map[String,Int]
</code>```

Then call the function as

```<code>scala> generateMap(list, Map.empty)
res1: Map[String,Int] = Map(abc -> 3, bc -> 1, b -> 1)
</code>```

ContentLicense: CC BY-SA 4.0

Title: Scala groupBy for a list

Body:
Suppose you have a list as

scala> val list = List("abc", "abc", "bc", "b", "abc")
list: List[String] = List(abc, abc, bc, b, abc)

You can write a function

scala> def generateMap(list: List[String], map:Map[String, Int]) : Map[String, Int] = list match {
     |       case x :: y => if(map.keySet.contains(x)) generateMap(y, map ++ Map(x -> (map(x)+1))) else generateMap(y, map ++ Map(x -> 1))
     |       case Nil => map
     |     }
generateMap: (list: List[String], map: Map[String,Int])Map[String,Int]

Then call the function as

scala> generateMap(list, Map.empty)
res1: Map[String,Int] = Map(abc -> 3, bc -> 1, b -> 1)


问:
video play in UIView in ios
I  am developing an app in objective-c.

In my UIViewController

.h file

```<code>@property(weak,nonatomic)IBOutlet UIView *vvv;
</code>```

.m file

```<code>  // to play the video
    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"alphabet learning splash" ofType:@"mp4"];
    NSURL *fileURL = [NSURL fileURLWithPath:filepath];

    self.avPlayer = [AVPlayer playerWithURL:fileURL];
    self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];

    [_vvv.layer addSublayer:videoLayer];
    [self.view addSubview:_vvv];
    [ self.avPlayer play];
</code>```

But the video is not displaying in the  UIView of vvv.How to set?

答:
Try setting the bounds</p>

```<code>// to play the video
NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"alphabet learning splash" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];

self.avPlayer = [AVPlayer playerWithURL:fileURL];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];

[_vvv.layer addSublayer:videoLayer];
[self.view addSubview:_vvv];
_vvv.frame = self.bounds;
[ self.avPlayer play];
</code>```

Title: video play in UIView in ios

Body:
I  am developing an app in objective-c.

In my UIViewController

.h file

@property(weak,nonatomic)IBOutlet UIView *vvv;

.m file

  // to play the video
    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"alphabet learning splash" ofType:@"mp4"];
    NSURL *fileURL = [NSURL fileURLWithPath:filepath];

    self.avPlayer = [AVPlayer playerWithURL:fileURL];
    self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];

    [_vvv.layer addSublayer:videoLayer];
    [self.view addSubview:_vvv];
    [ self.avPlayer play];

But the video is not displaying in the  UIView of vvv.How to set?

Body:
Try setting the bounds

// to play the video
NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"alphabet learning splash" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];

self.avPlayer = [AVPlayer playerWithURL:fileURL];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];

[_vvv.layer addSublayer:videoLayer];
[self.view addSubview:_vvv];
_vvv.frame = self.bounds;
[ self.avPlayer play];


问:
How to write two operations at a time inside function in node.js?
I have two tables in my database, i want to get both datas with one function using nodejs

My table name is ContactGroup and Group

My code:

```<code>exports.getNewGroup = function (req, res) {
    ContactGroup.findAndCountAll({
        attributes: ['id', [sequelize.fn('COUNT', sequelize.col('group.id')),
            'contactCount'
        ]],
        include: [{
            model: Group,
        }],
    }).then(seenData => {
        console.log('seenData:', seenData);
    });

    Group.findAll().then(function (data) {
        return res.status(200).send(data);
    }).catch(function (err) {
        return res.status(400).send(err.message);
    });
};
</code>```

Like above code, i am writing ContactGroup.findandcount and Group.findall, i checked this api via postman, but only one working here,
I want both of them working? help me!

答:
although others  answers are  correct but as i saw there are two independent  async function so it's better to populate them parallel (more performance gain) as below.

```<code>exports.getNewGroup = function (req, res) {
    p1= ContactGroup.findAndCountAll({
        attributes: ['id', [sequelize.fn('COUNT', sequelize.col('group.id')),
            'contactCount'
        ]],
        include: [{
            model: Group,
        }],
    })
    p2 =Group.findAll()

    Promise.all([p1,p2]).then(values => {
        console.log(values);
    })
    .catch(function (err) {
       return res.status(400).send(err.message);
    });

};
</code>```

Body:
I have two tables in my database, i want to get both datas with one function using nodejs

My table name is ContactGroup and Group

My code:

exports.getNewGroup = function (req, res) {
    ContactGroup.findAndCountAll({
        attributes: ['id', [sequelize.fn('COUNT', sequelize.col('group.id')),
            'contactCount'
        ]],
        include: [{
            model: Group,
        }],
    }).then(seenData => {
        console.log('seenData:', seenData);
    });

    Group.findAll().then(function (data) {
        return res.status(200).send(data);
    }).catch(function (err) {
        return res.status(400).send(err.message);
    });
};

Like above code, i am writing ContactGroup.findandcount and Group.findall, i checked this api via postman, but only one working here,
I want both of them working? help me!

Body:
although others  answers are  correct but as i saw there are two independent  async function so it's better to populate them parallel (more performance gain) as below.

exports.getNewGroup = function (req, res) {
    p1= ContactGroup.findAndCountAll({
        attributes: ['id', [sequelize.fn('COUNT', sequelize.col('group.id')),
            'contactCount'
        ]],
        include: [{
            model: Group,
        }],
    })
    p2 =Group.findAll()

    Promise.all([p1,p2]).then(values => {
        console.log(values);
    })
    .catch(function (err) {
       return res.status(400).send(err.message);
    });

};


答:
With bootstrap-4, For equal height columns use row-eq-height

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>

.row.row-eq-height > .col-xs-4

.row.row-eq-height > .col-xs-4
this is
a much
taller
column
than the others

.row.row-eq-height > .col-xs-4

```
</div>
</div>
</p>

<p>Ref: http://getbootstrap.com.vn/examples/equal-height-columns/</p>

<p>add this css if you are using bootstrap 3 </p>

```@media (min-width: 768px) {
  .row.row-eq-height{
    display: flex;
    flex-wrap: wrap;
  }
}
```

Title: make two side-by-side divs of equal heights

Body:
This is my final layout

I want to keep the left column height same as the right one. I am simplifying my html so would be easy for you.

The div with class col-md-2 contains the picture, the prev/next buttons and the list with check boxes

The div with class col-md-9 contains the graphs and the buttons, labels at the bottom.

I have not specified a fixed height any where inside. How can I make the two divs of equal height?

UPDATES

Default Popup Window

Maximized Window

Body:
With bootstrap-4, For equal height columns use row-eq-height

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
    <div class="row row-eq-height">
            <div class="col-xs-4" style="border: 1px solid grey;">.row.row-eq-height &gt; .col-xs-4</div>
            <div class="col-xs-4" style="border: 1px solid grey;">.row.row-eq-height &gt; .col-xs-4<br>this is<br>a much<br>taller<br>column<br>than the others</div>
            <div class="col-xs-4" style="border: 1px solid grey;">.row.row-eq-height &gt; .col-xs-4</div>
          </div>

Ref: http://getbootstrap.com.vn/examples/equal-height-columns/

add this css if you are using bootstrap 3

@media (min-width: 768px) {
  .row.row-eq-height{
    display: flex;
    flex-wrap: wrap;
  }
}


答:
You can do it like this :

```<code>    String str1;
    int n;

    Scanner sc=new Scanner(System.in);
    System.out.println("Enter the string");
    str1=sc.next();

    sc.close();

    StringBuffer a = new StringBuffer(str1);
    n=a.length();
    for(int i=0;i<n;i++)
    {
        if(str1.charAt(i)=='*')
        {
            int aa = i-1;
            int bb = i+1;
            for(;bb<n; bb++){
                if(str1.charAt(bb)!='*'){
                    break;
                }
            }
            a.delete( aa, bb+1 );
            i = bb;

        }
    }
    String res = a.toString();
    System.out.println("The final string is"+res);
</code>```

But a better java regex way is :

After reading value from scanner -

```<code>    String res2 = str1.replaceAll( ".[\\*]+.", "" );
    System.out.println("The final string is"+res2);
</code>```

Body:
I need to delete all characters before and after a specific character using java programming
for example:

input: ab*cd output:ad

input: ab**cd output:ad

import java.util.Scanner;

public class Starstring {
    public static void main(String[] args) {
        String str1;
        String res="";
        int n,i=0;

        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the string");
        str1=sc.next();
        res=str1;
        StringBuffer a = new StringBuffer(str1);
        n=str1.length()-1;
        for(i=0;i<n;i++)
        {
            if(str1.charAt(i)=='*')
            {
                res=a.delete(i-1, i+2).toString();
            }
        }
        System.out.println("The final string is"+res);
    }

}

I am getting expected output for case 1 but case 2 wrong output with ac as output.I don't know where I am going wrong.Someone please help me.Thanks in advance:)

Body:
You can do it like this :

    String str1;
    int n;

    Scanner sc=new Scanner(System.in);
    System.out.println("Enter the string");
    str1=sc.next();

    sc.close();

    StringBuffer a = new StringBuffer(str1);
    n=a.length();
    for(int i=0;i<n;i++)
    {
        if(str1.charAt(i)=='*')
        {
            int aa = i-1;
            int bb = i+1;
            for(;bb<n; bb++){
                if(str1.charAt(bb)!='*'){
                    break;
                }
            }
            a.delete( aa, bb+1 );
            i = bb;

        }
    }
    String res = a.toString();
    System.out.println("The final string is"+res);

But a better java regex way is :

After reading value from scanner -

    String res2 = str1.replaceAll( ".[\\*]+.", "" );
    System.out.println("The final string is"+res2);


问:
Making 2 sequential requests with Axios - second request depends on the response of 1st
The following code is not waiting for the else part to return data before resolving.

Where I'm going wrong with this code?

```<code>return request.get(`${<URL1>}`)
.then((res) => {
    if (res1.data[0]) {
        data1 = res.data[0]};
    } else {
        request.get(`${<URL2>`)
            .then((res2) => {
                data1 = res2.data
            });
    }
    return Promise.resolve(data1);
})
</code>```

Thanks in advance.

San

答:
That is because you're doing it wrong :)

When the program execution encounters an 'async' operation (making a network request with axios), it schedules the task and continues execution of the following lines of code. This include any return statements.

Your return should appear in the 'then' clause:

```<code>return request.get(`${<URL1>}`)
    .then((res1) => {
        if (res1.data[0]) {
            data1 = res1.data[0]
            return Promise.resolve(data1);
        } else {
            request.get(`${<URL2>`)
                .then((res2) => {
                    data1 = res2.data
                    return Promise.resolve(data1);
                });
        }
    });
</code>```

Hope this helps...

Clinton.

Body:
The following code is not waiting for the else part to return data before resolving.

Where I'm going wrong with this code?

return request.get(`${<URL1>}`)
.then((res) => {
    if (res1.data[0]) {
        data1 = res.data[0]};
    } else {
        request.get(`${<URL2>`)
            .then((res2) => {
                data1 = res2.data
            });
    }
    return Promise.resolve(data1);
})

Thanks in advance.

San

Body:
That is because you're doing it wrong :)

When the program execution encounters an 'async' operation (making a network request with axios), it schedules the task and continues execution of the following lines of code. This include any return statements.

Your return should appear in the 'then' clause:

return request.get(`${<URL1>}`)
    .then((res1) => {
        if (res1.data[0]) {
            data1 = res1.data[0]
            return Promise.resolve(data1);
        } else {
            request.get(`${<URL2>`)
                .then((res2) => {
                    data1 = res2.data
                    return Promise.resolve(data1);
                });
        }
    });

Hope this helps...

Clinton.


答:
Using @Vasan regex.. below is the code.

```<code>public static void main(String[] args) {
        String str1;
        String res="";
        int n;

        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the string");
        str1=sc.next();
        res=str1;
        StringBuffer a = new StringBuffer(str1);
        n=str1.length()-1;

        String[] splitVal = str1.split(".\\*+.");
        String newString ="";
        for(int i=0; i<splitVal.length; i++){
            newString = newString + splitVal[i];
        }

        System.out.println("The final string is "+newString);
    }
</code>```

Hope you understand.

Body:
Using @Vasan regex.. below is the code.

public static void main(String[] args) {
        String str1;
        String res="";
        int n;

        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the string");
        str1=sc.next();
        res=str1;
        StringBuffer a = new StringBuffer(str1);
        n=str1.length()-1;

        String[] splitVal = str1.split(".\\*+.");
        String newString ="";
        for(int i=0; i<splitVal.length; i++){
            newString = newString + splitVal[i];
        }

        System.out.println("The final string is "+newString);
    }

Hope you understand.


问:
Class has no objects member
```<code>def index(request):
   latest_question_list = Question.objects.all().order_by('-pub_date')[:5]
   template = loader.get_template('polls/index.html')
   context = {'latest_question_list':latest_question_list}
   return HttpResponse(template.render(context, request))
</code>```

The first line of that function gets an error on Question.objects.all():

E1101: Class 'Question' has no 'objects' member

I'm following the Django documentation tutorial and they have the same code up and running.

I have tried calling an instance.

```<code>Question = new Question()
and using MyModel.objects.all()
</code>```

Also my models.py code for that class is this...

```<code>class Question(models.Model):
    question_text = models.CharField(max_length = 200)
    pub_date = models.DateTimeField('date published')

    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)

    def __str__(self):
        return self.question_text
</code>```

To no avail I still have this error.

I have read about pylint and ran this...

pylint --load-plugins pylint_django
```

Which didn't help, even tho the github readme file says...

Prevents warnings about Django-generated attributes such as
Model.objects or Views.request.

I ran the command within my virtualenv, and yet nothing.

So any help would be great.

答:
Install pylint-django using pip as follows

```<code>pip install pylint-django
</code>```

Then in Visual Studio Code goto: User Settings (Ctrl + , or File > Preferences > Settings if available ) Put in the following (please note the curly braces which are required for custom user settings in VSC):

```<code>{"python.linting.pylintArgs": [
     "--load-plugins=pylint_django"
],}
</code>```

Title: Class has no objects member

Body:
def index(request):
   latest_question_list = Question.objects.all().order_by('-pub_date')[:5]
   template = loader.get_template('polls/index.html')
   context = {'latest_question_list':latest_question_list}
   return HttpResponse(template.render(context, request))

The first line of that function gets an error on Question.objects.all():

E1101: Class 'Question' has no 'objects' member

I'm following the Django documentation tutorial and they have the same code up and running.

I have tried calling an instance.

Question = new Question()
and using MyModel.objects.all()

Also my models.py code for that class is this...

class Question(models.Model):
    question_text = models.CharField(max_length = 200)
    pub_date = models.DateTimeField('date published')

    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)

    def __str__(self):
        return self.question_text

To no avail I still have this error.

I have read about pylint and ran this...

pylint --load-plugins pylint_django

Which didn't help, even tho the github readme file says...

Prevents warnings about Django-generated attributes such as
Model.objects or Views.request.

I ran the command within my virtualenv, and yet nothing.

So any help would be great.

Body:
Install pylint-django using pip as follows

pip install pylint-django

Then in Visual Studio Code goto: User Settings (Ctrl + , or File > Preferences > Settings if available ) Put in the following (please note the curly braces which are required for custom user settings in VSC):

{"python.linting.pylintArgs": [
     "--load-plugins=pylint_django"
],}


问:
Create a table in SQL where the Composite Primary Key is also a Foreign Key
I need to create a table called LFM_Enroll in SQL that has a composite primary key of Student_ID and Section_Number. Student_ID is also a foreign key, it references Student_ID in the LFM_Student table and Section_Number is also a foreign key, it references Section_Number in the LFM_Section table. How do I write the constraints and foreign keys? I've attached an image of the tables and below is what I have done so far. After the LFM_Enroll table is created I need to update one row. I tried doing so but kept getting the below error.

: Error starting at line : 173 in command -
UPDATE LFM_Enroll
SET Student_ID = 1234567,
    Section_Number = 01234
WHERE Student_ID = 900000 AND Section_Number =  4138
Error report -
ORA-02291: integrity constraint (SYSTEM.FK_LFM_ENROLL_SECTION_NUMBER) violated - parent key not found.```
</div>
</div>
</p>

<p>Tables Thanks in advance for all your help. </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>CREATE TABLE LFM_Enroll (
    Student_ID         char(7),
    Section_Number     char(4),
    constraint PK_LFM_Enroll Primary Key (Student_ID,Section_Number),
    constraint FK_LFM_Enroll_Student_ID
      Foreign Key (Student_ID,Section_Number) references LFM_Student (Student_ID),
    constraint FK_LFM_Enroll_Section_Number
      Foreign Key (Student_ID,Section_Number) references LFM_Section (Section_Number)

    );</code>```

答:
Your foreign key constraints are not right. You are trying to map two columns {Student_ID,Section_Number} to a single column LFM_Student.Student_ID.

The number of columns in the principal key must match the number of columns in the foreign key. In other words, the key LFM_Student is one column (Student_ID), so the foreign key also needs to be a single matching column - in this case LFM_Enroll.Student_ID. Correct DDL would be:

```<code>constraint FK_LFM_Enroll_Student_ID
  Foreign Key (Student_ID) references LFM_Student (Student_ID),
constraint FK_LFM_Enroll_Section_Number
  Foreign Key (Section_Number) references LFM_Section (Section_Number)
</code>```

I'm not quite sure why your RDBMS is allowing what you have, but it may be using the first column and simply ignoring the second. In which case FK_LFM_Enroll_Section_Number is creating a foreign key LFM_Enroll.Student_ID => LFM_Section.Section_Number.

Body:
I need to create a table called LFM_Enroll in SQL that has a composite primary key of Student_ID and Section_Number. Student_ID is also a foreign key, it references Student_ID in the LFM_Student table and Section_Number is also a foreign key, it references Section_Number in the LFM_Section table. How do I write the constraints and foreign keys? I've attached an image of the tables and below is what I have done so far. After the LFM_Enroll table is created I need to update one row. I tried doing so but kept getting the below error.

: Error starting at line : 173 in command -
UPDATE LFM_Enroll
SET Student_ID = 1234567,
    Section_Number = 01234
WHERE Student_ID = 900000 AND Section_Number =  4138
Error report -
ORA-02291: integrity constraint (SYSTEM.FK_LFM_ENROLL_SECTION_NUMBER) violated - parent key not found.

Tables Thanks in advance for all your help.

CREATE TABLE LFM_Enroll (
    Student_ID         char(7),
    Section_Number     char(4),
    constraint PK_LFM_Enroll Primary Key (Student_ID,Section_Number),
    constraint FK_LFM_Enroll_Student_ID
      Foreign Key (Student_ID,Section_Number) references LFM_Student (Student_ID),
    constraint FK_LFM_Enroll_Section_Number
      Foreign Key (Student_ID,Section_Number) references LFM_Section (Section_Number)

    );

Body:
Your foreign key constraints are not right. You are trying to map two columns {Student_ID,Section_Number} to a single column LFM_Student.Student_ID.

The number of columns in the principal key must match the number of columns in the foreign key. In other words, the key LFM_Student is one column (Student_ID), so the foreign key also needs to be a single matching column - in this case LFM_Enroll.Student_ID. Correct DDL would be:

constraint FK_LFM_Enroll_Student_ID
  Foreign Key (Student_ID) references LFM_Student (Student_ID),
constraint FK_LFM_Enroll_Section_Number
  Foreign Key (Section_Number) references LFM_Section (Section_Number)

I'm not quite sure why your RDBMS is allowing what you have, but it may be using the first column and simply ignoring the second. In which case FK_LFM_Enroll_Section_Number is creating a foreign key LFM_Enroll.Student_ID => LFM_Section.Section_Number.


问:
Printing the results of Futures in Scala Worksheet
I'm taking the Reactive programming course on Coursera and when doing one of the assignments I came across something weird. Anyways I added a few methods to the Future Companion object via this extension

```<code>implicit class FutureCompanionOps[T](val f: Future.type) extends AnyVal {

    /** Returns a future that is always completed with `value`.
     */
    def always[T](value: T): Future[T] = Future(value)

    /** Returns a future that is never completed.
     *
     *  This future may be useful when testing if timeout logic works correctly.
     */
    def never[T]: Future[T] = Promise().future

    /** Given a list of futures `fs`, returns the future holding the list of values of all the futures from `fs`.
     *  The returned future is completed only once all of the futures in `fs` have been completed.
     *  The values in the list are in the same order as corresponding futures `fs`.
     *  If any of the futures `fs` fails, the resulting future also fails.
     */
    def all[T](fs: List[Future[T]]): Future[List[T]] = {
      val resPr = Promise[List[T]]()
      def function( in: List[Future[T]], fxs:Future[List[T]] ): Future[List[T]] =
      {
        if(in.isEmpty) fxs
        else
        function( in.tail, for { i <- in.head ; xs <- fxs } yield { i :: xs } )
      }
      function( fs, resPr.success(Nil).future )
    }
}
</code>```

i then wrote this on a Scala WorkSheet in Eclipse

```<code>object TestSheet {

val tempPr = Promise[Boolean]()
val anotherFuLs = List( Future.always(true), Future.always(false), tempPr.future )
                                                  //> anotherFuLs  : List[scala.concurrent.Future[Boolean]] = List(scala.concurren
                                                  //| t.impl.Promise$DefaultPromise@a19b1de, scala.concurrent.impl.Promise$Default
                                                  //| Promise@1cec6b00, scala.concurrent.impl.Promise$DefaultPromise@625dcec6)
  val crapFut = Future.all(anotherFuLs)           //> crapFut  : scala.concurrent.Future[List[Boolean]] = scala.concurrent.impl.Pr
                                                  //| omise$DefaultPromise@6564dbd5
  crapFut.isCompleted                             //> res3: Boolean = false
  tempPr.success(false)                           //> res4: nodescala.TestSheet.tempPr.type = scala.concurrent.impl.Promise$Defaul
                                                  //| tPromise@625dcec6
  crapFut.isCompleted                             //> res5: Boolean = true
  crapFut onComplete {
    case Success(ls) => println( ls )
    case Failure(e) => println( "Failed with Exception " + e )
  }
}
</code>```

no matter what I can't get the Scala Work Sheet to print out the values of the resulting List. However when I write a unit test and run scala test, I have no problem comparing the final resulting list. Is this a bug in scala worksheet when working with asynchronous stuff ?

This is the unit test

```<code>test("A composed future with all should complete when all futures complete") {
    val tempPr = Promise[Boolean]()
    val lsFu = List( Future.always(true), Future.always(false), tempPr.future );
    val fuL = Future.all( lsFu )
    fuL onComplete { case Success(ls) => println( "This got done" ); assert( ls === List( true, false, true ), "I should get back the expected List" )
                     case Failure(ex) => assert( false, "Failed with Exception " + ex ) }
    assert( fuL.isCompleted === false, "The resulting Future should not be complete when the depending futures are still pending" )
    tempPr.success(true)

  }
</code>```

答:
Because we cannot println the result of Future on worksheet, I suggest to write the result into a file. Then, you can use writeFile instead of println on your worksheet.</p>

```<code> def writeFile(text : String) =  {
  val fw = new FileWriter("result.txt", true)
  try {
    fw.write(text)
    fw.write("\n")
  }
  finally fw.close()
}
</code>```

Body:
I'm taking the Reactive programming course on Coursera and when doing one of the assignments I came across something weird. Anyways I added a few methods to the Future Companion object via this extension

implicit class FutureCompanionOps[T](val f: Future.type) extends AnyVal {

    /** Returns a future that is always completed with `value`.
     */
    def always[T](value: T): Future[T] = Future(value)

    /** Returns a future that is never completed.
     *
     *  This future may be useful when testing if timeout logic works correctly.
     */
    def never[T]: Future[T] = Promise().future

    /** Given a list of futures `fs`, returns the future holding the list of values of all the futures from `fs`.
     *  The returned future is completed only once all of the futures in `fs` have been completed.
     *  The values in the list are in the same order as corresponding futures `fs`.
     *  If any of the futures `fs` fails, the resulting future also fails.
     */
    def all[T](fs: List[Future[T]]): Future[List[T]] = {
      val resPr = Promise[List[T]]()
      def function( in: List[Future[T]], fxs:Future[List[T]] ): Future[List[T]] =
      {
        if(in.isEmpty) fxs
        else
        function( in.tail, for { i <- in.head ; xs <- fxs } yield { i :: xs } )
      }
      function( fs, resPr.success(Nil).future )
    }
}

i then wrote this on a Scala WorkSheet in Eclipse

object TestSheet {

val tempPr = Promise[Boolean]()
val anotherFuLs = List( Future.always(true), Future.always(false), tempPr.future )
                                                  //> anotherFuLs  : List[scala.concurrent.Future[Boolean]] = List(scala.concurren
                                                  //| t.impl.Promise$DefaultPromise@a19b1de, scala.concurrent.impl.Promise$Default
                                                  //| Promise@1cec6b00, scala.concurrent.impl.Promise$DefaultPromise@625dcec6)
  val crapFut = Future.all(anotherFuLs)           //> crapFut  : scala.concurrent.Future[List[Boolean]] = scala.concurrent.impl.Pr
                                                  //| omise$DefaultPromise@6564dbd5
  crapFut.isCompleted                             //> res3: Boolean = false
  tempPr.success(false)                           //> res4: nodescala.TestSheet.tempPr.type = scala.concurrent.impl.Promise$Defaul
                                                  //| tPromise@625dcec6
  crapFut.isCompleted                             //> res5: Boolean = true
  crapFut onComplete {
    case Success(ls) => println( ls )
    case Failure(e) => println( "Failed with Exception " + e )
  }
}

no matter what I can't get the Scala Work Sheet to print out the values of the resulting List. However when I write a unit test and run scala test, I have no problem comparing the final resulting list. Is this a bug in scala worksheet when working with asynchronous stuff ?

This is the unit test

test("A composed future with all should complete when all futures complete") {
    val tempPr = Promise[Boolean]()
    val lsFu = List( Future.always(true), Future.always(false), tempPr.future );
    val fuL = Future.all( lsFu )
    fuL onComplete { case Success(ls) => println( "This got done" ); assert( ls === List( true, false, true ), "I should get back the expected List" )
                     case Failure(ex) => assert( false, "Failed with Exception " + ex ) }
    assert( fuL.isCompleted === false, "The resulting Future should not be complete when the depending futures are still pending" )
    tempPr.success(true)

  }

Body:
Because we cannot println the result of Future on worksheet, I suggest to write the result into a file. Then, you can use writeFile instead of println on your worksheet.

 def writeFile(text : String) =  {
  val fw = new FileWriter("result.txt", true)
  try {
    fw.write(text)
    fw.write("\n")
  }
  finally fw.close()
}


问:
git gui branch management
Hi I am an inexperienced Git user on Windows. I am using Git Gui.
I am interested in Branch Management.

My repo has a branch called 'leafy', how do I check this branch out to my local machine, and them cherry pick a commit from master into leafy?

Thanks a LOT

--MB

答:
how do I check this branch out to my
  local machine

Everything is already on your local machine, what checkout does is to update the files in your file system to match the state of the commit you are checking out.

```<code>git checkout leafy
</code>```

updates your files with the content of the commit at the top of the branch (note that if you have uncommited changes in your files, git refuses to checkout. This is done to prevent you from losing changes. You can override this behaviour by adding the -f option). It also sets leafy as your current HEAD, in this case your current HEAD defines which branch you are on.

Then to cherry-pick, you need to find out the SHA1 ID of the commits you want to pick (gitk --all& might be handy here). Then use several git cherry-pick <the-interesting-SHA1-ID> in the correct order to cherry-pick the commits.

Title: git gui branch management

Body:
how do I check this branch out to my
  local machine

Everything is already on your local machine, what checkout does is to update the files in your file system to match the state of the commit you are checking out.

git checkout leafy

updates your files with the content of the commit at the top of the branch (note that if you have uncommited changes in your files, git refuses to checkout. This is done to prevent you from losing changes. You can override this behaviour by adding the -f option). It also sets leafy as your current HEAD, in this case your current HEAD defines which branch you are on.

Then to cherry-pick, you need to find out the SHA1 ID of the commits you want to pick (gitk --all& might be handy here). Then use several git cherry-pick <the-interesting-SHA1-ID> in the correct order to cherry-pick the commits.


答:
Added runnable code:

var str = '{"fdfd":4}
fdfdf
';
str = str.replace(/<\/?.*[^>*]+>/gi, '');

console.log(str);```

Title: Remove all HTML tags *AND* content from json response

Body:
I am aware of this solution - str.replace(/<\/?[^>]+>/gi, '') - which removes the HTML tags from json response.

{"fdfd":4}
fdfdf
 -> {"fdfd":4} fdfdf

However i want to remove all content within the HTML, script tags as well for which i am seeking a solution.
Requirement -

{"fdfd":4}
fdfdf
 -> {"fdfd":4}

Body:
Added runnable code:

var str = '{"fdfd":4}<p>fdfdf</p>';
str = str.replace(/<\/?.*[^>*]+>/gi, '');

console.log(str);


答: Just try Linear layout with layout orientation horizontal of EditText and ImageView. It is simple.</p>

Title: Edittext as spinner

Body:
I have a editext which I would like to show as drop down. SO for that I have background.xml file:

<?xml version="1.0" encoding="utf-8" ?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

  <item>
    <layer-list>
      <item>
        <shape>
          <solid android:color="#ffffff" />
          <stroke android:width="1dp" android:color="#000000" />
          <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape>
      </item>
      <item>
        <bitmap android:gravity="right" android:src="@drawable/ic_arrow_drop_down" />
      </item>
    </layer-list>
  </item>

</selector>

And added that as background for my edittext. This is what I get:

As you can see there is slight gap between the image and editext border. I would like to make my edittext like this:

How can I achieve this?


问:
Deploying a polymer project to app engine/java standard of flex environments
I'm looking for instructions similar to these (python) on how to deploy a polymer project to app engine that uses java standard or, preferably, flexible environment.  I don't fully understand how a polymer project can be integrated with Jetty. Any help would be greatly appreciated.</p>

答:
It seems that the key here is to integrate static content into my application.  There is even no need to add web.xml:

If you do not specify a web.xml, a default is used that maps
  everything to the default servlet.

The article even talks about alternatives to serving directly from the application to reduce the costs.


问:
How to set image in circle in swift
How can i make i circle picture with swift ?

My ViewController :

```<code>import UIKit
import Foundation

class FriendsViewController : UIViewController{

    @IBOutlet weak var profilPicture: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
        profilPicture = UIImageView(frame: CGRectMake(0, 0, 100, 100))
    }
}
</code>```

My profilPicture = UIImageView(frame: CGRectMake(0, 0, 100, 100)) do nothing ..

Exemple: http://www.appcoda.com/ios-programming-circular-image-calayer/

答:
For Swift3/Swift4 Developers:</p>

```<code>let radius = yourImageView.frame.width / 2
yourImageView.layer.cornerRadius = radius
yourImageView.layer.masksToBounds = true
</code>```

Title: How to set image in circle in swift

Body:
How can i make i circle picture with swift ?

My ViewController :

import UIKit
import Foundation

class FriendsViewController : UIViewController{

    @IBOutlet weak var profilPicture: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
        profilPicture = UIImageView(frame: CGRectMake(0, 0, 100, 100))
    }
}

My profilPicture = UIImageView(frame: CGRectMake(0, 0, 100, 100)) do nothing ..

Exemple: http://www.appcoda.com/ios-programming-circular-image-calayer/

Body:
For Swift3/Swift4 Developers:

let radius = yourImageView.frame.width / 2
yourImageView.layer.cornerRadius = radius
yourImageView.layer.masksToBounds = true


问:
SQL Server pagination of a result set
I have a very meaty stored procedure in a SQL Server 2000 DB which returns a single resultset. I don't want to (not allowed to) touch the original SP but would like add pagination to the returned records.

Is it possible to wrap this SP with another that takes the returned resultset and only gives me rows X to Y ?

答:
As others have said you will have to put the results of the procedure in a temp table then select the rows you want from that.

To get a set of rows from your results you need to use the ROW_NUMER() function:

```<code>SELECT
   ROW_NUMBER() OVER (ORDER BY ID) AS row_number, *
FROM
   Your_Temp_Table
WHERE row_number BETWEEN 11 AND 20 -- For the second page of results with 10 per page.
</code>```

EDIT: Just realised you are using SQL Server 2000 which does not have ROW_NUMBER(), sorry

EDIT2: Since you are storing the results of the query in a temp table you can add an incrementing integer field to that result set and use that as a simulation for the ROW_NUMBER() in order to select the row you need.

EDIT3: Here's a link to an article discussing pagination in SQL Server 2000

Title: SQL Server pagination of a result set

Body:
As others have said you will have to put the results of the procedure in a temp table then select the rows you want from that.

To get a set of rows from your results you need to use the ROW_NUMER() function:

SELECT
   ROW_NUMBER() OVER (ORDER BY ID) AS row_number, *
FROM
   Your_Temp_Table
WHERE row_number BETWEEN 11 AND 20 -- For the second page of results with 10 per page.

EDIT: Just realised you are using SQL Server 2000 which does not have ROW_NUMBER(), sorry

EDIT2: Since you are storing the results of the query in a temp table you can add an incrementing integer field to that result set and use that as a simulation for the ROW_NUMBER() in order to select the row you need.

EDIT3: Here's a link to an article discussing pagination in SQL Server 2000