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 |
|---|---|---|---|---|---|
51,733,971 | I'm currently trying to implement a generic method to adapt a DTO that comes from an external service into a model of my servisse and I ran into an issue.
First let me just contextualize the problem.
Let's say that an external service returns the following DTO to my application.
```
public class ExampleDTO
{
publi... | 2018/08/07 | [
"https://Stackoverflow.com/questions/51733971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6184160/"
] | As I understand it, the solution is broken into two parts, that should work independently from one another.
**Part A: generic pattern for object transformation**
Create an interface to be implemented by all your models that need to be adapted from an external DTO.
```
public interface IExampleModel<S>
{
void Ada... | You have two choices here,
1. Generate list of properties of Model and Dto via reflection. and then match their types.
```
class AdapterHelper<T1, T2>
{
public T1 Adapt(T2 source)
{
T1 targetItem = Activator.CreateInstance<T1>();
var props = typeof(T1).GetProperties();
var targetProps =... |
51,733,971 | I'm currently trying to implement a generic method to adapt a DTO that comes from an external service into a model of my servisse and I ran into an issue.
First let me just contextualize the problem.
Let's say that an external service returns the following DTO to my application.
```
public class ExampleDTO
{
publi... | 2018/08/07 | [
"https://Stackoverflow.com/questions/51733971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6184160/"
] | As I understand it, the solution is broken into two parts, that should work independently from one another.
**Part A: generic pattern for object transformation**
Create an interface to be implemented by all your models that need to be adapted from an external DTO.
```
public interface IExampleModel<S>
{
void Ada... | Because you are implementing a generic method, you need to either implement a generic method for transforming S to T (see other answers), or you need to pass in the transformation function.
```
public PagedCollectionResult<T> Adapt<S, T>(PagedCollectionResultDTO<S> source, Func<S, T> adapt)
{
if (source == null) r... |
51,733,971 | I'm currently trying to implement a generic method to adapt a DTO that comes from an external service into a model of my servisse and I ran into an issue.
First let me just contextualize the problem.
Let's say that an external service returns the following DTO to my application.
```
public class ExampleDTO
{
publi... | 2018/08/07 | [
"https://Stackoverflow.com/questions/51733971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6184160/"
] | As I understand it, the solution is broken into two parts, that should work independently from one another.
**Part A: generic pattern for object transformation**
Create an interface to be implemented by all your models that need to be adapted from an external DTO.
```
public interface IExampleModel<S>
{
void Ada... | Thank you all for your responses, they helped me getting in the right direction.
I used reflection at runtime to resolve the right adapt method.
I learned a few things about reflection thanks to you.
I'm sharing the solution in hope I can also give something back.
This is what I ended up with.
```
public PagedCollecti... |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Using the dest option, you can assign it to anything:
```
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt", dest='infile')
parser.add_argument("outputfile.txt", dest='out')
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(infile='hello', out='world')
```
Hope that helps. | I strongly recommend you to refactor your code to change the argument name.
But, if you won't or can't, this will do the job:
```
args.__dict__['inputfile.txt']
``` |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Internally, `argparse` will add all attributes to the `Namespace()` instance with [`setattr`](https://docs.python.org/2/library/functions.html#setattr). Accordingly, you can access the values with [`getattr`](https://docs.python.org/2/library/functions.html#getattr):
```
getattr(args, 'inputfile.txt')
```
However, t... | Using the dest option, you can assign it to anything:
```
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt", dest='infile')
parser.add_argument("outputfile.txt", dest='out')
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(infile='hello', out='world')
```
Hope that helps. |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Rename the argument to `inputfile` and use `metavar` to set the display value for the user.
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile", metavar = "inputfile.txt")
parser.add_argument("outputfile", metavar = "outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# ... | Using the dest option, you can assign it to anything:
```
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt", dest='infile')
parser.add_argument("outputfile.txt", dest='out')
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(infile='hello', out='world')
```
Hope that helps. |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Internally, `argparse` will add all attributes to the `Namespace()` instance with [`setattr`](https://docs.python.org/2/library/functions.html#setattr). Accordingly, you can access the values with [`getattr`](https://docs.python.org/2/library/functions.html#getattr):
```
getattr(args, 'inputfile.txt')
```
However, t... | I strongly recommend you to refactor your code to change the argument name.
But, if you won't or can't, this will do the job:
```
args.__dict__['inputfile.txt']
``` |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Why not use [FileType](https://docs.python.org/2.7/library/argparse.html#filetype-objects) objects instead?
```
>>> import argparse
>>>
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--infile', type=argparse.FileType('r'))
_StoreAction(option_strings=['--infile'], dest='infile', nargs=None, const=None... | I strongly recommend you to refactor your code to change the argument name.
But, if you won't or can't, this will do the job:
```
args.__dict__['inputfile.txt']
``` |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Rename the argument to `inputfile` and use `metavar` to set the display value for the user.
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile", metavar = "inputfile.txt")
parser.add_argument("outputfile", metavar = "outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# ... | I strongly recommend you to refactor your code to change the argument name.
But, if you won't or can't, this will do the job:
```
args.__dict__['inputfile.txt']
``` |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Internally, `argparse` will add all attributes to the `Namespace()` instance with [`setattr`](https://docs.python.org/2/library/functions.html#setattr). Accordingly, you can access the values with [`getattr`](https://docs.python.org/2/library/functions.html#getattr):
```
getattr(args, 'inputfile.txt')
```
However, t... | Why not use [FileType](https://docs.python.org/2.7/library/argparse.html#filetype-objects) objects instead?
```
>>> import argparse
>>>
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--infile', type=argparse.FileType('r'))
_StoreAction(option_strings=['--infile'], dest='infile', nargs=None, const=None... |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Internally, `argparse` will add all attributes to the `Namespace()` instance with [`setattr`](https://docs.python.org/2/library/functions.html#setattr). Accordingly, you can access the values with [`getattr`](https://docs.python.org/2/library/functions.html#getattr):
```
getattr(args, 'inputfile.txt')
```
However, t... | Rename the argument to `inputfile` and use `metavar` to set the display value for the user.
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile", metavar = "inputfile.txt")
parser.add_argument("outputfile", metavar = "outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# ... |
32,259,248 | Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# now args is:
# Namespace(inputfi... | 2015/08/27 | [
"https://Stackoverflow.com/questions/32259248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599567/"
] | Rename the argument to `inputfile` and use `metavar` to set the display value for the user.
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("inputfile", metavar = "inputfile.txt")
parser.add_argument("outputfile", metavar = "outputfile.txt")
args = parser.parse_args(['hello', 'world'])
# ... | Why not use [FileType](https://docs.python.org/2.7/library/argparse.html#filetype-objects) objects instead?
```
>>> import argparse
>>>
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--infile', type=argparse.FileType('r'))
_StoreAction(option_strings=['--infile'], dest='infile', nargs=None, const=None... |
501,248 | I was bored recently so I decided to download and install drivers from ASUS site. My motherboard is Asus P5K. After downloading the drivers, I messed up the installation somehow (don't remember the details) and now I don't have sound at all!
I'm new to Ubuntu and I don't have a clue how driver setup works.
Can you te... | 2014/07/22 | [
"https://askubuntu.com/questions/501248",
"https://askubuntu.com",
"https://askubuntu.com/users/231422/"
] | I think you should install the *ibus-m17n* package.
```
sudo apt-get install ibus-m17n
```
Then, next time you log in, you should see a bunch of new Sinhala options when running *ibus-setup*. Pick the one of your choice, and hopefully it makes a difference. | To add the functionality of multiple keyboards, first add (as root) to
/etc/xdg/lxsession/LXDE/autostart your language choices, for example, for US and French, add
@setxkbmap -layout "us,fr".
See <http://lxlinux.com/#19> for additional information. |
501,248 | I was bored recently so I decided to download and install drivers from ASUS site. My motherboard is Asus P5K. After downloading the drivers, I messed up the installation somehow (don't remember the details) and now I don't have sound at all!
I'm new to Ubuntu and I don't have a clue how driver setup works.
Can you te... | 2014/07/22 | [
"https://askubuntu.com/questions/501248",
"https://askubuntu.com",
"https://askubuntu.com/users/231422/"
] | I recently had a really hard time making this work and finally solved my problem using `xfce4-xkb-plugin` on Lubuntu 18.04.
First install the plugin
```
sudo apt-get install xfce4-xkb-plugin
```
then right-click on the task-bar and click **add/remove panel items** , it will open a **Panel Preferences** window
Clic... | To add the functionality of multiple keyboards, first add (as root) to
/etc/xdg/lxsession/LXDE/autostart your language choices, for example, for US and French, add
@setxkbmap -layout "us,fr".
See <http://lxlinux.com/#19> for additional information. |
501,248 | I was bored recently so I decided to download and install drivers from ASUS site. My motherboard is Asus P5K. After downloading the drivers, I messed up the installation somehow (don't remember the details) and now I don't have sound at all!
I'm new to Ubuntu and I don't have a clue how driver setup works.
Can you te... | 2014/07/22 | [
"https://askubuntu.com/questions/501248",
"https://askubuntu.com",
"https://askubuntu.com/users/231422/"
] | I think you should install the *ibus-m17n* package.
```
sudo apt-get install ibus-m17n
```
Then, next time you log in, you should see a bunch of new Sinhala options when running *ibus-setup*. Pick the one of your choice, and hopefully it makes a difference. | I recently had a really hard time making this work and finally solved my problem using `xfce4-xkb-plugin` on Lubuntu 18.04.
First install the plugin
```
sudo apt-get install xfce4-xkb-plugin
```
then right-click on the task-bar and click **add/remove panel items** , it will open a **Panel Preferences** window
Clic... |
68,690,565 | I have following *IProduct* and *ProductResolved* interfaces
```
export interface IProduct {
id: number;
productName: string;
productCode: string;
category: string;
tags?: string[];
releaseDate: string;
price: number;
description: string;
starRating: number;
imageUrl: string;
}
export interface Pr... | 2021/08/07 | [
"https://Stackoverflow.com/questions/68690565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12415466/"
] | There are three options to resolve this issue:
* modify property product as optional:
More information you can find [here](https://exploringjs.com/tackling-ts/ch_typing-objects.html#optional-properties-interfaces)
```
export interface ProductResolved {
product?: IProduct;
error?: any;
}
```
* modify... | you can try with {} instead of null.
If that didnt work, just give product?: IProduct |
58,379,887 | am trying to add a function to a script where a user is ask for code, which i have added. but having one issue of i want to unable when to ask the user code and when to to ask .
so i need a php if else and it sql
so when i unable to ask code for a user it will ask code and when i disable it wont ask code
below is th... | 2019/10/14 | [
"https://Stackoverflow.com/questions/58379887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9043773/"
] | You could use [string formatting](https://docs.python.org/3/library/string.html#formatspec) to pad zeros to strings, e.g. to pad to the left:
```
>>> nums = ['10:30', '9:30', '11:0']
>>> ['{:0>2}:{:0>2}'.format(*n.split(':')) for n in nums]
['10:30', '09:30', '11:00']
```
Alternatively, converting strings to numbers... | Here's a way using string formatting:
```
def add_zeros(item: str) -> str:
nums = item.split(":")
formatted_item = ":".join(f"{int(num):02d}" for num in nums)
return formatted_item
```
Then apply it to each item in your list:
```
nums = ["10:30", "9:30", "11:0"]
[add_zeros(num) for num in nums]
``` |
58,379,887 | am trying to add a function to a script where a user is ask for code, which i have added. but having one issue of i want to unable when to ask the user code and when to to ask .
so i need a php if else and it sql
so when i unable to ask code for a user it will ask code and when i disable it wont ask code
below is th... | 2019/10/14 | [
"https://Stackoverflow.com/questions/58379887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9043773/"
] | You could use [string formatting](https://docs.python.org/3/library/string.html#formatspec) to pad zeros to strings, e.g. to pad to the left:
```
>>> nums = ['10:30', '9:30', '11:0']
>>> ['{:0>2}:{:0>2}'.format(*n.split(':')) for n in nums]
['10:30', '09:30', '11:00']
```
Alternatively, converting strings to numbers... | Here's a solution utilizing `zfill` & `ljust`
```
nums = ["10:30", "9:30", "11:0"]
fixed = []
for t in nums:
x, y = t.split(':')
fixed.append(x.zfill(2) + ':' + y.ljust(2, '0'))
print(fixed)
``` |
58,379,887 | am trying to add a function to a script where a user is ask for code, which i have added. but having one issue of i want to unable when to ask the user code and when to to ask .
so i need a php if else and it sql
so when i unable to ask code for a user it will ask code and when i disable it wont ask code
below is th... | 2019/10/14 | [
"https://Stackoverflow.com/questions/58379887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9043773/"
] | You could use [string formatting](https://docs.python.org/3/library/string.html#formatspec) to pad zeros to strings, e.g. to pad to the left:
```
>>> nums = ['10:30', '9:30', '11:0']
>>> ['{:0>2}:{:0>2}'.format(*n.split(':')) for n in nums]
['10:30', '09:30', '11:00']
```
Alternatively, converting strings to numbers... | You probably need to think this through a bit, because like mentioned in the commends 11:3 could be 11:03 or 11:30, but none the less, using actual datetime in python you can do the following:
```
from datetime import datetime
nums = ["10:30", "9:30", "11:3"]
x = [datetime.strptime(x, '%H:%M').strftime('%H:%M') for x ... |
58,379,887 | am trying to add a function to a script where a user is ask for code, which i have added. but having one issue of i want to unable when to ask the user code and when to to ask .
so i need a php if else and it sql
so when i unable to ask code for a user it will ask code and when i disable it wont ask code
below is th... | 2019/10/14 | [
"https://Stackoverflow.com/questions/58379887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9043773/"
] | You could use [string formatting](https://docs.python.org/3/library/string.html#formatspec) to pad zeros to strings, e.g. to pad to the left:
```
>>> nums = ['10:30', '9:30', '11:0']
>>> ['{:0>2}:{:0>2}'.format(*n.split(':')) for n in nums]
['10:30', '09:30', '11:00']
```
Alternatively, converting strings to numbers... | >
> I need to add zero if number is single
>
>
>
Using list comprehension
```
nums = ["10:30", "9:30", "11:0"]
nums_added = [ i + "0" if len(i.split(":")[1]) == 1 else i for i in nums]
print(nums_added)
```
Output:
```
['10:30', '9:30', '11:00']
``` |
58,379,887 | am trying to add a function to a script where a user is ask for code, which i have added. but having one issue of i want to unable when to ask the user code and when to to ask .
so i need a php if else and it sql
so when i unable to ask code for a user it will ask code and when i disable it wont ask code
below is th... | 2019/10/14 | [
"https://Stackoverflow.com/questions/58379887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9043773/"
] | You could use [string formatting](https://docs.python.org/3/library/string.html#formatspec) to pad zeros to strings, e.g. to pad to the left:
```
>>> nums = ['10:30', '9:30', '11:0']
>>> ['{:0>2}:{:0>2}'.format(*n.split(':')) for n in nums]
['10:30', '09:30', '11:00']
```
Alternatively, converting strings to numbers... | A solution leaning the fact that these look **a lot** like dates could be ...
Set up your list
```
nums = ["10:30", "9:30", "11:0"]
```
Iterate through the list converting, grabbing the time and lopping off (technical term) the last 3 characters
```
for item in nums:
print(str(datetime.strptime(item, '%H:%M'... |
52,012,145 | I'm trying to code my own bot python selenium bot for instagram to experiment a little. I succeeded to log in and to search an hashtag in the search bar which lead me to the following web page:
[](https://i.stack.imgur.com/Ij9bq.png)
But I can not figure out how to like ... | 2018/08/24 | [
"https://Stackoverflow.com/questions/52012145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6053483/"
] | First of all, in your case it is recommended to use the official Instagram Api for Python ([documentation here on github](https://github.com/facebookarchive/python-instagram)).
It would make your bot much simpler, more readable and most of all lighter and faster. So this is my first advice.
If you really need using S... | i'm trying to do the same)
Here is a working method.
Firstly, we find a class of posts(v1Nh3), then we catch link attribute(href).
```
posts = bot.find_elements_by_class_name('v1Nh3')
links = [elem.find_element_by_css_selector('a').get_attribute('href') for elem in posts]
``` |
52,012,145 | I'm trying to code my own bot python selenium bot for instagram to experiment a little. I succeeded to log in and to search an hashtag in the search bar which lead me to the following web page:
[](https://i.stack.imgur.com/Ij9bq.png)
But I can not figure out how to like ... | 2018/08/24 | [
"https://Stackoverflow.com/questions/52012145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6053483/"
] | First of all, in your case it is recommended to use the official Instagram Api for Python ([documentation here on github](https://github.com/facebookarchive/python-instagram)).
It would make your bot much simpler, more readable and most of all lighter and faster. So this is my first advice.
If you really need using S... | I implemented a function that likes all the picture from an Instagram page. It could be used on the "Explore" page or simply on an user's profil page.
Here's how I did it.
First, to navigate to a profil page from Instagram's main page, I create a xPath for the "SearchBox" and a xPath to the element in the dropdown me... |
64,403,863 | I am trying to model a bag of words. I am having some trouble incrementing the counter inside my dictionary when the word is found in my data (type series):
```
def build_voc(self, data):
for document in data:
for word in document.split(' '):
if word in self.voc:
... | 2020/10/17 | [
"https://Stackoverflow.com/questions/64403863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5587209/"
] | I presume you realize you're supposed to compare Strings with `equals` and not `==`. However, look at the identity hashCodes for the strings. `abcdef` and `b` have the same one. That is why they are equal using `==` They are referencing the same object from the internal cache.
```
String abcdef = "abcdef";
final Strin... | This is happening because `b` is equal to `"abc" + def`, and `def` is equal to `"def"`. So, essentially, you are comparing `"abcdef"` with `"abcdef"` by using `abcdef == b`.
So, in conclusion, it will *not* print nothing, because `"abcdef" == "abcdef"` *always* evaluates to `true`. |
64,403,863 | I am trying to model a bag of words. I am having some trouble incrementing the counter inside my dictionary when the word is found in my data (type series):
```
def build_voc(self, data):
for document in data:
for word in document.split(' '):
if word in self.voc:
... | 2020/10/17 | [
"https://Stackoverflow.com/questions/64403863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5587209/"
] | In Java the operator "==" checks if the two operands reference to the same object. Do not use "==" with any objects including Strings. And note Java Strings are immutable. That mean all the operations with them don't modify them but create new objects. | This is happening because `b` is equal to `"abc" + def`, and `def` is equal to `"def"`. So, essentially, you are comparing `"abcdef"` with `"abcdef"` by using `abcdef == b`.
So, in conclusion, it will *not* print nothing, because `"abcdef" == "abcdef"` *always* evaluates to `true`. |
64,403,863 | I am trying to model a bag of words. I am having some trouble incrementing the counter inside my dictionary when the word is found in my data (type series):
```
def build_voc(self, data):
for document in data:
for word in document.split(' '):
if word in self.voc:
... | 2020/10/17 | [
"https://Stackoverflow.com/questions/64403863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5587209/"
] | I presume you realize you're supposed to compare Strings with `equals` and not `==`. However, look at the identity hashCodes for the strings. `abcdef` and `b` have the same one. That is why they are equal using `==` They are referencing the same object from the internal cache.
```
String abcdef = "abcdef";
final Strin... | In Java the operator "==" checks if the two operands reference to the same object. Do not use "==" with any objects including Strings. And note Java Strings are immutable. That mean all the operations with them don't modify them but create new objects. |
94,499 | I am an international student in a interdisciplinary PhD in the social sciences.
1. My supervisor has about 60 students and does not do any advising beyond a few personal favorites.
2. My second supervisor considers me a student of the first, resents the fact that he is the expert on the subject, and as a result won't... | 2017/08/13 | [
"https://academia.stackexchange.com/questions/94499",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/78397/"
] | It is not uncommon that a German professor does not give advise to their PhD students. Neither is it uncommon that the 2nd referee does not want to read your thesis. In Germany, whether your dissertation is good enough or not is mainly decided by the first advisor. If they say it's ok, then it's ok. Your advisor theirs... | Did your first supervisor ever say to you that he/she won't read your thesis? Why don't you try to finish writing the first draft of your thesis first and let your first supervisor to read and comment? My supervisor also is a type that doesn't do much supervising and only let me do whatever I want. But she took time to... |
94,499 | I am an international student in a interdisciplinary PhD in the social sciences.
1. My supervisor has about 60 students and does not do any advising beyond a few personal favorites.
2. My second supervisor considers me a student of the first, resents the fact that he is the expert on the subject, and as a result won't... | 2017/08/13 | [
"https://academia.stackexchange.com/questions/94499",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/78397/"
] | It is not uncommon that a German professor does not give advise to their PhD students. Neither is it uncommon that the 2nd referee does not want to read your thesis. In Germany, whether your dissertation is good enough or not is mainly decided by the first advisor. If they say it's ok, then it's ok. Your advisor theirs... | I have had problems that are similar to yours.
I would say that you need to finish your PhD. The strongest thing you can have in your CV besides your publications is your degree.
Apply for Postdoc in other countries within the EU. There are many opportunities and you may get lucky. America is having difficulties with... |
2,573,982 | Given $f(x, y) = x$ and $X$ is defined as $2rx \leq x^2 + y^2 \leq R^2$ and $0 < 2r < R$.
Calculate $\int \int\_X f(x, y)dxdy$.
So $x^2 + y^2 \leq R^2$ is an area inside a circle with radius $R$.
$2rx \leq x^2 + y^2$ and $0 < 2r < R$ give us a second circle, which area depends on value of $x$ with center on somewh... | 2017/12/20 | [
"https://math.stackexchange.com/questions/2573982",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/376675/"
] | For the big circle:
$x^2 + y^2 \leq R^2$.
Let $x=\rho\cos\phi$ and $y=\rho\sin\phi$
$$I\_1=\int \int\_{X\_1} x dx dy =\int \limits\_{0}^{2\pi}\int \limits\_{0}^{R} \rho^2\cos\phi d\rho d\phi = \int \limits\_{0}^{R} \rho^2 d\rho\int \limits\_{0}^{2\pi}\cos\phi d\phi =0$$
For the small circle:
$2rx \geq x^2 + y^2 \... | Well, firstly, I'd like you to realize that it would be best to deal with this in terms of polar coordinates, as we are dealing with circles.
Now let's analyse this.
$2rx\leq x^2+y^2\leq R^2$, $0\leq 2r\leq R$, where $R$ is the radius of the circle.
Now remember that in polar coordinates, $x=R\cos\theta,y=R\sin\thet... |
58,659,448 | I am working on many large gz file like the below examples (only the first 5 rows are showed here).
```
gene_id variant_id tss_distance ma_samples ma_count maf pval_nominal slope slope_se
ENSG00000223972.4 1_13417_C_CGAGA_b37 1548 50 50 0.0766871 0.735446 -0.0468165 0.138428
ENSG00000223972.... | 2019/11/01 | [
"https://Stackoverflow.com/questions/58659448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196742/"
] | one way of doing this is with `split`
```
$ awk '{split($2,f2,"_")}
f2[1]==1 && f2[2]>20000 {gsub("_"," ",$2); print > (FILENAME".output")}' file
```
however, if you provide data though stdin, `awk` won't capture a filename to write to. You need to pass it to the script as a variable perhaps... | The simple solution is to combine the filter into single `awk` script, than and only than parallel can work.
Here is a sample solution that scan the whole `input.txt` only once (twice the performance):
```
awk 'BEGIN{FS="[ ]*[_]?"}$2==1 && $7 > 20000 {print}' input.txt
```
### Explanation:
`BEGIN{FS="[ ]*[_]?"}` M... |
58,659,448 | I am working on many large gz file like the below examples (only the first 5 rows are showed here).
```
gene_id variant_id tss_distance ma_samples ma_count maf pval_nominal slope slope_se
ENSG00000223972.4 1_13417_C_CGAGA_b37 1548 50 50 0.0766871 0.735446 -0.0468165 0.138428
ENSG00000223972.... | 2019/11/01 | [
"https://Stackoverflow.com/questions/58659448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196742/"
] | <https://www.gnu.org/software/parallel/man.html#QUOTING> concludes:
>
> **Conclusion:** To avoid dealing with the quoting problems it may be easier just to write a small script or a function (remember to export -f the function) and have GNU parallel call that.
>
>
>
So:
```
doit() {
zcat "$1" |
awk -F "_" ... | one way of doing this is with `split`
```
$ awk '{split($2,f2,"_")}
f2[1]==1 && f2[2]>20000 {gsub("_"," ",$2); print > (FILENAME".output")}' file
```
however, if you provide data though stdin, `awk` won't capture a filename to write to. You need to pass it to the script as a variable perhaps... |
58,659,448 | I am working on many large gz file like the below examples (only the first 5 rows are showed here).
```
gene_id variant_id tss_distance ma_samples ma_count maf pval_nominal slope slope_se
ENSG00000223972.4 1_13417_C_CGAGA_b37 1548 50 50 0.0766871 0.735446 -0.0468165 0.138428
ENSG00000223972.... | 2019/11/01 | [
"https://Stackoverflow.com/questions/58659448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196742/"
] | <https://www.gnu.org/software/parallel/man.html#QUOTING> concludes:
>
> **Conclusion:** To avoid dealing with the quoting problems it may be easier just to write a small script or a function (remember to export -f the function) and have GNU parallel call that.
>
>
>
So:
```
doit() {
zcat "$1" |
awk -F "_" ... | The simple solution is to combine the filter into single `awk` script, than and only than parallel can work.
Here is a sample solution that scan the whole `input.txt` only once (twice the performance):
```
awk 'BEGIN{FS="[ ]*[_]?"}$2==1 && $7 > 20000 {print}' input.txt
```
### Explanation:
`BEGIN{FS="[ ]*[_]?"}` M... |
38,067,742 | I get this message: The Google Maps API server rejected your request. You have exceeded your daily request quota for this API.
Despite the site not yet being indexable and only having had 265 visitors - it's hosted at wordpress.com so I can't access the site code at all. Site theme is Selma (is it because the theme de... | 2016/06/28 | [
"https://Stackoverflow.com/questions/38067742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6521475/"
] | It is defined:
```
private static Timer aTimer;
```
and assigned:
```
aTimer = new Timer(5);
``` | The `static void Main` is the acces point of program.
It will be executed at the very beginning.
And it will assign a value to `aTimer`.
```
public class Example
{
private static Timer aTimer;
...
public static void Main()
{
...
aTimer = new Timer(5);
...
}
...
}
``` |
38,067,742 | I get this message: The Google Maps API server rejected your request. You have exceeded your daily request quota for this API.
Despite the site not yet being indexable and only having had 265 visitors - it's hosted at wordpress.com so I can't access the site code at all. Site theme is Selma (is it because the theme de... | 2016/06/28 | [
"https://Stackoverflow.com/questions/38067742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6521475/"
] | ```
using System;
using System.IO;
using System.Collections.Generic;
using System.Timers;
public class Example
{
private static Timer aTimer;
```
Last line of this code. Press Ctrl+F and Highlight All (Mozilla Firefox), search for aTimer | The `static void Main` is the acces point of program.
It will be executed at the very beginning.
And it will assign a value to `aTimer`.
```
public class Example
{
private static Timer aTimer;
...
public static void Main()
{
...
aTimer = new Timer(5);
...
}
...
}
``` |
23,598,213 | I'm trying my first adventure using viewmodels, but I got a problem, this is my view model and the models:
**ViewModel:**
```
public class ProfessionalDashboard
{
public List<JobOffertModel> AcceptedJobOfferts { get; set; }
public List<JobOffertModel> NotAcceptedJobOfferts { get; set; }
... | 2014/05/11 | [
"https://Stackoverflow.com/questions/23598213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1121139/"
] | All I see in your form are `Model.NotAcceptedJobOfferts`. If you want to maintain your data you need to add it as a hidden input in your form. Once the view is rendered to the user, your model is lost, the only data available is what has been rendered on the page. | You have a plenty of complex types in play. The default model binder is having difficulties in binding the values that are getting posted in the form. Here's something you can do:
* Check the names of the values in the HTML by doing view source. Make sure they are following [PropertyNameInParentModelClass].[PropertyNa... |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | The default background color is based on the **`colorOnSurface`** attribute.
You can override this value using:
```
<com.google.android.material.textfield.TextInputLayout
android:theme="@style/MyTextInputLayout_overlay"
..>
```
with:
```
<style name="MyTextInputLayout_overlay">
<item name="colorOnSurface... | At beginning everything was working fine. Later layout was broken. The reason was I changed property background TextInputEditText. Transaparency must be set on TextInputEditText, not in TextInputLayout **`android:background="#80FFFFFF"`** |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | **Method A**
*(completely transparent background)*
```
<com.google.android.material.textfield.TextInputLayout
app:boxBackgroundMode="filled"
app:boxBackgroundColor="@null"
..>
<com.google.android.material.textfield.TextInputEditText
android:backgroundTint="@android:color/transparent"
..>
```
**Method B... | You can use these options to customise the TextInputLayout.
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/menuMakeList"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width... |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | For me it worked with `app:boxBackgroundColor="@null"`, like this:
```
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundColor="@null"
android:hint="@string/description">
<com.goo... | I recently faced with this issue. None of the above solutions worked for the latest material theme release. Took me a while to figure it out. Here's my solution:
**Style:**
```
<style name="Widget.App.TextInputLayout" parent="Widget.Design.TextInputLayout">
<item name="materialThemeOverlay">@style/ThemeOverlay.Ap... |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | <https://github.com/material-components/material-components-android/issues/102>
It seems a material textfield bug.
You can use this code to change background white temporarily.
```
<com.google.android.material.textfield.TextInputLayout
app:boxBackgroundColor="@android:color/transparent"
android:background="... | **Method A**
*(completely transparent background)*
```
<com.google.android.material.textfield.TextInputLayout
app:boxBackgroundMode="filled"
app:boxBackgroundColor="@null"
..>
<com.google.android.material.textfield.TextInputEditText
android:backgroundTint="@android:color/transparent"
..>
```
**Method B... |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | For me it worked with `app:boxBackgroundColor="@null"`, like this:
```
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundColor="@null"
android:hint="@string/description">
<com.goo... | Simple way worked for me!
```
app:boxBackgroundMode="filled"
app:boxBackgroundColor="@color/white"
``` |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | For me it worked with `app:boxBackgroundColor="@null"`, like this:
```
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundColor="@null"
android:hint="@string/description">
<com.goo... | The default background color is based on the **`colorOnSurface`** attribute.
You can override this value using:
```
<com.google.android.material.textfield.TextInputLayout
android:theme="@style/MyTextInputLayout_overlay"
..>
```
with:
```
<style name="MyTextInputLayout_overlay">
<item name="colorOnSurface... |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | One way to remove the background color is to adjust the background mode of TextInputLayout.
app:boxBackgroundMode="none"
Worked for me.
Example XML Code:
```
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
... | For me it worked with `app:boxBackgroundColor="@null"`, like this:
```
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundColor="@null"
android:hint="@string/description">
<com.goo... |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | Simple way worked for me!
```
app:boxBackgroundMode="filled"
app:boxBackgroundColor="@color/white"
``` | At beginning everything was working fine. Later layout was broken. The reason was I changed property background TextInputEditText. Transaparency must be set on TextInputEditText, not in TextInputLayout **`android:background="#80FFFFFF"`** |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | I recently faced with this issue. None of the above solutions worked for the latest material theme release. Took me a while to figure it out. Here's my solution:
**Style:**
```
<style name="Widget.App.TextInputLayout" parent="Widget.Design.TextInputLayout">
<item name="materialThemeOverlay">@style/ThemeOverlay.Ap... | You can use these options to customise the TextInputLayout.
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/menuMakeList"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width... |
56,141,507 | I have `TextInputLayout` and `TextInputEditText` like this
```
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/loginUsernameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/text_input... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56141507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2325929/"
] | I recently faced with this issue. None of the above solutions worked for the latest material theme release. Took me a while to figure it out. Here's my solution:
**Style:**
```
<style name="Widget.App.TextInputLayout" parent="Widget.Design.TextInputLayout">
<item name="materialThemeOverlay">@style/ThemeOverlay.Ap... | At beginning everything was working fine. Later layout was broken. The reason was I changed property background TextInputEditText. Transaparency must be set on TextInputEditText, not in TextInputLayout **`android:background="#80FFFFFF"`** |
59,737,839 | I'm using `vuex-presistedstate` in my project. In the source code on github the plugin calls `store.replaceState` to hydrate store from storage. Is there a way to know when the store hydrates? | 2020/01/14 | [
"https://Stackoverflow.com/questions/59737839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9388051/"
] | The `vuex-presistedstate` plugin has a configuration option called `rehydrated` that allows you to pass a function that will be called immediately after `replaceState`. If you only care about calls to `replaceState` from that plugin then that should fit your needs nicely.
I don't believe the store itself provides a 'h... | You can try rewrite `store.replaceState`:
```js
import store from './your/path/to/store'
// ...
store.replaceState = (fn => (...params) => {
console.log('do something before replaceState called')
fn.apply(store, params)
console.log('do something after replaceState called')
})(store.replaceState)
```
In this wa... |
52,186,029 | I have a `DBContext` that is initializing through `DropCreateDatabaseAlways` class.
In the `Seed` method I have this code:
```
base.Seed(context);
var c1 = new Company { Name = "Samsung"};
var c2 = new Company { Name = "Microsoft"};
context.Companies.AddRange(new List<Co... | 2018/09/05 | [
"https://Stackoverflow.com/questions/52186029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9047572/"
] | If you want to automagically load the companies when you load a phone, you need to add the `virtual` keyword before the Company property.
```
public class Phone {
public Phone() {
}
public Phone(string name, int price, Company company)
{
Name = name;
Price = price;
Company =... | In addition to the cool answer from Immorality, I'll place here these links:
1. [Virtual properties](https://stackoverflow.com/questions/8542864/why-use-virtual-for-class-properties-in-entity-framework-model-definitions)
2. [MSDN - Loading related data strategies](https://msdn.microsoft.com/en-us/magazine/hh205756.asp... |
70,274,059 | I want to write unique initials before listing an array of names, so given
const names = ["Bill", "Jack", "john"], I would like to print something like:
```
<ul>
<li>B
<ul>
<li>Bill</li>
</ul>
</li>
<li>J
<ul>
<li>John</li>
<li>jack</li>
<... | 2021/12/08 | [
"https://Stackoverflow.com/questions/70274059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6130262/"
] | Here we go:
```
const names = ['Bill', 'Jack', 'john', 'Alex'];
const groupedNames = names.reduce((accumulator, name) => {
// first char of name, uppercased
const firstLetter = name[0].toUpperCase();
// check if data for key exist
const namesList = accumulator[firstLetter] || [];
// check if name... | You can use this::
```
const names = ['Bill', 'John', 'bob', 'Jack'];
const category = names.reduce((unique, name) => {
const char = name.charAt(0).toUpperCase();
return (unique[char] ? { ...unique, [char]: [...unique[char], name] } : { ...unique, [char]: [name] });
}, {});
return (
... |
39,492,631 | I am doing a little code for my programming class and we need to make a program that calculates the cost of building a desk. I need help changing my DrawerAmount to an integer, not a string!
```
def Drawers():
print("How many drawers are there?")
DrawerAmount = input(int)
print("Okay, I accept that the total amount of... | 2016/09/14 | [
"https://Stackoverflow.com/questions/39492631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6831132/"
] | >
> I need help changing my DrawerAmount to an integer, not a string!
>
>
>
Try this:
```
v = int(DrawerAmount)
``` | ```
def Drawers():
draweramount = input("How many drawers are there?")
print("Okay, I accept that the total amount of drawers is " + draweramount + ".")
return int(draweramount)
def Desk():
desktype = input("What type of wood is your desk?")
print("Alright, your desk is made of " + desktype + "... |
9,060,217 | I have a iPhone app and want to develop iPad app with the same name. I want to design different UI for ipad app including new features. So my question is, Will i have to make changes in iPhone app for iPad or need to create another new app for iPad ? Note: Name of both app will be same. Please explain how should i perf... | 2012/01/30 | [
"https://Stackoverflow.com/questions/9060217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1177466/"
] | What you describe is perfectly possible with [universal apps](http://developer.apple.com/library/ios/ipad/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html). You will have to maintain to completely different hierachies of NIBs/Storyboards for your UI though. Controllers ... | Here is a [tutorial](http://www.slideshare.net/cliffmcc/creating-a-universal-ios-application) for creating universal app(both for iPad and iPhone). Go through it |
9,060,217 | I have a iPhone app and want to develop iPad app with the same name. I want to design different UI for ipad app including new features. So my question is, Will i have to make changes in iPhone app for iPad or need to create another new app for iPad ? Note: Name of both app will be same. Please explain how should i perf... | 2012/01/30 | [
"https://Stackoverflow.com/questions/9060217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1177466/"
] | What you describe is perfectly possible with [universal apps](http://developer.apple.com/library/ios/ipad/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html). You will have to maintain to completely different hierachies of NIBs/Storyboards for your UI though. Controllers ... | You can use same app for iPad but you have make different UI for iPad as size of iPhone and iPad screen is different but controllers and modal classes will remain same. |
34,214,860 | I have an unordered\_map with key as ULONG.
I know that there can be a huge number of entries but not sure how many. So can't specify the bucket count before hand. I was expecting the time complexity for inserts to be O(1) since the keys are unique. But it seems like the inserts are taking very long time.
I've read... | 2015/12/11 | [
"https://Stackoverflow.com/questions/34214860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5666874/"
] | Couple of things that might help:
1. You can actually compute when a rehash will take place and work out if that is the issue. From [cplusplus.com](http://www.cplusplus.com/reference/unordered_map/unordered_map/insert/):
"A rehash is forced if the new container size after the insertion operation would increase above ... | Between [`max_load_factor`](http://www.cplusplus.com/reference/unordered_map/unordered_map/max_load_factor/) and preemptively calling [`reserve`](http://www.cplusplus.com/reference/unordered_map/unordered_map/reserve/), you should be able to both minimize rehashing, and minimize bucket collisions. Getting the balance r... |
34,214,860 | I have an unordered\_map with key as ULONG.
I know that there can be a huge number of entries but not sure how many. So can't specify the bucket count before hand. I was expecting the time complexity for inserts to be O(1) since the keys are unique. But it seems like the inserts are taking very long time.
I've read... | 2015/12/11 | [
"https://Stackoverflow.com/questions/34214860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5666874/"
] | Couple of things that might help:
1. You can actually compute when a rehash will take place and work out if that is the issue. From [cplusplus.com](http://www.cplusplus.com/reference/unordered_map/unordered_map/insert/):
"A rehash is forced if the new container size after the insertion operation would increase above ... | For a start, many Standard Library implementations hash integers with an identity function, i.e. `hash(x) == x`. This is usually ok, especially if the implementation ensures the bucket count is prime (e.g. GCC), but some implementations use power-of-two bucket counts (e.g. Visual C++). You could run some numbers throug... |
42,478,576 | I'm programming a game in C# and I'm using a SoA pattern for performance-critical components.
Here's an example:
```
public class ComponentData
{
public int[] Ints;
public float[] Floats;
}
```
Ideally, I'd want other programmers to only specify this data (as above) and be done with it. However, some operat... | 2017/02/27 | [
"https://Stackoverflow.com/questions/42478576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1757253/"
] | The idea was the following:
```
public abstract class ComponentData : BaseData
{
public Collection<Array> ArraysRegister { get; private set; }
public int[] Ints;
public float[] Floats;
public ComponentData()
{
ArraysRegister = new Collection<Array>();
ArraysRegister.Add(this.Ints);
... | I would suggest defining a collection of all arrays used by class and then making all the necessary operations upon all of them in cycle. |
56,785,717 | [](https://i.stack.imgur.com/d34st.png)
I want the icon `details` to point upward like as shown in the image.
but the list of material icon has icon `details` points to downward,
so how can I rotate the material icon in my flutter project, without do... | 2019/06/27 | [
"https://Stackoverflow.com/questions/56785717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5846565/"
] | You can wrap your `IconButton` in a `Transform` widget using the [rotate constructor](https://api.flutter.dev/flutter/widgets/Transform/Transform.rotate.html):
```
import 'dart:math' as math;
Transform.rotate(
angle: 180 * math.pi / 180,
child: IconButton(
icon: Icon(
Icons.details,
color: Colors.... | One solution could be to use the `Transform` widget.
```dart
Column(children: <Widget>[
Container(
height: 48,
decoration: BoxDecoration(
color: Color(0xFFFBBC05),
borderRadius: BorderRadius.circular(48),
boxShadow: [
BoxShadow(
blurRadius: 16,
o... |
56,785,717 | [](https://i.stack.imgur.com/d34st.png)
I want the icon `details` to point upward like as shown in the image.
but the list of material icon has icon `details` points to downward,
so how can I rotate the material icon in my flutter project, without do... | 2019/06/27 | [
"https://Stackoverflow.com/questions/56785717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5846565/"
] | You can wrap your `IconButton` in a `Transform` widget using the [rotate constructor](https://api.flutter.dev/flutter/widgets/Transform/Transform.rotate.html):
```
import 'dart:math' as math;
Transform.rotate(
angle: 180 * math.pi / 180,
child: IconButton(
icon: Icon(
Icons.details,
color: Colors.... | If you want to rotate icons like arrow\_forward\_ios, could help following code.
```
icon: Transform.rotate(
angle: 90 *math.pi /180,
child: Icon(Icons.arrow_forward_ios,
color: Colors.white,size: 18,),,
``` |
56,785,717 | [](https://i.stack.imgur.com/d34st.png)
I want the icon `details` to point upward like as shown in the image.
but the list of material icon has icon `details` points to downward,
so how can I rotate the material icon in my flutter project, without do... | 2019/06/27 | [
"https://Stackoverflow.com/questions/56785717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5846565/"
] | ```
Transform.rotate(
angle: 180 * pi / 180,
child: IconButton(
icon: Icon(
Icons.details,
color: Colors.white,
),
onPressed: null,
),
),
``` | One solution could be to use the `Transform` widget.
```dart
Column(children: <Widget>[
Container(
height: 48,
decoration: BoxDecoration(
color: Color(0xFFFBBC05),
borderRadius: BorderRadius.circular(48),
boxShadow: [
BoxShadow(
blurRadius: 16,
o... |
56,785,717 | [](https://i.stack.imgur.com/d34st.png)
I want the icon `details` to point upward like as shown in the image.
but the list of material icon has icon `details` points to downward,
so how can I rotate the material icon in my flutter project, without do... | 2019/06/27 | [
"https://Stackoverflow.com/questions/56785717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5846565/"
] | Another solution is:
```dart
RotatedBox(
quarterTurns: 2,
child: IconButton(
icon: Icon(
Icons.details,
color: Colors.white,
),
onPressed: null,
),
),
``` | One solution could be to use the `Transform` widget.
```dart
Column(children: <Widget>[
Container(
height: 48,
decoration: BoxDecoration(
color: Color(0xFFFBBC05),
borderRadius: BorderRadius.circular(48),
boxShadow: [
BoxShadow(
blurRadius: 16,
o... |
56,785,717 | [](https://i.stack.imgur.com/d34st.png)
I want the icon `details` to point upward like as shown in the image.
but the list of material icon has icon `details` points to downward,
so how can I rotate the material icon in my flutter project, without do... | 2019/06/27 | [
"https://Stackoverflow.com/questions/56785717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5846565/"
] | ```
Transform.rotate(
angle: 180 * pi / 180,
child: IconButton(
icon: Icon(
Icons.details,
color: Colors.white,
),
onPressed: null,
),
),
``` | If you want to rotate icons like arrow\_forward\_ios, could help following code.
```
icon: Transform.rotate(
angle: 90 *math.pi /180,
child: Icon(Icons.arrow_forward_ios,
color: Colors.white,size: 18,),,
``` |
56,785,717 | [](https://i.stack.imgur.com/d34st.png)
I want the icon `details` to point upward like as shown in the image.
but the list of material icon has icon `details` points to downward,
so how can I rotate the material icon in my flutter project, without do... | 2019/06/27 | [
"https://Stackoverflow.com/questions/56785717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5846565/"
] | Another solution is:
```dart
RotatedBox(
quarterTurns: 2,
child: IconButton(
icon: Icon(
Icons.details,
color: Colors.white,
),
onPressed: null,
),
),
``` | If you want to rotate icons like arrow\_forward\_ios, could help following code.
```
icon: Transform.rotate(
angle: 90 *math.pi /180,
child: Icon(Icons.arrow_forward_ios,
color: Colors.white,size: 18,),,
``` |
6,878,776 | What's the difference between using XS and the Inline::C module? This was mentioned by someone in [this](https://stackoverflow.com/questions/6684351/when-should-you-use-xs) question and has made me curious. | 2011/07/29 | [
"https://Stackoverflow.com/questions/6878776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/474819/"
] | Inline::C generates XS and builds the generated module. It does this at run-time, although it caches past builds.
Inline::C is possibly easier to use, but there are a few downsides. The first time it runs, it slows down startup, it requires permissions to create files at run-time, and it requires the tools to compile ... | Inline compiles the C code at the same time when your Perl is compiled, and will be recompiled every time your source code is changed. XS is compiled once and the binary is saved as a .so file like a library.
Perl is written in C so XS uses the native Perl types and subroutine mechanisms. A module using XS runs almost... |
29,946,831 | I guess this question is geared more towards the language-geeks.
I have the following class:
```
<?php
abstract class ScopeFactory
{
public static function doStuff()
{
}
}
```
Now, I'm able to call this function, like so:
`ScopeFactory::doStuff()`
And this works happily. I've always coded under the ... | 2015/04/29 | [
"https://Stackoverflow.com/questions/29946831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/385265/"
] | Static methods in OOP do not change internal state, therefore you can call static methods from an abstract class. | I would be surprised if this wouldn't be allowed. Abstract class assumes you cannot instantiate it. As static methods don't need a class instance, you can happily use them.
Looking deeper, you could create an abstract static method and call it from your non-abstract method:
```
abstract class ScopeFactory
{
publi... |
22,531,961 | ```
public class DetailsActivity extends Activity {
private ArrayAdapter<Imageclass> adapter;
ArrayList<String> imageselect = new ArrayList<String>();
private ArrayList<Imageclass> array1;
private ArrayList<Imageclass> list = new ArrayList<Imageclass>();
//private ArrayList<Imageclass> array;
ArrayList<String> imagete... | 2014/03/20 | [
"https://Stackoverflow.com/questions/22531961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2231384/"
] | whatever i understood from this you want to execute your ImageDownload thread after the task thread,so start the ImageDownload Thread from the onPostExecute() of your task thread | When executing an async task a new thread is started, but your current thread keeps running. It immediately runs into your thread.sleep(1000) just after starting test.async.
It looks like your doing some internet downloading in test.async, and as you might have guessed, it takes longer than 1000 milliseconds (1 second... |
22,531,961 | ```
public class DetailsActivity extends Activity {
private ArrayAdapter<Imageclass> adapter;
ArrayList<String> imageselect = new ArrayList<String>();
private ArrayList<Imageclass> array1;
private ArrayList<Imageclass> list = new ArrayList<Imageclass>();
//private ArrayList<Imageclass> array;
ArrayList<String> imagete... | 2014/03/20 | [
"https://Stackoverflow.com/questions/22531961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2231384/"
] | whatever i understood from this you want to execute your ImageDownload thread after the task thread,so start the ImageDownload Thread from the onPostExecute() of your task thread | Have a look here, This Help me for same..Pass your url to `GetTemplateImageController` and get the result in `Bitmap` array
GetTemplateImageController Class:
```
public class GetTemplateImageController extends AsyncTask<String, Void, Bitmap[]>
{
Context mcontext;
private ProgressDialog pDialog;
... |
22,531,961 | ```
public class DetailsActivity extends Activity {
private ArrayAdapter<Imageclass> adapter;
ArrayList<String> imageselect = new ArrayList<String>();
private ArrayList<Imageclass> array1;
private ArrayList<Imageclass> list = new ArrayList<Imageclass>();
//private ArrayList<Imageclass> array;
ArrayList<String> imagete... | 2014/03/20 | [
"https://Stackoverflow.com/questions/22531961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2231384/"
] | Over time there have been several changes to the way Android deals with AsyncTasks that run concurrently. In very old Android versions (pre-1.6 afaik) multiple AsyncTasks were executed in sequence. That behavior has been changed to run the AsyncTasks in parallel up until Android 2.3. Beginning with Android 3.0 the the ... | When executing an async task a new thread is started, but your current thread keeps running. It immediately runs into your thread.sleep(1000) just after starting test.async.
It looks like your doing some internet downloading in test.async, and as you might have guessed, it takes longer than 1000 milliseconds (1 second... |
22,531,961 | ```
public class DetailsActivity extends Activity {
private ArrayAdapter<Imageclass> adapter;
ArrayList<String> imageselect = new ArrayList<String>();
private ArrayList<Imageclass> array1;
private ArrayList<Imageclass> list = new ArrayList<Imageclass>();
//private ArrayList<Imageclass> array;
ArrayList<String> imagete... | 2014/03/20 | [
"https://Stackoverflow.com/questions/22531961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2231384/"
] | Over time there have been several changes to the way Android deals with AsyncTasks that run concurrently. In very old Android versions (pre-1.6 afaik) multiple AsyncTasks were executed in sequence. That behavior has been changed to run the AsyncTasks in parallel up until Android 2.3. Beginning with Android 3.0 the the ... | Have a look here, This Help me for same..Pass your url to `GetTemplateImageController` and get the result in `Bitmap` array
GetTemplateImageController Class:
```
public class GetTemplateImageController extends AsyncTask<String, Void, Bitmap[]>
{
Context mcontext;
private ProgressDialog pDialog;
... |
15,644,353 | I have a database access, and one of this field is double-precision.
Normally if i set in the textbox 1.71 or 1,71 the field in database should contain 1.71.
But if i execute query the value of acces'field is 171 !!.
```
public const string QUERY =
@"UPDATE TBLART
SET TBLART.COST = @cost
... | 2013/03/26 | [
"https://Stackoverflow.com/questions/15644353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2204958/"
] | `double.Parse` will use the current thread's culture by default. I *suspect* your current culture uses "." as a grouping separator.
Two options:
* Continue to use `Replace` as you are already doing, but then specify `CultureInfo.InvariantCulture` when parsing
* Remove the replacement, and just use the current thread'... | If I remember correctly in windows forms you can bind an double property to a textbox and it will automatically take care of parsing and converting. You should not manually do parsing from string to double.
That problem is already solved fro you by the .NET framework.
Another suggestion, your data access code should ... |
1,590,898 | For Christmas my family have been playing a card game called [Wordaround](http://thinkfun.com/products/wordaround/). The rules are irrelevant here, other than the fact that each card has $3$ words printed on it and there are $100$ cards. In each "game" of Wordaround, we use exactly one word from each of the $100$ cards... | 2015/12/27 | [
"https://math.stackexchange.com/questions/1590898",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/252983/"
] | The first answer has correct reasoning, as well. Your doubt stems from the (true) fact that the survival of one word is not independent from survival of another on the same card. But expectation values are additive, even when the underlying variables are not independent. | Both are valid ways to get the answer. A valid justification for the first method goes as follows:
For each of the 300 words ($1 \leq i \leq 300$), let $X\_{i,n}$ be the random variable which is $1$ if the $i$-th word has never been chosen after $n$ games, and $0$ otherwise.
As you stated, $E(X\_{i,n}) =\text{Pr}(X\_{... |
24,297,726 | im trying to write a program which create a new text file with asp.
it is giving Microsoft VBScript runtime error '800a0035'. However when I change the file for the line
```
Set f=fs.GetFile("c:\vie4.txt")
```
to an existing file it does not give this error.
>
> Hello !
>
>
> Welcome to my Web site!
>
>
> Micr... | 2014/06/19 | [
"https://Stackoverflow.com/questions/24297726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2439070/"
] | When in doubt, read the [documentation](http://msdn.microsoft.com/en-us/library/sheydkke%28v=vs.84%29.aspx). `GetFile` doesn't create files. Use [`CreateTextFile`](http://msdn.microsoft.com/en-us/library/5t9b5c0c%28v=vs.84%29.aspx) for that:
```
...
filename = "c:\vie4.txt"
If Not fs.FileExists(filename) Then fs.Creat... | ```html
Table1.Rows.Clear();
List<Knjiga> knjige = new List<Knjiga>();
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("biblioteka.xml"));
foreach (XmlElement el in doc.GetElementsByTagName("knjiga"))
{
knjige.Add(new Kn... |
3,858,377 | Here is the question:
A rectangular prism has a volume of $720$ cm$^3$ and a surface area of $666$ cm$^2$. If the lengths of all its edges are integers, what is the length of the longest edge?
This is from a previously timed competition. Quick answers will be the most helpful.
You can set up equations and use Vieta's... | 2020/10/09 | [
"https://math.stackexchange.com/questions/3858377",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/807252/"
] | We have $$xyz=720$$ and $$xy+xz+yz=333,$$ where $x$, $y$ and $z$ are naturals.
Now, let $x\geq y\geq z$.
Thus, $$720\geq z^3,$$ which gives $$1\leq z\leq8$$ and $z=3$ is valid, which gives $x=16$ and $y=15.$ | Factorize $720$ as a product of three factors, then pairwise, their products sum to $333$. Once you see this, you know that two of the factors must be odd.
From trial and error, I get the longest side to be $16$, with the other two sides being $3$ and $15$. Verifying:
$$3\times15\times16=720,\qquad 2\times(3\times15+... |
5,713,276 | I have a function in PHP that retrieves all the directories and files from a given path. This returns me an array like:
```
array(
"dirname1" => array(
"dirname2" => array(
"dirname3" => array(
"0" => "file1",
"1" => "file2",
"2" => "file3"
... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5713276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/569908/"
] | While I like the DBC idea, AOP is the wrong weapon for this task in my opinion.
Aspects need special infrastructure complicating your build process
Aspects enforcing contracts need to run in production code, with the risk of actually introducing bugs instead of preventing them.
Aspects do not provide any compile tim... | Look at [Contract4j](http://www.polyglotprogramming.com/contract4j) which uses AspectJ to inforce DBC. |
5,713,276 | I have a function in PHP that retrieves all the directories and files from a given path. This returns me an array like:
```
array(
"dirname1" => array(
"dirname2" => array(
"dirname3" => array(
"0" => "file1",
"1" => "file2",
"2" => "file3"
... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5713276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/569908/"
] | C# (actually .NET) supports DBC using the [Code Contracts](http://msdn.microsoft.com/en-us/devlabs/dd491992) framework and tooling.
It provides an API for declaring your pre-, post- and invariant conditions, plus the ability to perform runtime checks, static checks and generate documentation.
The framework is built-i... | Look at [Contract4j](http://www.polyglotprogramming.com/contract4j) which uses AspectJ to inforce DBC. |
4,446,331 | In Shiryaev's book *problems in probability*, an upper bound for binomial coefficients is shown in section 1.2.1:
$$\binom{m+n}{n}\le(1+m/n)^n(1+n/m)^m.$$
It seems that this bound is sharper than the well known result that $\binom{n}{k}\le (ne/k)^k$ because $(1+n/m)^m = (1+m/n)^{(m/n)n} < e^n$.
Could anyone tell me ho... | 2022/05/09 | [
"https://math.stackexchange.com/questions/4446331",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1055875/"
] | If you multiply the inequality by $n^nm^m$, the RHS can be expanded with the binomial theorem, and the LHS will be but one of the terms of the resulting sum. | *If you want a tighter bound.*
Using my answer [here](https://math.stackexchange.com/questions/4434203/the-lower-bound-about-the-binomial-coefficient/4434415#4434415)
$$\binom{m+n}{n}\le \frac{1}{\sqrt{2 \pi }}\sqrt{\frac{1}{m}+\frac{1}{n}}\,\frac{(m+n)^{m+n} }{m^m\, n^n }$$ Comparing
$$\frac{\frac{1}{\sqrt{2 \pi }}... |
381,242 | I'd like to know how to configure Apache 2 to specify the same error documents for both 403 (Forbidden) and 404 (Page Not Found) responses. I assume there is a directive to add to httpd.conf, but not sure what it is.
Most of the tutorials I see for doing this are based around .htaccess files, but I want to set this di... | 2012/04/19 | [
"https://serverfault.com/questions/381242",
"https://serverfault.com",
"https://serverfault.com/users/93209/"
] | Add in a block like:
```
ErrorDocument 403 /40x.html
ErrorDocument 404 /40x.html
```
into the server or virtualhost configuration.
Here's the relevant section of the documentation:
<http://httpd.apache.org/docs/2.2/mod/core.html#errordocument> | You can set this globally in httpd.conf with the [ErrorDocument](http://httpd.apache.org/docs/2.0/mod/core.html#errordocument) directive
```
ErrorDocument 404 /error.html
ErrorDocument 403 /error.html
``` |
62,282,625 | I have a Vue application which communicates with API (using axios requests) and return error(s).
It works fine if I get only one error, for example when response is like this: `{"error":"passwords.token"}`
When i'm getting cumulated errors like this:
```
{"message":"The given data was invalid.",
"errors":{
"pass... | 2020/06/09 | [
"https://Stackoverflow.com/questions/62282625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4276819/"
] | What your are literally trying to do, introducing arbitrary scopes for types, can be accomplished via a *TypeScript* namespace.
```
declare namespace myNamespace {
type IntermediaryType = {
decisiveKey: true,
mutatedKey: (params: any) => void,
} | {
decisiveKey: false,
mutatedKey?: false,
}
in... | I'm not sure about your preface
>
> due to it's complexity, this type required the declaration of intermediary types
>
>
>
this compiles
```
type FinalType = (
| {
decisiveKey: true;
mutatedKey: (params: any) => void;
}
| {
decisiveKey: false;
mutatedKey?: false;
}
) & {
foo... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | If the php files you want to include are PHP classes, then you should use [PHP Autoloader](http://php.net/manual/en/language.oop5.autoload.php)
It's not a safe practice to include all php files in all directories automatically. Performance might be degraded if you're including unnecessary files.
Here's the code that ... | One that I use is
```
function fileLoader($dir) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file == '.' || $file == '..') {
continue;
}
$path = $dir . '/' . $file;
if (is_dir($path)) {
__DIR__.$path;
} else {
require_onc... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | Well, if you want to include all php files with a certain ending even in subdirectories, you have to make a recursive function. Something like this:
```
function load_classphp($directory) {
if(is_dir($directory)) {
$scan = scandir($directory);
unset($scan[0], $scan[1]); //unset . and ..
for... | If the php files you want to include are PHP classes, then you should use [PHP Autoloader](http://php.net/manual/en/language.oop5.autoload.php)
It's not a safe practice to include all php files in all directories automatically. Performance might be degraded if you're including unnecessary files.
Here's the code that ... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | This is probably the simplest way to recursively find patterned files:
```
$dir = new RecursiveDirectoryIterator('classes/');
$iter = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($iter, '/^.+\.class\.php$/', RecursiveRegexIterator::GET_MATCH); // an Iterator, not an array
foreach ( $files as $file ... | ```
function autoload( $path ) {
$items = glob( $path . DIRECTORY_SEPARATOR . "*" );
foreach( $items as $item ) {
$isPhp = pathinfo( $item )["extension"] === "php";
if ( is_file( $item ) && $isPhp ) {
require_once $item;
} elseif ( is_dir( $item ) ) {
autoload( ... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | Well, if you want to include all php files with a certain ending even in subdirectories, you have to make a recursive function. Something like this:
```
function load_classphp($directory) {
if(is_dir($directory)) {
$scan = scandir($directory);
unset($scan[0], $scan[1]); //unset . and ..
for... | An easy way : a simple function using `RecursiveDirectoryIterator` instead of `glob()`.
```
function include_dir_r( $dir_path ) {
$path = realpath( $dir_path );
$objects = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path ), \RecursiveIteratorIterator::SELF_FIRST );
foreach( $objects a... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | This is probably the simplest way to recursively find patterned files:
```
$dir = new RecursiveDirectoryIterator('classes/');
$iter = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($iter, '/^.+\.class\.php$/', RecursiveRegexIterator::GET_MATCH); // an Iterator, not an array
foreach ( $files as $file ... | One that I use is
```
function fileLoader($dir) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file == '.' || $file == '..') {
continue;
}
$path = $dir . '/' . $file;
if (is_dir($path)) {
__DIR__.$path;
} else {
require_onc... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | Well, if you want to include all php files with a certain ending even in subdirectories, you have to make a recursive function. Something like this:
```
function load_classphp($directory) {
if(is_dir($directory)) {
$scan = scandir($directory);
unset($scan[0], $scan[1]); //unset . and ..
for... | ```
$dir = new RecursiveDirectoryIterator('change this to your custom root directory');
foreach (new RecursiveIteratorIterator($dir) as $file) {
if (!is_dir($file)) {
if( fnmatch('*.php', $file) ) // you can change the file extension to any that you require.
/* do anything here */
}
}
``` |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | Well, if you want to include all php files with a certain ending even in subdirectories, you have to make a recursive function. Something like this:
```
function load_classphp($directory) {
if(is_dir($directory)) {
$scan = scandir($directory);
unset($scan[0], $scan[1]); //unset . and ..
for... | This is probably the simplest way to recursively find patterned files:
```
$dir = new RecursiveDirectoryIterator('classes/');
$iter = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($iter, '/^.+\.class\.php$/', RecursiveRegexIterator::GET_MATCH); // an Iterator, not an array
foreach ( $files as $file ... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | This is probably the simplest way to recursively find patterned files:
```
$dir = new RecursiveDirectoryIterator('classes/');
$iter = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($iter, '/^.+\.class\.php$/', RecursiveRegexIterator::GET_MATCH); // an Iterator, not an array
foreach ( $files as $file ... | An easy way : a simple function using `RecursiveDirectoryIterator` instead of `glob()`.
```
function include_dir_r( $dir_path ) {
$path = realpath( $dir_path );
$objects = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path ), \RecursiveIteratorIterator::SELF_FIRST );
foreach( $objects a... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | ```
$dir = new RecursiveDirectoryIterator('change this to your custom root directory');
foreach (new RecursiveIteratorIterator($dir) as $file) {
if (!is_dir($file)) {
if( fnmatch('*.php', $file) ) // you can change the file extension to any that you require.
/* do anything here */
}
}
``` | An easy way : a simple function using `RecursiveDirectoryIterator` instead of `glob()`.
```
function include_dir_r( $dir_path ) {
$path = realpath( $dir_path );
$objects = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path ), \RecursiveIteratorIterator::SELF_FIRST );
foreach( $objects a... |
25,339,838 | I would like to automatically `include/require` all `.php` files under all directories. For example:
(Directory structure)
```
-[ classes
--[ loader (directory)
---[ plugin.class.php
--[ main.class.php
--[ database.class.php
```
I need a function that automatically loads all files that end in `.... | 2014/08/16 | [
"https://Stackoverflow.com/questions/25339838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3947035/"
] | This is probably the simplest way to recursively find patterned files:
```
$dir = new RecursiveDirectoryIterator('classes/');
$iter = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($iter, '/^.+\.class\.php$/', RecursiveRegexIterator::GET_MATCH); // an Iterator, not an array
foreach ( $files as $file ... | ```
$dir = new RecursiveDirectoryIterator('change this to your custom root directory');
foreach (new RecursiveIteratorIterator($dir) as $file) {
if (!is_dir($file)) {
if( fnmatch('*.php', $file) ) // you can change the file extension to any that you require.
/* do anything here */
}
}
``` |
37,219,313 | Given the following object:
```
scala> object P2pClient {
| type Num = Double
| type Weights = Array[Array[Num]]
| }
defined object P2pClient
```
and the following import:
```
import P2pClient._
```
The `Weights` type *seems* to be properly understood:
```
val w: Weights = new Weights(3)
w: P... | 2016/05/13 | [
"https://Stackoverflow.com/questions/37219313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1056563/"
] | I see the issue is due to my using the **Spark** REPL `spark-shell`. The issue is not happening in the normal Scala REPL. | Good news: your code works! Bad news: I have no idea why it doesn't work for you.
Here is my REPL session; I was going to build up to your example and see what broke, but nothing did.
```
scala> object P2pClient { type Num = Int; type Weights = Array[Array[Num]] }
defined object P2pClient
scala> import P2pClient._
i... |
15,293,529 | call a function continuously in c# console application. without using infinite loop and recursion because if use those then cpu usage is more.please can any one help me to solve this problem.some one suggest me to use background thread, but it doesn't call the function continuously.
```
Thread th = new Thread(//fun);
... | 2013/03/08 | [
"https://Stackoverflow.com/questions/15293529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138896/"
] | You can not use join on update and delete queries. You have to use subqueries.
>
> Joins are not supported on update and delete queries because it is not
> supported on all dbms. It won't be implemented in Doctrine 1 or
> Doctrine 2. You can however get the same affect by using subqueries.
>
>
>
<http://www.doc... | Doctrine DQL does not support join in update.
Try doing the following :
```
$qb = $this->getEntityManager()->createQueryBuilder();
$qb
->update('MyBundle:Entity1', 'e1')
->set('e1.visibile', '1')
->where('e1.Entity2 = :id')
->setParameter("id", 123)
;
```
You can set the id, as long as it is the pr... |
15,293,529 | call a function continuously in c# console application. without using infinite loop and recursion because if use those then cpu usage is more.please can any one help me to solve this problem.some one suggest me to use background thread, but it doesn't call the function continuously.
```
Thread th = new Thread(//fun);
... | 2013/03/08 | [
"https://Stackoverflow.com/questions/15293529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138896/"
] | You can not use join on update and delete queries. You have to use subqueries.
>
> Joins are not supported on update and delete queries because it is not
> supported on all dbms. It won't be implemented in Doctrine 1 or
> Doctrine 2. You can however get the same affect by using subqueries.
>
>
>
<http://www.doc... | try using a subquery instead [Join will not work in DQL while you re doing an update](https://stackoverflow.com/a/5598894/1427338):
>
> LEFT JOIN, or JOINs in particular are only supported in UPDATE
> statements of MySQL. DQL abstracts a subset of common ansi sql, so
> this is not possible. Try with a subselect:
> ... |
15,293,529 | call a function continuously in c# console application. without using infinite loop and recursion because if use those then cpu usage is more.please can any one help me to solve this problem.some one suggest me to use background thread, but it doesn't call the function continuously.
```
Thread th = new Thread(//fun);
... | 2013/03/08 | [
"https://Stackoverflow.com/questions/15293529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138896/"
] | You can not use join on update and delete queries. You have to use subqueries.
>
> Joins are not supported on update and delete queries because it is not
> supported on all dbms. It won't be implemented in Doctrine 1 or
> Doctrine 2. You can however get the same affect by using subqueries.
>
>
>
<http://www.doc... | Very old question, but do not contain an answer in full query builder.
So yes, the following query is not possible to sync fields of two tables:
```
$this->createQueryBuilder('v')
->update()
->join(Pegass::class, 'p', Join::WITH, 'v.identifier = p.identifier')
->set('v.enabled', 'p.enabled')
->where('... |
35,754,539 | How can we know that which type of linker(static/dynamic) our system is using?
Is it decided on type of library(static/dynamic) we have used or is there any other thing? | 2016/03/02 | [
"https://Stackoverflow.com/questions/35754539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3765130/"
] | You have to write a nested loop to find that,
```
var keys = Object.keys(answers);
var dupe = false;
for(var i=0;i<keys.length;i++){
for(var j=i+1;j<keys.length;j++){
if(answers[keys[i]] === answers[keys[j]]){
dupe = true;
break;
}
}
if(dupe){ console.log("dupe value is there.."); break; }
}
```
... | I guess you mean duplicate values and not duplicate key/value pairs. This is how I'd do it:
```
function findDuplicateValues(input) {
var values = {},
key;
for (key in input) {
if (input.hasOwnProperty(key)) {
values[input[key]] = values.hasOwnProperty(input[key]) ? values[input[ke... |
24,497,337 | I've a javascript function `setErrorImages()`, which searches all `img` tags and and gives them an `onerror` function. This works great.
I also have a division `content` with dynamic content by calling de `jquery .load` function like this, which also works:
```
$("#content").load("http://example.com/otherpage.php");
... | 2014/06/30 | [
"https://Stackoverflow.com/questions/24497337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2970516/"
] | ```
$("#content").load("http://example.com/otherpage.php", setErrorImages);
```
**.load()** accepts a "complete" parameter:
>
> A callback function that is executed when the request completes.
>
>
> | Firstly, I suggest using the `this` context instead of a parameter for your error handler:
```
function setErrorImage() {
this.onerror = null;
this.src = 'http://tanuri.eu/images/error.png';
}
```
Secondly, change `setErrorImages` to use `this` too:
```
function setErrorImages() {
var images = this.getE... |
38,976 | I just started working as a QA Automation Engineer to a certain company which provides ERP and CRM services. However, I recently discovered that they have no test case documentation for the testing they do, and just report bugs. I am now having a hard time to automate their tests because I have no reference, what do yo... | 2019/04/30 | [
"https://sqa.stackexchange.com/questions/38976",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/37425/"
] | Mindmap all the high-level features of the application together with business owners. Go over the map with stakeholders (e.g users, developers, managers, and sponsors). Do a risk assessment with some key people, maybe also analyze brittle areas based on defect reports.
* Write automated happy-path tests for the highe... | You could tackle that from two directions. You could take the bugs and ask the people who opened the bugs how to reproduce them. There is your testcase. You can probably start automating regression tests for these bugs immediately.
Or you could just write the test cases yourself based on the documents and SUT you have... |
38,976 | I just started working as a QA Automation Engineer to a certain company which provides ERP and CRM services. However, I recently discovered that they have no test case documentation for the testing they do, and just report bugs. I am now having a hard time to automate their tests because I have no reference, what do yo... | 2019/04/30 | [
"https://sqa.stackexchange.com/questions/38976",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/37425/"
] | You could tackle that from two directions. You could take the bugs and ask the people who opened the bugs how to reproduce them. There is your testcase. You can probably start automating regression tests for these bugs immediately.
Or you could just write the test cases yourself based on the documents and SUT you have... | Test Automation is not about having or not having test cases, which you can automate. This is about you deciding on **test automation strategy**. I wrote a [blog post](http://testretreat.com/2019/04/15/approach-to-test-automation/), which has several links and ideas where to start. Main idea is that you start with stra... |
38,976 | I just started working as a QA Automation Engineer to a certain company which provides ERP and CRM services. However, I recently discovered that they have no test case documentation for the testing they do, and just report bugs. I am now having a hard time to automate their tests because I have no reference, what do yo... | 2019/04/30 | [
"https://sqa.stackexchange.com/questions/38976",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/37425/"
] | You could tackle that from two directions. You could take the bugs and ask the people who opened the bugs how to reproduce them. There is your testcase. You can probably start automating regression tests for these bugs immediately.
Or you could just write the test cases yourself based on the documents and SUT you have... | As detailed in
<https://sqa.stackexchange.com/a/38917/8992>
* Learn about the domain
* Capture the existing functionality using a tool such as Cucumber or RSpec to document it
* Make real tests described in English
* Create Smoke, Happy and Sad cases |
38,976 | I just started working as a QA Automation Engineer to a certain company which provides ERP and CRM services. However, I recently discovered that they have no test case documentation for the testing they do, and just report bugs. I am now having a hard time to automate their tests because I have no reference, what do yo... | 2019/04/30 | [
"https://sqa.stackexchange.com/questions/38976",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/37425/"
] | Mindmap all the high-level features of the application together with business owners. Go over the map with stakeholders (e.g users, developers, managers, and sponsors). Do a risk assessment with some key people, maybe also analyze brittle areas based on defect reports.
* Write automated happy-path tests for the highe... | Test Automation is not about having or not having test cases, which you can automate. This is about you deciding on **test automation strategy**. I wrote a [blog post](http://testretreat.com/2019/04/15/approach-to-test-automation/), which has several links and ideas where to start. Main idea is that you start with stra... |
38,976 | I just started working as a QA Automation Engineer to a certain company which provides ERP and CRM services. However, I recently discovered that they have no test case documentation for the testing they do, and just report bugs. I am now having a hard time to automate their tests because I have no reference, what do yo... | 2019/04/30 | [
"https://sqa.stackexchange.com/questions/38976",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/37425/"
] | Mindmap all the high-level features of the application together with business owners. Go over the map with stakeholders (e.g users, developers, managers, and sponsors). Do a risk assessment with some key people, maybe also analyze brittle areas based on defect reports.
* Write automated happy-path tests for the highe... | As detailed in
<https://sqa.stackexchange.com/a/38917/8992>
* Learn about the domain
* Capture the existing functionality using a tool such as Cucumber or RSpec to document it
* Make real tests described in English
* Create Smoke, Happy and Sad cases |
61,703,706 | Hello I'm working with an AR Camera and once the camera identifies the anchored image it plays the video. Once the video finishes playing and return back to the camera I view the same anchored image again the video does not play. I want to be able to view the image and play the video as many times as possible.
***Her... | 2020/05/09 | [
"https://Stackoverflow.com/questions/61703706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11235245/"
] | For starters the logic of the function is wrong.
Usually such a function should return `1` (or a positive value) that corresponds to the logical `true` or `0` that corresponds to the logical `false` when it answers to a question like "yes or no".
This call
```
strcmp(string, "OH")
```
returns 0 if two strings are ... | Get the length of the string and check the last two characters.
```
int len = strlen(string);
if(string[len-1] == 'H' && string[len-2] =='O')
return -1;
``` |
61,703,706 | Hello I'm working with an AR Camera and once the camera identifies the anchored image it plays the video. Once the video finishes playing and return back to the camera I view the same anchored image again the video does not play. I want to be able to view the image and play the video as many times as possible.
***Her... | 2020/05/09 | [
"https://Stackoverflow.com/questions/61703706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11235245/"
] | Your function is too complicated and it returns `0` if the suffix is `OH`. A simpler way is to compute the length of the string and if this length is at least 2, compare the last 2 characters with `'O'` and `'H'`:
```c
int hydroxide(const char *string) {
size_t len = strlen(string);
if (len >= 2 && string[len ... | Get the length of the string and check the last two characters.
```
int len = strlen(string);
if(string[len-1] == 'H' && string[len-2] =='O')
return -1;
``` |
61,703,706 | Hello I'm working with an AR Camera and once the camera identifies the anchored image it plays the video. Once the video finishes playing and return back to the camera I view the same anchored image again the video does not play. I want to be able to view the image and play the video as many times as possible.
***Her... | 2020/05/09 | [
"https://Stackoverflow.com/questions/61703706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11235245/"
] | For starters the logic of the function is wrong.
Usually such a function should return `1` (or a positive value) that corresponds to the logical `true` or `0` that corresponds to the logical `false` when it answers to a question like "yes or no".
This call
```
strcmp(string, "OH")
```
returns 0 if two strings are ... | Your function is too complicated and it returns `0` if the suffix is `OH`. A simpler way is to compute the length of the string and if this length is at least 2, compare the last 2 characters with `'O'` and `'H'`:
```c
int hydroxide(const char *string) {
size_t len = strlen(string);
if (len >= 2 && string[len ... |
63,170,801 | So I have this issue
```
//This holds 5 messages submitted prev by the user, temporarily stored
string arrayOfMessages[5];
```
lets say
```
arrayOfMessages[0]="This is my message"//The message in the first position.
```
I need to copy `arrayOfMessages[0]` to an array of `char` like this one;
```
char message [20... | 2020/07/30 | [
"https://Stackoverflow.com/questions/63170801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14020395/"
] | There are many ways of doing it
By using the c\_str() function of the string class
```
string message = "This is my message";
const char *arr;
arr = message.c_str();
```
By copying all the characters from the string to the char array
```
string message = "This is my message";
char arr[200];
for(int i = 0; i < 200 ... | To copy the contents of `std::string` into a `char[]`, use `c_str()`:
```
std::string str = "hello";
char copy[20];
strcpy(copy, str.c_str());
```
But the datatype of `copy` must be only `char*` and not `const char*`. If you want to assign it to a `const char*`, then you can use direct assignment:
```
std::string ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.