qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
48,425 | Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg\_grep function calls within drupal\_find\_theme\_functions() in theme.inc. This happened on every page load.
It's my understanding that the drupal\_find\_theme\_functions function should only ... | 2012/10/22 | [
"https://drupal.stackexchange.com/questions/48425",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/10862/"
] | Try this code:
```
/**
* Implements hook_preprocess_taxonomy_term().
*/
function YOURTHEME_preprocess_taxonomy_term(&$variables) {
if ($variables->vid == YOUR_VOCABULARY_ID) {
$variables['theme_hook_suggestions'][] = 'taxonomy_term__authors';
}
}
``` | You can use the [Taxonomy Views Integrator](http://drupal.org/project/tvi), or its working [patched version](http://drupal.org/node/1817570).
Navigate to yoursite.com/admin/structure/taxonomy/yourtaxonomyvocabulary/edit
and choose your view and view display for every vocabulary you have. |
48,425 | Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg\_grep function calls within drupal\_find\_theme\_functions() in theme.inc. This happened on every page load.
It's my understanding that the drupal\_find\_theme\_functions function should only ... | 2012/10/22 | [
"https://drupal.stackexchange.com/questions/48425",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/10862/"
] | Try this code:
```
/**
* Implements hook_preprocess_taxonomy_term().
*/
function YOURTHEME_preprocess_taxonomy_term(&$variables) {
if ($variables->vid == YOUR_VOCABULARY_ID) {
$variables['theme_hook_suggestions'][] = 'taxonomy_term__authors';
}
}
``` | Each term has link taxonomy/term/TERM\_ID and if you want vocabulary based theme(customize HTML markup) on terms pages then you can use "Taxonomy Views Integrator" module.
On particular vocabulary edit page you can select views template.
And in that views template you can write customize html so, that pages with taxon... |
48,425 | Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg\_grep function calls within drupal\_find\_theme\_functions() in theme.inc. This happened on every page load.
It's my understanding that the drupal\_find\_theme\_functions function should only ... | 2012/10/22 | [
"https://drupal.stackexchange.com/questions/48425",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/10862/"
] | You can have full control over the taxonomy/term/ID page by intercepting the menu call with hook\_menu\_alter() and let the content be generated by a custom function.
This allows you to completely customize the taxonomy term page. You can check for a certain vocabulary ("Authors") and have a custom generated page for ... | Try this code:
```
/**
* Implements hook_preprocess_taxonomy_term().
*/
function YOURTHEME_preprocess_taxonomy_term(&$variables) {
if ($variables->vid == YOUR_VOCABULARY_ID) {
$variables['theme_hook_suggestions'][] = 'taxonomy_term__authors';
}
}
``` |
48,425 | Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg\_grep function calls within drupal\_find\_theme\_functions() in theme.inc. This happened on every page load.
It's my understanding that the drupal\_find\_theme\_functions function should only ... | 2012/10/22 | [
"https://drupal.stackexchange.com/questions/48425",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/10862/"
] | You can have full control over the taxonomy/term/ID page by intercepting the menu call with hook\_menu\_alter() and let the content be generated by a custom function.
This allows you to completely customize the taxonomy term page. You can check for a certain vocabulary ("Authors") and have a custom generated page for ... | You can use the [Taxonomy Views Integrator](http://drupal.org/project/tvi), or its working [patched version](http://drupal.org/node/1817570).
Navigate to yoursite.com/admin/structure/taxonomy/yourtaxonomyvocabulary/edit
and choose your view and view display for every vocabulary you have. |
48,425 | Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg\_grep function calls within drupal\_find\_theme\_functions() in theme.inc. This happened on every page load.
It's my understanding that the drupal\_find\_theme\_functions function should only ... | 2012/10/22 | [
"https://drupal.stackexchange.com/questions/48425",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/10862/"
] | You can have full control over the taxonomy/term/ID page by intercepting the menu call with hook\_menu\_alter() and let the content be generated by a custom function.
This allows you to completely customize the taxonomy term page. You can check for a certain vocabulary ("Authors") and have a custom generated page for ... | Each term has link taxonomy/term/TERM\_ID and if you want vocabulary based theme(customize HTML markup) on terms pages then you can use "Taxonomy Views Integrator" module.
On particular vocabulary edit page you can select views template.
And in that views template you can write customize html so, that pages with taxon... |
5,882,957 | >
> **Possible Duplicate:**
>
> [Java tree data-structure?](https://stackoverflow.com/questions/3522454/java-tree-data-structure)
>
>
>
Is there any Java data structure implementation similar to tree and graph? | 2011/05/04 | [
"https://Stackoverflow.com/questions/5882957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/236501/"
] | Not in the `java.util` Collections API.
You can use the [DefaultTreeModel](http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/tree/DefaultTreeModel.html) from Swing for trees.
[Jung](http://jung.sourceforge.net/) is a graph framework. | As I [answered for a similar question](https://stackoverflow.com/questions/4978487/why-java-collection-framework-doesnt-contain-tree-and-graph/4979522#4979522), the Java API contains no general API for trees/graphs, since there is no unique set of features needed in every usecase. There are quite some tree/graph-like A... |
61,554,287 | I need to move some text from `demoBoxA` to `demoBoxB`.
The `demoBoxA` parent element has an id selector, but the child element below it has no identifiable selector.
Is it possible to select the text content directly? Then move it into the `demoBoxB` sub-element (the `demoBoxB` sub-element has an id selector)
There... | 2020/05/02 | [
"https://Stackoverflow.com/questions/61554287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You can chain selectors like this:
```
var rows = document.querySelectorAll("#demoBoxA > .row");
```
That will return a list of all rows inside of demoBoxA. If you need more info about chaining selectors, you can read about it [here](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll).
Then,... | You can use html drag api .
Just add `draggable=true` for elements you want to drag and add event listeners for `dragstart` and `dragend`
html
```
<div class="container" id="demoBoxA">
<div class="row " draggable="true">
<div class="col-md-6">Samsung</div>
<div class="col-md-6">Galaxy S10</div>
... |
69,629,358 | I am converting a list to set and back to list. I know that `set(list)` takes O(n) time, but I am converting it back to list in same line `list(set(list))`. Since both these operations take O(n) time, would the time complexity be O(n^2) now?
Logic 1:
```
final = list(set(list1)-set(list2))
```
Logic 2:
```
s = set... | 2021/10/19 | [
"https://Stackoverflow.com/questions/69629358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13878064/"
] | There are normally a few ways to do this, here are some suggestions:
1. Set menu to null when creating the window:
`const mainWin = new BrowserWindow({menu: null});`
2. Remove menu after window object has been created (Set a blank menu with MacOS):
`const { Menu } = require('electron');`
`process.platform === "win3... | You could try this
```js
const { Menu } = require('electron');
Menu.setApplicationMenu(null);
``` |
57,385,570 | To return a big struct "MODULEENTRY32" from WINAPI I want to use a pointer, but need to allocate memory in the heap inside the function without deleting it. Then, out of the function when I don't want to use that struct anymore I know that I should use the keyword delete to free memory.
```
#include <iostream>
#includ... | 2019/08/07 | [
"https://Stackoverflow.com/questions/57385570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The error happens because [control flow analysis is difficult](https://github.com/microsoft/TypeScript/issues/9998), especially when the information you want to keep track of cannot be represented in the type system.
In the general case, the compiler really cannot figure out much about what happens when functions acc... | The Map's `get` method is defined as `Map<string, TestIF>.get(key: string): TestIF | undefined`, so when you set `obj`, it's type is `TestIF | undefined`.
When you (re-set) `obj`'s type inside the `if` block, it's in a different scope. When you read `obj` inside the `forEach`, it's also in another scope. The TypeScrip... |
57,385,570 | To return a big struct "MODULEENTRY32" from WINAPI I want to use a pointer, but need to allocate memory in the heap inside the function without deleting it. Then, out of the function when I don't want to use that struct anymore I know that I should use the keyword delete to free memory.
```
#include <iostream>
#includ... | 2019/08/07 | [
"https://Stackoverflow.com/questions/57385570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The error happens because [control flow analysis is difficult](https://github.com/microsoft/TypeScript/issues/9998), especially when the information you want to keep track of cannot be represented in the type system.
In the general case, the compiler really cannot figure out much about what happens when functions acc... | I was suffering with the same problem now, and the solution to me was (adapted to your case):
```
if (!obj) {
return ( ... );
}
``` |
57,385,570 | To return a big struct "MODULEENTRY32" from WINAPI I want to use a pointer, but need to allocate memory in the heap inside the function without deleting it. Then, out of the function when I don't want to use that struct anymore I know that I should use the keyword delete to free memory.
```
#include <iostream>
#includ... | 2019/08/07 | [
"https://Stackoverflow.com/questions/57385570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The error happens because [control flow analysis is difficult](https://github.com/microsoft/TypeScript/issues/9998), especially when the information you want to keep track of cannot be represented in the type system.
In the general case, the compiler really cannot figure out much about what happens when functions acc... | This happens because the `forEach()` function accepts a callback that can mutate `obj` (i.e. you could do `obj = null;` inside the loop). For this reason Typescript cannot assume that `obj` is not null.
An easy solution is to use a `for...of` loop instead, which doesn't required a callback:
```
for (const v of map2) ... |
57,385,570 | To return a big struct "MODULEENTRY32" from WINAPI I want to use a pointer, but need to allocate memory in the heap inside the function without deleting it. Then, out of the function when I don't want to use that struct anymore I know that I should use the keyword delete to free memory.
```
#include <iostream>
#includ... | 2019/08/07 | [
"https://Stackoverflow.com/questions/57385570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The Map's `get` method is defined as `Map<string, TestIF>.get(key: string): TestIF | undefined`, so when you set `obj`, it's type is `TestIF | undefined`.
When you (re-set) `obj`'s type inside the `if` block, it's in a different scope. When you read `obj` inside the `forEach`, it's also in another scope. The TypeScrip... | I was suffering with the same problem now, and the solution to me was (adapted to your case):
```
if (!obj) {
return ( ... );
}
``` |
57,385,570 | To return a big struct "MODULEENTRY32" from WINAPI I want to use a pointer, but need to allocate memory in the heap inside the function without deleting it. Then, out of the function when I don't want to use that struct anymore I know that I should use the keyword delete to free memory.
```
#include <iostream>
#includ... | 2019/08/07 | [
"https://Stackoverflow.com/questions/57385570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This happens because the `forEach()` function accepts a callback that can mutate `obj` (i.e. you could do `obj = null;` inside the loop). For this reason Typescript cannot assume that `obj` is not null.
An easy solution is to use a `for...of` loop instead, which doesn't required a callback:
```
for (const v of map2) ... | I was suffering with the same problem now, and the solution to me was (adapted to your case):
```
if (!obj) {
return ( ... );
}
``` |
29,899,818 | I have a table like this in SQL Server 2008:
```
create table test (id int, array varchar(max))
insert into test values (1,',a,b,c,d')
insert into test values (2,',a,b,c,d,e')
insert into test values (3,',a,b,c')
```
I want to count the number of elements of the array column with the result being the following:
```... | 2015/04/27 | [
"https://Stackoverflow.com/questions/29899818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1794925/"
] | By far the best option would be to stop storing array in your database. This violates 1NF and it a poor design decision.
You can however get the results you are looking for with a simple replace.
```
select ID
, LEN(array) - LEN(replace(array, ',', ''))
from test
``` | You can calc difference in length:
```
select id, len(array) - len(replace(array, ',', ''))
from test
``` |
31,069,933 | I've been researching all around the web the most efficient way to design a connection pool and tried to analyze into details the available libraries (HikariCP, BoneCP, etc.).
Our application is a heavy-load consumer webapp and most of the time the users are working on similar business objects (thus the underlying SQL... | 2015/06/26 | [
"https://Stackoverflow.com/questions/31069933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1434561/"
] | For your scheme to work, you'd need to be able to get the connection that already has that statement prepared.
This falls foul on two points:
1. In JDBC you obtain the connection first,
2. Cached prepared statements (if a driver or connection pool even supports that) aren't exposed in a standardized way (if at all) n... | A solution could be for a connection pool implementation to delay retrieving the connection from the pool until the Connection.prepareStatement() is called. At that time a connection pool would look up available connections by the SQL statement text and then play forward all the calls made before Connection.prepareStat... |
129,245 | By giving an Huffman coding tree and the total frequency of the characters. how can I find the most unoptimal frequencies for each character such that the size of the code will require the most possible of bits? | 2020/08/13 | [
"https://cs.stackexchange.com/questions/129245",
"https://cs.stackexchange.com",
"https://cs.stackexchange.com/users/125438/"
] | There are several definitions of "unoptimal".
As vonbrand noted, Huffman coding falls back to binary encoding if all frequencies are equal.
For longest code length, this happens if the frequencies are Fibonacci numbers.
For worst compression rate compared to the entropy, this happens with an alphabet of two symbols ... | All frequencies the same. Thus there is no space for compression. |
69,151,309 | I have this block of code:
```
public class LinearFunction implements Function<Double, Double> {
private final double slope;
private final double yIntercept;
private final double xIntercept;
public LinearFunction(double m, double b) {
this.slope = m;
this.yIntercept = b;
this.x... | 2021/09/12 | [
"https://Stackoverflow.com/questions/69151309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15924233/"
] | IntelliJ is complaining that you don't copy the value from one `LinearFunction` instance to the other. It's analysis is apparently not thorough enough to understand that this member is computed directly from the two other members, and can never change afterward (because it's `final`).
You could copy it directly to app... | In this case, you can ignore the warning message because it is a "false alarm".
If you want the compiler to stop producing the warning, annotate the method with `@SuppressWarnings("CopyConstructorMissesField")`:
```
@SuppressWarnings("CopyConstructorMissesField")
public LinearFunction(LinearFunction f) {
... |
35,730,637 | I'm writing unit tests for a project the requires some fairly complex json objects. They have become too verbose to plug into the spec file and I'd like to import local json files into my tests. I've tried a number of solutions that don't really work for this project:
[Loading a mock JSON file within Karma+AngularJS te... | 2016/03/01 | [
"https://Stackoverflow.com/questions/35730637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5241159/"
] | I think the best way for testing in your case is to use [$httpBackend](https://docs.angularjs.org/api/ngMock/service/$httpBackend). It allows to use your `$resource` or `$http` and provide them with test data.
And if you have to deal with large `json` objects you can define them in separate js files (in functions), in... | ```
path = basepath;
var json = fixture.load(path + '/login-response.json');
```
Use fixture. In plugin section, add 'karma-fixture' package and add in karma.conf.js
```
jsonFixturesPreprocessor: {
variableName: '__json__'
}
``` |
2,614,677 | I want implement in my software solution an VBA editor but in c# 3.0.
VBA edtior (vb 6.5) is obsolete. Microsoft have a solution for create macros and scripts editor for .net? if not how to implement a like solution? | 2010/04/10 | [
"https://Stackoverflow.com/questions/2614677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/127891/"
] | You are probably looking for VSTA, [Visual Studio Tools for Applications](http://msdn.microsoft.com/en-us/vstudio/aa700828.aspx), which provides an IDE for .NET languages that can be integrated with your application similar to the VBA IDE. | <http://msdn.microsoft.com/en-us/vstudio/aa700828.aspx>
<http://www.winwrap.com/web/basic/default.asp> |
4,564,951 | I have an arraylist with few duplicate items. I need to know the count of each duplicated item. I am using 2.0 so cannot use linq.
I had posted a similar question earlier, but my question was not clear.
Thanks
Prady | 2010/12/30 | [
"https://Stackoverflow.com/questions/4564951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/193247/"
] | I've done something in the past. My solution was to loop through the ArrayList and store the counts in a dictionary. Then loop though the dictionary to display the results:
```
ArrayList list = new ArrayList();
list.Add(1);
list.Add("test");
list.Add("test");
list.Add("test");
... | **Option 1**: Sort the list and then count adjacently Equal items (requires you to override the Equals method for your class)
**Option 2**: Use your unique identifier (however you're defining two objects to be equal) as the key for a Dictionary and add each of your objects to that entry. |
4,564,951 | I have an arraylist with few duplicate items. I need to know the count of each duplicated item. I am using 2.0 so cannot use linq.
I had posted a similar question earlier, but my question was not clear.
Thanks
Prady | 2010/12/30 | [
"https://Stackoverflow.com/questions/4564951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/193247/"
] | I've done something in the past. My solution was to loop through the ArrayList and store the counts in a dictionary. Then loop though the dictionary to display the results:
```
ArrayList list = new ArrayList();
list.Add(1);
list.Add("test");
list.Add("test");
list.Add("test");
... | i needed something similar for a project a long time ago, and made a function for it
```
static Dictionary<object, int> GetDuplicates(ArrayList list, out ArrayList uniqueList)
{
uniqueList = new ArrayList();
Dictionary<object, int> dups = new Dictionary<object, int>();
foreach (object o... |
2,132,369 | I have an array:
```
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
'key4' => 'value4',
'key5' => 'value5',
);
```
and I would like to get a part of it with specified keys - for example `key2, key4, key5`.
Expected result:
```
$result = array(
'key2' => 'value2',
'key4' =... | 2010/01/25 | [
"https://Stackoverflow.com/questions/2132369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223386/"
] | You need [`array_intersect_key`](http://www.php.net/manual/en/function.array-intersect-key.php) function:
```
$result = array_intersect_key($array, array('key2'=>1, 'key4'=>1, 'key5'=>1));
```
Also [`array_flip`](http://www.php.net/manual/en/function.array-flip.php) can help if your keys are in array as values:
```... | Only way I see is to iterate the array and construct a new one.
Either walk the array with array\_walk and construct the new one or construct a matching array and use array\_intersect\_key et al. |
2,132,369 | I have an array:
```
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
'key4' => 'value4',
'key5' => 'value5',
);
```
and I would like to get a part of it with specified keys - for example `key2, key4, key5`.
Expected result:
```
$result = array(
'key2' => 'value2',
'key4' =... | 2010/01/25 | [
"https://Stackoverflow.com/questions/2132369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223386/"
] | You need [`array_intersect_key`](http://www.php.net/manual/en/function.array-intersect-key.php) function:
```
$result = array_intersect_key($array, array('key2'=>1, 'key4'=>1, 'key5'=>1));
```
Also [`array_flip`](http://www.php.net/manual/en/function.array-flip.php) can help if your keys are in array as values:
```... | You can use [`array_intersect_key`](http://php.net/array_intersect_key) and [`array_fill_keys`](http://php.net/array_fill_keys) to do so:
```
$keys = array('key2', 'key4', 'key5');
$result = array_intersect_key($array, array_fill_keys($keys, null));
```
[`array_flip`](http://php.net/array_flip) instead of `array_fil... |
2,132,369 | I have an array:
```
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
'key4' => 'value4',
'key5' => 'value5',
);
```
and I would like to get a part of it with specified keys - for example `key2, key4, key5`.
Expected result:
```
$result = array(
'key2' => 'value2',
'key4' =... | 2010/01/25 | [
"https://Stackoverflow.com/questions/2132369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223386/"
] | You can use [`array_intersect_key`](http://php.net/array_intersect_key) and [`array_fill_keys`](http://php.net/array_fill_keys) to do so:
```
$keys = array('key2', 'key4', 'key5');
$result = array_intersect_key($array, array_fill_keys($keys, null));
```
[`array_flip`](http://php.net/array_flip) instead of `array_fil... | Only way I see is to iterate the array and construct a new one.
Either walk the array with array\_walk and construct the new one or construct a matching array and use array\_intersect\_key et al. |
44,083,492 | I've written an android app that requires users to register online. Is there a way to ensure incoming JSON registration data originated from my app? Thanks. | 2017/05/20 | [
"https://Stackoverflow.com/questions/44083492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6114016/"
] | >
> Is there a way to ensure incoming JSON registration data originated from my app?
>
>
>
Well, `Yes` and `No` :)
`Yes`
=====
When you expose API to the internet, you usually do not want anyone to talk to it. Therefore first wall most APIs use is client token that you may show you hold while using API calls. So... | You can generate a random hash and/or a validator/verification hash (e.g. like a public key)
The easiest form:
Your app stores the hash, including an expiration time, eg a few minutes.
Send the verification hash to the user to be added with the registration.
So only your app can generate the tokens.
e.g:
```
$tok... |
44,083,492 | I've written an android app that requires users to register online. Is there a way to ensure incoming JSON registration data originated from my app? Thanks. | 2017/05/20 | [
"https://Stackoverflow.com/questions/44083492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6114016/"
] | >
> Is there a way to ensure incoming JSON registration data originated from my app?
>
>
>
Well, `Yes` and `No` :)
`Yes`
=====
When you expose API to the internet, you usually do not want anyone to talk to it. Therefore first wall most APIs use is client token that you may show you hold while using API calls. So... | Write this **Auth** function in your api controller.
```
protected function Auth($id,$token){
if(!empty($id) and !empty($token)){
$user = DB::table('users')->where('id',$id)
->where('token',$token)->count();
if($user == 1){
return true;
}else{
return false;
}
}else{
ret... |
33,015,935 | I'm trying to use **DynamicComponentLoader** and the sample code is below:
```
import {Component, View, bootstrap, OnInit, DynamicComponentLoader} from 'angular2';
...
DynamicComponentLoader.loadIntoLocation(PersonsComponent, itemElement);
```
When I run the app, I get the error:
>
> DynamicComponentLoader.load... | 2015/10/08 | [
"https://Stackoverflow.com/questions/33015935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768008/"
] | `DynamicComponentLoader` is **class**. It doesn't have any static method `loadIntoLocation`. But instances of this class have it. You must instantiate `DynamicComponentLoader` using dependency injection:
```
import { Component, View, DynamicComponentLoader, ElementRef } from 'angular2/angular2'
@Component({
selecto... | `DynamicComponentLoader` is long gone.
<https://angular.io/guide/dynamic-component-loader> explains how it's done in newer Angular version.
>
>
> ```
> loadComponent() {
> this.currentAddIndex = (this.currentAddIndex + 1) % this.ads.length;
> let adItem = this.ads[this.currentAddIndex];
>
> let compo... |
45,857,019 | I have abstract class-factory `Factory` with factory-method `getProduct()` and his child classes.
I have abstract class-product `Product` and his child classes.
Classes-factories created objects of classes-products.
```
abstract class Factory {
abstract function getProduct();
}
class FirstFactory extends Factory... | 2017/08/24 | [
"https://Stackoverflow.com/questions/45857019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8510521/"
] | If you know at compile time that `firstProduct` is always of type `FirstProduct` and `secondProduct` is always of type `SecondProduct` then there is no need for an factory method.
A factory method is only useful if you want to create a product that might be `FirstProduct` or might be `SecondProduct` depending on the r... | a Factory can be injected instead of the actual class. Suppose you have a class that can be instantiated only at runtime based on some specific conditions, in this case you cannot do new Foo(...args) .
One option is to inject FooFactory instead and have it create the Foo instance for you. |
45,857,019 | I have abstract class-factory `Factory` with factory-method `getProduct()` and his child classes.
I have abstract class-product `Product` and his child classes.
Classes-factories created objects of classes-products.
```
abstract class Factory {
abstract function getProduct();
}
class FirstFactory extends Factory... | 2017/08/24 | [
"https://Stackoverflow.com/questions/45857019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8510521/"
] | It's important to note that the Factory Pattern is not always the best solution and for simple case, it is even better having simple `new`. For instance, your example would probably be better without Factory.
Factory Pattern takes all its power when you don't need to work on the exact implementation of a class but stay... | If you know at compile time that `firstProduct` is always of type `FirstProduct` and `secondProduct` is always of type `SecondProduct` then there is no need for an factory method.
A factory method is only useful if you want to create a product that might be `FirstProduct` or might be `SecondProduct` depending on the r... |
45,857,019 | I have abstract class-factory `Factory` with factory-method `getProduct()` and his child classes.
I have abstract class-product `Product` and his child classes.
Classes-factories created objects of classes-products.
```
abstract class Factory {
abstract function getProduct();
}
class FirstFactory extends Factory... | 2017/08/24 | [
"https://Stackoverflow.com/questions/45857019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8510521/"
] | It's important to note that the Factory Pattern is not always the best solution and for simple case, it is even better having simple `new`. For instance, your example would probably be better without Factory.
Factory Pattern takes all its power when you don't need to work on the exact implementation of a class but stay... | a Factory can be injected instead of the actual class. Suppose you have a class that can be instantiated only at runtime based on some specific conditions, in this case you cannot do new Foo(...args) .
One option is to inject FooFactory instead and have it create the Foo instance for you. |
325,743 | What I did
----------
Aura Component
```
<aura:component>
<lightning:flow aura:id="flowData"/>
</aura:component>
```
Controller
```
({
init: function (component, event, helper) {
console.log('Hello world from Component');
var flow = cmp.find("flowData");
flow.startFlow("Self_Registr... | 2020/11/07 | [
"https://salesforce.stackexchange.com/questions/325743",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/60493/"
] | There is no **init handler** in the component code.
```
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
``` | Have you ensured that the site guest user for your community endpoint has the right permissions to run the flow? There might be no errors starting the Lightning-out container but the guest user may be running into an issue accessing the flow. More details about site guest users and flow access can be found [here](https... |
36,558,810 | I have tried every way possible, but I am still not able to logout the current user.
Currently I have the following code:
```
_authenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
string sKey = (string)HttpContext.Current.Session["user"];
string sUser = Convert.ToString(HttpCon... | 2016/04/11 | [
"https://Stackoverflow.com/questions/36558810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3647304/"
] | Your syntax is wrong, because only the first statement in a `for` preamble is the declaration part — you've attempted to use two statements for that job.
However, you *can* declare multiple variables in a single statement, which is what you presumably intended to do:
```
for (int i = 0, n = 10; n < NAX; i++, n++)
// ... | ```
void reformat(double input[], double newarray[], int MAX)
{
for(int i=0; int n=10; n<MAX; i++, n++)
{
newarray[n] = input[i]*2;
}
for(i=0; n=11; n<MAX; i++, n++)
{
newarray[i] = pow(input[n], 0.3);
}
return;
}
```
When you declare a variable in a **for** block as you have done here with the varia... |
36,558,810 | I have tried every way possible, but I am still not able to logout the current user.
Currently I have the following code:
```
_authenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
string sKey = (string)HttpContext.Current.Session["user"];
string sUser = Convert.ToString(HttpCon... | 2016/04/11 | [
"https://Stackoverflow.com/questions/36558810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3647304/"
] | Your syntax is wrong, because only the first statement in a `for` preamble is the declaration part — you've attempted to use two statements for that job.
However, you *can* declare multiple variables in a single statement, which is what you presumably intended to do:
```
for (int i = 0, n = 10; n < NAX; i++, n++)
// ... | You've got couple of problems with the use of variables in the `for` loops in `reformat`.
```
for(int i=0; int n=10; n<MAX; i++, n++)
```
is not right. A `for` loop cannot have four clauses. You need to use:
```
for(int i=0, n=10; n<MAX; i++, n++)
```
The second problem is that the above declaration makes `i` and... |
4,475 | On the main site, this
```
<!-- language: lang-shell -->
# do these steps on each distro
mv Documents Documents.old
ln -s /shared/your-user/Documents Documents
mv -i Documents.old/* Documents/
rmdir Documents.old
```
produced rather silly syntax highlighting (screenshot, since I can't get *any* ... | 2017/05/15 | [
"https://unix.meta.stackexchange.com/questions/4475",
"https://unix.meta.stackexchange.com",
"https://unix.meta.stackexchange.com/users/977/"
] | You either need to specify a tag name, or a language prefixed with `lang-`. There is no registered language named `shell`, so `lang-shell` kicks it into a default mode the same as if you'd done `lang-foobarbaz`, and apparently in that mode it looks for C-style comments.
If you do `<!-- language: lang-sh -->`, or `<!--... | You didn't notice (or at least didn't mention)
that the last word of the fourth line, and the entire fifth line,
are colored gray as comments.
That is almost surely because, right in the middle of the fourth line,
you have `/*`, so everything up through a matching `*/` is a comment.
I find `lang-sh` formatting to be ... |
185,932 | I have a used iPhone 4 with 16GB of memory in it, running IOS 7.1.2. The problem with this iPhone is that the volume is really quiet whenever i'm playing music or making a call and setting the caller on the speaker.
The volume is currently at it's max (by tapping the buttons on the side).
![enter image description he... | 2015/05/06 | [
"https://apple.stackexchange.com/questions/185932",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/126759/"
] | The general answer is
>
> "just be sure to paste into an unoccupied area of the Keynote slide"
>
>
>
My issue was that I was trying to paste into an area already occupied by a textbox. It may not be obvious due to a bunch of blank lines that make the box extend longer than immediately apparent. | Be sure you are on the slide by clicking into it. The universal keyboard Command + V should pass your image. If that doesn't work then be sure you actually **have** something copied to the clipboard.
Alternatively you can easily drag and drop an image onto a slide. |
24,862 | What are the new features/updates are available in Selenium 3 as compared with Selenium-2.0?
What are the impacts of using Selenium 3.0? What are the recent errors which were found in Selenium 3.0? You can share Pros and Cons/your experience with the use of Selenium 3.0. | 2017/01/12 | [
"https://sqa.stackexchange.com/questions/24862",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/17411/"
] | Good question, everyone should aware of the new updates and features in Selenium 3.
As of my experience Selenium 3 has lots changes made in configuration/setup level. Even though we have to use GekoDriver for launching Firefox driver. There is also some browser compatibility restrictions are applied in Selenium 3 like... | Moving `Selenium 2` to `selenium 3.0.1` is bit easy take less effort
[Code Changes](http://seleniumsimplified.com/2016/10/upgrading-to-selenium-3-with-my-first-selenium-project/)
One of the biggest change is that the old Selenium Core libraries will be dropped in 3.0. The focus will shift completely to the WebDriver... |
4,519,875 | So far I have it down to
\begin{align}
\sqrt{x+iy}&=u+iv \\
\Rightarrow x+iy&=u^2-v^2+i(2uv) \\
\Rightarrow x&=u^2-v^2, y=2uv
\end{align}
But I keep getting stuck here. | 2022/08/27 | [
"https://math.stackexchange.com/questions/4519875",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/620355/"
] | You have arrived at $x = u^2-v^2$ and $y = 2uv$. Now use the second relation to eliminate either $u$ or $v$ from the first relation, and you obtain expressions for $u$ or $v$ in terms of $x$ and $y$.
From $4u^4-4xu^2-y^2=0$ we get: $u^2 = 0.5(x+\sqrt{x^2+y^2})$
From $4v^4+4xv^2-y^2=0$ we get: $v^2 = 0.5(-x+\sqrt{x^2+... | You are almost done, following your way we obtain, with $u\neq 0$
$$2uv=y \implies v = \frac y {2u}$$
and then from the first equation
$$x=u^2-\left(\frac y {2u}\right)^2 \implies 4u^4-4u^2x-y^2=0 \implies u^2=\frac{x\pm\sqrt{x^2+y^2}}{2}$$
and then by $r=\sqrt{x^2+y^2}$
$$u=\pm \sqrt\frac{x+r}{2},\; v= \pm \frac ... |
155,732 | I have this table :
[](https://i.stack.imgur.com/0zqIF.png)
column **F** is my data and column **H** is to check if column **F** has **N/A** error. In **H1** i use this formula :
```
ifna(F1,"error")
```
Seems to work fine. But in the 2nd row when... | 2021/07/11 | [
"https://webapps.stackexchange.com/questions/155732",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/229140/"
] | Use [filter views](https://support.google.com/docs/answer/3540681) to let view-only users sort the sheet. This feature lets multiple simultaneous users sort and filter the sheet without disturbing each other.
For additional ease of use, insert links in the frozen section of the sheet to easily switch between filter vi... | In case you cannot find a solution using formulas I will give a solution using the following code:
```
function onEdit(e) {
const as = e.source.getActiveSheet();
const row = e.range.getRow();
const col = e.range.getColumn();
const lc = as.getLastColumn();
const lr = as.getLastRow();
const rg = as.getRang... |
28,614,371 | On a table, there's a delete trigger that performs some operations and then at the end, executes a select statement, so when you do something like...
```
delete from mytable where id=1
```
it returns a recordset.
Is there a way to save the results of that recordset into a temp table or something? I tried something ... | 2015/02/19 | [
"https://Stackoverflow.com/questions/28614371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3093863/"
] | You are amost there. *And I am not challenging or judging this approach, just providing the answer.* There is [a working example](http://plnkr.co/edit/DNas7u8e8NuJMP2n0RUe?p=preview) .
You've properly created new scope. Very good. But that is just an **A**. The essential and curcial **B** is missing. **B** - is opposi... | Why do you make it so complicated? Is there a special reason why you are using
```
if(view == 'Alerts'){
view = '<div ui-view="Alerts"></div>';
state = 'appHome'
}
else{
view = '<div ui-view="Other"></div>';
state = 'appOther'
}
$('#test').html($compile(view)(scope));
$state.go(state);
```
Isn't it... |
3,578,286 | My code base has a lot of `#if DEBUG/#endif` statements that mostly have assertion type logic that I'm not brave enough to run in production.
```
[Conditional("DEBUG")]
public void CheckFontSizeMath()
{
//This check must not block SellSnakeOil() in production, even if it fails.
if(perferredSize+increment!=incremen... | 2010/08/26 | [
"https://Stackoverflow.com/questions/3578286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] | There's no problem doing this. The more current approach is to use [Code Contracts](http://msdn.microsoft.com/en-us/library/dd264808.aspx). | Other options that you have is to either use Code Contracts as suggested by Hans or to use the assertion methods in the `System.Diagnostics.Debug` namespace, e.g.
```
Debug.Assert(1 + 1 == 2, "Math went wrong!");
```
This check is automatically removed when building the Release version. |
3,578,286 | My code base has a lot of `#if DEBUG/#endif` statements that mostly have assertion type logic that I'm not brave enough to run in production.
```
[Conditional("DEBUG")]
public void CheckFontSizeMath()
{
//This check must not block SellSnakeOil() in production, even if it fails.
if(perferredSize+increment!=incremen... | 2010/08/26 | [
"https://Stackoverflow.com/questions/3578286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] | There's no problem doing this. The more current approach is to use [Code Contracts](http://msdn.microsoft.com/en-us/library/dd264808.aspx). | The downsides:
1. It's not as robust as hard checks and exceptions that function independently of build configuration. It's a good idea to take into account the fact that most code should handle errors in release mode.
2. Behaviour has the potential to differ between configurations. If you're careless, you may end up ... |
3,578,286 | My code base has a lot of `#if DEBUG/#endif` statements that mostly have assertion type logic that I'm not brave enough to run in production.
```
[Conditional("DEBUG")]
public void CheckFontSizeMath()
{
//This check must not block SellSnakeOil() in production, even if it fails.
if(perferredSize+increment!=incremen... | 2010/08/26 | [
"https://Stackoverflow.com/questions/3578286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] | Write tests! Then you don't have to be afraid that your code is doing something that you don't expect when you start making these changes.
Once you get your code under test you can refactor to your heart's content.
Code without tests, even written yesterday, is legacy code...
Get a copy of [Working Effectively with L... | Other options that you have is to either use Code Contracts as suggested by Hans or to use the assertion methods in the `System.Diagnostics.Debug` namespace, e.g.
```
Debug.Assert(1 + 1 == 2, "Math went wrong!");
```
This check is automatically removed when building the Release version. |
3,578,286 | My code base has a lot of `#if DEBUG/#endif` statements that mostly have assertion type logic that I'm not brave enough to run in production.
```
[Conditional("DEBUG")]
public void CheckFontSizeMath()
{
//This check must not block SellSnakeOil() in production, even if it fails.
if(perferredSize+increment!=incremen... | 2010/08/26 | [
"https://Stackoverflow.com/questions/3578286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] | Write tests! Then you don't have to be afraid that your code is doing something that you don't expect when you start making these changes.
Once you get your code under test you can refactor to your heart's content.
Code without tests, even written yesterday, is legacy code...
Get a copy of [Working Effectively with L... | The downsides:
1. It's not as robust as hard checks and exceptions that function independently of build configuration. It's a good idea to take into account the fact that most code should handle errors in release mode.
2. Behaviour has the potential to differ between configurations. If you're careless, you may end up ... |
12,748,113 | Please help me understand, the below code is showing Type mismatch: "cannot convert from element type Object to List" in the for statement. I know I'm missing something silly. Please help.
```
public void setMapPriceValue(SolrItemVO solrItemVO, ArrayList proce1) throws SolrDAOException
{
List xcatentAttrList = (Li... | 2012/10/05 | [
"https://Stackoverflow.com/questions/12748113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1228270/"
] | First you are mixing generics and raw types - it would make your life easier if you only used generics:
```
List<Xcatentattr> xcatentAttrList = (List<Xcatentattr>) proce1.get(0);
```
You might also consider using the correct generic type in your method signature (I assume `proce1` is a list of list):
```
public voi... | There are two issues here.
* First, if you declare `List xcatentAttrList` without using generics, Java can only know that your list contains `Object`s. So your `for` loop would have to iterate through a list of `Object`s.
* Second, the cast `(List<Xcatentattr>)proce1` implies the list contains `Xcatentattr` elements, ... |
12,748,113 | Please help me understand, the below code is showing Type mismatch: "cannot convert from element type Object to List" in the for statement. I know I'm missing something silly. Please help.
```
public void setMapPriceValue(SolrItemVO solrItemVO, ArrayList proce1) throws SolrDAOException
{
List xcatentAttrList = (Li... | 2012/10/05 | [
"https://Stackoverflow.com/questions/12748113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1228270/"
] | If you are going to type things try and keep them typed
```
List<Xcatentattr> xcatentAttrList = (List<Xcatentattr>) proce1.get(0);
solrItemVO.setMapPrice(-1); // setting default value
for(Xcatentattr xcatentattr : xcatentAttrList){
if(xcatentattr.get(0) == 33)
solrItemVO.setMapPrice(xcatentattr.ge... | There are two issues here.
* First, if you declare `List xcatentAttrList` without using generics, Java can only know that your list contains `Object`s. So your `for` loop would have to iterate through a list of `Object`s.
* Second, the cast `(List<Xcatentattr>)proce1` implies the list contains `Xcatentattr` elements, ... |
93,364 | I'm studying for my AIRAT (Instructor Written) in Canada using Nizus, but I've always had trouble answering the questions about takeoff distances at 27 ºC when given [a chart](https://i.imgur.com/9HnYWR3.png) with 20 ºC and 30 ºC, even since the start of PPL. I want to understand it properly so I can effectively teach ... | 2022/05/28 | [
"https://aviation.stackexchange.com/questions/93364",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/63711/"
] | I am getting a takeoff distance of 3,502' for a takeoff over 50 FT on a **grass strip** with a **10-kt tailwind**.
>
> 2,030' \* 1.5 \* 1.15 = 3,502'
>
>
>
To interpolate you will need to figure out the percentage between the two temperatures.
>
> (27-20) / (30-20) = 70%
>
>
>
We take the difference between... | Pressure altitude with Kollsman at 30.92 would be 3000 feet - 1000 feet = 2000 feet. Dry grass **only affects ground roll**.
Distance to clear 50' obstacle at 30 C : 2030 feet
Ground roll distance: 1155 feet
30 C with 10 knot tailwind: 2030 × 1.50 = 3045 feet
Ground roll with tailwind: 1155 × 1.5 = 1732 feet
Groun... |
36,792,073 | I've got 3 labels in a custom UITableview cell and I'm trying to pass in json data I've gotten from an api with Alamofire but I'm struggling to understand how to push the returned json into the tableview. Any help would be greatly appreciated.
Code below:
```
import UIKit
import Parse
import Alamofire
class LeagueTab... | 2016/04/22 | [
"https://Stackoverflow.com/questions/36792073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5463857/"
] | Since the question is very broad and doesn't specify what exactly is the problem here, The general steps are:
1) map your json to dictionary/nsdictionary. Suppose the JSON snippet you posted is a chunk of JSONArray in following format [{}], all you need to do is:
```
var arrayOfDictionaries:NSArray = NSJSONSerializat... | You'll need to create a subclass of `UITableViewCell`, say `MyTableViewCell` and add a property named `JSON`.
Now, since you're probably using Interface Builder to define your cell and its reuse identifier ("Cell"), set that cell's class to your newly created `MyTableViewCell` and connect the labels to some `IBOutlets... |
36,792,073 | I've got 3 labels in a custom UITableview cell and I'm trying to pass in json data I've gotten from an api with Alamofire but I'm struggling to understand how to push the returned json into the tableview. Any help would be greatly appreciated.
Code below:
```
import UIKit
import Parse
import Alamofire
class LeagueTab... | 2016/04/22 | [
"https://Stackoverflow.com/questions/36792073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5463857/"
] | Since the question is very broad and doesn't specify what exactly is the problem here, The general steps are:
1) map your json to dictionary/nsdictionary. Suppose the JSON snippet you posted is a chunk of JSONArray in following format [{}], all you need to do is:
```
var arrayOfDictionaries:NSArray = NSJSONSerializat... | First, you should create a model that contain 3 properties that you want to save, like:
```
class Data {
var team = ""
var point = 0
var teamText = ""
init(fromJSON json: NSDictionary) {
team = json["team"] as! String
point = json["points"] as! Int
teamText = json["team/_te... |
3,098,231 | The question is from [here](http://web.evanchen.cc/handouts/FuncEq-Intro/FuncEq-Intro.pdf):
>
> Find all continuous functions $f:\mathbb R\to \mathbb R$ such that for any real $x$ and $y$,
> $$f(f(x+y))=f(x)+f(y).$$
>
>
>
I'm totally new to functional equations so please correct me if I make a mistake.
I try p... | 2019/02/03 | [
"https://math.stackexchange.com/questions/3098231",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/432780/"
] | This is not correct. You can not let $u=f(x)$ since you haven't prove that $f(x)$ is surjective.
Here is a hint: use $f(f(x))=f(x)+f(0)$ to change the LHS or the original functional equation so you have $f(x+y)+f(0)=f(x)+f(y)$. This really looks like Cauchy's functional equation. Can you keep going? | All such functions are of the form $$f(x) = \lambda x + c ,\ x\in \Bbb R$$ where $c = f(0), \lambda = f(1)-f(0)$ and where either $\lambda = c = 0$ or $\lambda = 1$. So either $$f(x) = 0,\ \text {for all}\ x \in \Bbb R$$ or $$f(x) = x + c,\ \text {for all}\ x \in \Bbb R.$$
**EDIT** $:$
First observe that $$f(x+y) + ... |
23,176,076 | I'm working with a logit regression and created a model that predicts the likelihood of getting a loan based on FICO Score and the amount requested. I created a data frame that has the results of my probability function -- the rows are the potential FICO Scores, and the columns are the potential requested loan values. ... | 2014/04/19 | [
"https://Stackoverflow.com/questions/23176076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2516989/"
] | If I understand what you want to do, I think a heatmap might work better. There's more than one way to do that in R. `ggplot2`'s `geom_tile` provides a pretty nice way to do it provided you reshape the data first:
```
# using http://www.free-ocr.com/ to OCR your image gives:
dat <- structure(list(FICO = c(640L, 650L, ... | The `lattice` package is nice for plots like the one you want. Here's an example with some fake data
```
> z <- as.logical(sample(TRUE:FALSE, 10, TRUE))
> d <- data.frame(x = 1:10, y = 101:110, z)
> d
## x y z
## 1 1 101 FALSE
## 2 2 102 FALSE
## 3 3 103 FALSE
## 4 4 104 TRUE
## 5 5 105 FALSE
## 6... |
23,176,076 | I'm working with a logit regression and created a model that predicts the likelihood of getting a loan based on FICO Score and the amount requested. I created a data frame that has the results of my probability function -- the rows are the potential FICO Scores, and the columns are the potential requested loan values. ... | 2014/04/19 | [
"https://Stackoverflow.com/questions/23176076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2516989/"
] | If I understand what you want to do, I think a heatmap might work better. There's more than one way to do that in R. `ggplot2`'s `geom_tile` provides a pretty nice way to do it provided you reshape the data first:
```
# using http://www.free-ocr.com/ to OCR your image gives:
dat <- structure(list(FICO = c(640L, 650L, ... | You can do this with the `ggplot2` as well.
A sample of some FICO data:
```
fico <- structure(list(LoanValue = c(20000, 19200, 35000, 9975, 12000, 6000, 10000, 33450, 14675, 7000, 2000, 10625, 27975, 34950, 9600, 24975, 10000, 13900.25, 10000, 5175, 21975, 30000, 6500, 17400, 4000, 7200, 8000, 8000, 3000, 14500, 2385... |
16,179,700 | I have an xml file, saml.config that contains some saml info. That information needs to get transformed in release builds to include production urls instead of development and staging urls. In my development and staging environments the transformation happens perfectly, in the release environment, the transformation do... | 2013/04/23 | [
"https://Stackoverflow.com/questions/16179700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257975/"
] | We have just rolled out the solution (using the newest transformation assemblies as you point out) for this issue and updated <http://webconfigtransformationtester.apphb.com/> accordingly. Your transformations should be applied as expected now.
Thank you for your thorough investigation of this issue. | Come to find out, the answer to my original question as to way the transformation is not taking place, is because the xmlns attribute in the root node of the config file.
Unfortunately, the <http://webconfigtransformationtester.apphb.com/> does not give you any kind of information about why the transformation did not ... |
923,561 | How can I use YUI to locate a text input by name and insert a div after it?
For example, this doesn't work:
```
<input name="some_name" type="text">
<script>
var el = new YAHOO.util.Element(document.createElement('div'));
var some_element = document.getElementsByName('some_name');
// doesn't work .... replacing 'so... | 2009/05/28 | [
"https://Stackoverflow.com/questions/923561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32242/"
] | As mentioned, document.getElementsByName returns an array. You may want to give your input an ID with the same name as the name attribute. (Aside: This is common and good practice for forms. Other js libraries provide helpful extensions when you do this.)
```
<input name="some_name" id="some_name" type="text">
<script... | document.getElementsByName('some\_name') always return a collection (an Array), if you are sure that the name is unique you can safely write this.
```
var some_element = document.getElementsByName('some_name')[0];
``` |
923,561 | How can I use YUI to locate a text input by name and insert a div after it?
For example, this doesn't work:
```
<input name="some_name" type="text">
<script>
var el = new YAHOO.util.Element(document.createElement('div'));
var some_element = document.getElementsByName('some_name');
// doesn't work .... replacing 'so... | 2009/05/28 | [
"https://Stackoverflow.com/questions/923561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32242/"
] | document.getElementsByName('some\_name') always return a collection (an Array), if you are sure that the name is unique you can safely write this.
```
var some_element = document.getElementsByName('some_name')[0];
``` | With YUI 3 you can now do [this](https://stackoverflow.com/a/21319966/274502):
```html
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script>
<input id="some_id" type="text">
<script>
YUI().use('node', function(Y) {
var contentNode = Y.Node.create('<p>');
contentNode.setHTML('Thi... |
923,561 | How can I use YUI to locate a text input by name and insert a div after it?
For example, this doesn't work:
```
<input name="some_name" type="text">
<script>
var el = new YAHOO.util.Element(document.createElement('div'));
var some_element = document.getElementsByName('some_name');
// doesn't work .... replacing 'so... | 2009/05/28 | [
"https://Stackoverflow.com/questions/923561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32242/"
] | document.getElementsByName('some\_name') always return a collection (an Array), if you are sure that the name is unique you can safely write this.
```
var some_element = document.getElementsByName('some_name')[0];
``` | You basically put a condition and say name="some\_name".
See the code below and observe that is still does insert the aragraph.
```html
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script>
<input id="some_id" type="text" name="inpuname" >
<script>
YUI().use('node', function(Y) {
... |
923,561 | How can I use YUI to locate a text input by name and insert a div after it?
For example, this doesn't work:
```
<input name="some_name" type="text">
<script>
var el = new YAHOO.util.Element(document.createElement('div'));
var some_element = document.getElementsByName('some_name');
// doesn't work .... replacing 'so... | 2009/05/28 | [
"https://Stackoverflow.com/questions/923561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32242/"
] | As mentioned, document.getElementsByName returns an array. You may want to give your input an ID with the same name as the name attribute. (Aside: This is common and good practice for forms. Other js libraries provide helpful extensions when you do this.)
```
<input name="some_name" id="some_name" type="text">
<script... | With YUI 3 you can now do [this](https://stackoverflow.com/a/21319966/274502):
```html
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script>
<input id="some_id" type="text">
<script>
YUI().use('node', function(Y) {
var contentNode = Y.Node.create('<p>');
contentNode.setHTML('Thi... |
923,561 | How can I use YUI to locate a text input by name and insert a div after it?
For example, this doesn't work:
```
<input name="some_name" type="text">
<script>
var el = new YAHOO.util.Element(document.createElement('div'));
var some_element = document.getElementsByName('some_name');
// doesn't work .... replacing 'so... | 2009/05/28 | [
"https://Stackoverflow.com/questions/923561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32242/"
] | As mentioned, document.getElementsByName returns an array. You may want to give your input an ID with the same name as the name attribute. (Aside: This is common and good practice for forms. Other js libraries provide helpful extensions when you do this.)
```
<input name="some_name" id="some_name" type="text">
<script... | You basically put a condition and say name="some\_name".
See the code below and observe that is still does insert the aragraph.
```html
<script src="http://yui.yahooapis.com/3.18.1/build/yui/yui-min.js"></script>
<input id="some_id" type="text" name="inpuname" >
<script>
YUI().use('node', function(Y) {
... |
323,640 | I want to supply a microcontroller with 4x AA alkaline batteries or via USB, with the USB source being dominant. Meaning when USB is on, the batteries should be disconnected.
For the USB path, I intend to use a Schottky diode.
For the battery path, I initially thought about using a "ORing" IC or one of those "powerpat... | 2017/08/12 | [
"https://electronics.stackexchange.com/questions/323640",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/152813/"
] | Use this circuit, when USB is active it took power from USB.

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fJ91m9.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) | I think this will work. The only drawback is that maybe M1 and M2 will turn on just a little bit when VBATT is high, even though VBUS is present. This could lead to the batteries discharging just a bit. They will stop discharging when the voltage drops a little. This can be partially controlled by selecting M1 and M2 w... |
323,640 | I want to supply a microcontroller with 4x AA alkaline batteries or via USB, with the USB source being dominant. Meaning when USB is on, the batteries should be disconnected.
For the USB path, I intend to use a Schottky diode.
For the battery path, I initially thought about using a "ORing" IC or one of those "powerpat... | 2017/08/12 | [
"https://electronics.stackexchange.com/questions/323640",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/152813/"
] | Use this circuit, when USB is active it took power from USB.

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fJ91m9.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) | With quick simulation, this kind of circuit should work. The FETs take a little time to open after the USB voltage goes away, so you need a bulk capacitor to offer current for that time.
Make sure that the P-FET conducts with 5 V V\_GS
[](https://i.stack.imgur.com/xeCkf.png) |
323,640 | I want to supply a microcontroller with 4x AA alkaline batteries or via USB, with the USB source being dominant. Meaning when USB is on, the batteries should be disconnected.
For the USB path, I intend to use a Schottky diode.
For the battery path, I initially thought about using a "ORing" IC or one of those "powerpat... | 2017/08/12 | [
"https://electronics.stackexchange.com/questions/323640",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/152813/"
] | Use this circuit, when USB is active it took power from USB.

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fJ91m9.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) | You might check out the TI tips 22860. It's an integrated, low leakage, high side switch. Tie the input to the USB +5VDC Though a resistor. It's also pretty cheap. |
323,640 | I want to supply a microcontroller with 4x AA alkaline batteries or via USB, with the USB source being dominant. Meaning when USB is on, the batteries should be disconnected.
For the USB path, I intend to use a Schottky diode.
For the battery path, I initially thought about using a "ORing" IC or one of those "powerpat... | 2017/08/12 | [
"https://electronics.stackexchange.com/questions/323640",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/152813/"
] | Use this circuit, when USB is active it took power from USB.

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fJ91m9.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) | I routinely do this with use an isolated power source/regulator powering a low-side gate drive (any low-side gate drive method will work...nothing fancy here) with an optocoupler to float the control signal to the now floating gate driver. |
15,919,815 | I want to write a macro which converts all the shapes and pictures in my word document to inline with text.
The code that I am using converts all shapes(which are edited by drawing tools) to inline with text, but the table which are previously converted to pictures(edited by picture tools) or any other pictures are n... | 2013/04/10 | [
"https://Stackoverflow.com/questions/15919815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1800271/"
] | The first answer was a good start but there is a problem. For Each iterates over the collection but the collection is changed by ConvertToInlineShape. In other languages this throws an exception that the collection has been modified, here it just stops silently.
To avoid this you need to either add each shape to anoth... | give this a go
```
For Each oShp In ActiveDocument.Shapes
oShp.Select
Selection.ShapeRange.ConvertToInlineShape
Next oShp
``` |
15,919,815 | I want to write a macro which converts all the shapes and pictures in my word document to inline with text.
The code that I am using converts all shapes(which are edited by drawing tools) to inline with text, but the table which are previously converted to pictures(edited by picture tools) or any other pictures are n... | 2013/04/10 | [
"https://Stackoverflow.com/questions/15919815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1800271/"
] | The first answer was a good start but there is a problem. For Each iterates over the collection but the collection is changed by ConvertToInlineShape. In other languages this throws an exception that the collection has been modified, here it just stops silently.
To avoid this you need to either add each shape to anoth... | I think selecting each iterated shape is unnecessary and may be getting in the way.
Anyone who still needs an answer, this works for me:
```
For Count = 1 To 2
For Each oShp In ActiveDocument.Shapes
oShp.ConvertToInlineShape
Next oShp
Next Count
```
The first iteration of the outer loop tackles the ... |
15,919,815 | I want to write a macro which converts all the shapes and pictures in my word document to inline with text.
The code that I am using converts all shapes(which are edited by drawing tools) to inline with text, but the table which are previously converted to pictures(edited by picture tools) or any other pictures are n... | 2013/04/10 | [
"https://Stackoverflow.com/questions/15919815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1800271/"
] | The first answer was a good start but there is a problem. For Each iterates over the collection but the collection is changed by ConvertToInlineShape. In other languages this throws an exception that the collection has been modified, here it just stops silently.
To avoid this you need to either add each shape to anoth... | For i = 1 To ActiveDocument.Shapes.Count
ActiveDocument.Shapes(1).ConvertToInlineShape
'index value be 1 as the count will decrease on every conversion
Next |
56,961,594 | I'm curious what `x` means when you look at this:
```
import random
for x in range(10):
print random.randint(1,101)
``` | 2019/07/09 | [
"https://Stackoverflow.com/questions/56961594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11512753/"
] | `x` itself has no special meaning, it simply (as a part of the `for` loop) provides a way to repeat
```
print random.randint(1,101)
```
10 times, regardless of the variable name (i.e., `x` could be, say, `n`).
In each iteration the value of `x` keeps increasing, but we don't use it. On the other hand, e.g.,
```
fo... | X is a variable name, so could be any name allowed by python for variable names. As a variable , it’s value will be different every time the loop circle ends, in this particular loop range(10) the value of x will start in 0 and next 1 , and next 2, until reach value of 10
so If you want to print a random int:
```
for... |
56,961,594 | I'm curious what `x` means when you look at this:
```
import random
for x in range(10):
print random.randint(1,101)
``` | 2019/07/09 | [
"https://Stackoverflow.com/questions/56961594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11512753/"
] | `x` itself has no special meaning, it simply (as a part of the `for` loop) provides a way to repeat
```
print random.randint(1,101)
```
10 times, regardless of the variable name (i.e., `x` could be, say, `n`).
In each iteration the value of `x` keeps increasing, but we don't use it. On the other hand, e.g.,
```
fo... | For x in range(3) simply means,
for each value of x in range(3), range(3) = 0,1,2
As it is range(3), the loop is looped three times and at each time, value of x becomes 0, then 1 and then 2 |
56,961,594 | I'm curious what `x` means when you look at this:
```
import random
for x in range(10):
print random.randint(1,101)
``` | 2019/07/09 | [
"https://Stackoverflow.com/questions/56961594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11512753/"
] | `x` itself has no special meaning, it simply (as a part of the `for` loop) provides a way to repeat
```
print random.randint(1,101)
```
10 times, regardless of the variable name (i.e., `x` could be, say, `n`).
In each iteration the value of `x` keeps increasing, but we don't use it. On the other hand, e.g.,
```
fo... | Here, x is just a variable name used to store the integer value of the current position in the range of loop and it iterates through out the range of a loop.
Like in for x in range(10):
x iterates 10 times and for instance in your for loop above, during the first iteration of the loop x = 1, then x=2 for the next ite... |
56,961,594 | I'm curious what `x` means when you look at this:
```
import random
for x in range(10):
print random.randint(1,101)
``` | 2019/07/09 | [
"https://Stackoverflow.com/questions/56961594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11512753/"
] | `x` itself has no special meaning, it simply (as a part of the `for` loop) provides a way to repeat
```
print random.randint(1,101)
```
10 times, regardless of the variable name (i.e., `x` could be, say, `n`).
In each iteration the value of `x` keeps increasing, but we don't use it. On the other hand, e.g.,
```
fo... | I am coming from a short intro in C, and I was confused by the 'x' as well. For those coming from C,C++,C# etc.:
The 'x in range(10)' is the same thing as doing this in C:
for (x = 0; x < 10; x++) |
40,729,525 | How do I configure vim to open a default file (in my case, `~/Desktop/now.md`) if the `vim` command is invoked without arguments on the command-line? | 2016/11/21 | [
"https://Stackoverflow.com/questions/40729525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742/"
] | You're asking the user for a date in the format `YYYY-MM-DD` but then trying to parse it according to this format `%d/%m/%y`.
You instead should parse the string in the same way that you requested it, [`%Y-%m-%d`](https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior) | You're looking for format `%d/%m/%y` and asking for `%Y-%m-%d`
```
> date_visit = '2016-11-23'
> datetime.datetime.strptime(date_visit, "%Y-%m-%d")
datetime.datetime(2016, 11, 23, 0, 0)
```
Some notes:
* `%Y` : Year in four digits
`%y` : year in two digits.
* `%d/%m/%y` translates to *"day of month in one or two... |
40,729,525 | How do I configure vim to open a default file (in my case, `~/Desktop/now.md`) if the `vim` command is invoked without arguments on the command-line? | 2016/11/21 | [
"https://Stackoverflow.com/questions/40729525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742/"
] | You're asking the user for a date in the format `YYYY-MM-DD` but then trying to parse it according to this format `%d/%m/%y`.
You instead should parse the string in the same way that you requested it, [`%Y-%m-%d`](https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior) | Your prompt asks you to enter in `YYYY-MM-DD`, but your `strptime` is attempting to use the format `%d/%m/%y`. You need to have the formats to match for `strptime` to work
```
import datetime
d = '2016-11-21'
d = datetime.datetime.strptime(d, "%Y-%m-%d")
d = datetime.datetime(2016, 11, 21, 0, 0)
>>> 2016-11-21 00:00... |
57,076,530 | I need to convert this:
```
prev = {in_progress: 1, todo: 3, done: 1}
```
Into this
```
output = {[ ['Status', 'Count'], ['Todo', 3], ['In Progress', 1], ['Done', 1] ]}
```
When I'm trying to assign `prev` to a variable, it gets assigned.
```
let a = {in_progress: 1, todo: 3, done: 1}
```
Success.
But when i... | 2019/07/17 | [
"https://Stackoverflow.com/questions/57076530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9015957/"
] | The problem is that `{[ ['Status', 'Count'], ['Todo', 3], ['In Progress', 1], ['Done', 1] ]}` is not a valid object literal. It's just curly braces around a list of lists. Object literals have to have key: value pairs.
If you wanted to turn it into an object, it would look like `{ 'Status': 'Count', 'Todo': 3, 'In Pro... | You could get the entries and map the formatted key with the value.
```js
const format = s => s.split('_').map(([c, ...s]) => [c.toUpperCase(), ...s].join('')).join(' ');
var prev = { in_progress: 1, todo: 3, done: 1 },
result = [
['Status', 'Count'],
...Object.entries(prev).map(([k, v]) => [f... |
1,792,397 | Is there a way to back up a mercurial repository while preserving the files' timestamps?
Right now, I'm using `hg clone` to copy the repository to a staging directory, and the backup program picks up the files from there. I'm not pointing the backup program directly at the repository because I don't want it to be chan... | 2009/11/24 | [
"https://Stackoverflow.com/questions/1792397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6160/"
] | I suggest using `hg pull` instead of `hg clone`. So you'll keep a mirror of the repository on your server and update it periodically with `hg pull`. You then let your backup program take a backup of *that*. When you use `hg pull` you will transfer the newest history and only changed files under `.hg/store/data` which w... | **Plan A:** When the source and destination directories reside on the *same file system*, `hg clone -U` would simply hardlink all its files in the repository, without changing timestamps. This approach is quite fast and always safe (files are unlinked lazily when written to).
If you need to, you can clone on the same ... |
1,792,397 | Is there a way to back up a mercurial repository while preserving the files' timestamps?
Right now, I'm using `hg clone` to copy the repository to a staging directory, and the backup program picks up the files from there. I'm not pointing the backup program directly at the repository because I don't want it to be chan... | 2009/11/24 | [
"https://Stackoverflow.com/questions/1792397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6160/"
] | **Plan A:** When the source and destination directories reside on the *same file system*, `hg clone -U` would simply hardlink all its files in the repository, without changing timestamps. This approach is quite fast and always safe (files are unlinked lazily when written to).
If you need to, you can clone on the same ... | Here's a hg extension that might help: [TimestampExtension](https://www.mercurial-scm.org/wiki/TimestampExtension). |
1,792,397 | Is there a way to back up a mercurial repository while preserving the files' timestamps?
Right now, I'm using `hg clone` to copy the repository to a staging directory, and the backup program picks up the files from there. I'm not pointing the backup program directly at the repository because I don't want it to be chan... | 2009/11/24 | [
"https://Stackoverflow.com/questions/1792397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6160/"
] | I suggest using `hg pull` instead of `hg clone`. So you'll keep a mirror of the repository on your server and update it periodically with `hg pull`. You then let your backup program take a backup of *that*. When you use `hg pull` you will transfer the newest history and only changed files under `.hg/store/data` which w... | Here's a hg extension that might help: [TimestampExtension](https://www.mercurial-scm.org/wiki/TimestampExtension). |
1,780,496 | My understanding is limited and I'm trying to learn more about how homotopy forms the notion of equivalence. I can grasp its definition as "continuous", but my understanding of homotopy falls away in spaces that are discrete. How does the mapping actually work? | 2016/05/11 | [
"https://math.stackexchange.com/questions/1780496",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/257252/"
] | Two discrete spaces are homotopy equivalent if and only if they have the same number of points. Any function whose domain is discrete is automatically continuous, and two functions $X \to Y$ for discrete $Y$ are homotopic if and only if they are equal.
(I'm not sure I understood your question, let me know if that clea... | Old question, but let me cast some light (or maybe not) for future readers.
Instead of looking at homotopy in discrete spaces, it works better looking to define a homotopy between graphs, so you could identify the form, or at least the connections between discrete objects, graphs inherit a topology by it's connection t... |
938,647 | I am developing a CMS based on Zend Framework which have many modules, for example News and Gallery.
Each module has some part with same function as manage categories and comments (Categories and comments for News, Photos, Albums - cames from News and Gallery modules - are separate).
Can somebody give me the advise to ... | 2009/06/02 | [
"https://Stackoverflow.com/questions/938647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Write classes to abstract the logic to a central source file.
Basically, use encapsulation. | Separate the part of your application that should be reused. It's a good strategy to begin by copy-pasting, and only refactor it out into a shared component once you have at least two concrete uses for an abstraction. |
49,159,420 | Is it possible to get the permissions of a folder and its sub-folders then display the path, group, and users associated to that group? So, to look something like this. Or will it have to be one folder at a time.
**`-Folder1`**
```
-Line separator
-Group
-Line separator
-List of users
```
**`-Folder2`**
```
-Line... | 2018/03/07 | [
"https://Stackoverflow.com/questions/49159420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9458089/"
] | Ok, let's take it from the top! Excellent, you actually declare a parameter. What you might want to consider is setting a default value for the parameter. What I would do is use the current directory, which conveniently has an automatic variable `$PWD` (I believe that's short for PowerShell Working Directory).
```
Par... | I have managed to get this working for me.
I edited the below section to show the Name and Username of the user.
```
$Members = Get-ADGroupMember $Group -Recursive -ErrorAction Ignore | % Name | Get-ADUser -Property DisplayName | Select-Object DisplayName,Name | Sort-Object DisplayName
```
This works really well, b... |
55,132,453 | [](https://i.stack.imgur.com/ULXR2.png)
I have been trying to achieve something like the above in ionic 4 but it seems like there is no hope for me cos it seems I can only use inputs and not a custom HTML & icons been passed on the alert. any idea on how to a... | 2019/03/13 | [
"https://Stackoverflow.com/questions/55132453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7468924/"
] | The Ionic team has not made alert components easily customizable so icons can be added to the alert component. See issue:
<https://github.com/ionic-team/ionic/issues/7874>
But you could easily create a modal component and reduce its size to be closer to that of the alert dialog box. | Why you want use ion alert.
You can use other components like
[popovers](https://ionicframework.com/docs/v3/components/#popovers) to do that |
55,132,453 | [](https://i.stack.imgur.com/ULXR2.png)
I have been trying to achieve something like the above in ionic 4 but it seems like there is no hope for me cos it seems I can only use inputs and not a custom HTML & icons been passed on the alert. any idea on how to a... | 2019/03/13 | [
"https://Stackoverflow.com/questions/55132453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7468924/"
] | The Ionic team has not made alert components easily customizable so icons can be added to the alert component. See issue:
<https://github.com/ionic-team/ionic/issues/7874>
But you could easily create a modal component and reduce its size to be closer to that of the alert dialog box. | I know this is a bit late, but I just created an [npm package](https://www.npmjs.com/package/ionic-custom-alert) to handle adding an angular component into a popup. |
42,262,282 | I refactored my storyboard and now I'm unable to set the badge value on the refactored storyboard.
This is the main story board and MessageCenter is the refactored storyboard.
[](https://i.stack.imgur.com/Qflvp.png)
Message Center StoryBoard:
[![en... | 2017/02/15 | [
"https://Stackoverflow.com/questions/42262282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5992282/"
] | Try with this code in your TabBarCustomViewController:
```
DispatchQueue.main.async(execute: {
self.tabBar.items?[3].badgeValue = "3"
})
``` | if let tabBarController = self.window?.rootViewController as? UITabBarController {
tabBarController.viewControllers?[2].tabBarItem.badgeValue = "3"
} |
46,897,375 | I did overloading of '+' operator using friend functions for base and derived classes as below.
```
#include <iostream>
using namespace std;
class base
{
private:
int x;
public:
base(int a) : x(a)
{
}
void printx()
{
cout << "x : " << x << endl;
... | 2017/10/23 | [
"https://Stackoverflow.com/questions/46897375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3137388/"
] | The dot operator is for *member access*. But there is not a `base` member in `derived`, so `obj.base` is ill-formed. To obtain a base class reference explicitly from a derived object, you need to cast:
```
operator+(data, static_cast<base&>(obj));
```
In the second program `obj.d1::x` does not access the *member* `d... | The line `operator+(data, obj.base);` implies that `obj` has a member named `base`, which is not true. The base portion of a derived object is not represented as a member.
To coerce overloading to consider your object as if it was it's base type, you can case it to a reference of it's base class. The compiler must the... |
59,695,746 | I have following string
1,2,3,a,b,c,a,b,c,1,2,3,c,b,a,2,3,1,
I would like to get only the first occurrence of any number without changing the order. This would be
1,2,3,a,b,c,
With this regex (found @ <https://stackoverflow.com/a/29480898/9307482>) I can find them, but only the last occurrences. And this reverses t... | 2020/01/11 | [
"https://Stackoverflow.com/questions/59695746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9307482/"
] | Regular expression is not meant for that purpose. You will need to use an index filter or Set on array of characters.
Since you don't have a language specified I assume you are using javascript.
Example modified from: <https://stackoverflow.com/a/14438954/1456201>
```js
String.prototype.uniqueChars = function() {
... | I would use something like this:
```
// each index represents one digit: 0-9
const digits = new Array(10);
// make your string an array
const arr = '123abcabc123cba231'.split('');
// test for digit
var reg = new RegExp('^[0-9]$');
arr.forEach((val, index) => {
if (reg.test(val) && !reg.test(digits[val])) {
d... |
59,695,746 | I have following string
1,2,3,a,b,c,a,b,c,1,2,3,c,b,a,2,3,1,
I would like to get only the first occurrence of any number without changing the order. This would be
1,2,3,a,b,c,
With this regex (found @ <https://stackoverflow.com/a/29480898/9307482>) I can find them, but only the last occurrences. And this reverses t... | 2020/01/11 | [
"https://Stackoverflow.com/questions/59695746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9307482/"
] | Regular expression is not meant for that purpose. You will need to use an index filter or Set on array of characters.
Since you don't have a language specified I assume you are using javascript.
Example modified from: <https://stackoverflow.com/a/14438954/1456201>
```js
String.prototype.uniqueChars = function() {
... | A perl way to do the job:
```
use Modern::Perl;
my $in = '4,d,e,1,2,3,4,a,b,c,d,e,f,a,b,c,1,2,3,c,b,a,2,3,1,';
my (%h, @r);
for (split',',$in) {
push @r, $_ unless exists $h{$_};
$h{$_} = 1;
}
say join',',@r;
```
**Output:**
```
4,d,e,1,2,3,a,b,c,f
``` |
4,603,576 | In Vakil's FOAG, the projective space $\Bbb{P}^n\_A$ is defined to be $\operatorname{Proj} A[x\_0, x\_1, \ldots, x\_n]$. (there is another definition in the book too, just glueing $n+1$ affine space). Then in serveral exercises, the author uses the symbol $[x\_0, x\_1, \ldots, x\_n]$ without giving the meaning of it. F... | 2022/12/22 | [
"https://math.stackexchange.com/questions/4603576",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/195865/"
] | In classical, i.e. non-scheme-theoretic algebraic geometry, the projective space of dimension $n$ over some field $k$ is usually defined as $\mathbb{P}^n(k) = (k^{n+1} \setminus \lbrace 0 \rbrace) / k^\times = (\mathbb{A}^{n+1}(k) \setminus \lbrace 0 \rbrace) / k^\times$. This means that an element of $\mathbb{P}^n(k)$... | **Question:** "Thank you very much."
**Answer:** If $V:=\{e\_0,..,e\_n\}$ is a vector space over a field $k$ and if $V^\*:=\{x\_0,..,x\_n\}$ is the dual vector space it follows the symbols $x\_i:=e\_i^\*$ are the coordinate functions on $V$ in the sense that for a vector $v:=\sum\_i a\_ie\_i$ it follows $x\_i(v):=e\_i... |
23,207,471 | say I have a piece of code in a local method
```
int a = 5, b;
```
and then some code to indirectly initialize B such as
```
if (true) b = 5; // legal
if (someBool) b = 10; else b = 7; // legal
if (false) b = 5; // illegal
```
illegal even though B will always be initialized
```
if (a > 10)
b = 4;
if (a <= 1... | 2014/04/21 | [
"https://Stackoverflow.com/questions/23207471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2255185/"
] | A local variable can be considered to be "initialized" if the compiler can easily deduce that every possible code path will lead through a path where the value has been set.
* `if(true)` can be determined to always run.
* `if(false)` can be determined to never run.
* `if/else` can be determined to run at least one of ... | In this case:
```
if (false) b = 5; // illegal
```
The compiler throws an exception since `if(false)` can be erased at compile time. It is futile to even analyze a block of code that won't be executed by any mean.
In this case:
```
int a = 5, b;
if (a > 10)
b = 4;
if (a <= 10)
b = 4;
```
The compiler cannot ass... |
29,191,682 | I am having user id's and equivalent mail ids in file. according to user input ( i.e, we will give input as "apple") it should grep only mail id (only apple@gmail.com) and stored in email=$(...)
in-between user ids & mail ids have one space gap in file
*mail id's in file*
```
user_id's mail_id's
apple apple@gmai... | 2015/03/22 | [
"https://Stackoverflow.com/questions/29191682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4627729/"
] | You can use the Jackson library. An example can be found here: <http://www.mkyong.com/spring-mvc/spring-3-mvc-and-json-example/> | You will have to provide csrf token for POST request. Instead you can try this.
[sending HashMap by angularjs $http.get in spring mvc](https://stackoverflow.com/questions/29060493/sending-hashmap-by-angularjs-http-get-in-spring-mvc)
It works fine just a bit extra @RequestParams but on the better side you can send ad... |
29,191,682 | I am having user id's and equivalent mail ids in file. according to user input ( i.e, we will give input as "apple") it should grep only mail id (only apple@gmail.com) and stored in email=$(...)
in-between user ids & mail ids have one space gap in file
*mail id's in file*
```
user_id's mail_id's
apple apple@gmai... | 2015/03/22 | [
"https://Stackoverflow.com/questions/29191682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4627729/"
] | Serialization (POJO -> JSON) and deserialization (JSON -> POJO) in Spring is simply obtained via `@RequestBody` and `@ResponseBody` annotations.
You just need to define a Java class that represents/maps your JSON object on server-side.
Example:
### Input JSON
```
{id: 123, name: "your name", description: ""}
```
... | You will have to provide csrf token for POST request. Instead you can try this.
[sending HashMap by angularjs $http.get in spring mvc](https://stackoverflow.com/questions/29060493/sending-hashmap-by-angularjs-http-get-in-spring-mvc)
It works fine just a bit extra @RequestParams but on the better side you can send ad... |
53,912,256 | I'm trying to implement a CSSTransition to a modal in my project. The problem is that I am using css modules.
**My modal's render method**
```
render() {
return (
<Aux>
<Backdrop
show={this.props.show}
clicked={this.props.modalClosed}/>
... | 2018/12/24 | [
"https://Stackoverflow.com/questions/53912256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6193913/"
] | JSX:
```
<CSSTransition in={focused} timeout={500} classNames={{
enterActive: styles.MyClassEnterActive,
enterDone: styles.MyClassEnterDone,
exitActive: styles.MyClassExit,
exitDone: styles.MyClassExitActive
}}>
<span className={styles.MyClass}>animated</span>
</CSSTransition>
```
CSS Modul... | Solved by entering classes like this:
```
render() {
return (
<Aux>
<Backdrop
show={this.props.show}
clicked={this.props.modalClosed}/>
<CSSTransition
in={this.props.show}
timeout={10... |
33,608,523 | Having the following test case: (find fiddle [**here**](https://jsfiddle.net/5qct25hu/))
```
var a = new Date();
var b = null;
var c = {test: "test"};
if(a)
console.log(a); //--- prints the current date
if(b)
console.log('null'); //--- never reached
if(c)
console.log('test'); //--- prints 'test'
consol... | 2015/11/09 | [
"https://Stackoverflow.com/questions/33608523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1054151/"
] | From [the MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Logical_operators):
>
> `expr1 && expr2` : Returns expr1 if it can be converted to false; **otherwise, returns expr2**
>
>
>
`new Date` can't be converted to `false` (it's not [falsy](https://developer.mozilla.o... | From MDN:
>
> Logical AND (&&) expr1 && expr2 Returns expr1 if it can be converted
> to false; otherwise, returns expr2. Thus, when used with Boolean
> values, && returns true if both operands are true; otherwise, returns
> false.
>
>
>
[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScrip... |
33,608,523 | Having the following test case: (find fiddle [**here**](https://jsfiddle.net/5qct25hu/))
```
var a = new Date();
var b = null;
var c = {test: "test"};
if(a)
console.log(a); //--- prints the current date
if(b)
console.log('null'); //--- never reached
if(c)
console.log('test'); //--- prints 'test'
consol... | 2015/11/09 | [
"https://Stackoverflow.com/questions/33608523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1054151/"
] | >
> I expect the result of
>
>
>
> ```
> console.log(a && b);
>
> ```
>
> to be `false` and not `null` as it shown in the example.
>
>
>
In many languages with `&&` and `||` operators (or `AND` and `OR`), the result is always a boolean, yes.\* But JavaScript's `&&` and `||` are more useful than that: Their re... | From [the MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Logical_operators):
>
> `expr1 && expr2` : Returns expr1 if it can be converted to false; **otherwise, returns expr2**
>
>
>
`new Date` can't be converted to `false` (it's not [falsy](https://developer.mozilla.o... |
33,608,523 | Having the following test case: (find fiddle [**here**](https://jsfiddle.net/5qct25hu/))
```
var a = new Date();
var b = null;
var c = {test: "test"};
if(a)
console.log(a); //--- prints the current date
if(b)
console.log('null'); //--- never reached
if(c)
console.log('test'); //--- prints 'test'
consol... | 2015/11/09 | [
"https://Stackoverflow.com/questions/33608523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1054151/"
] | >
> I expect the result of
>
>
>
> ```
> console.log(a && b);
>
> ```
>
> to be `false` and not `null` as it shown in the example.
>
>
>
In many languages with `&&` and `||` operators (or `AND` and `OR`), the result is always a boolean, yes.\* But JavaScript's `&&` and `||` are more useful than that: Their re... | From MDN:
>
> Logical AND (&&) expr1 && expr2 Returns expr1 if it can be converted
> to false; otherwise, returns expr2. Thus, when used with Boolean
> values, && returns true if both operands are true; otherwise, returns
> false.
>
>
>
[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScrip... |
27,482,207 | I'm trying to get all data-name atributes from this html section
```
<div class='get-all'>
<div class='left-wrapper'>
<div class='field-wrapper'>
<div class='field'> <span class='product-id' data-name='itemId'>5</span>
<img src='carousel/images/120231671_1GG.jpg' width='52' hei... | 2014/12/15 | [
"https://Stackoverflow.com/questions/27482207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803434/"
] | Do you mean that you want a list of the names of the objects in the database?
That would be `select * from sys.objects` | You should check out [Tokenizer](http://search.cpan.org/~izut/SQL-Tokenizer-0.19/lib/SQL/Tokenizer.pm) - it splits your query on separate parts ("WHERE CLAUSE", "FUNCTION" etc.)
I guess you can use any other tool, but the general approach is to tokenize your query. |
27,482,207 | I'm trying to get all data-name atributes from this html section
```
<div class='get-all'>
<div class='left-wrapper'>
<div class='field-wrapper'>
<div class='field'> <span class='product-id' data-name='itemId'>5</span>
<img src='carousel/images/120231671_1GG.jpg' width='52' hei... | 2014/12/15 | [
"https://Stackoverflow.com/questions/27482207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803434/"
] | Do you mean that you want a list of the names of the objects in the database?
That would be `select * from sys.objects` | There are lots of different ways to solve this one, but each can be different depending on the version of SQL server you're on.
One of the lowest levels to extract this info from is sysobjects...
```
SELECT o.name,
CASE o.type
WHEN 'U' THEN 'Table'
WHEN 'V' THEN 'View'
WHEN 'P' THEN 'Procedure'
WHEN 'FN' THEN 'Func... |
27,482,207 | I'm trying to get all data-name atributes from this html section
```
<div class='get-all'>
<div class='left-wrapper'>
<div class='field-wrapper'>
<div class='field'> <span class='product-id' data-name='itemId'>5</span>
<img src='carousel/images/120231671_1GG.jpg' width='52' hei... | 2014/12/15 | [
"https://Stackoverflow.com/questions/27482207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803434/"
] | Do you mean that you want a list of the names of the objects in the database?
That would be `select * from sys.objects` | This will give you the list of objects. Just similar to Paul Answer.
SELECT name,
type\_desc,
type,
create\_Date,
modify\_date
FROM sys.objects
ORDER BY type\_Desc,
type,
name |
23,199,085 | I am writing a subroutine that prints an array of non redundant elements from another array.
This code is inside my subroutine.
```
foreach (@old_table) { push(@new_table, $_) unless ($seen{$_}++); }
print "@new_table" . "\n";
```
Then i call my subroutine in a loop inside my main program... | 2014/04/21 | [
"https://Stackoverflow.com/questions/23199085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2250162/"
] | Due to incorrect scoping, you're reusing the `@new_table` and `%seen` of previous passes. Create these just before the loop.
```
my @new_table;
my %seen;
foreach (@old_table) { push(@new_table, $_) unless ($seen{$_}++); }
print "@new_table" . "\n";
```
This can be simplified to
```
my %seen;
my @new_table = grep { ... | You can try `uniq` from `List::MoreUtils` to remove redundant elements.
```
my @new_table = uniq(@old_table);
```
To quote from perldoc
>
> uniq LIST
>
> distinct LIST
>
>
> Returns a new list by stripping duplicate values in LIST. The order of elements in the returned list is the same as in LIST. In
> scal... |
25,501,251 | I installed a fresh copy of GGTS on a fresh copy of windows 8 with JDK 1.7 installed.
I tried to get it to compile my existing project which was based on 2.3.6 and it failed miserably as GGTS comes with grails 2.4.2.
I know serveral people who had problems with 2.4.x so decided to stick with 2.3.
So I downloaded ... | 2014/08/26 | [
"https://Stackoverflow.com/questions/25501251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1072187/"
] | **check** all grails-project's '`app.grails.version`' in `application.properties`, then open window - preferences - groovy -grails, make sure that **all** VERSIONs were defined ( I use sts, maybe a little difference ).
alternatively
**update** all `application.properties` set `app.grails.version=2.3.11` ( the version... | Check if your environment variable of `GRAILS_HOME` is set to the right version of Grails. |
25,501,251 | I installed a fresh copy of GGTS on a fresh copy of windows 8 with JDK 1.7 installed.
I tried to get it to compile my existing project which was based on 2.3.6 and it failed miserably as GGTS comes with grails 2.4.2.
I know serveral people who had problems with 2.4.x so decided to stick with 2.3.
So I downloaded ... | 2014/08/26 | [
"https://Stackoverflow.com/questions/25501251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1072187/"
] | In my case the problem was, that I had moved grails to a different folder. I just had to change the location of grails in the settings. Hope that helps somebody. | **check** all grails-project's '`app.grails.version`' in `application.properties`, then open window - preferences - groovy -grails, make sure that **all** VERSIONs were defined ( I use sts, maybe a little difference ).
alternatively
**update** all `application.properties` set `app.grails.version=2.3.11` ( the version... |
25,501,251 | I installed a fresh copy of GGTS on a fresh copy of windows 8 with JDK 1.7 installed.
I tried to get it to compile my existing project which was based on 2.3.6 and it failed miserably as GGTS comes with grails 2.4.2.
I know serveral people who had problems with 2.4.x so decided to stick with 2.3.
So I downloaded ... | 2014/08/26 | [
"https://Stackoverflow.com/questions/25501251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1072187/"
] | **check** all grails-project's '`app.grails.version`' in `application.properties`, then open window - preferences - groovy -grails, make sure that **all** VERSIONs were defined ( I use sts, maybe a little difference ).
alternatively
**update** all `application.properties` set `app.grails.version=2.3.11` ( the version... | I ran into this same issue, and the problem was caused by the Grails installation it was trying to use. It wanted to use the default version that comes with GGTS rather than the one I installed myself.
To fix, go to Window > Preferences > Groovy > Grails, then "Edit" the Grails installation it shows. I had to switch m... |
25,501,251 | I installed a fresh copy of GGTS on a fresh copy of windows 8 with JDK 1.7 installed.
I tried to get it to compile my existing project which was based on 2.3.6 and it failed miserably as GGTS comes with grails 2.4.2.
I know serveral people who had problems with 2.4.x so decided to stick with 2.3.
So I downloaded ... | 2014/08/26 | [
"https://Stackoverflow.com/questions/25501251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1072187/"
] | In my case the problem was, that I had moved grails to a different folder. I just had to change the location of grails in the settings. Hope that helps somebody. | Check if your environment variable of `GRAILS_HOME` is set to the right version of Grails. |
25,501,251 | I installed a fresh copy of GGTS on a fresh copy of windows 8 with JDK 1.7 installed.
I tried to get it to compile my existing project which was based on 2.3.6 and it failed miserably as GGTS comes with grails 2.4.2.
I know serveral people who had problems with 2.4.x so decided to stick with 2.3.
So I downloaded ... | 2014/08/26 | [
"https://Stackoverflow.com/questions/25501251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1072187/"
] | In my case the problem was, that I had moved grails to a different folder. I just had to change the location of grails in the settings. Hope that helps somebody. | I ran into this same issue, and the problem was caused by the Grails installation it was trying to use. It wanted to use the default version that comes with GGTS rather than the one I installed myself.
To fix, go to Window > Preferences > Groovy > Grails, then "Edit" the Grails installation it shows. I had to switch m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.