问:
Generate a UNIQUE string made out of numeric / ALPHABET

My Problem

I don't know any VBA

Need to generate a string of 12 chars (ALPHA +  numbers , 0-9 , A-Z) IN VBA...

Sample output :

```<code>"ADF3V3224K1WQ"
</code>```

(12 characters long , Higher caps Alphabetical letters , and Numeric values aswell).

Story

I'm having a hard time figuring out how to create a string generator (didn't say it has to be random, but it 100% has to be unique, meaning it has to check for duplications or store existing values), I have no experience with VBA. I already found a similar post here, but it is different then mine, as it does not specifically ask for the string to be 100% unique. (I don't need a very low chance, I need 100% across the board).

Syntax-wise I'm pretty confused, I managed to find where the code behind events are, ie Button presses, so I know where I need to write it, but I have no idea how to check for duplications. (even relying on a time seed that can ensure it will be 100% unique is great).

Link to the similar post: MS Access Visual Basic - generate random string in text field

答:
Use the date-time string:

Formula: =TEXT(NOW(),"yymmddhhmmss") -> 170705161201

VBA: Debug.Print Format(Now, "yymmddhhmmss")

Body:
My Problem

I don't know any VBA

Need to generate a string of 12 chars (ALPHA +  numbers , 0-9 , A-Z) IN VBA...

Sample output :

"ADF3V3224K1WQ"

(12 characters long , Higher caps Alphabetical letters , and Numeric values aswell).

Story

I'm having a hard time figuring out how to create a string generator (didn't say it has to be random, but it 100% has to be unique, meaning it has to check for duplications or store existing values), I have no experience with VBA. I already found a similar post here, but it is different then mine, as it does not specifically ask for the string to be 100% unique. (I don't need a very low chance, I need 100% across the board).

Syntax-wise I'm pretty confused, I managed to find where the code behind events are, ie Button presses, so I know where I need to write it, but I have no idea how to check for duplications. (even relying on a time seed that can ensure it will be 100% unique is great).

Link to the similar post: MS Access Visual Basic - generate random string in text field


来源: stackexchange

问:
Pass data between UIview inside ViewController
I have a Viewcontroller, and it has a View outsite it (in between those 3 symbols (viewcontroller, first responder, exit)), and when I click on a button it shows up my View, then I created a class file for it, and the textfields data inside this View has to come back to the ViewController.
How do I do that? I only know the method by segues.
tks</p>

答:
If I correctly understood your question, you're trying to reference the view objects inside your ViewController. For this, you don't need a separate class for the view. You have two options to reference views objects in ViewController:

Create objects in code, after the view is loaded in ViewController;

Connect the objects to @IBOulets in UI Editor.

The second option is more easy. Mainly if you are starting with Swift. You can learn to do this in this example. Or check this stackoverflow answer.

ContentLicense: CC BY-SA 3.0


问:
Python convert txt file to JSON stripping and element ordering
I have a txt file that contains data split by spaces such as:

```<code>2017-05-16 00:44:36.151724381 +43.8187 -104.7669 -004.4 00.6 00.2 00.2 090 C
2017-05-16 00:44:36.246672534 +41.6321 -104.7834 +004.3 00.6 00.3 00.2 130 C
2017-05-16 00:44:36.356132768 +46.4559 -104.5989 -004.2 01.1 00.4 00.2 034 C
</code>```

and I would like to convert it into JSON data to something like:

```{"dataset": "Lightning","observation_date": "20170516004436151", "location": { "type": "point", "coordinates": [43.8187, -104.7669]}}
{"dataset": "Lightning","observation_date": "20170516004436246", "location": { "type": "point", "coordinates": [41.6321, -104.7834]}}
{"dataset": "Lightning","observation_date": "20170516004436356", "location": { "type": "point", "coordinates": [46.4559, -104.5989]}}```

where I have to append a 'dataset':'lightning' key/val pair, combine and strip the date and time, and combine the lat/lng into a dict before doing any json conversion.

But right now I still get the date and time elements without being stripped of the "-" and ":" characters like:

```{"observation_date": "2017-05-1600:44:36.151724381", "location": {"type": "point", "coordinates": ["+43.8187", "-104.7669"]}, "dataset": "Lightning"}
{"observation_date": "2017-05-1600:44:36.246672534", "location": {"type": "point", "coordinates": ["+41.6321", "-104.7834"]}, "dataset": "Lightning"}
{"observation_date": "2017-05-1600:44:36.356132768", "location": {"type": "point", "coordinates": ["+46.4559", "-104.5989"]}, "dataset": "Lightning"}```

What I coded so far:

```<code>import json
import sys
def convert(filename):
    dataDict = {}
    txtFile = filename[0]
    print "Opening TXT file: ",txtFile
    infile = open(txtFile, "r")
    for line in infile:
        lineStrip = line.strip()
        parts = [p.strip() for p in lineStrip.split()]
        date = parts[0].strip("-") #trying to get rid of "-" but not working
        time = parts[1].strip(":") #trying to get rid of ":" and "." but not working
        dataDict.update({"dataset":"Lightning"})
        dataDict.update({"observation_date": date + time})
        dataDict.update({"location": {"type":"point", "coordinates": [parts[2], parts[3]]}})
        json_filename = txtFile.split(".")[0]+".json"
        jsonf = open(json_filename,'a')
        data = json.dumps(dataDict)
        jsonf.write(data + "\n")
        print dataDict
    infile.close()
    jsonf.close()
if __name__=="__main__":
    convert(sys.argv[1:])
</code>```

But I'm not sure how to strip the "-", ".", and ":" as well as place the "dataset":"lightning" element in the front.

答:
This should work</p>

```<code>date = parts[0].replace("-",'') #trying to get rid of "-" but not working

time = parts[1].replace(":",'') #trying to get rid of ":" and "." but not working
</code>```

Body:
I have a txt file that contains data split by spaces such as:

2017-05-16 00:44:36.151724381 +43.8187 -104.7669 -004.4 00.6 00.2 00.2 090 C
2017-05-16 00:44:36.246672534 +41.6321 -104.7834 +004.3 00.6 00.3 00.2 130 C
2017-05-16 00:44:36.356132768 +46.4559 -104.5989 -004.2 01.1 00.4 00.2 034 C

and I would like to convert it into JSON data to something like:

{"dataset": "Lightning","observation_date": "20170516004436151", "location": { "type": "point", "coordinates": [43.8187, -104.7669]}}
{"dataset": "Lightning","observation_date": "20170516004436246", "location": { "type": "point", "coordinates": [41.6321, -104.7834]}}
{"dataset": "Lightning","observation_date": "20170516004436356", "location": { "type": "point", "coordinates": [46.4559, -104.5989]}}

where I have to append a 'dataset':'lightning' key/val pair, combine and strip the date and time, and combine the lat/lng into a dict before doing any json conversion.

But right now I still get the date and time elements without being stripped of the "-" and ":" characters like:

{"observation_date": "2017-05-1600:44:36.151724381", "location": {"type": "point", "coordinates": ["+43.8187", "-104.7669"]}, "dataset": "Lightning"}
{"observation_date": "2017-05-1600:44:36.246672534", "location": {"type": "point", "coordinates": ["+41.6321", "-104.7834"]}, "dataset": "Lightning"}
{"observation_date": "2017-05-1600:44:36.356132768", "location": {"type": "point", "coordinates": ["+46.4559", "-104.5989"]}, "dataset": "Lightning"}

What I coded so far:

import json
import sys
def convert(filename):
    dataDict = {}
    txtFile = filename[0]
    print "Opening TXT file: ",txtFile
    infile = open(txtFile, "r")
    for line in infile:
        lineStrip = line.strip()
        parts = [p.strip() for p in lineStrip.split()]
        date = parts[0].strip("-") #trying to get rid of "-" but not working
        time = parts[1].strip(":") #trying to get rid of ":" and "." but not working
        dataDict.update({"dataset":"Lightning"})
        dataDict.update({"observation_date": date + time})
        dataDict.update({"location": {"type":"point", "coordinates": [parts[2], parts[3]]}})
        json_filename = txtFile.split(".")[0]+".json"
        jsonf = open(json_filename,'a')
        data = json.dumps(dataDict)
        jsonf.write(data + "\n")
        print dataDict
    infile.close()
    jsonf.close()
if __name__=="__main__":
    convert(sys.argv[1:])

But I'm not sure how to strip the "-", ".", and ":" as well as place the "dataset":"lightning" element in the front.

Body:
This should work

date = parts[0].replace("-",'') #trying to get rid of "-" but not working

time = parts[1].replace(":",'') #trying to get rid of ":" and "." but not working


问:
FileName Port is not supported with connection or merge option
I need to create a csv flat file and need to store in particular path in ftp .

File name should be dynmaically created with timestamp . i have created the filename port in informatica and mapped to expression which i created. when i ran the workflow , am getting below error

Severity    Timestamp   Node    Thread  Message Code    Message
ERROR   28-06-2017 07:31:19 PM  node01_oktst93  WRITER_1_*_1    WRT_8419    Flat File Target [NewOrders] FileName Port is not supported with connection or merge option.

Please help to resolve without deleting filename port .

Thanks

答:
file port option dosen't work with the FTP target option. If you are simply using a local flat file: please disable the append if exists option at session level.

Please refer the below informatica KB :

https://kb.informatica.com/solution/11/Pages/102937.aspx


问:
My static method is not running
Here is my recipe.js file...

```<code>const express = require('express');
const mongoose = require('mongoose');
const User = require('../model/user');
require('mongoose-currency').loadType(mongoose);
const Currency = mongoose.Types.Currency;
const Schema = mongoose.Schema;
const reviewSchema = require('../model/review');

let recipeSchema = new Schema({

  name: {
    type: String,
    required: true
  },

  description: {
    type: String,
  },

  steps: {
    type: String,
    required: true,
  },

  ingredients: {
    type: Array,
    default: ['1', '2', '3', '4']
  },

  category: {
    type: String,
    required: true,
    index: true
  },

  postedBy: {
    type: String,
    required: true,
  },

  reviewsOfRecipe: [reviewSchema],

  numberOfRatings: {
    type: Number,
    default: 0
  },

  totalAddedRatings: {
      type: Number,
      default: 0
  },

  reviewAverage: {
      type: Number,
      default: 0
  },

  postersCreationDate: {
    type: Number,
    index: true
  },

  likedBy: {
      type: Array

  },

  reviewedBy: {
      type: Array
  }

});

// Here is my static method

recipeSchema.methods.calculateAverage = function(){

  let recipe = this;

  if (recipe.numberOfRatings === 0  && recipe.totalAddedRatings === 0){
    recipe.reviewAverage = 0;
  }
  else {

    recipe.reviewAverage = recipe.totalAddedRatings / recipe.numberOfRatings

  }

};

let Recipe = mongoose.model('Recipe', recipeSchema);

module.exports = Recipe;
</code>```

In my router file, every time a user submits a review for a recipe, the fields numberOfRatings and totalAddedRatings get incremented. And after they get incremented, my static method calculateAverage should run and update the document.

Here is what it looks like in my code:

```<code>Recipe.findOneAndUpdate({_id: recipe._id, postersCreationDate: recipe.postersCreationDate},{$inc: {numberOfRatings: 1, totalAddedRatings: reviewScore}}, {returnNewDocument: true}).then((recipe) => {

               recipe.calculateAverage();
});
</code>```

However, every time a user submits a review, although numberOfRatings and numberOfRatings get incremented accordingly, reviewAverage does not.

I am thinking about setting reviewAverage as a virtual field instead; but I am worried that doing so would make it harder and inefficient to sort the recipes by the highest and lowest review averages.

答:
first some things about your findOneAndUpdate can change. Id should be sufficient to find by and 'returnNewDocument' is not an option. In mongoose it's just 'new'

```<code>Recipe.findOneAndUpdate({_id: recipe._id},{$inc: {numberOfRatings: 1, totalAddedRatings: reviewScore}}, {new: true}).then((recipe) => {
    recipe.calculateAverage();
});
</code>```

The problem is that you aren't saving the average to the recipe.

```<code>recipeSchema.methods.calculateAverage = function(callback) {
  let recipe = this;
  if (recipe.numberOfRatings === 0  && recipe.totalAddedRatings === 0) {
      recipe.reviewAverage = 0;
  }
  else {
      recipe.reviewAverage = recipe.totalAddedRatings / recipe.numberOfRatings
  }
  recipe.save(callback);
};
</code>```

Title: My static method is not running

Body:
Here is my recipe.js file...

const express = require('express');
const mongoose = require('mongoose');
const User = require('../model/user');
require('mongoose-currency').loadType(mongoose);
const Currency = mongoose.Types.Currency;
const Schema = mongoose.Schema;
const reviewSchema = require('../model/review');

let recipeSchema = new Schema({

  name: {
    type: String,
    required: true
  },

  description: {
    type: String,
  },

  steps: {
    type: String,
    required: true,
  },

  ingredients: {
    type: Array,
    default: ['1', '2', '3', '4']
  },

  category: {
    type: String,
    required: true,
    index: true
  },

  postedBy: {
    type: String,
    required: true,
  },

  reviewsOfRecipe: [reviewSchema],

  numberOfRatings: {
    type: Number,
    default: 0
  },

  totalAddedRatings: {
      type: Number,
      default: 0
  },

  reviewAverage: {
      type: Number,
      default: 0
  },

  postersCreationDate: {
    type: Number,
    index: true
  },

  likedBy: {
      type: Array

  },

  reviewedBy: {
      type: Array
  }

});

// Here is my static method

recipeSchema.methods.calculateAverage = function(){

  let recipe = this;

  if (recipe.numberOfRatings === 0  && recipe.totalAddedRatings === 0){
    recipe.reviewAverage = 0;
  }
  else {

    recipe.reviewAverage = recipe.totalAddedRatings / recipe.numberOfRatings

  }

};

let Recipe = mongoose.model('Recipe', recipeSchema);

module.exports = Recipe;

In my router file, every time a user submits a review for a recipe, the fields numberOfRatings and totalAddedRatings get incremented. And after they get incremented, my static method calculateAverage should run and update the document.

Here is what it looks like in my code:

Recipe.findOneAndUpdate({_id: recipe._id, postersCreationDate: recipe.postersCreationDate},{$inc: {numberOfRatings: 1, totalAddedRatings: reviewScore}}, {returnNewDocument: true}).then((recipe) => {

               recipe.calculateAverage();
});

However, every time a user submits a review, although numberOfRatings and numberOfRatings get incremented accordingly, reviewAverage does not.

I am thinking about setting reviewAverage as a virtual field instead; but I am worried that doing so would make it harder and inefficient to sort the recipes by the highest and lowest review averages.

Body:
first some things about your findOneAndUpdate can change. Id should be sufficient to find by and 'returnNewDocument' is not an option. In mongoose it's just 'new'

Recipe.findOneAndUpdate({_id: recipe._id},{$inc: {numberOfRatings: 1, totalAddedRatings: reviewScore}}, {new: true}).then((recipe) => {
    recipe.calculateAverage();
});

The problem is that you aren't saving the average to the recipe.

recipeSchema.methods.calculateAverage = function(callback) {
  let recipe = this;
  if (recipe.numberOfRatings === 0  && recipe.totalAddedRatings === 0) {
      recipe.reviewAverage = 0;
  }
  else {
      recipe.reviewAverage = recipe.totalAddedRatings / recipe.numberOfRatings
  }
  recipe.save(callback);
};


问:
Surpassing MySQL's TIME value limit of 838:59:59
The title might be a bit confusing so allow me to explain. I'm using a table to record my work logs. Every day I'll create an entry stating from what time to what time I have worked and I'll add a comment describing what I did.

I then use a query to compare the timestamps to figure out exactly how many hours and minutes I have worked that day. Additionally, I use a query to calculate the sum of hours and minutes I have worked the entire year. That's where I'm running into a problem. My query is as follows.

```<code>SELECT TIME_FORMAT(SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(entry_end_time, entry_start_time)))), '%H:%i')
AS total FROM entry
WHERE entry_date BETWEEN '2012-01-01' AND '2012-12-31' AND user_id = 3
</code>```

By default, MySQL TIME fields allow a time range of '-838:59:59' to '838:59:59'. I have currently logged more than 900 hours of work this year though, and I want the result of my query to reflect this. Instead, the result is 838:59:59, which makes sense because that is the limit.

Is there any way around this so the result of the query can go beyond 839 hours, or would I have to use something like PHP to go over the entire table and add it all up? I kind of want to avoid that if possible.

答:
```<code>select  concat(truncate(sum(time_to_sec(TIMEDIFF(hora_fim, hora_ini)))/3600,0), ':',
TIME_FORMAT(sec_to_time(sum(time_to_sec(TIMEDIFF(hora_fim, hora_ini))) - truncate(sum(time_to_sec(TIMEDIFF(hora_fim, hora_ini)))/3600,0)*3600), '%i:%s'))
as hms from  tb_XXXXXX
</code>```

Body:
The title might be a bit confusing so allow me to explain. I'm using a table to record my work logs. Every day I'll create an entry stating from what time to what time I have worked and I'll add a comment describing what I did.

I then use a query to compare the timestamps to figure out exactly how many hours and minutes I have worked that day. Additionally, I use a query to calculate the sum of hours and minutes I have worked the entire year. That's where I'm running into a problem. My query is as follows.

SELECT TIME_FORMAT(SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(entry_end_time, entry_start_time)))), '%H:%i')
AS total FROM entry
WHERE entry_date BETWEEN '2012-01-01' AND '2012-12-31' AND user_id = 3

By default, MySQL TIME fields allow a time range of '-838:59:59' to '838:59:59'. I have currently logged more than 900 hours of work this year though, and I want the result of my query to reflect this. Instead, the result is 838:59:59, which makes sense because that is the limit.

Is there any way around this so the result of the query can go beyond 839 hours, or would I have to use something like PHP to go over the entire table and add it all up? I kind of want to avoid that if possible.


问:
React Linting: Unclosed Regular Expression
I'm working through the React Tutorial using Codepen. I have the react libraries inlcuded in script tags and have selected the Babel preprocessor but I get a linting error at the JSX closing tag:

```<code>render() {
  return (
    <button className="square" onClick={() => this.props.onClick()}>
      {this.props.value}
    </button> // Error here
  );
}
</code>```

The error is for an unclosed regular expression.

When I check the Codepen for the tutorial itself, it returns the same error but the pen functions. Mine doesn't. Other React pens on the site also return the error but work.

My pen is here. I haven't been able to find any typos in my code.

What am I missing?

答: Remove extra curly braces at the end @line 30 in js file  from 'handleClick()' function. After removing this extra brace your code is working fine.</p>

Body:
I'm working through the React Tutorial using Codepen. I have the react libraries inlcuded in script tags and have selected the Babel preprocessor but I get a linting error at the JSX closing tag:

render() {
  return (
    <button className="square" onClick={() => this.props.onClick()}>
      {this.props.value}
    </button> // Error here
  );
}

The error is for an unclosed regular expression.

When I check the Codepen for the tutorial itself, it returns the same error but the pen functions. Mine doesn't. Other React pens on the site also return the error but work.

My pen is here. I haven't been able to find any typos in my code.

What am I missing?


问:
Google Maps Android API v2 Authorization failure
My steps:

got SHA1 code from debug.keystore

create app in google apis console

enabled google map api v2

input SHA1;my.package.name

get API key

created AndroidManifest file:

```<code>    <permission
            android:name="my.package.name.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>

    <uses-permission android:name="my.package.name.permission.MAPS_RECEIVE"/>

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:hardwareAccelerated="true">

        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_API_KEY_HERE" />

        <activity android:name="MyActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>
</code>```

created layout

put "google-play-services.jar" to libs

After compilation I've got crash:

```<code>  ERROR/AndroidRuntime(10182): FATAL EXCEPTION: main
                java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
                at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
                at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
                at android.app.Activity.onCreateView(Activity.java:4716)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
                at android.app.Activity.setContentView(Activity.java:1881)
                at com.example.gm2.MyActivity.onCreate(MyActivity.java:16)
                at android.app.Activity.performCreate(Activity.java:5104)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
                at android.app.ActivityThread.access$600(ActivityThread.java:141)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:5039)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                at dalvik.system.NativeStart.main(Native Method)
</code>```

After that I've changed layout to:

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

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/map"
             android:layout_width="match_parent"
             android:layout_height="match_parent" />
</code>```

and changed MyActivity to

```<code>  super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();

    transaction.add(R.id.map, MapFragment.newInstance());
    transaction.commit();
</code>```

As result, the application was started, but I didn't see the map.

Console log:

```<code>ERROR/Google Maps Android API(10369): Authorization failure.
</code>```

答:
I faced the same issue.

If you issued an api for your release version of the application.
Then that api will only work for the release version not for the debug version.
So make sure you are using the release version in your phone or emulator .

Body:
My steps:

got SHA1 code from debug.keystore

create app in google apis console

enabled google map api v2

input SHA1;my.package.name

get API key

created AndroidManifest file:

    <permission
            android:name="my.package.name.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>

    <uses-permission android:name="my.package.name.permission.MAPS_RECEIVE"/>

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:hardwareAccelerated="true">

        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="MY_API_KEY_HERE" />

        <activity android:name="MyActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

created layout

put "google-play-services.jar" to libs

After compilation I've got crash:

  ERROR/AndroidRuntime(10182): FATAL EXCEPTION: main
                java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
                at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
                at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
                at android.app.Activity.onCreateView(Activity.java:4716)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
                at android.app.Activity.setContentView(Activity.java:1881)
                at com.example.gm2.MyActivity.onCreate(MyActivity.java:16)
                at android.app.Activity.performCreate(Activity.java:5104)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
                at android.app.ActivityThread.access$600(ActivityThread.java:141)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:5039)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                at dalvik.system.NativeStart.main(Native Method)

After that I've changed layout to:

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

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/map"
             android:layout_width="match_parent"
             android:layout_height="match_parent" />

and changed MyActivity to

  super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();

    transaction.add(R.id.map, MapFragment.newInstance());
    transaction.commit();

As result, the application was started, but I didn't see the map.

Console log:

ERROR/Google Maps Android API(10369): Authorization failure.


问:
How would you separate a list into sublists of all the duplicates in the original?
```<code>l = [a, a, a, b, b, c]

desired1 = [a, a, a]

desired2 = [b, b]

desired3 = [c]
</code>```

desired could also be a list of all the lists above.

答:
You can use itertools.groupby() to group common elements together:

```<code>>>> from itertools import groupby
>>> l = ['a', 'a', 'a', 'b', 'b', 'c']
>>>
>>> runs = [list(group) for _, group in groupby(l)]
>>> runs
[['a', 'a', 'a'], ['b', 'b'], ['c']]
>>>
</code>```

Note this will only work if the list has already been sorted, so you may have to sort before grouping:

```<code>>>> l = ['a', 'b', 'a', 'b', 'a', 'c'] # unsorted
>>> runs = [list(group) for _, group in groupby(sorted(l))]
>>> runs
[['a', 'a', 'a'], ['b', 'b'], ['c']]
>>>
</code>```

Body:
l = [a, a, a, b, b, c]

desired1 = [a, a, a]

desired2 = [b, b]

desired3 = [c]

desired could also be a list of all the lists above.

Body:
You can use itertools.groupby() to group common elements together:

>>> from itertools import groupby
>>> l = ['a', 'a', 'a', 'b', 'b', 'c']
>>>
>>> runs = [list(group) for _, group in groupby(l)]
>>> runs
[['a', 'a', 'a'], ['b', 'b'], ['c']]
>>>

Note this will only work if the list has already been sorted, so you may have to sort before grouping:

>>> l = ['a', 'b', 'a', 'b', 'a', 'c'] # unsorted
>>> runs = [list(group) for _, group in groupby(sorted(l))]
>>> runs
[['a', 'a', 'a'], ['b', 'b'], ['c']]
>>>


问:
YUI "Saved" notification
I'm trying to create a short term overlay notification for an app I'm working on. I also happen to be completely constrained to using YUI as my only script library. The goal is to make a YUI-styled notification appear over the page following a post wherein the form was saved. I would use the simpledialog, but the client doesn't want to have to interact with the notification, and they don't want any buttons or controls on it whatsoever, just a featureless, styled box that displays a message.

The effect I'm trying to pull off right now is to produce something similar to jQuery's showGlobalMessage function. So, are there any YUI controls capable of doing this? and if not, what would be the best way, using self-written js, to produce this effect?

Thanks for the help.

答:
Is the YUI Overlay widget what you're looking for?

I pasted a sample page demonstrating how it works. If that's more or less what you're looking for, then you should be able to have a function that, upon form submission, activates the overlay. You will have to lookup the API to learn more about it -- http://developer.yahoo.com/yui/3/overlay/

Also, YUI has custom events (but I don't know much about them): http://developer.yahoo.com/yui/3/event/

```<code><body>
<div id="myContent">
    <div class="yui3-widget-hd">Overlay Header</div>
    <div class="yui3-widget-bd">Overlay Body</div>
    <div class="yui3-widget-ft">Overlay Footer</div>
</div>
<style>
#myContent
{
background-color:blue;
color:red;
}
</style>
<div id="parentNode"></div>
<style>
#parentNode
{
color:red;
background-color:blue;
}
</style>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ornare phare

Etiam porttitor consectetur sagittis. Suspendisse libero lorem, porta ut tincidu

Etiam dapibus urna ut mauris semper varius. Vestibulum auctor tincidunt urna, id

Nam posuere rutrum sem porttitor pretium. Suspendisse pulvinar sodales viverra.

Donec eleifend nisi nec mauris vestibulum a placerat sapien molestie. In tempus

Proin tincidunt feugiat accumsan. Fusce vel sagittis tellus. Quisque vitae conse

Nam vestibulum, ipsum suscipit dignissim feugiat, nisl lectus sodales felis, nec

Quisque venenatis, nulla sit amet sodales semper, turpis nulla viverra lectus, a

Phasellus euismod ligula at lectus interdum a malesuada ante lacinia. Nam venena

Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos

Donec ut eros lorem, eget bibendum neque. Aliquam semper, tortor sed euismod luc

Nullam volutpat adipiscing congue. Aliquam fringilla diam quis quam pharetra tin

Etiam a tortor at justo sodales mattis. Praesent porttitor enim ac sem ultrices

Nam condimentum, ante non adipiscing tristique, magna felis semper arcu, eu temp

Morbi ut enim eget urna ornare elementum ac a ligula. Vestibulum commodo quam se
<script src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
<script>
YUI().use('overlay', function(Y) {
var overlay = new Y.Overlay({
    srcNode: '#myContent',
    centered: true
    });
    //overlay.render();
    overlay.render('#parentNode');
});
</script>
</body>
</code>```

ContentLicense: CC BY-SA 2.5

Title: YUI "Saved" notification

Body:
Is the YUI Overlay widget what you're looking for?

I pasted a sample page demonstrating how it works. If that's more or less what you're looking for, then you should be able to have a function that, upon form submission, activates the overlay. You will have to lookup the API to learn more about it -- http://developer.yahoo.com/yui/3/overlay/

Also, YUI has custom events (but I don't know much about them): http://developer.yahoo.com/yui/3/event/

<body>
<div id="myContent">
    <div class="yui3-widget-hd">Overlay Header</div>
    <div class="yui3-widget-bd">Overlay Body</div>
    <div class="yui3-widget-ft">Overlay Footer</div>
</div>
<style>
#myContent
{
background-color:blue;
color:red;
}
</style>
<div id="parentNode"></div>
<style>
#parentNode
{
color:red;
background-color:blue;
}
</style>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ornare phare

Etiam porttitor consectetur sagittis. Suspendisse libero lorem, porta ut tincidu

Etiam dapibus urna ut mauris semper varius. Vestibulum auctor tincidunt urna, id

Nam posuere rutrum sem porttitor pretium. Suspendisse pulvinar sodales viverra.

Donec eleifend nisi nec mauris vestibulum a placerat sapien molestie. In tempus

Proin tincidunt feugiat accumsan. Fusce vel sagittis tellus. Quisque vitae conse

Nam vestibulum, ipsum suscipit dignissim feugiat, nisl lectus sodales felis, nec

Quisque venenatis, nulla sit amet sodales semper, turpis nulla viverra lectus, a

Phasellus euismod ligula at lectus interdum a malesuada ante lacinia. Nam venena

Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos

Donec ut eros lorem, eget bibendum neque. Aliquam semper, tortor sed euismod luc

Nullam volutpat adipiscing congue. Aliquam fringilla diam quis quam pharetra tin

Etiam a tortor at justo sodales mattis. Praesent porttitor enim ac sem ultrices

Nam condimentum, ante non adipiscing tristique, magna felis semper arcu, eu temp

Morbi ut enim eget urna ornare elementum ac a ligula. Vestibulum commodo quam se
<script src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
<script>
YUI().use('overlay', function(Y) {
var overlay = new Y.Overlay({
    srcNode: '#myContent',
    centered: true
    });
    //overlay.render();
    overlay.render('#parentNode');
});
</script>
</body>


问:
Why does my url spits out the two // at the end?
I am very new to React so bear with me here. I have this button here:

```<code>let showButton
if (schema.type === 'belongs_to') {
  showButton = (
    <Link to={['collections', 'locks', this.props.collectionName]}>
      <button>Visa</button>
    </Link>
  )
}
</code>```

This button will redirect to this URL: http://localhost:3000/#/collections/locks/ and there is nothing wrong with that, but when I'm adding this: this.props.id which is a legit prop, but the url I get is this: http://localhost:3000/#/collections/locks//. Notice the two // at the end.

My Question

Why does my url spits out the two // at the end? Is it because this.props.id is empty? As I said, I am very new to this. Thankful for all the support!

Code:

I just want to say that I'm maintaining this project, so all of the code is not written by me, therefor I might not know every little line.

However.. The this.props.id if from here:

```<code>class DeleteDocument extends Component {
  constructor(props) {
    super(props)
    this.state = { confirmed: false }
  }
  render() {
    return (
      <div className="DeleteDocument">
        <div className="box">
          <div className="title">
            Är du säker på att du vill ta bort dokumentet?
          </div>
          <label>
            <input
              type="checkbox"
              value={this.state.confirmed}
              onChange={e =>
                this.setState({ confirmed: !this.state.confirmed })}
            />
            Ja, jag är säker
          </label>
          <div className="box" />
        </div>
        <div style={{ marginTop: '20px' }}>
          <button
            disabled={!this.state.confirmed}
            onClick={this.props.deleteDocument}
          >
            Ta bort
          </button>
          <div style={{ padding: '15px', borderBottom: '1px solid #ccc' }}>
            <Link to={'/collections/locks/${this.props.id}'}> HERE IT IS
              <button>Avbryt</button>
            </Link>
          </div>
        </div>
      </div>
    )
  }
}
</code>```

So I made a decision to use the same props because it's working here and the naming of it seemed to suit my use for it (don't know if this makes sense).

答:
I believe you may be almost right in your assumption, this.props.collectionName may be empty, along with this.props.id.

For the following examples, imagine _ to mean an empty string.

What I believe Link is doing here is joining the items in the array with a /. So if you have ['collections', 'locks', '_'] you will get collections/locks/_. Notice that there is a slash in the end, this is because there is an empty item in the array so Link does put a slash between that and the item before it. Not an issue since it is just one trailing slash.

Now, if you have ['collections', 'locks', '_', '_'] now there should be a slash between locks and _, and a slash between _ and _. The result would look like this: collections/locks/_/_, now you have two trailing slashes, which I believe is not a valid move in URLs.

Take a look at the scope of your function there, are you sure you have the props that you are expecting?

Hope this explains the issue!

Body:
I am very new to React so bear with me here. I have this button here:

let showButton
if (schema.type === 'belongs_to') {
  showButton = (
    <Link to={['collections', 'locks', this.props.collectionName]}>
      <button>Visa</button>
    </Link>
  )
}

This button will redirect to this URL: http://localhost:3000/#/collections/locks/ and there is nothing wrong with that, but when I'm adding this: this.props.id which is a legit prop, but the url I get is this: http://localhost:3000/#/collections/locks//. Notice the two // at the end.

My Question

Why does my url spits out the two // at the end? Is it because this.props.id is empty? As I said, I am very new to this. Thankful for all the support!

Code:

I just want to say that I'm maintaining this project, so all of the code is not written by me, therefor I might not know every little line.

However.. The this.props.id if from here:

class DeleteDocument extends Component {
  constructor(props) {
    super(props)
    this.state = { confirmed: false }
  }
  render() {
    return (

            Är du säker på att du vill ta bort dokumentet?

            <input
              type="checkbox"
              value={this.state.confirmed}
              onChange={e =>
                this.setState({ confirmed: !this.state.confirmed })}
            />
            Ja, jag är säker

          <button
            disabled={!this.state.confirmed}
            onClick={this.props.deleteDocument}
          >
            Ta bort
          </button>

            <Link to={'/collections/locks/${this.props.id}'}> HERE IT IS
              <button>Avbryt</button>
            </Link>

    )
  }
}

So I made a decision to use the same props because it's working here and the naming of it seemed to suit my use for it (don't know if this makes sense).


问:
Numerical differentiation using Cauchy (CIF)
I am trying to create a module with a mathematical class for Taylor series, to have it easily accessible for other projects. Hence I wish to optimize it as far as I can.

For those who are not too familiar with Taylor series, it will be a necessity to be able to differentiate a function in a point many times. Given that the normal definition of the mathematical derivative of a function will require immense precision for higher order derivatives, I've decided to use Cauchy's integral formula instead. With a little bit of work, I've managed to rearrange the formula a little bit, as you can see on this picture: Rearranged formula. This provided me with much more accurate results on higher order derivatives than the traditional definition of the derivative. Here is the function i am currently using to differentiate a function in a point:

```<code>def myDerivative(f, x, dTheta, degree):
  riemannSum = 0
  theta = 0

  while theta < 2*np.pi:
      functionArgument = np.complex128(x + np.exp(1j*theta))
      secondFactor = np.complex128(np.exp(-1j * degree * theta))
      riemannSum += f(functionArgument) * secondFactor * dTheta
      theta += dTheta
  return factorial(degree)/(2*np.pi) * riemannSum.real
</code>```

I've tested this function in my main function with a carefully thought out mathematical function which I know the derivatives of, namely f(x) = sin(x).

```<code>def main():
  print(myDerivative(f, 0, 2*np.pi/(4*4096), 16))
  pass
</code>```

These derivatives seems to freak out at around the derivative of degree 16. I've also tried to play around with dTheta, but with no luck. I would like to have higher orders as well, but I fear I've run into some kind of machine precission.

My question is in it's simplest form: What can I do to improve this function in order to get higher order of my derivatives?

答:
I seem to have come up with a solution to the problem. I did this by rearranging Cauchy's integral formula in a different way, by exploiting that the initial contour integral can be an arbitrarily large circle around the point of differentiation. Be aware that it is very important that the function is analytic in the complex plane for this to be valid.

New formula

Also this gives a new function for differentiation:

```<code>def myDerivative(f, x, dTheta, degree, contourRadius):
  riemannSum = 0
  theta = 0

  while theta < 2*np.pi:
      functionArgument = np.complex128(x + contourRadius*np.exp(1j*theta))
      secondFactor = (1/contourRadius)**degree*np.complex128(np.exp(-1j * degree * theta))
      riemannSum += f(functionArgument) * secondFactor * dTheta
      theta += dTheta

  return factorial(degree) * riemannSum.real / (2*np.pi)
</code>```

This gives me a very accurate differentiation of high orders. For instance I am able to differentiate f(x)=e^x 50 times without a problem.

Body:
I am trying to create a module with a mathematical class for Taylor series, to have it easily accessible for other projects. Hence I wish to optimize it as far as I can.

For those who are not too familiar with Taylor series, it will be a necessity to be able to differentiate a function in a point many times. Given that the normal definition of the mathematical derivative of a function will require immense precision for higher order derivatives, I've decided to use Cauchy's integral formula instead. With a little bit of work, I've managed to rearrange the formula a little bit, as you can see on this picture: Rearranged formula. This provided me with much more accurate results on higher order derivatives than the traditional definition of the derivative. Here is the function i am currently using to differentiate a function in a point:

def myDerivative(f, x, dTheta, degree):
  riemannSum = 0
  theta = 0

  while theta < 2*np.pi:
      functionArgument = np.complex128(x + np.exp(1j*theta))
      secondFactor = np.complex128(np.exp(-1j * degree * theta))
      riemannSum += f(functionArgument) * secondFactor * dTheta
      theta += dTheta
  return factorial(degree)/(2*np.pi) * riemannSum.real

I've tested this function in my main function with a carefully thought out mathematical function which I know the derivatives of, namely f(x) = sin(x).

def main():
  print(myDerivative(f, 0, 2*np.pi/(4*4096), 16))
  pass

These derivatives seems to freak out at around the derivative of degree 16. I've also tried to play around with dTheta, but with no luck. I would like to have higher orders as well, but I fear I've run into some kind of machine precission.

My question is in it's simplest form: What can I do to improve this function in order to get higher order of my derivatives?

Body:
I seem to have come up with a solution to the problem. I did this by rearranging Cauchy's integral formula in a different way, by exploiting that the initial contour integral can be an arbitrarily large circle around the point of differentiation. Be aware that it is very important that the function is analytic in the complex plane for this to be valid.

New formula

Also this gives a new function for differentiation:

def myDerivative(f, x, dTheta, degree, contourRadius):
  riemannSum = 0
  theta = 0

  while theta < 2*np.pi:
      functionArgument = np.complex128(x + contourRadius*np.exp(1j*theta))
      secondFactor = (1/contourRadius)**degree*np.complex128(np.exp(-1j * degree * theta))
      riemannSum += f(functionArgument) * secondFactor * dTheta
      theta += dTheta

  return factorial(degree) * riemannSum.real / (2*np.pi)

This gives me a very accurate differentiation of high orders. For instance I am able to differentiate f(x)=e^x 50 times without a problem.


问:
CSS Copy and paste problem
I've developed a system in my application where emails are picked up with a regex, and then reversed in the source (to thwart bots). I then add the span class 'obfuscate email'. I then use CSS to reverse the the text back to be displayed and Javascript make sure that mailto: links still work.

I was pretty happy with my solution until I realised that copying and pasting the email puts it in the clipboard backwards. I was wondering if there was any way I could remedy this? I've been testing in Firefox 3 for OS X.

The page in question is available here: http://www.leaklocations.com.au/contact-us/

To see the problem, simply copy and paste the email on that site.

答:
Seriously, is it worth all this effort to obfuscate email addresses? Once the email makes it into a spammer's hands, it's all over. Better to have a good spam filter instead.

And if you use JavaScript to reverse the email addresses back again you are adding extra work for the browser on page load. If JavaScript is turned off or a user is on a mobile device that doesn't support JavaScript, they are screwed too.

OwnerDisplayName: alex

Title: CSS Copy and paste problem

OwnerDisplayName: Ryan Doherty


问:
How to test Iterators (including the off-the-end and the before-the-beginning iterators) to a list or forward_list remain valid,
Working through C++ Primer and puzzled by Exercise 9.25.

Consider the following code erasing all elements from a list:

```<code>list<int> lst = {0,1,2,3,4,5,6,7,8,9};
elem1 = lst.begin();
elem2 = lst.end();
elem1 = lst.erase(elem1, elem2);
</code>```

Exercise 9.25 asks about invalid elements: what happens if elem2 or both elem1 and elem2 are the off-the-end iterator?

How do I write code to test this question that has an off-the-end iterator?

I have tried this:

```<code>std::list<int> lst = { 0,1,2,3,4,5,6,7,8,9 };
lst.erase(lst.begin(), ++lst.end());
</code>```

According to the text at section 9.3.6.: The answer is

```<code>Iterators, pointers, and references (including the off-the-end and the
before-the-beginning iterators) to a list or forward_list remain valid.
</code>```

How do I create a sample code to see that the solution is correct? That iterators remain valid? When I use the above code the error thrown is  "list iterator not incrementable"

答:
There is no built-in mechanism to check if an iterator, pointer or reference is valid. In some cases, if you know an iterator or pointer will become invalidated, you can set it to a known value such as nullptr (for pointers) or the containers end iterator (for iterators). Usually, you must simply design your software in such a way that you never preform an operation on an invalidated iterator. Once an iterator is invalidated it cannot be used, even to compare it with other iterators to see if it's valid.

If you want to check if a valid iterator is a past-the-end iterator, you would usually compare it with the container's end iterator (see std::end).

Body:
Working through C++ Primer and puzzled by Exercise 9.25.

Consider the following code erasing all elements from a list:

list<int> lst = {0,1,2,3,4,5,6,7,8,9};
elem1 = lst.begin();
elem2 = lst.end();
elem1 = lst.erase(elem1, elem2);

Exercise 9.25 asks about invalid elements: what happens if elem2 or both elem1 and elem2 are the off-the-end iterator?

How do I write code to test this question that has an off-the-end iterator?

I have tried this:

std::list<int> lst = { 0,1,2,3,4,5,6,7,8,9 };
lst.erase(lst.begin(), ++lst.end());

According to the text at section 9.3.6.: The answer is

Iterators, pointers, and references (including the off-the-end and the
before-the-beginning iterators) to a list or forward_list remain valid.

How do I create a sample code to see that the solution is correct? That iterators remain valid? When I use the above code the error thrown is  "list iterator not incrementable"


问:
Is there any way to create an Understand (from Scitools) DB within a python script?
I am in the process of writing a python script to determine projects that reference a given project and have come across Understand from Scitools. After research on the Understands Python API it appears that I need to “open” a DB in order to execute any commands and discover all there is to discover about a given project. For example when I execute this:

example.py
```<code>import understand
import sys

def sortedEntities(db):
  for ent in sorted(db.ents(),key= lambda ent: ent.name()):
    print (ent.name(),"  [",ent.kindname(),"]",sep="",end="\n")

if __name__ == '__main__':
  # Open Database
  args = sys.argv
  db = understand.open(args[1])
  sortedEntities(db)
</code>```

I am faced with an understand.UnderstandError: DBCorrupt error because I am not feeding in a .udb file and instead feeding in a .csproj file. I assume then that I have to create this .udb file which is a db file.

I am trying to avoid using Understands GUI and automate this static tool within a python script. Is there any way I can create a DB from a given project and then execute the many commands Understand has to offer. Any guidance would be very much appreciated!

答:
you can use the command line utility for this, udb_path is where UDB is created, language is Java/Python/c#/or whatever, project_root is the root path of your project you want to run understand on.

```<code>@staticmethod
def create_udb(udb_path, language, project_root):
    try:
        output = subprocess.check_output(
            "und create -db {udb_path} -languages {lang}".format(udb_path=udb_path, lang=language),
            shell=True)
        logging.info(output)
        output = subprocess.check_output("und add -db {udb_path} {project}".format(
            udb_path=udb_path, project=project_root), shell=True)
        logging.info(output)
    except subprocess.CalledProcessError as e:
        logging.exception(e.output)
        logging.fatal("udb creation failed")
        raise Exception
</code>```

Body:
I am in the process of writing a python script to determine projects that reference a given project and have come across Understand from Scitools. After research on the Understands Python API it appears that I need to “open” a DB in order to execute any commands and discover all there is to discover about a given project. For example when I execute this:

example.py

import understand
import sys

def sortedEntities(db):
  for ent in sorted(db.ents(),key= lambda ent: ent.name()):
    print (ent.name(),"  [",ent.kindname(),"]",sep="",end="\n")

if __name__ == '__main__':
  # Open Database
  args = sys.argv
  db = understand.open(args[1])
  sortedEntities(db)

I am faced with an understand.UnderstandError: DBCorrupt error because I am not feeding in a .udb file and instead feeding in a .csproj file. I assume then that I have to create this .udb file which is a db file.

I am trying to avoid using Understands GUI and automate this static tool within a python script. Is there any way I can create a DB from a given project and then execute the many commands Understand has to offer. Any guidance would be very much appreciated!

Body:
you can use the command line utility for this, udb_path is where UDB is created, language is Java/Python/c#/or whatever, project_root is the root path of your project you want to run understand on.

@staticmethod
def create_udb(udb_path, language, project_root):
    try:
        output = subprocess.check_output(
            "und create -db {udb_path} -languages {lang}".format(udb_path=udb_path, lang=language),
            shell=True)
        logging.info(output)
        output = subprocess.check_output("und add -db {udb_path} {project}".format(
            udb_path=udb_path, project=project_root), shell=True)
        logging.info(output)
    except subprocess.CalledProcessError as e:
        logging.exception(e.output)
        logging.fatal("udb creation failed")
        raise Exception


问:
Remove "V" letter in column names when a matrix without column names is converted to data.frame
When a matrix is converted to a date frame, the original column names are removed while V1, V2, ... are added as the new column names.

Is there any options to disable that? I expect the same column names as that in the matrix, e.g. 1, 2.

```<code>m <- cbind(1:2, 2:3); m

      [,1] [,2]
[1,]    1    2
[2,]    2    3

as.data.frame(m)

   V1 V2
1  1  2
2  2  3
</code>```

答:
You seem to be confusing column names and column indexes, but if you really want to have numbers as column names they'll be turned into  character class.</p>

```<code>m <- matrix(c(1, 2, 2, 3), 2)
colnames(m) <- c(1, 2)
rownames(m) <- c(1, 2)
m
#   1 2
# 1 1 2
# 2 2 3

is.character(unlist(dimnames(m)))
# TRUE

ddf <- as.data.frame(m)
ddf
#   1 2
# 1 1 2
# 2 2 3
</code>```

ContentLicense: CC BY-SA 4.0

Body:
When a matrix is converted to a date frame, the original column names are removed while V1, V2, ... are added as the new column names.

Is there any options to disable that? I expect the same column names as that in the matrix, e.g. 1, 2.

m <- cbind(1:2, 2:3); m

      [,1] [,2]
[1,]    1    2
[2,]    2    3

as.data.frame(m)

   V1 V2
1  1  2
2  2  3

Body:
You seem to be confusing column names and column indexes, but if you really want to have numbers as column names they'll be turned into  character class.

m <- matrix(c(1, 2, 2, 3), 2)
colnames(m) <- c(1, 2)
rownames(m) <- c(1, 2)
m
#   1 2
# 1 1 2
# 2 2 3

is.character(unlist(dimnames(m)))
# TRUE

ddf <- as.data.frame(m)
ddf
#   1 2
# 1 1 2
# 2 2 3


问:
C# - How can i get the count of child elements using LINQ to XML
This is an extract of the XML i'm using

```<code>    <AccountNumber>
      <RecordID>A9</RecordID>
      <SegmentLength>14</SegmentLength>
      <Number>6770307103</Number>
    </AccountNumber>
    <PaymentCounter>
      <RecordID>B2</RecordID>
      <SegmentLength>14</SegmentLength>
      <History>99</History>
      <Delinq30Day>00</Delinq30Day>
      <Delinq60Day>00</Delinq60Day>
      <Delinq90PlusDay>00</Delinq90PlusDay>
      <DerogCnt>00</DerogCnt>
    </PaymentCounter>
</code>```

Here I'm trying to identify the number of child elements under AccountNumber and PaymentCounter.

I'm looking for this answer
AccountNumber count = 3
PaymentCounter count = 7

After I get the count, I will use the data to dynamically populate a table.

I tried this :
int count1 = xmlDocument.Descendants("AccountNumber").Count();

The count() in LINQ to XML will give me the number of times element "AccountNumber" is repeated in the XML, but doesnot give me the number of child elements.

Is there a way to do this?

答: Yes, this is possible by using xmlDocument.Descendants("AccountNumber").First().Decendants().Count().

Body:
This is an extract of the XML i'm using

    <AccountNumber>
      <RecordID>A9</RecordID>
      <SegmentLength>14</SegmentLength>
      <Number>6770307103</Number>
    </AccountNumber>
    <PaymentCounter>
      <RecordID>B2</RecordID>
      <SegmentLength>14</SegmentLength>
      <History>99</History>
      <Delinq30Day>00</Delinq30Day>
      <Delinq60Day>00</Delinq60Day>
      <Delinq90PlusDay>00</Delinq90PlusDay>
      <DerogCnt>00</DerogCnt>
    </PaymentCounter>

Here I'm trying to identify the number of child elements under AccountNumber and PaymentCounter.

I'm looking for this answer
AccountNumber count = 3
PaymentCounter count = 7

After I get the count, I will use the data to dynamically populate a table.

I tried this :
int count1 = xmlDocument.Descendants("AccountNumber").Count();

The count() in LINQ to XML will give me the number of times element "AccountNumber" is repeated in the XML, but doesnot give me the number of child elements.

Is there a way to do this?


问:
Ionic2: sidemenu submenu (dropdown)
I don't do ionic, and it's not my question, it's my friend's question who's afraid of asking on StackOverflow since she doesn't really know how to ask.

She just would like to know how to create a submenu in ionic 2 side menu starter project.

The HTML

```<code><ion-menu [content]="content" side="left" id="menu1">
  <ion-content class="outer-content" no-border-top>
    <ion-list lines (click)="openSubCat($event,category)">
      <ion-list-header>
        Shop For
      </ion-list-header>
      <ion-item *ngFor="let item of categoryArray" let idx=index (click)="openSubCat(item.value)">
        <ion-icon [name]="item.icon" item-left></ion-icon>
          {{ item.value }}
        <ion-icon [name]="item.icon2" item-right ></ion-icon>
     </ion-item>
    </ion-list>
 </ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>`
</code>```

the app-components.ts

```<code>import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';

import { TutorialPage } from '../pages/tutorial/tutorial';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage: any = TutorialPage;

  pages: Array<{title: string, component: any}>;

  categoryArray: Array<any> = [{
      value:'Men',
      icon: 'man',
      icon2:'ios-arrow-forward-outline',
      view:'viewToGoTo'
   },{
      value:'Woman',
      icon: 'woman',
      icon2:'ios-arrow-forward-outline',
      view:'viewToGoTo'
   },{
      value:'Kids',
      icon: '',
      icon2:'ios-arrow-forward-outline',
      view:'viewToGoTo'
   }
   ];
  constructor(public platform: Platform) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
    });
  }

  openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }

openSubCat(category){
  console.log(category)

}

}
</code>```

I sent her this link  but couldn't really explain much, since I don't do ionic, but it seems to be that to create a dropdown you just need to create a 2d array, is that correct? Could you please edit the code in this question to include a submenu as an example for her to learn from?

答:
[...] it's my friend's question who's afraid of asking on
  StackOverflow since she doesn't really know how to ask.

First tell your friend that she doesn't need to be afraid of asking anything on StackOverflow, we're all here to learn, and even if the question is not ok, we will help her to learn how to write a good question.

About the repository (btw thanks for sharing my demo lol), that's just one way to create a side menu in Ionic. Just like you can see in the README.md file, first copy the content of the side-menu-content folder (the .ts, .html and .scss files) to your project.

Then add it to declarations array of your NgModule, in the app.module.ts file:

```<code>// The path could be different on your end
import { SideMenuContentComponent } from '../side-menu-content/side-menu-content.component';

@NgModule({
  declarations: [
    MyApp,
    // ...
    SideMenuContentComponent // <- Here!
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    // ...
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: ErrorHandler, useClass: IonicErrorHandler }
  ]
})
export class AppModule { }
</code>```

Now we just need to add some code to initialize the side menu, and also to handle what to do when an option is selected. So in the app.component.ts file, add this code:

```<code>@Component({
    templateUrl: 'app.html'
})
export class MyApp {
    @ViewChild(Nav) navCtrl: Nav;

    // Get the instance to call the public methods
    @ViewChild(SideMenuContentComponent) sideMenu: SideMenuContentComponent;

    public rootPage: any = HomePage;
    public options: Array<MenuOptionModel>;

    constructor(private platform: Platform,
                private statusBar: StatusBar,
                private splashScreen: SplashScreen,
                private menuCtrl: MenuController) {
        this.initializeApp();
    }

    initializeApp() {
        this.platform.ready().then(() => {
            this.statusBar.styleDefault();
            this.splashScreen.hide();

            // Create the options
            this.options = this.getSideMenuOptions();
        });
    }

    // Initialize the side menu options
    private getSideMenuOptions(): Array<MenuOptionModel> {
        let menuOptions = new Array<MenuOptionModel>();

        // Shop for (header)
        //  - Man
        //  - Woman
        //  - Kids

        menuOptions.push({
            iconName: 'ios-arrow-down',
            displayName: `Shop for`,
            component: null,    // This is just the header
            isLogin: false,     // It's not the login
            isLogout: false,    // It's not the logout
            subItems: [
                {
                    iconName: 'man',
                    displayName: `Men`,
                    component: viewToGoTo,
                    isLogin: false,
                    isLogout: false
                },
                {
                    iconName: 'woman',
                    displayName: `Woman`,
                    component: viewToGoTo,
                    isLogin: false,
                    isLogout: false
                },
                {
                    iconName: 'happy',
                    displayName: `Kids`,
                    component: viewToGoTo,
                    isLogin: false,
                    isLogout: false
                }
            ]
        });

        return menuOptions;

    }

    // Redirect the user to the selected page
    public selectOption(option: MenuOptionModel): void {
        this.menuCtrl.close().then(() => {

            // Collapse all the options
            this.sideMenu.collapseAllOptions();

            // Redirect to the selected page
            this.navCtrl.push(option.component);
        });
    }

    public collapseMenuOptions(): void {
        // Collapse all the options
        this.sideMenu.collapseAllOptions();
    }
}
</code>```

Now the last thing to do is to add the side menu in the view. So put this in the app.html file:

```<code><ion-menu persistent="true" [content]="content" (ionClose)="collapseMenuOptions()">
    <ion-header>
        <ion-toolbar color="secondary">
            <ion-title>Menu</ion-title>
        </ion-toolbar>
    </ion-header>

    <ion-content>

        <!-- Side Menu -->
        <side-menu-content [accordionMode]="true" [options]="options" (selectOption)="selectOption($event)"></side-menu-content>

    </ion-content>
</ion-menu>

<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
</code>```

Title: Ionic2: sidemenu submenu (dropdown)

Body:
I don't do ionic, and it's not my question, it's my friend's question who's afraid of asking on StackOverflow since she doesn't really know how to ask.

She just would like to know how to create a submenu in ionic 2 side menu starter project.

The HTML

<ion-menu [content]="content" side="left" id="menu1">
  <ion-content class="outer-content" no-border-top>
    <ion-list lines (click)="openSubCat($event,category)">
      <ion-list-header>
        Shop For
      </ion-list-header>
      <ion-item *ngFor="let item of categoryArray" let idx=index (click)="openSubCat(item.value)">
        <ion-icon [name]="item.icon" item-left></ion-icon>
          {{ item.value }}
        <ion-icon [name]="item.icon2" item-right ></ion-icon>
     </ion-item>
    </ion-list>
 </ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>`

the app-components.ts

import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';

import { TutorialPage } from '../pages/tutorial/tutorial';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage: any = TutorialPage;

  pages: Array<{title: string, component: any}>;

  categoryArray: Array<any> = [{
      value:'Men',
      icon: 'man',
      icon2:'ios-arrow-forward-outline',
      view:'viewToGoTo'
   },{
      value:'Woman',
      icon: 'woman',
      icon2:'ios-arrow-forward-outline',
      view:'viewToGoTo'
   },{
      value:'Kids',
      icon: '',
      icon2:'ios-arrow-forward-outline',
      view:'viewToGoTo'
   }
   ];
  constructor(public platform: Platform) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
    });
  }

  openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }

openSubCat(category){
  console.log(category)

}

}

I sent her this link  but couldn't really explain much, since I don't do ionic, but it seems to be that to create a dropdown you just need to create a 2d array, is that correct? Could you please edit the code in this question to include a submenu as an example for her to learn from?

Body:
[...] it's my friend's question who's afraid of asking on
  StackOverflow since she doesn't really know how to ask.

First tell your friend that she doesn't need to be afraid of asking anything on StackOverflow, we're all here to learn, and even if the question is not ok, we will help her to learn how to write a good question.

About the repository (btw thanks for sharing my demo lol), that's just one way to create a side menu in Ionic. Just like you can see in the README.md file, first copy the content of the side-menu-content folder (the .ts, .html and .scss files) to your project.

Then add it to declarations array of your NgModule, in the app.module.ts file:

// The path could be different on your end
import { SideMenuContentComponent } from '../side-menu-content/side-menu-content.component';

@NgModule({
  declarations: [
    MyApp,
    // ...
    SideMenuContentComponent // <- Here!
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    // ...
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: ErrorHandler, useClass: IonicErrorHandler }
  ]
})
export class AppModule { }

Now we just need to add some code to initialize the side menu, and also to handle what to do when an option is selected. So in the app.component.ts file, add this code:

@Component({
    templateUrl: 'app.html'
})
export class MyApp {
    @ViewChild(Nav) navCtrl: Nav;

    // Get the instance to call the public methods
    @ViewChild(SideMenuContentComponent) sideMenu: SideMenuContentComponent;

    public rootPage: any = HomePage;
    public options: Array<MenuOptionModel>;

    constructor(private platform: Platform,
                private statusBar: StatusBar,
                private splashScreen: SplashScreen,
                private menuCtrl: MenuController) {
        this.initializeApp();
    }

    initializeApp() {
        this.platform.ready().then(() => {
            this.statusBar.styleDefault();
            this.splashScreen.hide();

            // Create the options
            this.options = this.getSideMenuOptions();
        });
    }

    // Initialize the side menu options
    private getSideMenuOptions(): Array<MenuOptionModel> {
        let menuOptions = new Array<MenuOptionModel>();

        // Shop for (header)
        //  - Man
        //  - Woman
        //  - Kids

        menuOptions.push({
            iconName: 'ios-arrow-down',
            displayName: `Shop for`,
            component: null,    // This is just the header
            isLogin: false,     // It's not the login
            isLogout: false,    // It's not the logout
            subItems: [
                {
                    iconName: 'man',
                    displayName: `Men`,
                    component: viewToGoTo,
                    isLogin: false,
                    isLogout: false
                },
                {
                    iconName: 'woman',
                    displayName: `Woman`,
                    component: viewToGoTo,
                    isLogin: false,
                    isLogout: false
                },
                {
                    iconName: 'happy',
                    displayName: `Kids`,
                    component: viewToGoTo,
                    isLogin: false,
                    isLogout: false
                }
            ]
        });

        return menuOptions;

    }

    // Redirect the user to the selected page
    public selectOption(option: MenuOptionModel): void {
        this.menuCtrl.close().then(() => {

            // Collapse all the options
            this.sideMenu.collapseAllOptions();

            // Redirect to the selected page
            this.navCtrl.push(option.component);
        });
    }

    public collapseMenuOptions(): void {
        // Collapse all the options
        this.sideMenu.collapseAllOptions();
    }
}

Now the last thing to do is to add the side menu in the view. So put this in the app.html file:

<ion-menu persistent="true" [content]="content" (ionClose)="collapseMenuOptions()">
    <ion-header>
        <ion-toolbar color="secondary">
            <ion-title>Menu</ion-title>
        </ion-toolbar>
    </ion-header>

    <ion-content>

        <!-- Side Menu -->
        <side-menu-content [accordionMode]="true" [options]="options" (selectOption)="selectOption($event)"></side-menu-content>

    </ion-content>
</ion-menu>

<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>


问:
c# application crashes on ShowDialog() after running oledbconnection
I have been working on a c# project that connects to a access database, but a certain sequence of events causes it to crash with a AccessViolationException

The issue comes after calling a database connection using oledb in a separate form than the savefiledialog, and than calling savefiledialog1.ShowDialog()

Note: This also applies to the open file dialog.

答:
Be sure you are using System.Data.OleDb from System.data.dll

Then  try something like this:

```<code>using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        // Declare Command
        OleDbCommand command = new OleDbCommand(YourSQL);

        // Set the Connection to the new OleDbConnection.
        command.Connection = connection;

        // Open the connection and execute the command.
        try
        {
            connection.Open();
            command.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.
     }
</code>```

Body:
Be sure you are using System.Data.OleDb from System.data.dll

Then  try something like this:

using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        // Declare Command
        OleDbCommand command = new OleDbCommand(YourSQL);

        // Set the Connection to the new OleDbConnection.
        command.Connection = connection;

        // Open the connection and execute the command.
        try
        {
            connection.Open();
            command.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.
     }


问:
Hangs on run and exits only with CTRL + C
These are our images:

```<code>PS C:\Users\bigfo> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mongo               latest              71c101e16e61        12 days ago         358MB
mongo               <none>              88b7188af865        2 weeks ago         358MB
hello-world         latest              1815c82652c0        3 weeks ago         1.84kB
</code>```

These are our containers:

```<code>PS C:\Users\bigfo> docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS               NAMES
2b2b2d73559d        mongo               "docker-entrypoint..."   6 days ago          Exited (128) 6 days ago                       some-mongo
678d1e4a4b0c        hello-world         "/hello"                 2 weeks ago         Exited (0) 2 weeks ago                        eager_turing
</code>```

This is our docker version:

```<code>PS C:\Users\bigfo> docker -v
Docker version 17.06.0-ce, build 02c1d87
</code>```

The following hangs:

```<code>PS C:\Users\bigfo> docker run hello-world
</code>```

Two questions:

How can we troubleshoot this?

How can we resolve this?

We're on Windows 10.

答:
On Windows the fix was to restart Docker.

First quit docker ...

... then start the daemon from a shell (such as PowerShell) ...

```<code>PS> & "C:\Program Files\Docker\Docker\Docker for Windows.exe"
</code>```

Body:
These are our images:

PS C:\Users\bigfo> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mongo               latest              71c101e16e61        12 days ago         358MB
mongo               <none>              88b7188af865        2 weeks ago         358MB
hello-world         latest              1815c82652c0        3 weeks ago         1.84kB

These are our containers:

PS C:\Users\bigfo> docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS               NAMES
2b2b2d73559d        mongo               "docker-entrypoint..."   6 days ago          Exited (128) 6 days ago                       some-mongo
678d1e4a4b0c        hello-world         "/hello"                 2 weeks ago         Exited (0) 2 weeks ago                        eager_turing

This is our docker version:

PS C:\Users\bigfo> docker -v
Docker version 17.06.0-ce, build 02c1d87

The following hangs:

PS C:\Users\bigfo> docker run hello-world

Two questions:

How can we troubleshoot this?

How can we resolve this?

We're on Windows 10.

Body:
On Windows the fix was to restart Docker.

First quit docker ...

... then start the daemon from a shell (such as PowerShell) ...

PS> & "C:\Program Files\Docker\Docker\Docker for Windows.exe"


问:
font color through rendering in typescript react
Trying to set the font color through a variable inside a react component, but my  gives error:

```<code>Type '{ style: "color:yellow"; }' is not assignable to type 'HTMLProps<HTMLSpanElement>'
</code>```

The yellow is just for testing, I will replace with {color} in the end.

```<code>import * as React from 'react';

    export interface SkillListItemProps {
        name: string
        color: string
       // Icons:
    }

    interface SkillListItemState{
    }

    export class SkillListItem extends React.Component<SkillListItemProps,SkillListItemState>{
        public render(): JSX.Element{
            const {name, color} = this.props;
        return (
            <div className="SkillListItem">
                <span style="color:yellow">{name}</span>
            </div>
        )
        }
    }
</code>```

答:
You must use an object, like this:

```<code><span style={{color: "yellow"}}>{name}</span>
</code>```

JSFiddle Demo: https://jsfiddle.net/4wcmcpv3/1/

Body:
Trying to set the font color through a variable inside a react component, but my  gives error:

Type '{ style: "color:yellow"; }' is not assignable to type 'HTMLProps<HTMLSpanElement>'

The yellow is just for testing, I will replace with {color} in the end.

import * as React from 'react';

    export interface SkillListItemProps {
        name: string
        color: string
       // Icons:
    }

    interface SkillListItemState{
    }

    export class SkillListItem extends React.Component<SkillListItemProps,SkillListItemState>{
        public render(): JSX.Element{
            const {name, color} = this.props;
        return (

                {name}

        )
        }
    }

Body:
You must use an object, like this:

<span style={{color: "yellow"}}>{name}</span>

JSFiddle Demo: https://jsfiddle.net/4wcmcpv3/1/


问:
full width in container bootstrap
I have a little problem with bootstrap, I test lot of possibility for resolve my problem, but I dont found the good..

I have a footer. The footer is in the container for align with the bootstrap grid. I would like to put the width contact block at 100% at the right.Currently it is blocked against the container.

the block are perfectly align, i have just this problem

Curently:

Final result :

(See my code in full view)

@charset 'UTF-8';

@import url('https://fonts.googleapis.com/css?family=Lato:300,400,900|Merriweather:400,400i,700i');

.accompagnement {
    height: 550px;
    background: #fafafa;
}

.accompagnement__titre {
    font-family: Merriweather, serif;
    font-size: 30px;
    font-weight: 400;
    line-height: 240px;
    position: relative;
    color: #aba08c;
}

.accompagnement__titre:after {
    position: absolute;
    right: 40%;
    bottom: 70px;
    width: 200px;
    height: 1px;
    content: ' ';
    background: #aba08c;
}

.accompagnement__informations {
    background: white;
    background-clip: content-box;
}

.accompagnement__image {
    width: 100%;
    height: 210px;
    background: url('../assets/img/spot-of-light-1145368.jpg') no-repeat center center;
}

.accompagnement__texte {
    line-height: 26px;
    padding: 30px 30px;
}

.accompagnement__texte > h2 {
    font-size: 24px;
    color: #8b3d61;
}

.accompagnement__texte > p {
    font-weight: 300;
}

.valign {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
        -ms-flex-direction: row;
            flex-direction: row;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
}

.set-relative {
    position: relative;
}

.svg-button {
    /**
    Gestion du :Hover des SVG
   */
}

.svg-button-gauche,
.svg-button-droite {
    position: absolute;
    top: 50%;
    width: 46px;
    height: 46px;
    fill: #5e5f78;
}

.svg-button-gauche {
    left: -60px;
}

.svg-button-droite {
    right: -60px;
}

.svg-button-fleche {
    fill: none;
    stroke: #ccc;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2px;
}

.svg-button-contour {
    fill: #ccc;
}

.svg-button-gauche:hover .svg-button-fleche,
.svg-button-droite:hover .svg-button-fleche {
    stroke: red;
}

.svg-button-gauche:hover .svg-button-contour,
.svg-button-droite:hover .svg-button-contour {
    fill: red;
}

footer {
    position: relative;
    background: #e5e3e8;
}

footer ul {
    margin: 50px 0 140px 0;
    color: #5e5f78;
}

footer ul li {
    font-weight: 300;
    line-height: 25px;
}

footer ul li:first-child {
    font-family: Merriweather, serif;
    font-weight: 400;
    line-height: 30px;
}

footer ul li a {
    text-decoration: none;
    color: inherit;
}

footer ul li a:hover {
    color: inherit;
}

.footer {
    font-size: 13px;
    font-weight: 300;
    padding: 30px 0;
    color: #5e5f78;
    border-top: 1px solid #fff;
}

.footer__copyright {
    padding-left: 0;
}

.footer__appolo {
    padding-right: 0;
    text-align: right;
}

.footer__appolo > a {
    display: inline-block;
    text-decoration: none;
    color: #5e5f78;
}

.footer__appolo > a:first-child:after {
    margin: 0 15px;
    content: '•';
}

.contacts {
    position: absolute;
    top: -20px;
    right: 0;
    height: 409px;
    background: #fff;
    background-clip: content-box;
}

.contacts > h2 {
    font-family: Merriweather, serif;
    font-size: 30px;
    line-height: 30px;
    position: relative;
    margin-bottom: 55px;
    color: #aba08c;
}

.contacts > h2:after {
    position: absolute;
    bottom: -30px;
    left: 0;
    width: 300px;
    height: 1px;
    content: ' ';
    background: #aba08c;
}

.contacts__tel {
    font-weight: 300;
    line-height: 30px;
    margin: 0 0 50px 0;
}

.contacts__permanence,
.contacts__disponibilite,
.contacts__lieu {
    font-family: Merriweather, serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 30px;
    margin: 0;
}

.contacts__adresse {
    font-size: 14px;
    font-weight: 300;
    line-height: 20px;
    margin: 0;
    color: #5e5f78;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<section class="container-fluid accompagnement">
    <div class="container">
        <div class="row">
            <div class="container">
                <div class="row set-relative">
                    <div class="col-lg-4 accompagnement__informations">
                        <div class="accompagnement__image"></div>
                        <div class="accompagnement__texte">
                            <h2>Title</h2>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid blanditiis dignissimos fuga nobis, nulla, pariatur, quia quisquam reiciendis repellendus tempore vero voluptas voluptate voluptatibus. Alias ducimus impedit nostrum reprehenderit ut!</p>
                        </div>
                    </div>
                    <div class="col-lg-4 accompagnement__informations">
                        <div class="accompagnement__image"></div>
                        <div class="accompagnement__texte">
                            <h2>Title</h2>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda consectetur doloribus ducimus eveniet molestiae? Amet delectus, distinctio harum incidunt, laborum libero minima minus molestias quam repudiandae suscipit ut veniam voluptatum.</p>
                        </div>
                    </div>
                    <div class="col-lg-4 accompagnement__informations">
                        <div class="accompagnement__image"></div>
                        <div class="accompagnement__texte">
                            <h2>Title</h2>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores cumque eligendi expedita id itaque minus modi neque nostrum odio omnis provident quam quas quasi quisquam ratione repellendus, sapiente similique voluptas.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8">
                <div class="row">
                    <div class="col-lg-3">
                        <ul class="list-unstyled">
                            <li>Menu</li>
                            <li>SubMenu</li>
                            <li>SubMenu</li>
                            <li>SubMenu</li>
                        </ul>
                    </div>
                    <div class="col-lg-3">
                        <ul class="list-unstyled">
                            <li>Menu</li>
                            <li>Submenu</li>
                            <li>Submenu</li>
                            <li>Submenu</li>
                        </ul>
                    </div>
                    <div class="col-lg-3">
                        <ul class="list-unstyled">
                            <li>Menu</li>
                            <li>Submenu</li>
                            <li>Submenu</li>
                        </ul>
                    </div>
                    <div class="col-lg-3">
                        <ul class="list-unstyled">
                            <li>Menu</li>
                            <li>Submenu</li>
                            <li>Submenu</li>
                        </ul>
                    </div>
                </div>
                <div class="row footer">
                    <p class="col-lg-6 footer__copyright">© 2017 Company</p>
                    <div class="col-lg-6 footer__appolo">
                        Plan
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="row">
                    <div class="col-lg-12 contacts">
                        <h2>Contacts</h2>
                        <p class="contacts__permanence">Blablabla</p>
                        <p class="contacts__disponibilite">Blablabla</p>
                        <p class="contacts__tel">Blablabla</p>
                        <p class="contacts__lieu">Blablabla</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</footer>
</body></code>```

Thanks

答:
If your block is inside a .container, you can't expand it outside the container, unless you make it position:absolute or something like this.
You could also change the .container in the footer into a .container-fluid, and then create 2 blocks inside for placing.

.container is made to be centered on devices > "xs".

Title: full width in container bootstrap

Body:
I have a little problem with bootstrap, I test lot of possibility for resolve my problem, but I dont found the good..

I have a footer. The footer is in the container for align with the bootstrap grid. I would like to put the width contact block at 100% at the right.Currently it is blocked against the container.

the block are perfectly align, i have just this problem

Curently:

Final result :

(See my code in full view)

@charset 'UTF-8';

@import url('https://fonts.googleapis.com/css?family=Lato:300,400,900|Merriweather:400,400i,700i');

.accompagnement {
    height: 550px;
    background: #fafafa;
}

.accompagnement__titre {
    font-family: Merriweather, serif;
    font-size: 30px;
    font-weight: 400;
    line-height: 240px;
    position: relative;
    color: #aba08c;
}

.accompagnement__titre:after {
    position: absolute;
    right: 40%;
    bottom: 70px;
    width: 200px;
    height: 1px;
    content: ' ';
    background: #aba08c;
}

.accompagnement__informations {
    background: white;
    background-clip: content-box;
}

.accompagnement__image {
    width: 100%;
    height: 210px;
    background: url('../assets/img/spot-of-light-1145368.jpg') no-repeat center center;
}

.accompagnement__texte {
    line-height: 26px;
    padding: 30px 30px;
}

.accompagnement__texte > h2 {
    font-size: 24px;
    color: #8b3d61;
}

.accompagnement__texte > p {
    font-weight: 300;
}

.valign {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
        -ms-flex-direction: row;
            flex-direction: row;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
}

.set-relative {
    position: relative;
}

.svg-button {
    /**
    Gestion du :Hover des SVG
   */
}

.svg-button-gauche,
.svg-button-droite {
    position: absolute;
    top: 50%;
    width: 46px;
    height: 46px;
    fill: #5e5f78;
}

.svg-button-gauche {
    left: -60px;
}

.svg-button-droite {
    right: -60px;
}

.svg-button-fleche {
    fill: none;
    stroke: #ccc;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2px;
}

.svg-button-contour {
    fill: #ccc;
}

.svg-button-gauche:hover .svg-button-fleche,
.svg-button-droite:hover .svg-button-fleche {
    stroke: red;
}

.svg-button-gauche:hover .svg-button-contour,
.svg-button-droite:hover .svg-button-contour {
    fill: red;
}

footer {
    position: relative;
    background: #e5e3e8;
}

footer ul {
    margin: 50px 0 140px 0;
    color: #5e5f78;
}

footer ul li {
    font-weight: 300;
    line-height: 25px;
}

footer ul li:first-child {
    font-family: Merriweather, serif;
    font-weight: 400;
    line-height: 30px;
}

footer ul li a {
    text-decoration: none;
    color: inherit;
}

footer ul li a:hover {
    color: inherit;
}

.footer {
    font-size: 13px;
    font-weight: 300;
    padding: 30px 0;
    color: #5e5f78;
    border-top: 1px solid #fff;
}

.footer__copyright {
    padding-left: 0;
}

.footer__appolo {
    padding-right: 0;
    text-align: right;
}

.footer__appolo > a {
    display: inline-block;
    text-decoration: none;
    color: #5e5f78;
}

.footer__appolo > a:first-child:after {
    margin: 0 15px;
    content: '•';
}

.contacts {
    position: absolute;
    top: -20px;
    right: 0;
    height: 409px;
    background: #fff;
    background-clip: content-box;
}

.contacts > h2 {
    font-family: Merriweather, serif;
    font-size: 30px;
    line-height: 30px;
    position: relative;
    margin-bottom: 55px;
    color: #aba08c;
}

.contacts > h2:after {
    position: absolute;
    bottom: -30px;
    left: 0;
    width: 300px;
    height: 1px;
    content: ' ';
    background: #aba08c;
}

.contacts__tel {
    font-weight: 300;
    line-height: 30px;
    margin: 0 0 50px 0;
}

.contacts__permanence,
.contacts__disponibilite,
.contacts__lieu {
    font-family: Merriweather, serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 30px;
    margin: 0;
}

.contacts__adresse {
    font-size: 14px;
    font-weight: 300;
    line-height: 20px;
    margin: 0;
    color: #5e5f78;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

Title

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid blanditiis dignissimos fuga nobis, nulla, pariatur, quia quisquam reiciendis repellendus tempore vero voluptas voluptate voluptatibus. Alias ducimus impedit nostrum reprehenderit ut!

Title

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda consectetur doloribus ducimus eveniet molestiae? Amet delectus, distinctio harum incidunt, laborum libero minima minus molestias quam repudiandae suscipit ut veniam voluptatum.

Title

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores cumque eligendi expedita id itaque minus modi neque nostrum odio omnis provident quam quas quasi quisquam ratione repellendus, sapiente similique voluptas.

Menu

SubMenu

SubMenu

SubMenu

Menu

Submenu

Submenu

Submenu

Menu

Submenu

Submenu

Menu

Submenu

Submenu

© 2017 Company

                        Plan

Contacts

Blablabla

Blablabla

Blablabla

Blablabla

Thanks


问:
Get the value in an input text box
What are the ways to get and render an input value using jQuery?

Here is one:

$(document).ready(function() {
  $("#txt_name").keyup(function() {
    alert($(this).val());
  });
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<input type="text" id="txt_name" /></code>```

答:
You have to use various ways to get current value of an input element.

METHOD - 1

If you want to use a simple .val(), try this:

```<code><input type="text" id="txt_name" />
</code>```

Get values from Input

```<code>// use to select with DOM element.
$("input").val();

// use the id to select the element.
$("#txt_name").val();

// use type="text" with input to select the element
$("input:text").val();
</code>```

Set value to Input

```<code>// use to add "text content" to the DOM element.
$("input").val("text content");

// use the id to add "text content" to the element.
$("#txt_name").val("text content");

// use type="text" with input to add "text content" to the element
$("input:text").val("text content");
</code>```

METHOD - 2

Use .attr() to get the content.

```<code><input type="text" id="txt_name" value="" />
</code>```

I just add one attribute to the input field. value="" attribute is the one who carry the text content that we entered in input field.

```<code>$("input").attr("value");
</code>```

METHOD - 3

you can use this one directly on your input element.

```<code>$("input").keyup(function(){
    alert(this.value);
});
</code>```

Title: Get the value in an input text box

Body:
What are the ways to get and render an input value using jQuery?

Here is one:

$(document).ready(function() {
  $("#txt_name").keyup(function() {
    alert($(this).val());
  });
})

<input type="text" id="txt_name" />

Body:
You have to use various ways to get current value of an input element.

METHOD - 1

If you want to use a simple .val(), try this:

<input type="text" id="txt_name" />

Get values from Input

// use to select with DOM element.
$("input").val();

// use the id to select the element.
$("#txt_name").val();

// use type="text" with input to select the element
$("input:text").val();

Set value to Input

// use to add "text content" to the DOM element.
$("input").val("text content");

// use the id to add "text content" to the element.
$("#txt_name").val("text content");

// use type="text" with input to add "text content" to the element
$("input:text").val("text content");

METHOD - 2

Use .attr() to get the content.

<input type="text" id="txt_name" value="" />

I just add one attribute to the input field. value="" attribute is the one who carry the text content that we entered in input field.

$("input").attr("value");

METHOD - 3

you can use this one directly on your input element.

$("input").keyup(function(){
    alert(this.value);
});


问:
JSON with MultiValueMap on Java
I Would like to build a JSON like this:

```<code>{
  "Id": "33396",
  "Actions": [
    {
      "Key": "5",
      "Value": "Test"
    },
    {
      "Key": "6",
      "Value": "Test 2"
    }
  ]
}
</code>```

I'm using MultiValueMap and that's my code:

```<code>MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();

map.add("Id","33396");
</code>```

I don't know how to implement the Actions List on my code

I did this and worked but I think it's repetitive

MultiValueMap map = new LinkedMultiValueMap();
MultiValueMap mapActions0 = new LinkedMultiValueMap();
MultiValueMap mapActions1 = new LinkedMultiValueMap();

```<code>    //Id
    map.add("Id","33396");

    //Actions
    mapActions0.add("Key","5");
    mapActions0.add("Value","Test");
    mapActions1.add("Key","6");
    mapActions1.add("Value","Test 2");

    map.put("AcoesVideo",Arrays.asList(mapActions0,mapActions));
</code>```

答:
Use HashMap and use a Map<String, Map<String, String>> do this

```<code>Map<String, Map<String, String>> map = new HashMap<>();
Map<String, String> actions = new HashMap<>();

actions.put("5", "test");
actions.put("6", "test2");

map.put("33396", actions);
</code>```

Title: JSON with MultiValueMap on Java

Body:
I Would like to build a JSON like this:

{
  "Id": "33396",
  "Actions": [
    {
      "Key": "5",
      "Value": "Test"
    },
    {
      "Key": "6",
      "Value": "Test 2"
    }
  ]
}

I'm using MultiValueMap and that's my code:

MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();

map.add("Id","33396");

I don't know how to implement the Actions List on my code

I did this and worked but I think it's repetitive

MultiValueMap map = new LinkedMultiValueMap();
MultiValueMap mapActions0 = new LinkedMultiValueMap();
MultiValueMap mapActions1 = new LinkedMultiValueMap();

    //Id
    map.add("Id","33396");

    //Actions
    mapActions0.add("Key","5");
    mapActions0.add("Value","Test");
    mapActions1.add("Key","6");
    mapActions1.add("Value","Test 2");

    map.put("AcoesVideo",Arrays.asList(mapActions0,mapActions));

Body:
Use HashMap and use a Map<String, Map<String, String>> do this

Map<String, Map<String, String>> map = new HashMap<>();
Map<String, String> actions = new HashMap<>();

actions.put("5", "test");
actions.put("6", "test2");

map.put("33396", actions);