qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
sequence | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
35,253,840 | I am building an app which uploads files to the server via ajax.
The problem is that users most likely sometimes won't have the internet connection and client would like to have the ajax call scheduled to time when user have the connection back. This is possible that user will schedule the file upload when he's offline and close the app. Is it possible to do ajax call when the application is closed (not in background)?
When app is in the background, we can use background-fetch but I have never faced a problem to do something when app is closed. | 2016/02/07 | [
"https://Stackoverflow.com/questions/35253840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2008950/"
] | The short answer is no, your app can't run code after being terminated.
You can run code in your `AppDelegate`'s `applicationWillTerminate`, but that method is mainly intended for saving user data and other similar tasks.
See [this answer](https://stackoverflow.com/a/32225247/5389870) also. | I have already answered a similar question:
<https://stackoverflow.com/a/57245917/6157415>
You can implement notification, when user receive notification part of your code can be executed.
in particular there are **Silent Push Notification** to do this:
>
> Sometimes, you may want to use a **Silent Push Notification** to update
> content inside you app in the background. A silent push notification
> is defined as a push that does not have an alert, badge or sound, and
> just has Key-Value data.
>
>
>
From: <https://docs.mobile.sailthru.com/docs/silent-push-notifications> |
35,253,840 | I am building an app which uploads files to the server via ajax.
The problem is that users most likely sometimes won't have the internet connection and client would like to have the ajax call scheduled to time when user have the connection back. This is possible that user will schedule the file upload when he's offline and close the app. Is it possible to do ajax call when the application is closed (not in background)?
When app is in the background, we can use background-fetch but I have never faced a problem to do something when app is closed. | 2016/02/07 | [
"https://Stackoverflow.com/questions/35253840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2008950/"
] | Yes you can do stuff in the background. You are limited to several different background modes of execution. Server communication is one of the modes that is allowed (background fetch). Make sure you set the properties correctly in Xcode per the guidelines (i.e. don't say you are a audio app when you are doing data transfer). See the details here:
<https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html>
I found your question because it has the Cordova tag associated with it. If you are using Cordova you can use this plugin here to manage things in the background:
<https://github.com/katzer/cordova-plugin-background-mode>
Edit: If the user is FORCE closing / terminating the app then there is nothing you can do. If they are just exiting the app to the home screen and use other apps, then you can run in the background.
The other option you can do is schedule a local notification to upload the file. If you app successfully uploads the file because it is open / has a connection / did it in the background, then you cancel the local notification.
If the local notification isn't cancelled it will remind the user the file is not uploaded and when they open the notification your app will start back where it left off. | I have already answered a similar question:
<https://stackoverflow.com/a/57245917/6157415>
You can implement notification, when user receive notification part of your code can be executed.
in particular there are **Silent Push Notification** to do this:
>
> Sometimes, you may want to use a **Silent Push Notification** to update
> content inside you app in the background. A silent push notification
> is defined as a push that does not have an alert, badge or sound, and
> just has Key-Value data.
>
>
>
From: <https://docs.mobile.sailthru.com/docs/silent-push-notifications> |
35,253,840 | I am building an app which uploads files to the server via ajax.
The problem is that users most likely sometimes won't have the internet connection and client would like to have the ajax call scheduled to time when user have the connection back. This is possible that user will schedule the file upload when he's offline and close the app. Is it possible to do ajax call when the application is closed (not in background)?
When app is in the background, we can use background-fetch but I have never faced a problem to do something when app is closed. | 2016/02/07 | [
"https://Stackoverflow.com/questions/35253840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2008950/"
] | ```
- (void)applicationWillTerminate:(UIApplication *)application {
if (application) {
__block UIBackgroundTaskIdentifier backgroundTask = UIBackgroundTaskInvalid;
backgroundTask = [application beginBackgroundTaskWithName:@"MyTask" expirationHandler:^{
backgroundTask = UIBackgroundTaskInvalid;
}];
[self doSomething];
[application endBackgroundTask:backgroundTask];
backgroundTask = UIBackgroundTaskInvalid;
}
}
``` | I have already answered a similar question:
<https://stackoverflow.com/a/57245917/6157415>
You can implement notification, when user receive notification part of your code can be executed.
in particular there are **Silent Push Notification** to do this:
>
> Sometimes, you may want to use a **Silent Push Notification** to update
> content inside you app in the background. A silent push notification
> is defined as a push that does not have an alert, badge or sound, and
> just has Key-Value data.
>
>
>
From: <https://docs.mobile.sailthru.com/docs/silent-push-notifications> |
26,556 | I am wanting to write a chess engine (see here: [Creating chess engine, machine learning vs. traditional engine?](https://chess.stackexchange.com/questions/26489/creating-chess-engine-machine-learning-vs-traditional-engine)). The first step I am doing is taking a position in as an FEN and converting this position into an ideal move. Pseudocode would look something like this:
`Position → Move`
or using notation:
`rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 → e4`
I am trying to create an enumeration of every possible chess move, and I feel that I may be missing some. This includes moves like "e4", "Nxf5", "Bg3+", "Qxh4#", "exf8N#". My total count of unique moves that can be expressed using algebraic notation is **1884**. Can anybody confirm the total number of unique moves that can be expressed using algebraic notation? My full list of moves can be found here: <https://pastebin.com/xDNqbFt2> | 2019/10/08 | [
"https://chess.stackexchange.com/questions/26556",
"https://chess.stackexchange.com",
"https://chess.stackexchange.com/users/19802/"
] | I immediately notice that you've missed the castling moves (O-O and O-O-O).
I would list the pawn-promoting moves according to their PGN syntax (=Q/R/N/B suffix), as that's the most commonly used in computer chess.
Algebraic notation can be ambiguous for sliding and leaping pieces (everything except pawn and king, actually) which may require specifying the origin rank, file, or both. The latter is only needed for queens, bishops and knights, as rooks are always disambiguated by one or the other.
It might be useful to treat the suffix codes indicating whether the move results in check or checkmate as orthogonal to the move itself, since pretty much any move can theoretically have those results. This would effectively divide the number of unique moves you need to handle by three. Conversely, the different promotions of a pawn definitely should be considered as unique moves. | You've got a big list, but you forgot disambiguate moves. N1f3, N1f3+, N1f3#, Qd6d4...
If you want to include all possible Algebraic moves, you need to increase your list at least tenfold. |
988,147 | Can one give an example of an abelian Banach algebra with empty character space? Such algebra must be necessarily non-unital.
I couldn't find any examples of such algebras.
Thanks! | 2014/10/23 | [
"https://math.stackexchange.com/questions/988147",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/186437/"
] | The [Volterra algebra](http://mathworld.wolfram.com/VolterraAlgebra.html) $V$ is an example of a commutative Banach algebra without maximal ideals (hence with empty character space). See also Definition 4.7.38 in
>
> H. G. Dales, *Banach algebras and automatic continuity*, London Math. Soc.
> Monographs, Volume 24, Clarendon Press, Oxford, 2000.
>
>
>
Okay, let me prove this claim. This relies on three facts:
The algebra $V$ has a bounded approximate identity, *e.g.* $(n\cdot \mathbf{1}\_{\big[0, \tfrac{1}{n}\big]})\_{n=1}^\infty$, hence by the [Cohen factorisation theorem](http://en.wikipedia.org/wiki/Cohen%E2%80%93Hewitt_factorization_theorem), $V = V^2$. Consequently, [all maximal ideals of $V$ (if exist) are closed](https://math.stackexchange.com/questions/859247/maximal-ideals-and-maximal-subspaces-of-normed-algebras/863704#863704).
Now apply a result of Dixmier which tells you that no prime ideal of $V$ is closed. Of course, maximal ideals are prime so, the conclusion follows. You will find the proof of Dixmier's result in the above-mentioned book by Dales (Theorem 4.7.58). | A related comment: I think I have an example of a commutative unital complex algebra $A$ without
any nontrivial complex homomorphisms. Take
$A$ to be all rational functions with complex coefficients, that is
$$
A= \{[p/q]: p,q \text{ complex polynomials and }q \text{ not identically } 0\}.
$$
Here $[p/q]$ denotes the equivalence class of $(p,q)$ under the relation
$(p,q)\sim(r,s)$ if $ps=qr$. Then $A$ is a commutative unital complex algebra (which is also a field, and the only maximal ideal is $0$). But there is no nontrivial complex homomorphism $\varphi:A \rightarrow \mathbb{C}$, because if $\varphi(z)=\alpha$, then
$$
\varphi\Big(\frac{1}{z-\alpha}\Big)=\frac{1}{\varphi(z-\alpha)}=\frac{1}{0},
$$
a contradiction. |
59,699,155 | Now I started studying Angular, I was doing a simple exercise, but I had a giant doubt.
I have two components (Navbar and app), in navbar I present one that returns me the value 5. In the component app, by clicking the EXECUTE button, I want the value displayed in Navbar to 4 (-1). Is there a way to do this or make an event emitter that I pressed the EXECUTE button on the app component and thus perform a function on the navbar that allows me to reduce the number 5 to 4?
Thank you !
**[DEMO](https://stackblitz.com/edit/angular-vc5ndg?file=src%2Fapp%2Fnavbar%2Fnavbar.component.ts)**
**Navbar component**
```
total:any;
number = 5;
constructor() { }
ngOnInit() {
this.GetNumber();
}
GetNumber(){
this.total = this.number - 1;
}
``` | 2020/01/11 | [
"https://Stackoverflow.com/questions/59699155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12696698/"
] | In your case, the "button" and the component are in the same .html -and in the same `<router-outlet></router-outlet>` you only need a [template reference variable](https://angular.io/guide/template-syntax#template-reference-variables-var)
```
<app-navbar #navbar></app-navbar>
<p>My APP COMPONENT</p>
<button (click)="getNumber(navbar)">Execute Function</button>
```
Your getNumber function has access to all the properties or functions of your navbar,e.g.
```
getNumber(navbar:any){
navbar.getNumber()
console.log(navbar.number)
}
```
(\*)NOTE: I use the recomender notation to named functions using camelCase and only use a named in Capitalize when we defined a Class
If you use a service, you need inject in constructor of the two components the service, see [interaction using a service](https://angular.io/guide/component-interaction#parent-and-children-communicate-via-a-service), The idea using a service is that one component call a method of service that emit a value and in the other component we subscribe to the service to get the value emited, see [SO answer](https://stackoverflow.com/questions/40788458/how-to-call-component-method-from-service-angular2/57669031#57669031) | It depends on the structure of your program
If they're sibling components (meaning they're instanced in the same HTML, in this case requiring a 3rd component) the best way to do this would be to use a Service with an Observable.
If there exists a parent-child relationship (one of the components instances the other one in the HTML), then you could make use of [EventEmitter](https://angular.io/api/core/EventEmitter) or [ViewChild](https://angular.io/api/core/ViewChild) |
83,697 | Everybody needs a leisure activity. Most of the books I need for mine are downstairs, with none in the bedroom. But as I like to keep an eye on things I have this (unsorted) pile by my bed to remind me.
**What's my hobby?**
[](https://i.stack.imgur.com/KfTm8.jpg)
**Hint 1**
>
> Did you notice the hint in the question?
>
>
>
**Hint 2**
>
> Don't worry too much about the knowledge tag. You don't need any external knowledge at all to work out the answer, and once you have it you should be able to validate it with minimal research.
>
>
>
**Hint 3**
>
> No anagrams were used in the making of this puzzle. And it's nothing to do with beds or bedrooms.
>
>
> | 2019/05/06 | [
"https://puzzling.stackexchange.com/questions/83697",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/58787/"
] | Your hobby is
>
> **birdwatching** (hinted by the word "hobby" and the reference to "keeping an eye on things").
>
>
>
We have:
>
> The Four **Feathers**
>
> What is the name of this book? (published by **Pelican**)
>
> Poems of Matthew **Arnold** -- "Arnold" means something like "strength of the eagle", etymologically.
>
> The Annotated Snark edited by **Martin** Gardner
>
> The Testament of Mary by **Colm** Tóibín -- "Colm" means "dove".
>
> I have Landed by Stephen **Jay** Gould
>
> Life ... by **Robin** Skynner and John Cleese
>
> **Lore** & Language ... -- "lore", among several other meanings, means a particular portion of a bird's head
>
> Life and Times of the Thunderbolt Kid by **Bill** Bryson
>
>
>
Explanations that I proposed, apparently *aren't* the intended ones, but seem worth recording:
>
> Matthew Arnold: one poem is called **Philomena** (= nightingale), and the introduction in that edition is by Sir Arthur **Quiller**-Couch (quiller = not-fully-fledged young bird).
>
> Testament of Mary: I wondered whether it was the **Penguin** edition of that play.
>
> Lore and language...: O**pie** (pie = magpie, near enough), **Peter** (first name of one of the two Opies who wrote the book; it denotes the call of certain birds), and **Iona** (first name of other author), the famous island sharing whose name is strongly associated with St **Columba** (meaning dove).
>
>
> | I think your hobby might be
>
> [Scramblers](https://en.wikipedia.org/wiki/Scrambler)
>
>
>
Reasoning
>
> Take the first letter of the first author name, if shown, otherwise take the last letter of the last name. Then rearrage:
>
> **S** tephen Jay Gould
> **C** olm Tóibín
> **R** aymond Smullyan
> **A** EW Mason
> **M** atthew Arnold
> **B** ill Bryson
> **L** ewis Carroll
> **E** - Opi**e**
> **R** obin Skynner
>
>
>
Additional hint
>
> I think there is an additional hint in the first paragraph where the OP says the pile is "unsorted". This suggests taking an anagram of some sort and that the intended word is actually *scrambled*
>
>
> |
1,687 | Editing a question has the effect of bumping it on top of the front page.
Should we limit the number of edits done on old questions? Bumping forty old questions in the front page has just the effect to hide the newest questions.
I am asking the question because something I observed between today, and yesterday. I am not putting the blame on who is editing questions; I am wondering if we should not schedule those activities, in the same way it has been done in a different SE site. | 2011/07/29 | [
"https://english.meta.stackexchange.com/questions/1687",
"https://english.meta.stackexchange.com",
"https://english.meta.stackexchange.com/users/252/"
] | Are you referring to JSBangs removing a tag from 40 different questions? That's the only thing I see at the moment, scrolling down.
If you need to remove a lot of tags, **you should post a request here on meta,** since developers have the ability to destroy tags without causing revisions.
So the mistake in this case is deciding to manually remove a tag with too many questions. | For me, this brings the related question: **should tag edits really bump questions?** They are most often done either when the question is young, because it was badly tagged by its author (and thus in the top of the list anyway), or on old questions as part of retagging efforts (in which case, do we want to bump it?). |
6,902,467 | In some programming API's I see a list of methods to call, like getBoolean(String key, getDouble(String key), and getString(String key). Some other API's use a general get(String key) method, and return an Object which you are supposed to cast to an appropriate type yourself.
Now I am writing my own data accessing point, and I am wondering which approach to use. What are the advantages and disadvantages of each approach? When would you choose one over the other? | 2011/08/01 | [
"https://Stackoverflow.com/questions/6902467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/789939/"
] | Advantage: getBoolean(), getDouble(), etc. allow you to return the respective primitive types. As far as I've seen, that's the primary reason anyone writes methods like that. | Provide getters for the types that are most likely to be used. There's no real right or wrong way. |
6,902,467 | In some programming API's I see a list of methods to call, like getBoolean(String key, getDouble(String key), and getString(String key). Some other API's use a general get(String key) method, and return an Object which you are supposed to cast to an appropriate type yourself.
Now I am writing my own data accessing point, and I am wondering which approach to use. What are the advantages and disadvantages of each approach? When would you choose one over the other? | 2011/08/01 | [
"https://Stackoverflow.com/questions/6902467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/789939/"
] | Advantage: getBoolean(), getDouble(), etc. allow you to return the respective primitive types. As far as I've seen, that's the primary reason anyone writes methods like that. | It depends on the purpose of the library. When the output is a predictable set of items, then toy can have specific names. As in [ResultSet](http://download.oracle.com/javase/6/docs/api/java/sql/ResultSet.html).
If it is generic, then you will need generic get methods. Like [ObjectOutputStream](http://download.oracle.com/javase/6/docs/api/java/io/ObjectOutputStream.html)
In a very high level sense, you might need both: `getBoolean`, `getDouble`, `getIngeter` for the primitives (or their respective wrappers), a `getString`, for `Strings` and a generic `get` or a `getObject` for getting out objects.
However, this is a very generic answer for a very generic questions. What your tries to do very much decided such stuff. |
6,902,467 | In some programming API's I see a list of methods to call, like getBoolean(String key, getDouble(String key), and getString(String key). Some other API's use a general get(String key) method, and return an Object which you are supposed to cast to an appropriate type yourself.
Now I am writing my own data accessing point, and I am wondering which approach to use. What are the advantages and disadvantages of each approach? When would you choose one over the other? | 2011/08/01 | [
"https://Stackoverflow.com/questions/6902467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/789939/"
] | Advantage: getBoolean(), getDouble(), etc. allow you to return the respective primitive types. As far as I've seen, that's the primary reason anyone writes methods like that. | Two questions:
1) Why don't you use general Properties instead, à là:
```
String getName()
Address getAddress()
Date getDateOfBirth()
```
etc?
2) If you want to use methods like:
```
String getString(String key)
Double getDouble(String key)
Address getAddress(String key)
```
How on earth would I, as the user, know, which key's are associated with objects of type String, which are associated with objects of type Double, etc?
I would recommend going with a solution similar to 1).
If I didn't misunderstand your question, that is. |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | This is easily achievable now (typescript 2.x) with `Object.assign(target, source)`
example:
[](https://i.stack.imgur.com/9EtVw.png)
The magic here is that `Object.assign<T, U>(t: T, u: U)` is typed to return the *intersection* `T & U`.
Enforcing that this resolves to a known interface is also straight-forward. For example:
```
interface Foo {
(a: number, b: string): string[];
foo: string;
}
let method: Foo = Object.assign(
(a: number, b: string) => { return a * a; },
{ foo: 10 }
);
```
which errors due to incompatible typing:
>
> Error: foo:number not assignable to foo:string
>
> Error: number not assignable to string[] (return type)
>
>
>
*caveat: you may need to [polyfill](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) Object.assign if targeting older browsers.* | I can't say that it's very straightforward but it's definitely possible:
```
interface Optional {
<T>(value?: T): OptionalMonad<T>;
empty(): OptionalMonad<any>;
}
const Optional = (<T>(value?: T) => OptionalCreator(value)) as Optional;
Optional.empty = () => OptionalCreator();
```
if you got curious [this is from a gist of mine with the TypeScript/JavaScript version of `Optional`](https://gist.github.com/thiagoh/b3cff3fce3bbadab2231e0e55a74174a) |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | So if the requirement is to simply build and assign that function to "f" without a cast, here is a possible solution:
```
var f: { (): any; someValue: number; };
f = (() => {
var _f : any = function () { };
_f.someValue = 3;
return _f;
})();
```
Essentially, it uses a self executing function literal to "construct" an object that will match that signature before the assignment is done. The only weirdness is that the inner declaration of the function needs to be of type 'any', otherwise the compiler cries that you're assigning to a property which does not exist on the object yet.
EDIT: Simplified the code a bit. | Old question, but for versions of TypeScript starting with 3.1, you can simply do the property assignment as you would in plain JS, as long as you use a function declaration or the `const` keyword for your variable:
```
function f () {}
f.someValue = 3; // fine
const g = function () {};
g.someValue = 3; // also fine
var h = function () {};
h.someValue = 3; // Error: "Property 'someValue' does not exist on type '() => void'"
```
[Reference](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#properties-declarations-on-functions) and [online example](https://www.typescriptlang.org/play/index.html#src=function%20f%20()%20%7B%7D%0D%0Af.someValue%20%3D%203%3B%0D%0Aconst%20g%20%3D%20function%20()%20%7B%7D%3B%0D%0Ag.someValue%20%3D%203%3B%0D%0Avar%20h%20%3D%20function%20()%20%7B%7D%3B%0D%0Ah.someValue%20%3D%203%3B%0D%0A). |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | TypeScript is designed to handle this case through [**declaration merging**](https://www.typescriptlang.org/docs/handbook/declaration-merging.html):
>
> you may also be familiar with JavaScript practice of creating a function and then extending the function further by adding properties onto the function. TypeScript uses declaration merging to build up definitions like this in a type-safe way.
>
>
>
Declaration merging lets us say that something is both a function and a namespace (internal module):
```
function f() { }
namespace f {
export var someValue = 3;
}
```
This preserves typing and lets us write both `f()` and `f.someValue`. When writing a `.d.ts` file for existing JavaScript code, use `declare`:
```
declare function f(): void;
declare namespace f {
export var someValue: number;
}
```
Adding properties to functions is often a confusing or unexpected pattern in TypeScript, so try to avoid it, but it can be necessary when using or converting older JS code. This is one of the only times it would be appropriate to mix internal modules (namespaces) with external. | An updated answer: since the addition of intersection types via `&`, it is possible to "merge" two inferred types on the fly.
Here's a general helper that reads the properties of some object `from` and copies them over an object `onto`. It returns the same object `onto` but with a new type that includes both sets of properties, so correctly describing the runtime behaviour:
```
function merge<T1, T2>(onto: T1, from: T2): T1 & T2 {
Object.keys(from).forEach(key => onto[key] = from[key]);
return onto as T1 & T2;
}
```
This low-level helper does still perform a type-assertion, but it is type-safe by design. With this helper in place, we have an operator that we can use to solve the OP's problem with full type safety:
```
interface Foo {
(message: string): void;
bar(count: number): void;
}
const foo: Foo = merge(
(message: string) => console.log(`message is ${message}`), {
bar(count: number) {
console.log(`bar was passed ${count}`)
}
}
);
```
[Click here to try it out in the TypeScript Playground](http://www.typescriptlang.org/Playground#src=interface%20Foo%20%7B%0A%09(message%3A%20string)%3A%20void%3B%0A%09bar(count%3A%20number)%3A%20void%3B%0A%7D%0A%0Aconst%20foo%3A%20Foo%20%3D%20merge(%0A%09(message%3A%20string)%20%3D%3E%20console.log(%60message%20is%20%24%7Bmessage%7D%60)%2C%20%7B%0A%09%09bar(count%3A%20number)%20%7B%0A%09%09%09console.log(%60bar%20was%20passed%20%24%7Bcount%7D%60)%0A%09%09%7D%0A%09%7D%0A)%3B%0A%0Afunction%20merge%3CT1%2C%20T2%3E(onto%3A%20T1%2C%20from%3A%20T2)%3A%20T1%20%26%20T2%20%7B%0A%09Object.keys(from).forEach(key%20%3D%3E%20onto%5Bkey%5D%20%3D%20from%5Bkey%5D)%3B%0A%09return%20onto%20as%20T1%20%26%20T2%3B%0A%7D). Note that we have constrained `foo` to be of type `Foo`, so the result of `merge` has to be a complete `Foo`. So if you rename `bar` to `bad` then you get a type error.
**NB** There is still one type hole here, however. TypeScript doesn't provide a way to constrain a type parameter to be "not a function". So you could get confused and pass your function as the second argument to `merge`, and that wouldn't work. So until this can be declared, we have to catch it at runtime:
```
function merge<T1, T2>(onto: T1, from: T2): T1 & T2 {
if (typeof from !== "object" || from instanceof Array) {
throw new Error("merge: 'from' must be an ordinary object");
}
Object.keys(from).forEach(key => onto[key] = from[key]);
return onto as T1 & T2;
}
``` |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | This is easily achievable now (typescript 2.x) with `Object.assign(target, source)`
example:
[](https://i.stack.imgur.com/9EtVw.png)
The magic here is that `Object.assign<T, U>(t: T, u: U)` is typed to return the *intersection* `T & U`.
Enforcing that this resolves to a known interface is also straight-forward. For example:
```
interface Foo {
(a: number, b: string): string[];
foo: string;
}
let method: Foo = Object.assign(
(a: number, b: string) => { return a * a; },
{ foo: 10 }
);
```
which errors due to incompatible typing:
>
> Error: foo:number not assignable to foo:string
>
> Error: number not assignable to string[] (return type)
>
>
>
*caveat: you may need to [polyfill](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) Object.assign if targeting older browsers.* | An updated answer: since the addition of intersection types via `&`, it is possible to "merge" two inferred types on the fly.
Here's a general helper that reads the properties of some object `from` and copies them over an object `onto`. It returns the same object `onto` but with a new type that includes both sets of properties, so correctly describing the runtime behaviour:
```
function merge<T1, T2>(onto: T1, from: T2): T1 & T2 {
Object.keys(from).forEach(key => onto[key] = from[key]);
return onto as T1 & T2;
}
```
This low-level helper does still perform a type-assertion, but it is type-safe by design. With this helper in place, we have an operator that we can use to solve the OP's problem with full type safety:
```
interface Foo {
(message: string): void;
bar(count: number): void;
}
const foo: Foo = merge(
(message: string) => console.log(`message is ${message}`), {
bar(count: number) {
console.log(`bar was passed ${count}`)
}
}
);
```
[Click here to try it out in the TypeScript Playground](http://www.typescriptlang.org/Playground#src=interface%20Foo%20%7B%0A%09(message%3A%20string)%3A%20void%3B%0A%09bar(count%3A%20number)%3A%20void%3B%0A%7D%0A%0Aconst%20foo%3A%20Foo%20%3D%20merge(%0A%09(message%3A%20string)%20%3D%3E%20console.log(%60message%20is%20%24%7Bmessage%7D%60)%2C%20%7B%0A%09%09bar(count%3A%20number)%20%7B%0A%09%09%09console.log(%60bar%20was%20passed%20%24%7Bcount%7D%60)%0A%09%09%7D%0A%09%7D%0A)%3B%0A%0Afunction%20merge%3CT1%2C%20T2%3E(onto%3A%20T1%2C%20from%3A%20T2)%3A%20T1%20%26%20T2%20%7B%0A%09Object.keys(from).forEach(key%20%3D%3E%20onto%5Bkey%5D%20%3D%20from%5Bkey%5D)%3B%0A%09return%20onto%20as%20T1%20%26%20T2%3B%0A%7D). Note that we have constrained `foo` to be of type `Foo`, so the result of `merge` has to be a complete `Foo`. So if you rename `bar` to `bad` then you get a type error.
**NB** There is still one type hole here, however. TypeScript doesn't provide a way to constrain a type parameter to be "not a function". So you could get confused and pass your function as the second argument to `merge`, and that wouldn't work. So until this can be declared, we have to catch it at runtime:
```
function merge<T1, T2>(onto: T1, from: T2): T1 & T2 {
if (typeof from !== "object" || from instanceof Array) {
throw new Error("merge: 'from' must be an ordinary object");
}
Object.keys(from).forEach(key => onto[key] = from[key]);
return onto as T1 & T2;
}
``` |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | Update: This answer was the best solution in earlier versions of TypeScript, but there are better options available in newer versions (see other answers).
The accepted answer works and might be required in some situations, but have the downside of providing no type safety for building up the object. This technique will at least throw a type error if you attempt to add an undefined property.
```
interface F { (): any; someValue: number; }
var f = <F>function () { }
f.someValue = 3
// type error
f.notDeclard = 3
``` | This departs from strong typing, but you can do
```
var f: any = function() { }
f.someValue = 3;
```
if you are trying to get around oppressive strong typing like I was when I found this question. Sadly this is a case TypeScript fails on perfectly valid JavaScript so you have to you tell TypeScript to back off.
"You JavaScript is perfectly valid TypeScript" evaluates to false. (Note: using 0.95) |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | As a shortcut, you can dynamically assign the object value using the ['property'] accessor:
```
var f = function() { }
f['someValue'] = 3;
```
This bypasses the type checking. However, it is pretty safe because you have to intentionally access the property the same way:
```
var val = f.someValue; // This won't work
var val = f['someValue']; // Yeah, I meant to do that
```
However, if you really want the type checking for the property value, this won't work. | This departs from strong typing, but you can do
```
var f: any = function() { }
f.someValue = 3;
```
if you are trying to get around oppressive strong typing like I was when I found this question. Sadly this is a case TypeScript fails on perfectly valid JavaScript so you have to you tell TypeScript to back off.
"You JavaScript is perfectly valid TypeScript" evaluates to false. (Note: using 0.95) |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | So if the requirement is to simply build and assign that function to "f" without a cast, here is a possible solution:
```
var f: { (): any; someValue: number; };
f = (() => {
var _f : any = function () { };
_f.someValue = 3;
return _f;
})();
```
Essentially, it uses a self executing function literal to "construct" an object that will match that signature before the assignment is done. The only weirdness is that the inner declaration of the function needs to be of type 'any', otherwise the compiler cries that you're assigning to a property which does not exist on the object yet.
EDIT: Simplified the code a bit. | As a shortcut, you can dynamically assign the object value using the ['property'] accessor:
```
var f = function() { }
f['someValue'] = 3;
```
This bypasses the type checking. However, it is pretty safe because you have to intentionally access the property the same way:
```
var val = f.someValue; // This won't work
var val = f['someValue']; // Yeah, I meant to do that
```
However, if you really want the type checking for the property value, this won't work. |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | Update: This answer was the best solution in earlier versions of TypeScript, but there are better options available in newer versions (see other answers).
The accepted answer works and might be required in some situations, but have the downside of providing no type safety for building up the object. This technique will at least throw a type error if you attempt to add an undefined property.
```
interface F { (): any; someValue: number; }
var f = <F>function () { }
f.someValue = 3
// type error
f.notDeclard = 3
``` | As a shortcut, you can dynamically assign the object value using the ['property'] accessor:
```
var f = function() { }
f['someValue'] = 3;
```
This bypasses the type checking. However, it is pretty safe because you have to intentionally access the property the same way:
```
var val = f.someValue; // This won't work
var val = f['someValue']; // Yeah, I meant to do that
```
However, if you really want the type checking for the property value, this won't work. |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | Old question, but for versions of TypeScript starting with 3.1, you can simply do the property assignment as you would in plain JS, as long as you use a function declaration or the `const` keyword for your variable:
```
function f () {}
f.someValue = 3; // fine
const g = function () {};
g.someValue = 3; // also fine
var h = function () {};
h.someValue = 3; // Error: "Property 'someValue' does not exist on type '() => void'"
```
[Reference](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#properties-declarations-on-functions) and [online example](https://www.typescriptlang.org/play/index.html#src=function%20f%20()%20%7B%7D%0D%0Af.someValue%20%3D%203%3B%0D%0Aconst%20g%20%3D%20function%20()%20%7B%7D%3B%0D%0Ag.someValue%20%3D%203%3B%0D%0Avar%20h%20%3D%20function%20()%20%7B%7D%3B%0D%0Ah.someValue%20%3D%203%3B%0D%0A). | An updated answer: since the addition of intersection types via `&`, it is possible to "merge" two inferred types on the fly.
Here's a general helper that reads the properties of some object `from` and copies them over an object `onto`. It returns the same object `onto` but with a new type that includes both sets of properties, so correctly describing the runtime behaviour:
```
function merge<T1, T2>(onto: T1, from: T2): T1 & T2 {
Object.keys(from).forEach(key => onto[key] = from[key]);
return onto as T1 & T2;
}
```
This low-level helper does still perform a type-assertion, but it is type-safe by design. With this helper in place, we have an operator that we can use to solve the OP's problem with full type safety:
```
interface Foo {
(message: string): void;
bar(count: number): void;
}
const foo: Foo = merge(
(message: string) => console.log(`message is ${message}`), {
bar(count: number) {
console.log(`bar was passed ${count}`)
}
}
);
```
[Click here to try it out in the TypeScript Playground](http://www.typescriptlang.org/Playground#src=interface%20Foo%20%7B%0A%09(message%3A%20string)%3A%20void%3B%0A%09bar(count%3A%20number)%3A%20void%3B%0A%7D%0A%0Aconst%20foo%3A%20Foo%20%3D%20merge(%0A%09(message%3A%20string)%20%3D%3E%20console.log(%60message%20is%20%24%7Bmessage%7D%60)%2C%20%7B%0A%09%09bar(count%3A%20number)%20%7B%0A%09%09%09console.log(%60bar%20was%20passed%20%24%7Bcount%7D%60)%0A%09%09%7D%0A%09%7D%0A)%3B%0A%0Afunction%20merge%3CT1%2C%20T2%3E(onto%3A%20T1%2C%20from%3A%20T2)%3A%20T1%20%26%20T2%20%7B%0A%09Object.keys(from).forEach(key%20%3D%3E%20onto%5Bkey%5D%20%3D%20from%5Bkey%5D)%3B%0A%09return%20onto%20as%20T1%20%26%20T2%3B%0A%7D). Note that we have constrained `foo` to be of type `Foo`, so the result of `merge` has to be a complete `Foo`. So if you rename `bar` to `bad` then you get a type error.
**NB** There is still one type hole here, however. TypeScript doesn't provide a way to constrain a type parameter to be "not a function". So you could get confused and pass your function as the second argument to `merge`, and that wouldn't work. So until this can be declared, we have to catch it at runtime:
```
function merge<T1, T2>(onto: T1, from: T2): T1 & T2 {
if (typeof from !== "object" || from instanceof Array) {
throw new Error("merge: 'from' must be an ordinary object");
}
Object.keys(from).forEach(key => onto[key] = from[key]);
return onto as T1 & T2;
}
``` |
12,766,528 | I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast? | 2012/10/07 | [
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] | This is easily achievable now (typescript 2.x) with `Object.assign(target, source)`
example:
[](https://i.stack.imgur.com/9EtVw.png)
The magic here is that `Object.assign<T, U>(t: T, u: U)` is typed to return the *intersection* `T & U`.
Enforcing that this resolves to a known interface is also straight-forward. For example:
```
interface Foo {
(a: number, b: string): string[];
foo: string;
}
let method: Foo = Object.assign(
(a: number, b: string) => { return a * a; },
{ foo: 10 }
);
```
which errors due to incompatible typing:
>
> Error: foo:number not assignable to foo:string
>
> Error: number not assignable to string[] (return type)
>
>
>
*caveat: you may need to [polyfill](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) Object.assign if targeting older browsers.* | As a shortcut, you can dynamically assign the object value using the ['property'] accessor:
```
var f = function() { }
f['someValue'] = 3;
```
This bypasses the type checking. However, it is pretty safe because you have to intentionally access the property the same way:
```
var val = f.someValue; // This won't work
var val = f['someValue']; // Yeah, I meant to do that
```
However, if you really want the type checking for the property value, this won't work. |
3,059,019 | INFORMIX-SQL or any other SQL-based DB:
Suppose I have an app where depending on the value of some columns, example:
```
company.code char(3) {abc}
company.branch char(2) {01}
```
Can I construct table name "abc01" for inclusion in SELECT \* FROM abc01; ?
In other words, a variable table name.. same question applies for column names. | 2010/06/17 | [
"https://Stackoverflow.com/questions/3059019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366797/"
] | Only in a language which can manipulate character strings and handle Dynamic SQL. It has to create the statement on the fly.
You can only use placeholders in queries for values, not for the structural elements of the query such as the table name or column name. | Only if you use dynamic sql. It's like you build sql code in your app, then use something like execute immediate.
```
sprintf(cdb_text1, "create table %s (field1 char(3));", usr_db_id);
EXEC SQL execute immediate :cdb_text;
```
If you use dynamic sql, it's bad because of sql injections. |
29,549,905 | I am trying to create a simple 3D scatter plot but I want to also show a 2D projection of this data on the same figure.
This would allow to show a correlation between two of those 3 variables that might be hard to see in a 3D plot.
I remember seeing this somewhere before but was not able to find it again.
Here is some toy example:
```
x= np.random.random(100)
y= np.random.random(100)
z= sin(x**2+y**2)
fig= figure()
ax= fig.add_subplot(111, projection= '3d')
ax.scatter(x,y,z)
``` | 2015/04/09 | [
"https://Stackoverflow.com/questions/29549905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1130635/"
] | You can add 2D projections of your 3D scatter data by using the `plot` method and specifying `zdir`:
```
import numpy as np
import matplotlib.pyplot as plt
x= np.random.random(100)
y= np.random.random(100)
z= np.sin(3*x**2+y**2)
fig= plt.figure()
ax= fig.add_subplot(111, projection= '3d')
ax.scatter(x,y,z)
ax.plot(x, z, 'r+', zdir='y', zs=1.5)
ax.plot(y, z, 'g+', zdir='x', zs=-0.5)
ax.plot(x, y, 'k+', zdir='z', zs=-1.5)
ax.set_xlim([-0.5, 1.5])
ax.set_ylim([-0.5, 1.5])
ax.set_zlim([-1.5, 1.5])
plt.show()
```
 | The other answer works with matplotlib 0.99, but 1.0 and later versions need something a bit different (this code checked with v1.3.1):
```
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
x= np.random.random(100)
y= np.random.random(100)
z= np.sin(3*x**2+y**2)
fig= plt.figure()
ax = Axes3D(fig)
ax.scatter(x,y,z)
ax.plot(x, z, 'r+', zdir='y', zs=1.5)
ax.plot(y, z, 'g+', zdir='x', zs=-0.5)
ax.plot(x, y, 'k+', zdir='z', zs=-1.5)
ax.set_xlim([-0.5, 1.5])
ax.set_ylim([-0.5, 1.5])
ax.set_zlim([-1.5, 1.5])
plt.show()
```
You can see what version of matplotlib you have by importing it and printing the version string:
```
import matplotlib
print matplotlib.__version__
``` |
827,893 | I have two menu items for dir, mark, regexp, multiple and single on the menu bar in dired mode. While it doesn't affect the usage, but it seems something is wrong and makes me feel uncomfortable. Anyone know what is the cause?
Thank you very much! | 2014/10/17 | [
"https://superuser.com/questions/827893",
"https://superuser.com",
"https://superuser.com/users/380371/"
] | Do you see this problem already with `emacs -Q`?
If not, then try to see which part of your config file triggers this problem. | Someone else has the same issue. Here is the bug report
<https://bitbucket.org/lyro/evil/issue/404/dired-menus-are-duplicated> |
32,626,809 | I'm looking for a way to map "emacs" to "emacs -nw" in powershell. I tried this (screenshot below), and it adds it as an alias, but it doesn't work. However, the command "emacs -nw" works before setting the alias.
[](https://i.stack.imgur.com/q4HkM.png)
And I also want a way to save that alias for future sessions (restarting the powershell gets me back to square zero)
EDIT:(aditional info)
Also tried creating a function, but when calling that function powershell freezes for a while, then I get the following message (screenshot below)
[](https://i.stack.imgur.com/PMnc0.png)
EDIT2:(aditional info)
At first, `function enw {emacs.exe -nw}` (changed function name to 'enw' for explanation purposes) seems to work. But then there's a problem. For the standard emacs, I can type `emacs -nw filename.txt`, and that would open the file `filename.txt` in `emacs -nw`. Calling the function `enw filename.txt` will not open the `filename.txt` file, providing the same result as just typing `enw`.
The solution to this is `function enw {Param($myparam) emacs.exe -nw $myparam}` | 2015/09/17 | [
"https://Stackoverflow.com/questions/32626809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3603899/"
] | try creating a function:
```
function emacs {emacs.exe -nw}
```
then add it to your powershell profile ( `$profile` ) | Create a function, but within the function explicitly invoke the .exe :
```
function emacs {emacs.exe -nw}
``` |
32,626,809 | I'm looking for a way to map "emacs" to "emacs -nw" in powershell. I tried this (screenshot below), and it adds it as an alias, but it doesn't work. However, the command "emacs -nw" works before setting the alias.
[](https://i.stack.imgur.com/q4HkM.png)
And I also want a way to save that alias for future sessions (restarting the powershell gets me back to square zero)
EDIT:(aditional info)
Also tried creating a function, but when calling that function powershell freezes for a while, then I get the following message (screenshot below)
[](https://i.stack.imgur.com/PMnc0.png)
EDIT2:(aditional info)
At first, `function enw {emacs.exe -nw}` (changed function name to 'enw' for explanation purposes) seems to work. But then there's a problem. For the standard emacs, I can type `emacs -nw filename.txt`, and that would open the file `filename.txt` in `emacs -nw`. Calling the function `enw filename.txt` will not open the `filename.txt` file, providing the same result as just typing `enw`.
The solution to this is `function enw {Param($myparam) emacs.exe -nw $myparam}` | 2015/09/17 | [
"https://Stackoverflow.com/questions/32626809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3603899/"
] | try creating a function:
```
function emacs {emacs.exe -nw}
```
then add it to your powershell profile ( `$profile` ) | I see you have your answers but I just wanted to spell it out here. You created a recursive function.
By not specifying the .exe as part of the extension PowerShell was able to match `emacs` back to your function definition. So it would call itself infinitely.
You can see this by checking the results of `Get-Command emacs` both before and after you register your function. |
32,626,809 | I'm looking for a way to map "emacs" to "emacs -nw" in powershell. I tried this (screenshot below), and it adds it as an alias, but it doesn't work. However, the command "emacs -nw" works before setting the alias.
[](https://i.stack.imgur.com/q4HkM.png)
And I also want a way to save that alias for future sessions (restarting the powershell gets me back to square zero)
EDIT:(aditional info)
Also tried creating a function, but when calling that function powershell freezes for a while, then I get the following message (screenshot below)
[](https://i.stack.imgur.com/PMnc0.png)
EDIT2:(aditional info)
At first, `function enw {emacs.exe -nw}` (changed function name to 'enw' for explanation purposes) seems to work. But then there's a problem. For the standard emacs, I can type `emacs -nw filename.txt`, and that would open the file `filename.txt` in `emacs -nw`. Calling the function `enw filename.txt` will not open the `filename.txt` file, providing the same result as just typing `enw`.
The solution to this is `function enw {Param($myparam) emacs.exe -nw $myparam}` | 2015/09/17 | [
"https://Stackoverflow.com/questions/32626809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3603899/"
] | Create a function, but within the function explicitly invoke the .exe :
```
function emacs {emacs.exe -nw}
``` | I see you have your answers but I just wanted to spell it out here. You created a recursive function.
By not specifying the .exe as part of the extension PowerShell was able to match `emacs` back to your function definition. So it would call itself infinitely.
You can see this by checking the results of `Get-Command emacs` both before and after you register your function. |
48,583,446 | Which one is better: having a BLOB field in the same table or having a 1-TO-1 reference to it in another table?
I'm making a MySQL database whose main table is called item(ID, Description). This table is consulted by a program I'm developing in VB.NET which offers the possibility to double-click a specific item obtained with a query. Once opened its dedicated form, I would like to show an image stored in the BLOB field, a sort of item preview. The problem is I don't know where is better to create this BLOB field.
Assuming to have a table like this: Item(ID, Description, BLOB), will the BLOB field affect the database performance on queries like:
```
SELECT ID, Description FROM Item;
```
If yes, what do you think about this solution:
```
Item(ID, Description)
Images(Item, File)
```
Where Images.Item references to Item.ID, and File is the BLOB field. | 2018/02/02 | [
"https://Stackoverflow.com/questions/48583446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3802998/"
] | You can add the BLOB field directly to your main table, as BLOB fields are not stored in-row and require a separate look-up to retrieve its contents. Your dependent table is needless.
BUT another and preferred way is to store on your database table only a pointer (path to the file on server) to your image file. In this way you can retrive the path and access the file from your VB.NET application. | To quote [the documentation about blobs](https://dev.mysql.com/doc/refman/5.7/en/blob.html):
>
> Each `BLOB` or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened.
>
>
>
In simpler terms, the blob's storage isn't stored inside the table's row, only a pointer is - which is pretty similar to what you're trying to achieve with the secondary table. To make a long story short - there's no need for another table, MySQL already doesn't the same thing internally. |
48,583,446 | Which one is better: having a BLOB field in the same table or having a 1-TO-1 reference to it in another table?
I'm making a MySQL database whose main table is called item(ID, Description). This table is consulted by a program I'm developing in VB.NET which offers the possibility to double-click a specific item obtained with a query. Once opened its dedicated form, I would like to show an image stored in the BLOB field, a sort of item preview. The problem is I don't know where is better to create this BLOB field.
Assuming to have a table like this: Item(ID, Description, BLOB), will the BLOB field affect the database performance on queries like:
```
SELECT ID, Description FROM Item;
```
If yes, what do you think about this solution:
```
Item(ID, Description)
Images(Item, File)
```
Where Images.Item references to Item.ID, and File is the BLOB field. | 2018/02/02 | [
"https://Stackoverflow.com/questions/48583446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3802998/"
] | You can add the BLOB field directly to your main table, as BLOB fields are not stored in-row and require a separate look-up to retrieve its contents. Your dependent table is needless.
BUT another and preferred way is to store on your database table only a pointer (path to the file on server) to your image file. In this way you can retrive the path and access the file from your VB.NET application. | Most of what has been said in the other Answers is mostly correct. I'll start from scratch, adding some caveats.
The two-table, 1-1, design is *usually* better for MyISAM, but not for InnoDB. The rest of my Answer applies only to InnoDB.
"Off-record" storage *may* happen to `BLOB`, `TEXT`, and 'large' `VARCHAR` and `VARBINARY`, almost equally.
"Large" columns are *usually* stored "off-record", thereby providing something very similar to your 1-1 design. However, by having InnoDB do the work *usually* leads to better performance.
The `ROW_FORMAT` and the size of the column makes a difference.
* A "small" `BLOB` *may* be stored on-record. Pro: no need for the extra fetch when you include the blob in the `SELECT` list. Con: clutter.
* Some `ROW_FORMATs` cut off at 767 bytes.
* Some `ROW_FORMATs` store 20 bytes on-record; this is just a 'pointer'; the entire blob is off-record.
* etc, etc.
Off-record is beneficial when you need to filter out a bunch of rows, then fetch only a few. Also, when you don't need the column.
As a side note, `TINYTEXT` is possibly useless. There are situations where the 'equivalent' `VARCHAR(255)` performs better.
Storing an image in the table (on- *or* off-record) is arguably unwise if that image will be used in an HTML page. HTML is quite happy to request the `<img src=...>` from your server or even some other server. In this case, a smallish `VARCHAR` containing a url is the 'correct' design. |
30,540,835 | I am struggling with a problem big time and just can't see how it can be done... so any help appreciated from you SQL gurus!
What I have now is a table like this:
```
Sticker Price Cash Price Credit Price Value
Yes Yes NULL 107
NULL Yes NULL 115
Yes Yes NULL 127
```
And what I need to do is construct a table (flipped) to show :
```
Text Value IsDefault
Sticker Price Sticker 1
Cash Price Cash 0
```
And do not show Credit Price because all values were NULL in the first table.
Basically I want to only show Sticker if it's not all NULL, Cash if it's not all NULL, etc...
I thought of pivot but just cant work my head round it!!!
Currently I have this to give the top table:
```
SELECT SH1.[Sticker Price], SH1.[Credit Price], SH1.[Cash Price], SH1.[Credit Price], UG.Description as Value,
CASE ROW_NUMBER() OVER(ORDER BY UG.Description)
WHEN 1 THEN 1 ELSE 0 END as ISDEFAULT
FROM [uStore].[dbo].[ACL_UserGroup] UG
INNER JOIN [uStore].[dbo].[ACL_UserGroupMembership] UGM ON UG.UserGroupId = UGM.UserGroupId
INNER JOIN [XMPDBHDS].[XMPieHDSSchema60].[Sheet1] SH1 ON CONVERT(nvarchar(100), SH1.[Centre Code]) = UG.Description
WHERE UGM.UserId = 1012
```
I just can't see how I can get the table I want from this with my limited SQL knowledge... | 2015/05/30 | [
"https://Stackoverflow.com/questions/30540835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4955095/"
] | What do you mean by "any subsequent errors then end up failing silently"? If the original promise `rp` fails, the `catch` executes… *at the time of failure.* Once a promise is rejected, that's it, there can be no "subsequent errors."
Also, `should` looks like an assertion (e.g. from `chai`) which would suggest that you are trying to test this. Chai's `should.throw` doesn't throw an error, it checks that an error has been thrown. If you are testing this, you need to indicate to the test (`it` block) that the test is async, not sync — usually by naming & invoking a `done` parameter. Otherwise, the request will be sent out, and then before ANY response can be made, the script will synchronously end and no errors will be listened for.
What's more, you are spec'ing that something should `throw` to console, but nothing in your code `throw`s! If you DID write in a `throw`, you should understand that `throw` inside a `then` or `catch` will simply cause the outgoing promise from that handler to be rejected with the thrown value (yes, `catch` exports a new promise, just like `then` — it is 100% sugar for `.then(null, errHandler)`. If you want errors to be re-thrown back into the window, you need to finalize the chain with Bluebird's `.done()` promise method, accessed in request-promise via the somewhat arcane `.promise().done()`. But even in that case you'd still need to specify that you're doing an async test.
In short, it's not entirely clear what you think some of this code is supposed to be doing, and how it differs from your expectations. Please clarify!
```
var rp = require('request-promise');
rp.get({ // start an async call and return a promise
uri: 'http://httpstat.us/500',
transform: function(body, res){
res.data = JSON.parse(body);
return res;
}
}).then(function(res){ // if rp.get resolves, push res.data
results.push(res.data);
})
.catch(function(err){ // if rp.get rejects (e.g. 500), do this:
should.throw.error.to.console(); // test if something is thrown (but nothing has been!)
var respErr = JSON.parse(err.error);
var errorResult = {
origUrl: respErr.origUrl,
error: respErr
};
results.push(errorResult); // push an object with some of the error info into results
});
// this line (e.g., end of script) is reached before any of the async stuff above settles. If you are testing something, you need to make the test async and specify when it's complete by invoking `done()` (not the same as ending the promise chain in Bluebird's `.done()`).
``` | So apparently the .catch() in promises is basically a wrapper around a JS try-catch. So in order to have subsequent errors logged to the console after already having written one handler, you have to have a second handler to throw the eventual error to the console.
More info on GitHub here: <https://github.com/request/request-promise/issues/48#issuecomment-107734372> |
54,617,134 | The problem is incorrect path to remote host, but is not true. I have acces to my server via ftp without problems. All WP files are there and the site is working fine (frontend/backent). I have also access to phpMyAdmin to MySQL datepase binded to this site.
I have notce that paht to the web files is differ depend on FTP or SFTP is. In FTP app is such stright:
```
/[all wp files]
```
in editor app (such TextWrangler), after the samy access id/pass, I have got such path:
```
/home/[accountname]/public_html/[all wp files]
```
After click on detect button, app changing the path filed on:
- *blanc* - under FTP connection
or
- *public\_html* - under SFTP
so it mean conection between MAMP and my server is working. Fine. But after this when I trying to Check URLs & credentials or when I trying Import Host... I received:
**Error code: -3010** (The 'Path' to your remote document root is incorrect. The 'Path' field on the remote tab is the document root of your remote site that will be accessed via your Public Site URL (e.g.: 'public\_html').) - Start auto detect not solved the problem.
or
**Error code: -3113** (The 'Path' to your remote document root is incorrect. The 'Path' field on the remote tab is the document root of your remote site that will be accessed via your Public Site URL (e.g.: 'public\_html').)
**But it is not true!** All files are there!
Please help. Should I use some special code under Apache tab (Additional parameters for VirtualHost directive or Directory directive?
Should I know something more from my serverprovider (home.pl) and solved this problem with them (there is no, in my subscription plan, access via cPanel or so, to set up something)?
Should I change something in https.conf file?
I'm not so using server coding so please forgive me but I have no idea where is the problem (but I'm trying to learn) :o)
My environment is:
MacOS X: 10.13.6
MAMP Pro: 5.2.2 (17923)
Thanx for any help or redirection to the answers someware else (I used searching ;o) but without success or I used wrong ask). | 2019/02/10 | [
"https://Stackoverflow.com/questions/54617134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11041089/"
] | relative pathes resolved by current directory. Solutions: Get script directory and combine with the relative path, something like:
```
require(dirname(__FILE__).'/../../../app.config.php');
``` | You need to use absolute path. A different relative path may be produced if a script is called directly or the script is included in another script.
For example:
```
a.php is on path A/B/C the ../../ will result in in A/
b.php is on path A/B/C/D, if it inlcudes the a.php then the ../../ on a.php will result in A/B/.
``` |
24,217,412 | I am in the process of making a simple racing game using Apple's SceneKit library. I have modeled a left turn section of the race track. I am able to successfully load the model into an SCNGeometry that I can then render. However, I would like to be able to use this model for both a left and right turn segment. To do this, I need to mirror the SCNGeometry over the y-z plane, though I can't for the life of me figure out how.
In SpriteKit, one can mirror a sprite by setting the corresponding SKNode's scale to -1. However, if I set the SCNGeometry's SCNNode's x scale to -1, the SCNGeometry will not render at all. While I can mirror the model in my modeling software, I would prefer not to have two basically identical models. Any suggestions would be appreciated. | 2014/06/14 | [
"https://Stackoverflow.com/questions/24217412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2351182/"
] | Alright, turns out setting the SCNNode's x scale to -1 does in fact mirror the SCNGeometry.The issue is, when an SCNGeometry is mirrored that way, all of the faces are pointed inwards instead of outwards so none are rendered. If the object's material is changed so that the front faces are culled instead of the back faces, the SCNGeometry will be mirrored as expected. | When you scale the geometry to any "-" negative it flip the normals face. the default for normal faces are "One sided"
Set the "Material" property to "Double Sided"
with swift it might look like this
```
yourNode.geometry?.firstMaterial?.doubleSided = true
``` |
24,217,412 | I am in the process of making a simple racing game using Apple's SceneKit library. I have modeled a left turn section of the race track. I am able to successfully load the model into an SCNGeometry that I can then render. However, I would like to be able to use this model for both a left and right turn segment. To do this, I need to mirror the SCNGeometry over the y-z plane, though I can't for the life of me figure out how.
In SpriteKit, one can mirror a sprite by setting the corresponding SKNode's scale to -1. However, if I set the SCNGeometry's SCNNode's x scale to -1, the SCNGeometry will not render at all. While I can mirror the model in my modeling software, I would prefer not to have two basically identical models. Any suggestions would be appreciated. | 2014/06/14 | [
"https://Stackoverflow.com/questions/24217412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2351182/"
] | Alright, turns out setting the SCNNode's x scale to -1 does in fact mirror the SCNGeometry.The issue is, when an SCNGeometry is mirrored that way, all of the faces are pointed inwards instead of outwards so none are rendered. If the object's material is changed so that the front faces are culled instead of the back faces, the SCNGeometry will be mirrored as expected. | If you don't want to change the geometry, but just change the texture, you can do:
```
let flip = SCNMatrix4Translate(
SCNMatrix4Scale(material.diffuse.contentsTransform, 1.0, -1.0, 1.0),
0, 1, 0
)
material.diffuse.contentsTransform = flip
```
or directly,
```
material.diffuse.contentsTransform = SCNMatrix4FromGLKMatrix4(GLKMatrix4(m: (
-1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
-1.0, 0.0, 0.0, 1.0
)))
```
This will replace the texture `x` coordinate by `1-x` which should flip it. I've played around with shaders, and I believe the relevant shader code showing how SceneKit uses the content transform is
```
v_texcoord0 = (u_diffuseTextureMatrix * vec4(_geometry.texcoords[0], 0., 1.)).xy;
```
([see here](https://gist.github.com/gsabran/d705d1a305908156537d2a9418c67a22#file-scnshadable-vertex-shader-vert-L218)) |
24,217,412 | I am in the process of making a simple racing game using Apple's SceneKit library. I have modeled a left turn section of the race track. I am able to successfully load the model into an SCNGeometry that I can then render. However, I would like to be able to use this model for both a left and right turn segment. To do this, I need to mirror the SCNGeometry over the y-z plane, though I can't for the life of me figure out how.
In SpriteKit, one can mirror a sprite by setting the corresponding SKNode's scale to -1. However, if I set the SCNGeometry's SCNNode's x scale to -1, the SCNGeometry will not render at all. While I can mirror the model in my modeling software, I would prefer not to have two basically identical models. Any suggestions would be appreciated. | 2014/06/14 | [
"https://Stackoverflow.com/questions/24217412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2351182/"
] | If you don't want to change the geometry, but just change the texture, you can do:
```
let flip = SCNMatrix4Translate(
SCNMatrix4Scale(material.diffuse.contentsTransform, 1.0, -1.0, 1.0),
0, 1, 0
)
material.diffuse.contentsTransform = flip
```
or directly,
```
material.diffuse.contentsTransform = SCNMatrix4FromGLKMatrix4(GLKMatrix4(m: (
-1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
-1.0, 0.0, 0.0, 1.0
)))
```
This will replace the texture `x` coordinate by `1-x` which should flip it. I've played around with shaders, and I believe the relevant shader code showing how SceneKit uses the content transform is
```
v_texcoord0 = (u_diffuseTextureMatrix * vec4(_geometry.texcoords[0], 0., 1.)).xy;
```
([see here](https://gist.github.com/gsabran/d705d1a305908156537d2a9418c67a22#file-scnshadable-vertex-shader-vert-L218)) | When you scale the geometry to any "-" negative it flip the normals face. the default for normal faces are "One sided"
Set the "Material" property to "Double Sided"
with swift it might look like this
```
yourNode.geometry?.firstMaterial?.doubleSided = true
``` |
71,321 | My daughter is 8 and has been taking private piano lessons for around 3 months now but will take a break from lessons over the summer. In the fall (when school starts back up) she will be taking cello lessons at school.
What if anything can I do with her over the summer on the piano that will help prepare her or make learning the cello easier come fall?
She is learning to read (both treble and bass clef since she is playing the piano) and I have started doing some ear training games with her, but I am looking for more and am open to suggestions.
The ear training we have been doing is very basic so far, all diatonic, I play I, IV, V to get the key in her ear and then play DO and another note and she has to tell me what note it is.
(I studied music in school, and play the drums and Guitar, just so you know my background. I do not have any experience with classic instruments like the cello and have never played a fretless string instrument.) | 2018/05/25 | [
"https://music.stackexchange.com/questions/71321",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/10492/"
] | I have a couple of thoughts. First, she will be reading primarily bass clef for cello, so any drilling of those notes in particular will be useful. Also, help her to "forget" her piano fingering. I have piano students who play stringed instruments and discussing fingering is such a pain. I wish there was a universal fingering system! "1" on piano is thumb. "1" on cello is index finger, and so on. You could make or purchase flash cards to help with note reading. You can do a lot of rhythm games as well. | Some of your preparation you will probably want to do off of the piano.
Work with your student on being able to quickly and easily identify letters that come before other letters, and recite the alphabet backwards from G. This will aid in knowing the note names on the finger board and in the sheet music. Normally people are very good at knowing what letter comes after a letter in the alphabet, but are not as good as instantly knowing letters before other letters. This causes a pause in the flow of reading and/or reciting notes on the staff or fingerboard. Working this exercise before can speed up the note learning process.
Many of the lesson systems will start string players with the D Major scale, as the fingering pattern is simpler to start with on the 5th tuned instruments. Working on understanding the note pattern of D major, and how there are half step between B|C and E|F can help with visualizing the cello fingerboard.
Reviewing the chromatic notes, and reviewing how F moves up to F# and C moves up to C# when playing the Major pattern starting on D can help the student see where the notes are when they begin playing the notes of the beginning D Major pieces.
In some cases the beginning instruction for strings starts with finger numbers instead of note names. You can practice switching between "Piano 1st" and "Cello 1st" and other fingers to make a distinction.
On the piano in bass clef you can work on recognition of the notes that the cello strings play. If the student is able to instantly identify the C G D A notes on the bass clef that correspond with the strings, it sets up an easier recognition of the pattern that the notes are played on each string (open string note on a space, then line-space-line notes to the next string). This sets up the ability to determine which string a given note should be played on in beginning tunes.
Ear training is an excellent thing to do. You can work on whole steps and half steps (whole tones and semi tones) as well as thirds and arpeggios to prep finding notes on the cello.
Finally, one of the most important things you can to to prepare is to work on reading and playing rhythms. Playing a bow for the correct length of time may be challenging for some students, so working on counting out note duration, counting out loud while playing, and knowing how many notes are in other notes (four eighth notes in one half note etc.) can help rhythm playing in the beginning. |
2,042,775 | Solve the following recurrence relation by examining the first few values for a formula and then prove your conjectured formula by induction
$h\_n=h\_{n-1} -n+3, \ (n\geq 1); \ h\_0=2$
---
Here I've gone all the way to $n=8$ and the only pattern I've noticed is in the differences. By that I mean,
---
$h\_0=2$
$h\_1=2-1+3=4;$ $\ \ \ \ $from $h\_1$ to $h\_0$ there's a difference of $+2$
$h\_2=4-2+3=5;$$\ \ \ \ $from $h\_2$ to $h\_1$ there's a difference of $+1$
$h\_3=5-3+3=5;$$\ \ \ \ $from $h\_3$ to $h\_2$ there's a difference of $+0$
$h\_4=5-4+3=4;$$\ \ \ \ $from $h\_4$ to $h\_3$ there's a difference of $-1$
$h\_5=4-5+3=2;$$\ \ \ \ $from $h\_5$ to $h\_4$ there's a difference of $-2$
$h\_6=2-6+3=-1;$$\ \ \ \ $from $h\_6$ to $h\_5$ there's a difference of $-3$
$h\_7=-1-7+3=-5;$$\ \ \ \ $from $h\_7$ to $h\_6$ there's a difference of $-4$
$h\_8=-5-8+3=-10;$$\ \ \ \ $from $h\_8$ to $h\_7$ there's a difference of $-5$
---
I'm not really sure what this means as far as the formula goes though
Note: I'm only struggling with coming up with the formula. I can handle the induction. | 2016/12/04 | [
"https://math.stackexchange.com/questions/2042775",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/373431/"
] | \*\*Hint: \*\*Write it in terms of $n$.$$h\_n = h\_{n-1}-n+3,$$
but $$h\_{n-1}=h\_{n-2}-(n-1)+3,$$
so $$h\_n = h\_{n-2}-n-(n-1)+2\*3,$$
replace it now using $h\_{n-2}=h\_{n-3}-(n-2)+3,$ you will get $$h\_n=h\_{n-3}-(n-2)-(n-1)-n+3\*3,$$
Do it again and again and the pattern will pop out.
So what is $h\_{n-k}?$ what happens when $k=n?$ | You have: $h\_n = (h\_n - h\_{n-1}) + (h\_{n-1} - h\_{n-2})+ ...+ (h\_2 - h\_1) + (h\_1-h\_0) + h\_0 = -n+3 - (n-1) + 3 - (n-2) + 3 + ... + (-1 + 3) + 2 = -(1+2++\cdots + n) + 3n + 2 = $? Can you finish it off? |
2,042,775 | Solve the following recurrence relation by examining the first few values for a formula and then prove your conjectured formula by induction
$h\_n=h\_{n-1} -n+3, \ (n\geq 1); \ h\_0=2$
---
Here I've gone all the way to $n=8$ and the only pattern I've noticed is in the differences. By that I mean,
---
$h\_0=2$
$h\_1=2-1+3=4;$ $\ \ \ \ $from $h\_1$ to $h\_0$ there's a difference of $+2$
$h\_2=4-2+3=5;$$\ \ \ \ $from $h\_2$ to $h\_1$ there's a difference of $+1$
$h\_3=5-3+3=5;$$\ \ \ \ $from $h\_3$ to $h\_2$ there's a difference of $+0$
$h\_4=5-4+3=4;$$\ \ \ \ $from $h\_4$ to $h\_3$ there's a difference of $-1$
$h\_5=4-5+3=2;$$\ \ \ \ $from $h\_5$ to $h\_4$ there's a difference of $-2$
$h\_6=2-6+3=-1;$$\ \ \ \ $from $h\_6$ to $h\_5$ there's a difference of $-3$
$h\_7=-1-7+3=-5;$$\ \ \ \ $from $h\_7$ to $h\_6$ there's a difference of $-4$
$h\_8=-5-8+3=-10;$$\ \ \ \ $from $h\_8$ to $h\_7$ there's a difference of $-5$
---
I'm not really sure what this means as far as the formula goes though
Note: I'm only struggling with coming up with the formula. I can handle the induction. | 2016/12/04 | [
"https://math.stackexchange.com/questions/2042775",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/373431/"
] | You noticed the pattern examining the first few values and noticed that the difference between successive terms varies as a linear function of $n$.
If you make an analogy with derivatives, this seesm to mean that the terms vary as a quadratic function of $n$. | You have: $h\_n = (h\_n - h\_{n-1}) + (h\_{n-1} - h\_{n-2})+ ...+ (h\_2 - h\_1) + (h\_1-h\_0) + h\_0 = -n+3 - (n-1) + 3 - (n-2) + 3 + ... + (-1 + 3) + 2 = -(1+2++\cdots + n) + 3n + 2 = $? Can you finish it off? |
2,042,775 | Solve the following recurrence relation by examining the first few values for a formula and then prove your conjectured formula by induction
$h\_n=h\_{n-1} -n+3, \ (n\geq 1); \ h\_0=2$
---
Here I've gone all the way to $n=8$ and the only pattern I've noticed is in the differences. By that I mean,
---
$h\_0=2$
$h\_1=2-1+3=4;$ $\ \ \ \ $from $h\_1$ to $h\_0$ there's a difference of $+2$
$h\_2=4-2+3=5;$$\ \ \ \ $from $h\_2$ to $h\_1$ there's a difference of $+1$
$h\_3=5-3+3=5;$$\ \ \ \ $from $h\_3$ to $h\_2$ there's a difference of $+0$
$h\_4=5-4+3=4;$$\ \ \ \ $from $h\_4$ to $h\_3$ there's a difference of $-1$
$h\_5=4-5+3=2;$$\ \ \ \ $from $h\_5$ to $h\_4$ there's a difference of $-2$
$h\_6=2-6+3=-1;$$\ \ \ \ $from $h\_6$ to $h\_5$ there's a difference of $-3$
$h\_7=-1-7+3=-5;$$\ \ \ \ $from $h\_7$ to $h\_6$ there's a difference of $-4$
$h\_8=-5-8+3=-10;$$\ \ \ \ $from $h\_8$ to $h\_7$ there's a difference of $-5$
---
I'm not really sure what this means as far as the formula goes though
Note: I'm only struggling with coming up with the formula. I can handle the induction. | 2016/12/04 | [
"https://math.stackexchange.com/questions/2042775",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/373431/"
] | You noticed the pattern examining the first few values and noticed that the difference between successive terms varies as a linear function of $n$.
If you make an analogy with derivatives, this seesm to mean that the terms vary as a quadratic function of $n$. | \*\*Hint: \*\*Write it in terms of $n$.$$h\_n = h\_{n-1}-n+3,$$
but $$h\_{n-1}=h\_{n-2}-(n-1)+3,$$
so $$h\_n = h\_{n-2}-n-(n-1)+2\*3,$$
replace it now using $h\_{n-2}=h\_{n-3}-(n-2)+3,$ you will get $$h\_n=h\_{n-3}-(n-2)-(n-1)-n+3\*3,$$
Do it again and again and the pattern will pop out.
So what is $h\_{n-k}?$ what happens when $k=n?$ |
47,949,328 | I'm trying to pass a json script to curl using powershell. It seems to work if I hard code it right into a variable escaping the double quotes with backslash, but I want to pass the json in a file. I tried putting the json script in a separate json file and then use get-content and throw it in a variable, but it does not seem to work I get a "Validation\_Error". Any suggestions
This Works
[](https://i.stack.imgur.com/JEHdc.png)
But I want to do something like this
$json = Get-Content C:\test.json
curl -v -X POST <https://api.paypal.com/v1/invoicing/invoices/> \ -H "Content-Type:application/json" \ -H "Authorization: Bearer $token" \ -d $json | 2017/12/23 | [
"https://Stackoverflow.com/questions/47949328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4352563/"
] | Try:
```
$json = Get-Content C:\test.json -Raw
```
By default `Get-Content` loads into an array of strings. The `-Raw` flag forces it to load into a single string.
You should also be able to do this and tell curl to read the file itself:
```
curl -v -X POST https://[...] -d @test.json
```
From the man page:
>
> If you start the data with the letter @, the rest should be a file name to read the data from[.]
>
>
> | Remember curl in PoSH, is really this...
```
Get-Alias -Name curl
CommandType Name
----------- ----
Alias curl -> Invoke-WebRequest
```
... if you were not aware. The is another alias for Invoke-WebRequest as well.
If you want to use true curl in your PoSH session, you must use the full UNC to the executable (curl.exe) and that .exe extension is required or PoSH will use the alias above.
```
Get-Help -Name Invoke-WebRequest -Examples
Get-Help -Name Invoke-WebRequest -Full
```
So, for Invoke-WebRequest, the JSON must be in the body. Something like...
```
Invoke-WebRequest -uri "blahblahwhatever.com/api/uri" -Method POST -Body $JSON
```
So, virtually all the cmdlets have aliases, thus when we use commands we know that are really aliases, we must keep in mind what the real underlying cmdlet can and cannot do. |
63,570,652 | New to SQL.
I have two SQL tables T1 and T2 which looks like the following
```
T1
customer_key X1 X2 X3
1000 60 10 2018-02-01
1001 42 9 2018-02-01
1002 03 1 2018-02-01
1005 15 1 2018-02-01
1002 32 2 2018-02-05
T2
customer_key A1 A2 A3
1001 20 2 2018-02-17
1002 25 2 2018-02-11
1005 04 1 2018-02-17
1009 02 0 2018-02-17
```
I want to get T3 as shown below by joining T1 and T2 and filtering on T1.X3 = '2018-02-01'
and T2.A3 = '2018-02-17'
```
T3
customer_key X1 X2
1000 60 10
1001 42 9
1005 15 1
1009 null null
```
I tried doing full outer join in the following way
```
create table T3
AS
select T1.customer_key, T3.customer_key, T1.X1, T1.X2
from T1
full outer join T2
on T1.Customer_key = T2.customer_key
where T1.X3 = '2018-02-01' and T2.A3 = '2018-02-17'
```
It returns lesser number of rows than the total records that satisfying the where clause. Please advice | 2020/08/25 | [
"https://Stackoverflow.com/questions/63570652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7933418/"
] | Full outer join with filtering is just confusing. I recommend filtering in subqueries:
```
select T1.customer_key, T3.customer_key, T1.X1, T1.X2
from (select t1.*
from T1
where T1.X3 = '2018-02-01'
) t1 full outer join
(select t2.*
from T2
where T2.A3 = '2018-02-17'
) t2
on T1.Customer_key = T2.customer_key ;
```
Your filter turns the outer join into an inner join. Moving the conditions to the `on` clause returns all rows in both tables -- but generally with lots of `null` values. Using `(T1.X3 = '2018-02-01' or t1.X3 is null) and (T2.A3 = '2018-02-17' or T2.A3 is null)` doesn't quite do the right thing either. Filtering first is what you are looking for. | When you join tables via `FULL OUTER JOIN`, the query engine finds all matched records (`INNER JOIN`) and also add any unmatched records from both tables to the `JOIN` result set. The latter have `NULL`s in all columns for the other table.
So for example, `customer = 1000` in `T1` will be included in the `JOIN` result although there is no such customer in `T2` but all columns from `T2` will be `NULL` (because of `FULL OUTER`). Then, when you apply a `WHERE` clause on these records (`WHERE` is executed after `JOIN` operations) your result set will EXCLUDE `customer = 1000` because `T2.A3 = '2018-02-17'` will fail (because `T2.A3` is `NULL` for `customer = 100`).
I couldn't provide a query to your question because your explanation is lacking what you are trying to accomplish and I couldn't make sense of your result set: why `customer = 1000` included but not `customer = 1002` for example. Please describe what you're trying to accomplish.
Depending on what you're trying to accomplish, you can move part of your `WHERE` clause to `JOIN` or use filters like `T1.customer is NULL` / `T1.customer is NOT NULL` to identify cases where records didn't match / did match and filter exactly what you need. |
68,276,673 | Assume I have `df1`:
```
df1= pd.DataFrame({'alligator_apple': range(1, 11),
'barbadine': range(11, 21),
'capulin_cherry': range(21, 31)})
alligator_apple barbadine capulin_cherry
0 1 11 21
1 2 12 22
2 3 13 23
3 4 14 24
4 5 15 25
5 6 16 26
6 7 17 27
7 8 18 28
8 9 19 29
9 10 20 30
```
And a `df2`:
```
df2= pd.DataFrame({'alligator_apple': [6, 7, 15, 5],
'barbadine': [3, 19, 25, 12],
'capulin_cherry': [1, 9, 15, 27]})
alligator_apple barbadine capulin_cherry
0 6 3 1
1 7 19 9
2 15 25 15
3 5 12 27
```
I'm looking for a way to create a new column in `df2` that gets number of rows based on a condition where all columns in `df1` has values greater than their counterparts in `df2` for each row. For example:
```
alligator_apple barbadine capulin_cherry greater
0 6 3 1 4
1 7 19 9 1
2 15 25 15 0
3 5 12 27 3
```
To elaborate, at row 0 of `df2`, `df1.alligator_apple` has 4 rows which values are higher than `df2.alligator_apple` with the value of 6. `df1.barbadine` has 10 rows which values are higher than `df2.barbadine` with value of 3, while similarly `df1.capulin_cherry` has 10 rows.
Finally, apply an 'and' condition to all aforementioned conditions to get the number '4' of `df2.greater` of first row. Repeat for the rest of rows in `df2`.
Is there a simple way to do this? | 2021/07/06 | [
"https://Stackoverflow.com/questions/68276673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11133739/"
] | I just had the same issue and fixed it. So, you probably installed jest globally on accident. In doing so, it likely ended up installed inside of `users/yourname/node-modules/`. If you can pull up a terminal, try doing a `cd` into `node-modules` from your home folder then do a `ls -a`. If you see `babel-jest`, do a `rm -r babel-jest` and `rm -r jest`. This fixed the problem for me. I'm running Linux, but the same strategy should work on Windows (not sure if the commands are exactly the same). | You probably installed a different global (npm install -g) version that is currently conflicting with the one you installed in your project.
You can quite literally delete the folder `babel-jest` inside `C:\Users\YV\node_modules\` and try again. I would assume you're doing this by using create-react-app. Rest assured that Jest is already part of the installed dependencies (hence the message pointing to `package-lock.json`). |
2,314,781 | I have a class which sets an alarm but I need to set around 10 more of these alarms. Instead of duplicating classes, is there a way I can just make a new instance of the class and set the alarm time?
Here's my code.
```
import java.util.Calendar;
import java.lang.String;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.ListActivity;
import android.app.PendingIntent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Intent;
import android.widget.Button;
import android.widget.Toast;
public class Alarm extends Activity {
/* for logging - see my tutorial on debuggin Android apps for more detail */
private static final String TAG = "SomeApp ";
protected Toast mToast;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setAlarm();
}
public void setAlarm() {
try {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 0);
cal.set(Calendar.HOUR_OF_DAY, 9);
cal.set(Calendar.MINUTE, 01);
cal.set(Calendar.SECOND, 0);
Intent intent = new Intent(Alarm.this, Alarm1.class);
PendingIntent sender = PendingIntent.getBroadcast(this, 1234567, intent, 0);
PendingIntent sende2 = PendingIntent.getBroadcast(this, 123123, intent, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender); // to be alerted 30 seconds from now
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sende2); // to be alerted 15 seconds from now
/* To show how alarms are cancelled we will create a new Intent and a new PendingIntent with the
* same requestCode as the PendingIntent alarm we want to cancel. In this case, it is 1234567.
* Note: The intent and PendingIntent have to be the same as the ones used to create the alarms.
*/
Intent intent1 = new Intent(Alarm.this, Alarm1.class);
PendingIntent sender1 = PendingIntent.getBroadcast(this, 1234567, intent1, 0);
AlarmManager am1 = (AlarmManager) getSystemService(ALARM_SERVICE);
am1.cancel(sender1);
} catch (Exception e) {
Log.e(TAG, "ERROR IN CODE:"+e.toString());
}
}
};
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Intent i = new Intent(getContext(),Alarm.class);
//Code below is from another class which is where im calling the alarm application
// ctx.startActivity (i);// start the Alarm class activity (class)public void onClick(View v) {
Alarm a = new Alarm ();
a.setAlarm();
b1.setText(prod);
}
});
```
The above code is from another class and on the button click the user can set a reminder (the buttom invokes the alarm class, the only to get it to work is using an intent. I simply tried to call the setAlarm method but that didn't work.
Maybe I could make a new instance of calendar and set the time in the button handler. Then I would have to pass that instance to the alarm class. Do you know if that would be possible? | 2010/02/22 | [
"https://Stackoverflow.com/questions/2314781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264905/"
] | Can't you just create one Calendar instance in onCreate(), set its parameters, then pass the instance to setAlarm(), modify the instance, call setAlarm(), etc, or am I missing something?
e.g. -
```
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 0);
cal.set(Calendar.HOUR_OF_DAY, 9);
cal.set(Calendar.MINUTE, 01);
cal.set(Calendar.SECOND, 0);
setAlarm(cal);
cal.set(Calendar.HOUR_OF_DAY, 12);
cal.set(Calendar.MINUTE, 30);
setAlarm(cal);
//etc
}
public void setAlarm(Calendar cal) {
try {
Intent intent = new Intent(Alarm.this, Alarm1.class);
PendingIntent sender = PendingIntent.getBroadcast(this, 1234567, intent, 0);
PendingIntent sende2 = PendingIntent.getBroadcast(this, 123123, intent, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender); // to be alerted 30 seconds from now
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sende2); // to be alerted 15 seconds from now
/* To show how alarms are cancelled we will create a new Intent and a new PendingIntent with the
* same requestCode as the PendingIntent alarm we want to cancel. In this case, it is 1234567.
* Note: The intent and PendingIntent have to be the same as the ones used to create the alarms.
*/
Intent intent1 = new Intent(Alarm.this, Alarm1.class);
PendingIntent sender1 = PendingIntent.getBroadcast(this, 1234567, intent1, 0);
AlarmManager am1 = (AlarmManager) getSystemService(ALARM_SERVICE);
am1.cancel(sender1);
} catch (Exception e) {
Log.e(TAG, "ERROR IN CODE:"+e.toString());
}
}
``` | You can only have one activity in the foreground so to call setAlarm 10 times you would need to go an alternative route. Maybe loop? ;) |
978,052 | I have Alienware 15 R3 with:
* 512GB NVME SSD - Windows 10.
* 1TB HDD - 300GB free space available.
I would like to install Ubuntu using the free space available in 1TB HDD.
I have experience installing Dual Boot Ubuntu on my old laptop, but after a Windows 10 auto-update, the boot loader got corrupted.
So, how should I install Ubuntu without disturbing anything that links to Windows Boot? | 2017/11/19 | [
"https://askubuntu.com/questions/978052",
"https://askubuntu.com",
"https://askubuntu.com/users/136502/"
] | I have been having this issue for a while and I found an answer to a similar questions [here](https://askubuntu.com/questions/31786/chrome-asks-for-password-to-unlock-keyring-on-startup#answer-968149) that seems to resolve this. In short, copy `google-chrome.desktop` file to your home folder and edit it to use the 'Basic' password storage setting:
```
cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/
```
Then look for the line that looks like this:
```
Exec=/usr/bin/google-chrome-stable %U
```
And change it to:
```
Exec=/usr/bin/google-chrome-stable --password-store=basic %U
```
I also had a number of files in the `~/.local/share/applications/` folder that looked like `Chrome-jdj94r5hsfjnfasdfsdfafp-Default.desktop` that seemed to have been placed there over time based on the timestamps but I deleted them all.
Saved passwords now show up immediately when the page is loaded. | Chrome has fixed the bug and now available as per this bug report <https://bugs.chromium.org/p/chromium/issues/detail?id=571003> |
9,970,713 | I am having real trouble with provisioning and code signing issues. I have migrated to a new computer and have a bunch of "Valid signing identity not found" messages. In repeated attempts to fix distribution code signing I have managed to lose my developer code signing as well.
I am the first to admit that the root problem is my **complete and utter failure** to grasp the concepts of code signing, provisioning, and all related subjects. I am asking a [separate question](https://stackoverflow.com/questions/9970910/what-are-good-resources-other-than-apple-to-understand-certificates-code-sign) on SO to address this.
THIS question is to ask for concrete steps to wipe my provisioning and code signing mess completely clean. I am running Xcode 4.3 and have 2 live apps in the App Store that I do not want to interrupt the distribution of. Please help.
**Update:** I have imported my private key from the old mac, and it is showing in Keychain Access. When I try to request a certificate according to Apple docs, I don't get a "Let me specify key/value" checkbox, and when I try to save it to disk anyways I get the error "the specified item could not be found in the keychain". Arrgh. | 2012/04/02 | [
"https://Stackoverflow.com/questions/9970713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/401543/"
] | **Step 1**: Open XCode. In the Organizer, delete all provisioning profiles.
**Step 2**: Open Keychain Access (Utilities>Keychain Access); delete all certificates related to developer/distribution and the WWDCCA (or whatever it's called) intermediate certificate.
**Step 3**: Re-download and resign. Make sure you export and import your private key from your old machine to your new one.
If you need instructions on how to set up code signing, you can look at my answer to this question: [Code Signing Error](https://stackoverflow.com/questions/9287401/code-signing-error/9287639#9287639).
Cheers! | Have a look at this tutorial here. You may find this helpful
<http://seventhsoulmountain.blogspot.com/2013/09/ios-code-sign-in-complete-walkthrough.html> |
57,362,904 | I'll try to simplify my question:
I have a div container with a fixed height of 200px. Inside, I have a flexbox that shows vertical items. Each item has a FIXED height which should not change. I use `overflow: hidden` to prevent the last item to break out of that 200px. This works well.
**This is what I have with `overflow: hidden`**
[](https://i.stack.imgur.com/AIGU6.png)
**This is what I have without `overflow: hidden`**
[](https://i.stack.imgur.com/6C4VL.png)
But now, I'd like to take one step forward and prevent the rendering of the last item, if it's about to be cut and not displayed fully due to the container fixed height limitations and `overflow: hidden`
**This is what I really want, show only those items which are not cut fully or partially by the overflow: hidden;**
[](https://i.stack.imgur.com/JChAJ.png)
What's the best practice of achieving that? a kind of "**make sure all items fit in their fixed height inside the fixed height component and if one doesn't fit, don't show it at all**".
Using the lastest React. Probably doesn't matter but still.
I've made a small example here.
<https://jsfiddle.net/hfw1t2p0/>
Basically, I want to keep enforcing the 200px max height of the flexbox, but have some kind of automation that kills all elements which are partially or fully invisible, like items "4" and "5" in the example.
Please note the 200px flexbox height, and 50px item height are just examples. In reality, I need a flexbox that can weed out any item that doesn't fit fully in it... the max height of the flexbox or minimum height of elements is unknown until runtime. | 2019/08/05 | [
"https://Stackoverflow.com/questions/57362904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282918/"
] | First Thing : you should get benefits from using react:
To make Content Dynamically I'll add `gridItem` to state so that they're rendered dynamically.
```
state = {
items: [
"1",
"2",
"3",
" 4 I want this hidden, its partially visible",
"5 I want this hidden, its partially visible"
]
};
```
And For render:
```
render() {
return (
<div className="test">
<div className="gridContainer">
{this.state.items.map(el => {
return <div className="gridItem">{el}</div>;
})}
</div>
</div>
);
}
```
.
[First Demo](https://codesandbox.io/s/hungry-easley-kc88e)
Here is the Cool Part:
----------------------
Based on:
>
> Each item has a FIXED height which should not change
>
>
>
So that all items should have same height. The solution is to add:
1- ItemHeight
2- ContainerHeight
3-BorderWidth
to the state. Now with Some calculations + inline Styling You can achieve Your Goal:
first Your state will be:
```
state = {
containerHeight: 200, // referring to Container Height
gridHeight: 50, // referring to grid item Height
border: 1, // referring to border width
items: [
"1",
"2",
"3",
" 4 I want this hidden, its partially visible",
"5 I want this hidden, its partially visible"
]
};
```
in your `render()` method before return add this:
```
let ContHeight = this.state.containerHeight + "px";
let gridHeight = this.state.gridHeight + "px";
let border = this.state.border + "px solid green";
let gridStyle = {
maxHeight: ContHeight,
};
```
These are the same styles used in css but They're removed now from css and applied with inline styling.
`Container` will take it's max height property as:
```
<div className="gridContainer" style={gridStyle}> //gridStyle defined above.
```
let's see How `gridItems` will b e renderd:
```
//el for element, index for index of the element
{this.state.items.map((el, index) => {
// i now will start from 1 instead of 0
let i = index + 1,
// current height is calculating the height of the current item
// first item will be like: 1*50 + 1*1*2 = 52
// second item will be like: 2*50 + 2*1*2 = 104
// and so on
CurrentHeight =
i * this.state.gridHeight + i * this.state.border * 2,
// now we should determine if current height is larger than container height
// if yes: new Class "hidden" will be added.
// and in css we'll style it.
itemStyle =
CurrentHeight <= this.state.containerHeight
? "gridItem"
: "gridItem hidden";
return (
// YOU'RE A GOOD READER IF YOU REACHED HERE!
// now styleclass will be added to show-hide the item
// inline style will be added to make sure that the item will have same height, border-width as in state.
<div
className={itemStyle}
style={{ height: gridHeight, border: border }}
>
{el}
</div>
);
})}
```
Finally! in css add this:
```
.gridItem.hidden {
display: none;
}
```
[](https://i.stack.imgur.com/CJbRC.png)
**[Final Demo 1](https://codesandbox.io/s/affectionate-leaf-licnu)**
**[Final Demo 2 with 40px gridItem height](https://codesandbox.io/s/charming-snow-ig45r)**
**[Final Demo 3 with 300px container height](https://codesandbox.io/s/vigorous-yalow-h1zv5)** | why not test elements with `document.getElementById('element').clientHeight`?
check the container size and find which element is visible or not. |
57,362,904 | I'll try to simplify my question:
I have a div container with a fixed height of 200px. Inside, I have a flexbox that shows vertical items. Each item has a FIXED height which should not change. I use `overflow: hidden` to prevent the last item to break out of that 200px. This works well.
**This is what I have with `overflow: hidden`**
[](https://i.stack.imgur.com/AIGU6.png)
**This is what I have without `overflow: hidden`**
[](https://i.stack.imgur.com/6C4VL.png)
But now, I'd like to take one step forward and prevent the rendering of the last item, if it's about to be cut and not displayed fully due to the container fixed height limitations and `overflow: hidden`
**This is what I really want, show only those items which are not cut fully or partially by the overflow: hidden;**
[](https://i.stack.imgur.com/JChAJ.png)
What's the best practice of achieving that? a kind of "**make sure all items fit in their fixed height inside the fixed height component and if one doesn't fit, don't show it at all**".
Using the lastest React. Probably doesn't matter but still.
I've made a small example here.
<https://jsfiddle.net/hfw1t2p0/>
Basically, I want to keep enforcing the 200px max height of the flexbox, but have some kind of automation that kills all elements which are partially or fully invisible, like items "4" and "5" in the example.
Please note the 200px flexbox height, and 50px item height are just examples. In reality, I need a flexbox that can weed out any item that doesn't fit fully in it... the max height of the flexbox or minimum height of elements is unknown until runtime. | 2019/08/05 | [
"https://Stackoverflow.com/questions/57362904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282918/"
] | You could use the flexbox columns to send the overflowing items to another column and set the width to the width of the container to hide the items if you want to achieve this by plain flexbox css properties like you mentioned in the question. <https://jsfiddle.net/kna61edz/>
```css
.gridContainer {
display: flex;
flex-direction: column;
background: yellow;
max-height: 200px;
overflow: hidden;
flex-wrap: wrap;
width: 52px;
}
```
The only difference is that you won't be seeing the yellow background of the gridContainer but you can set the background in the enclosing div like in the picture below but it will adapt to the height of the child divs.
[](https://i.stack.imgur.com/pOvEM.png) | why not test elements with `document.getElementById('element').clientHeight`?
check the container size and find which element is visible or not. |
57,362,904 | I'll try to simplify my question:
I have a div container with a fixed height of 200px. Inside, I have a flexbox that shows vertical items. Each item has a FIXED height which should not change. I use `overflow: hidden` to prevent the last item to break out of that 200px. This works well.
**This is what I have with `overflow: hidden`**
[](https://i.stack.imgur.com/AIGU6.png)
**This is what I have without `overflow: hidden`**
[](https://i.stack.imgur.com/6C4VL.png)
But now, I'd like to take one step forward and prevent the rendering of the last item, if it's about to be cut and not displayed fully due to the container fixed height limitations and `overflow: hidden`
**This is what I really want, show only those items which are not cut fully or partially by the overflow: hidden;**
[](https://i.stack.imgur.com/JChAJ.png)
What's the best practice of achieving that? a kind of "**make sure all items fit in their fixed height inside the fixed height component and if one doesn't fit, don't show it at all**".
Using the lastest React. Probably doesn't matter but still.
I've made a small example here.
<https://jsfiddle.net/hfw1t2p0/>
Basically, I want to keep enforcing the 200px max height of the flexbox, but have some kind of automation that kills all elements which are partially or fully invisible, like items "4" and "5" in the example.
Please note the 200px flexbox height, and 50px item height are just examples. In reality, I need a flexbox that can weed out any item that doesn't fit fully in it... the max height of the flexbox or minimum height of elements is unknown until runtime. | 2019/08/05 | [
"https://Stackoverflow.com/questions/57362904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282918/"
] | First Thing : you should get benefits from using react:
To make Content Dynamically I'll add `gridItem` to state so that they're rendered dynamically.
```
state = {
items: [
"1",
"2",
"3",
" 4 I want this hidden, its partially visible",
"5 I want this hidden, its partially visible"
]
};
```
And For render:
```
render() {
return (
<div className="test">
<div className="gridContainer">
{this.state.items.map(el => {
return <div className="gridItem">{el}</div>;
})}
</div>
</div>
);
}
```
.
[First Demo](https://codesandbox.io/s/hungry-easley-kc88e)
Here is the Cool Part:
----------------------
Based on:
>
> Each item has a FIXED height which should not change
>
>
>
So that all items should have same height. The solution is to add:
1- ItemHeight
2- ContainerHeight
3-BorderWidth
to the state. Now with Some calculations + inline Styling You can achieve Your Goal:
first Your state will be:
```
state = {
containerHeight: 200, // referring to Container Height
gridHeight: 50, // referring to grid item Height
border: 1, // referring to border width
items: [
"1",
"2",
"3",
" 4 I want this hidden, its partially visible",
"5 I want this hidden, its partially visible"
]
};
```
in your `render()` method before return add this:
```
let ContHeight = this.state.containerHeight + "px";
let gridHeight = this.state.gridHeight + "px";
let border = this.state.border + "px solid green";
let gridStyle = {
maxHeight: ContHeight,
};
```
These are the same styles used in css but They're removed now from css and applied with inline styling.
`Container` will take it's max height property as:
```
<div className="gridContainer" style={gridStyle}> //gridStyle defined above.
```
let's see How `gridItems` will b e renderd:
```
//el for element, index for index of the element
{this.state.items.map((el, index) => {
// i now will start from 1 instead of 0
let i = index + 1,
// current height is calculating the height of the current item
// first item will be like: 1*50 + 1*1*2 = 52
// second item will be like: 2*50 + 2*1*2 = 104
// and so on
CurrentHeight =
i * this.state.gridHeight + i * this.state.border * 2,
// now we should determine if current height is larger than container height
// if yes: new Class "hidden" will be added.
// and in css we'll style it.
itemStyle =
CurrentHeight <= this.state.containerHeight
? "gridItem"
: "gridItem hidden";
return (
// YOU'RE A GOOD READER IF YOU REACHED HERE!
// now styleclass will be added to show-hide the item
// inline style will be added to make sure that the item will have same height, border-width as in state.
<div
className={itemStyle}
style={{ height: gridHeight, border: border }}
>
{el}
</div>
);
})}
```
Finally! in css add this:
```
.gridItem.hidden {
display: none;
}
```
[](https://i.stack.imgur.com/CJbRC.png)
**[Final Demo 1](https://codesandbox.io/s/affectionate-leaf-licnu)**
**[Final Demo 2 with 40px gridItem height](https://codesandbox.io/s/charming-snow-ig45r)**
**[Final Demo 3 with 300px container height](https://codesandbox.io/s/vigorous-yalow-h1zv5)** | You could use the flexbox columns to send the overflowing items to another column and set the width to the width of the container to hide the items if you want to achieve this by plain flexbox css properties like you mentioned in the question. <https://jsfiddle.net/kna61edz/>
```css
.gridContainer {
display: flex;
flex-direction: column;
background: yellow;
max-height: 200px;
overflow: hidden;
flex-wrap: wrap;
width: 52px;
}
```
The only difference is that you won't be seeing the yellow background of the gridContainer but you can set the background in the enclosing div like in the picture below but it will adapt to the height of the child divs.
[](https://i.stack.imgur.com/pOvEM.png) |
16,602,277 | I am trying to use the @Scheduled feature. I have followed [this](http://krams915.blogspot.com/2011/01/spring-3-task-scheduling-via.html) and [this](http://blog.springsource.com/2010/01/05/task-scheduling-simplifications-in-spring-3-0/) tutorials but I can not get my scheduled task to be executed.
I have created a worker:
```
@Component("syncWorker")
public class SyncedEliWorker implements Worker {
protected Logger logger = Logger.getLogger(this.getClass());
public void work() {
String threadName = Thread.currentThread().getName();
logger.debug(" " + threadName + " has began to do scheduled scrap with id=marketwatch2");
}
}
```
and a SchedulingService:
```
@Service
public class SchedulingService {
protected Logger logger = Logger.getLogger(this.getClass());
@Autowired
@Qualifier("syncWorker")
private Worker worker;
@Scheduled(fixedDelay = 5000)
public void doSchedule() {
logger.debug("Start schedule");
worker.work();
logger.debug("End schedule");
}
}
```
And tried different wiring in my applicationcontext.
The final version looks like:
```
<beans xmlns=...
xmlns:task="http://www.springframework.org/schema/task"
...
xsi:schemaLocation=" ..
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<context:annotation-config/>
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler"/>
<task:scheduler id="taskScheduler" pool-size="3"/>
<task:executor id="taskExecutor" pool-size="3"/>
... Other beans...
</beans>
```
The server starts up with out any errors.
Am I missing something? | 2013/05/17 | [
"https://Stackoverflow.com/questions/16602277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162345/"
] | `<context:annotation-config />` does not detect beans - it just processes the annotations on declared beans. Which means your `@Service` is not actually turned into a bean.
Use `<context:component-scan base-package="com.yourcomany" />` instead. | I faced the same problem, but the cause was different.
I had to add in my top project the following:
```
<task:annotation-driven />
```
When you add this, don't forget to also add to the correct place in your application context:
```
xmlns:task="http://www.springframework.org/schema/task"
```
and:
```
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
``` |
22,468,622 | While using resque-scheduler to set\_schedule dynamic cron jobs based on user's input the schedules seem to be set but the worker never actually starts at the set schedule.
In the Resque configuration dynamic is set to true like so: Resque::Scheduler.dynamic = true
And I am setting the schedule like so:
```
name = business.name + '_employee_import'
config = {}
config[:class] = 'ImporterWorker'
config[:args] = business.id.to_s
config[:cron] = cron_converter
config[:persist] = true
Resque.set_schedule(name, config)
```
If I do in the command line:
```
Resque.get_schedule("business_employee_import")
```
I get:
```
{"class"=>"MyWorker", "args"=>"87", "cron"=>"19 18 * * * *"}
```
But come 6:19pm the worker does not start. I have a worker running but the job never gets picked up and I have no idea why or how to troubleshoot. It seems to me this should work. I have also tried updating resque-scheduler to the latest release, no luck yet.
Thanks for any help in advanced. | 2014/03/18 | [
"https://Stackoverflow.com/questions/22468622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664675/"
] | You probably forgot to start the scheduler with the `DYNAMIC_SCHEDULE` environment variable set to `true`.
Here is the command I use to start the scheduler:
```
DYNAMIC_SCHEDULE=true rake resque:scheduler
```
Quote from README:
>
> DYNAMIC\_SCHEDULE - Enables dynamic scheduling if non-empty (default
> false)
>
>
> | Make sure you have queue task running. So your scheduled task will get picked up by the queue.
```
QUEUE=* rake resque:work
```
Set the cron job and try again after issuing that command |
22,468,622 | While using resque-scheduler to set\_schedule dynamic cron jobs based on user's input the schedules seem to be set but the worker never actually starts at the set schedule.
In the Resque configuration dynamic is set to true like so: Resque::Scheduler.dynamic = true
And I am setting the schedule like so:
```
name = business.name + '_employee_import'
config = {}
config[:class] = 'ImporterWorker'
config[:args] = business.id.to_s
config[:cron] = cron_converter
config[:persist] = true
Resque.set_schedule(name, config)
```
If I do in the command line:
```
Resque.get_schedule("business_employee_import")
```
I get:
```
{"class"=>"MyWorker", "args"=>"87", "cron"=>"19 18 * * * *"}
```
But come 6:19pm the worker does not start. I have a worker running but the job never gets picked up and I have no idea why or how to troubleshoot. It seems to me this should work. I have also tried updating resque-scheduler to the latest release, no luck yet.
Thanks for any help in advanced. | 2014/03/18 | [
"https://Stackoverflow.com/questions/22468622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664675/"
] | I actually solved my issue by using the following commands:
bundle exec rake environment resque:work
bundle exec rake resque:scheduler
Turns out by not using Bundle Exec the schedule would not get picked up.
I have not tried the environment variable command up there, but I will tomorrow and if that works out I'll give you the points. | Make sure you have queue task running. So your scheduled task will get picked up by the queue.
```
QUEUE=* rake resque:work
```
Set the cron job and try again after issuing that command |
22,468,622 | While using resque-scheduler to set\_schedule dynamic cron jobs based on user's input the schedules seem to be set but the worker never actually starts at the set schedule.
In the Resque configuration dynamic is set to true like so: Resque::Scheduler.dynamic = true
And I am setting the schedule like so:
```
name = business.name + '_employee_import'
config = {}
config[:class] = 'ImporterWorker'
config[:args] = business.id.to_s
config[:cron] = cron_converter
config[:persist] = true
Resque.set_schedule(name, config)
```
If I do in the command line:
```
Resque.get_schedule("business_employee_import")
```
I get:
```
{"class"=>"MyWorker", "args"=>"87", "cron"=>"19 18 * * * *"}
```
But come 6:19pm the worker does not start. I have a worker running but the job never gets picked up and I have no idea why or how to troubleshoot. It seems to me this should work. I have also tried updating resque-scheduler to the latest release, no luck yet.
Thanks for any help in advanced. | 2014/03/18 | [
"https://Stackoverflow.com/questions/22468622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664675/"
] | You probably forgot to start the scheduler with the `DYNAMIC_SCHEDULE` environment variable set to `true`.
Here is the command I use to start the scheduler:
```
DYNAMIC_SCHEDULE=true rake resque:scheduler
```
Quote from README:
>
> DYNAMIC\_SCHEDULE - Enables dynamic scheduling if non-empty (default
> false)
>
>
> | I actually solved my issue by using the following commands:
bundle exec rake environment resque:work
bundle exec rake resque:scheduler
Turns out by not using Bundle Exec the schedule would not get picked up.
I have not tried the environment variable command up there, but I will tomorrow and if that works out I'll give you the points. |
21,324,330 | How can I get `[jobNo]` using loop from array below?
```none
Array
(
[date] => 2014-01-13
[totcomdraft] => 400
[comdraft] => 0
[0] => Array
(
[jobNo] => 1401018618
[dateType] => 1
[comdraft] => 200
)
[1] => Array
(
[jobNo] => 1401018615
[dateType] => 1
[comdraft] => 100
)
[2] => Array
(
[jobNo] => 1401018617
[dateType] => 1
[comdraft] => 100
)
)
``` | 2014/01/24 | [
"https://Stackoverflow.com/questions/21324330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325668/"
] | Try this
```
foreach($array as $key=>$val){
if(is_array($val)){
echo $val["jobNo"];
echo "<br />";
}
}
``` | ```
for( $i = 0; $ < count($array); $i++ )
{
print $array[$i]['jobNo'] . "<br>";
}
``` |
21,324,330 | How can I get `[jobNo]` using loop from array below?
```none
Array
(
[date] => 2014-01-13
[totcomdraft] => 400
[comdraft] => 0
[0] => Array
(
[jobNo] => 1401018618
[dateType] => 1
[comdraft] => 200
)
[1] => Array
(
[jobNo] => 1401018615
[dateType] => 1
[comdraft] => 100
)
[2] => Array
(
[jobNo] => 1401018617
[dateType] => 1
[comdraft] => 100
)
)
``` | 2014/01/24 | [
"https://Stackoverflow.com/questions/21324330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325668/"
] | Try this
```
foreach($array as $key=>$val){
if(is_array($val)){
echo $val["jobNo"];
echo "<br />";
}
}
``` | try with array in-built function :-
```
$result_array=array_map(function($input_array)
{
return $input_array['desired_column'];
},$input_array_original
);
``` |
21,324,330 | How can I get `[jobNo]` using loop from array below?
```none
Array
(
[date] => 2014-01-13
[totcomdraft] => 400
[comdraft] => 0
[0] => Array
(
[jobNo] => 1401018618
[dateType] => 1
[comdraft] => 200
)
[1] => Array
(
[jobNo] => 1401018615
[dateType] => 1
[comdraft] => 100
)
[2] => Array
(
[jobNo] => 1401018617
[dateType] => 1
[comdraft] => 100
)
)
``` | 2014/01/24 | [
"https://Stackoverflow.com/questions/21324330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325668/"
] | Try this
```
foreach($array as $key=>$val){
if(is_array($val)){
echo $val["jobNo"];
echo "<br />";
}
}
``` | Use This
```
foreach($array as $key=>$val){
if(is_array($val)){ // check this value in array
echo $val["jobNo"];
echo "<br />";
}
}
``` |
21,324,330 | How can I get `[jobNo]` using loop from array below?
```none
Array
(
[date] => 2014-01-13
[totcomdraft] => 400
[comdraft] => 0
[0] => Array
(
[jobNo] => 1401018618
[dateType] => 1
[comdraft] => 200
)
[1] => Array
(
[jobNo] => 1401018615
[dateType] => 1
[comdraft] => 100
)
[2] => Array
(
[jobNo] => 1401018617
[dateType] => 1
[comdraft] => 100
)
)
``` | 2014/01/24 | [
"https://Stackoverflow.com/questions/21324330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325668/"
] | Try this
```
foreach($array as $key=>$val){
if(is_array($val)){
echo $val["jobNo"];
echo "<br />";
}
}
``` | This code should work. I have tested.
```
$array = array
(
'date' => '2014-01-13',
'totcomdraft' => 400,
'comdraft' => 0,
'0' => array
(
'jobNo' => 1401018618,
'dateType' => 1,
'comdraft' => 200
),
'1' => array
(
'jobNo' => 1401018615,
'dateType' => 1,
'comdraft' => 100
),
'2' => array
(
'jobNo' => 1401018617,
'dateType' => 1,
'comdraft' => 100
)
);
for($i=0; $i<3; $i++){
echo 'Job no:' . $array[$i]['jobNo']."<br>";
}
```
Output:
```
Job no:1401018618
Job no:1401018615
Job no:1401018617
``` |
4,404,711 | The **differential equation** is the following:
$ydx+(\frac{y^2}{4}-2x)dy=0$
It can be written as:
$\frac{y}{2x-\frac{y^2}{4}}=\frac{dy}{dx}$
However, this is not the linear shape. So we rewrite the equation as:
$\frac{2x-\frac{y^2}{4}}{y}=\frac{dx}{dy}\to\frac{dx}{dy}-\frac{2x}{y}=-\frac{y}{4}$
The **integrating factor** is:
$e^{\int{\frac{-2dy}{y}}}=\frac{k}{y^2}$ and k can't be zero (1).
If you **apply the integrating factor** to the original equation you get:
$\frac{k}{y}dx+(\frac{k}{4}-\frac{-2xk}{y^2})dy=0$
According to the **definition of an exact differential equation**, it must be true that the partial derivative in Y of $\frac{k}{y}$ is equal to the partial derivative in X of $(\frac{k}{4}-\frac{-2xk}{y^2})$. This leaves us with the equality:
$\frac{-k}{y^2}=\frac{-2k}{y^2}$
So the only possible solution is $k=0$, but this a **contradiction** (1).
How is it possible? Am I making a mistake? How can I get an integrating factor other than zero? | 2022/03/16 | [
"https://math.stackexchange.com/questions/4404711",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/986528/"
] | You can not just apply the integrating factor to the original equation. You need to apply it to the equation that you computed it for.
$$
\frac1{y^2}\frac{xy}{xy}-\frac{2x}{y^3}=-\frac1{4y}
$$
is nicely integrable. | $$ydx+(\frac{y^2}{4}-2x)dy=0$$
$$y\dfrac {dx}{dy}+(\frac{y^2}{4}-2x)=0$$
$$y\dfrac {dx}{dy}-2x=-\frac{y^2}{4}$$
The integrating factor is easy to find now.
$$y^2\dfrac {dx}{dy}-2yx=-\frac{y^3}{4}$$
$$\dfrac {y^2\dfrac {dx}{dy}-2yx}{y^4}=-\frac{1}{4y}$$
$$\left (\dfrac {x}{y^2}\right)'=-\frac{1}{4y}$$
As @Moo commented $\mu(y)=\dfrac {1}{y^3}$
. Now the DE is exact:
$$d\left (\dfrac {x}{y^2}\right)+\frac{dy}{4y}=0$$ |
24,398,937 | I have a flask running at domain.com
I also have another flask instance on another server running at username.domain.com
Normally user logs in through domain.com
However, for paying users they are suppose to login at username.domain.com
Using flask, how can I make sure that sessions are shared between domain.com and username.domain.com while ensuring that they will only have access to the specifically matching username.domain.com ?
I am concerned about security here. | 2014/06/25 | [
"https://Stackoverflow.com/questions/24398937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2982246/"
] | **EDIT:
Later, after reading your full question I noticed the original answer is not what you're looking for.**
I've left the original at the bottom of this answer for Googlers, but the revised version is below.
Cookies are automatically sent to subdomains on a domain (in most modern browsers the domain name must contain a period (indicating a TLD) for this behavior to occur). The authentication will need to happen as a pre-processor, and your session will need to be managed from a centralised source. Let's walk through it.
To confirm, I'll proceed assuming (from what you've told me) your setup is as follows:
* SERVER 1:
+ Flask app for domain.com
* SERVER 2:
+ Flask app for user profiles at username.domain.com
A problem that first must be overcome is storing the sessions in a location that is accessible to both servers. Since by default sessions are stored on disk (and both servers obviously don't share the same hard drive), we'll need to do some modifications to both the existing setup and the new Flask app for user profiles.
Step one is to choose where to store your sessions, a database powered by a DBMS such as MySQL, Postgres, etc. is a common choice, but people also often choose to put them somewhere more ephemeral such as Memcachd or Redis for example.
The short version for choosing between these two starkly different systems breaks down to the following:
**Database**
* Databases are readily available
* It's likely you already have a database implemented
* Developers usually have a pre-existing knowledge of their chosen database
**Memory (Redis/Memchachd/etc.)**
* Considerably faster
* Systems often offer basic self-management of data
* Doesn't incur extra load on existing database
You can find some examples database sessions in flask [here](https://stackoverflow.com/questions/17694469/flask-save-session-data-in-database-like-using-cookies) and [here](http://flask.pocoo.org/snippets/86/).
While Redis would be more difficult to setup depending on each users level of experience, it would be the option I recommend. You can see an example of doing this [here](http://flask.pocoo.org/snippets/75/).
The rest I think is covered in the original answer, part of which demonstrates the matching of username to database record (the larger code block).
**Old solution for a single Flask app**
Firstly, you'll have to setup Flask to handle subdomains, this is as easy as specifying a new variable name in your config file. For example, if your domain was example.com you would append the following to your Flask configuration.
```
SERVER_NAME = "example.com"
```
You can read more about this option [here](http://flask.pocoo.org/docs/config/).
Something quick here to note is that this will be extremely difficult (if not impossible) to test if you're just working off of localhost. As mentioned above, browsers often won't bother to send cookies to subdomains of a domain without dots in the name (a TLD). Localhost also isn't set up to allow subdomains by default in many operating systems. There are ways to do this like defining your own DNS entries that you can look into (`/etc/hosts` on \*UNIX, `%system32%/etc/hosts` on Windows).
Once you've got your config ready, you'll need to define a `Blueprint` for a subdomain wildard.
This is done pretty easily:
```
from flask import Blueprint
from flask.ext.login import current_user
# Create our Blueprint
deep_blue = Blueprint("subdomain_routes", __name__, subdomain="<username>")
# Define our route
@deep_blue.route('/')
def user_index(username):
if not current_user.is_authenticated():
# The user needs to log in
return "Please log in"
elif username != current_user.username:
# This is not the correct user.
return "Unauthorized"
# It's the right user!
return "Welcome back!"
```
The trick here is to make sure the `__repr__` for your user object includes a username key. For eg...
```
class User(db.Model):
username = db.Column(db.String)
def __repr__(self):
return "<User {self.id}, username={self.username}>".format(self=self)
```
Something to note though is the problem that arises when a username contains special characters (a space, @, ?, etc.) that don't work in a URL. For this you'll need to either enforce restrictions on the username, or properly escape the name first and unescape it when validating it.
If you've got any questions or requests, please ask. Did this during my coffee break so it was a bit rushed. | You can do this with the builtin Flask sessions, which are cookie-based client-side sessions. To allow users to login to multiple subdomains in '.domain.com', you need only to specify
```
app.config['SESSION_COOKIE_DOMAIN'] = '.domain.com'
```
and the client's browser will have a session cookie that allows him to login to every Flask instance that is at 'domain.com'.
This only works if every instance of Flask has the same app.secret\_key
For more information, also see
[Same Flask login session across two applications](https://stackoverflow.com/questions/58381669/same-flask-login-session-across-two-applications) |
8,412,530 | I have a hash with the following key/value pair
```
4 => model1
2 => model2
```
I want the following string created from the above hash
```
4 X model1 , 2 X model2
```
I tried the following
```
my %hash,
foreach my $keys (keys %hash) {
my $string = $string . join(' X ',$keys,$hash{$keys});
}
print $string;
```
What I get is
```
4 X model12Xmodel2
```
How can I accomplish the desired result `4 X model1 , 2 X model2`? | 2011/12/07 | [
"https://Stackoverflow.com/questions/8412530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238021/"
] | You could do:
```
my %hash = (4 => "model1", 2 => "model2");
my $str = join(", ", map { "$_ X $hash{$_}" } keys %hash);
print $str;
```
Output:
```
4 X model1, 2 X model2
```
How it works:
`map { expr } list` evaluates `expr` for every item in `list`, and returns the list that contains all the results of these evaluations. Here, `"$_ X $hash{$_}"` is evaluated for each key of the hash, so the result is a list of `key X value` strings. The `join` takes care of putting the commas in between each of these strings.
---
Note that your hash is a bit unusual if you're storing (item,quantity) pairs. It would usually be the other way around:
```
my %hash = ("model1" => 4, "model2" => 2);
my $str = join(", ", map { "$hash{$_} X $_" } keys %hash);
```
because with your scheme, you can't store the same quantity for two different items in your hash. | You can also modify your loop as follows:
```
my @tokens =();
foreach my $key (keys %hash) {
push @tokens, $string . join(' X ',$key, $hash{$key});
}
print join(', ' , @tokens);
``` |
3,913,574 | As the title implies, I want to compare two objects whose type may be diffrent.
For eg,
I expects 'true' for comparing 1000.0(Decimal) with 1000(Double) .
Similary, it should return true if I compare 10(string) and 10(double) .
I tried to compare using Object.Equals() , but it did NOT work.It return false if two objects have different data types.
```
Dim oldVal As Object ' assgin some value
Dim newVal As Object 'assgin some value
If Not Object.Equals(oldVal,newVal) Then
'do something
End If
```
**Edit:**
Could it be possible if I do the below?
```
1.check the type of oldVal
2.Covert the type of newVal to oldVal
3.Compare.
``` | 2010/10/12 | [
"https://Stackoverflow.com/questions/3913574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364412/"
] | Try this:
```
Dim oldVal As Object 'assgin some value
Dim newVal As Object 'assgin some value
Dim b As Boolean = False
If IsNumeric(oldVal) And IsNumeric(newVal) Then
b = (Val(oldVal) = Val(newVal))
ElseIf IsDate(oldVal) And IsDate(newVal) Then
b = (CDate(oldVal) = CDate(newVal))
Else
b = (oldVal.ToString() = newVal.ToString())
End If
If Not b Then
'do something
End If
```
Or use IIf like this:
```
If Not CBool(IIf(IsNumeric(oldVal) And IsNumeric(newVal),
(Val(oldVal) = Val(newVal)),
IIf(IsDate(oldVal) And IsDate(newVal),
(CDate(oldVal) = CDate(newVal)),
(oldVal.ToString() = newVal.ToString())))) Then
'do something
End If
``` | Mixing pears and apples? :)
Equals does equality comparison (the eefault implementation of Equals tests for referential equality). While "=" does identity comparison.
If you need a different behaviour for comparing two objects, then define an Equals method and/or a CompareTo method.
To compare integers with doubles, you have to (implicitly or explicitly) convert one of the two operands.
```
dim i as integer = 1000
dim d as double = 1000.0
return i = CInt(d)
``` |
3,913,574 | As the title implies, I want to compare two objects whose type may be diffrent.
For eg,
I expects 'true' for comparing 1000.0(Decimal) with 1000(Double) .
Similary, it should return true if I compare 10(string) and 10(double) .
I tried to compare using Object.Equals() , but it did NOT work.It return false if two objects have different data types.
```
Dim oldVal As Object ' assgin some value
Dim newVal As Object 'assgin some value
If Not Object.Equals(oldVal,newVal) Then
'do something
End If
```
**Edit:**
Could it be possible if I do the below?
```
1.check the type of oldVal
2.Covert the type of newVal to oldVal
3.Compare.
``` | 2010/10/12 | [
"https://Stackoverflow.com/questions/3913574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364412/"
] | Try this:
```
Dim oldVal As Object 'assgin some value
Dim newVal As Object 'assgin some value
Dim b As Boolean = False
If IsNumeric(oldVal) And IsNumeric(newVal) Then
b = (Val(oldVal) = Val(newVal))
ElseIf IsDate(oldVal) And IsDate(newVal) Then
b = (CDate(oldVal) = CDate(newVal))
Else
b = (oldVal.ToString() = newVal.ToString())
End If
If Not b Then
'do something
End If
```
Or use IIf like this:
```
If Not CBool(IIf(IsNumeric(oldVal) And IsNumeric(newVal),
(Val(oldVal) = Val(newVal)),
IIf(IsDate(oldVal) And IsDate(newVal),
(CDate(oldVal) = CDate(newVal)),
(oldVal.ToString() = newVal.ToString())))) Then
'do something
End If
``` | [Object.Equals](http://msdn.microsoft.com/en-us/library/w4hkze5k.aspx) considers two value objects equal when they (a) have the **same binary representation** and (b) are bitwise equal, so basically it will always return false for different value types.
You can try to convert all values to double using [Convert.ToDouble](http://msdn.microsoft.com/en-us/library/system.convert.todouble.aspx) and then compare double values, if that suits your task; be ready to catch possible exceptions with conversion though. |
3,913,574 | As the title implies, I want to compare two objects whose type may be diffrent.
For eg,
I expects 'true' for comparing 1000.0(Decimal) with 1000(Double) .
Similary, it should return true if I compare 10(string) and 10(double) .
I tried to compare using Object.Equals() , but it did NOT work.It return false if two objects have different data types.
```
Dim oldVal As Object ' assgin some value
Dim newVal As Object 'assgin some value
If Not Object.Equals(oldVal,newVal) Then
'do something
End If
```
**Edit:**
Could it be possible if I do the below?
```
1.check the type of oldVal
2.Covert the type of newVal to oldVal
3.Compare.
``` | 2010/10/12 | [
"https://Stackoverflow.com/questions/3913574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364412/"
] | Try this:
```
Dim oldVal As Object 'assgin some value
Dim newVal As Object 'assgin some value
Dim b As Boolean = False
If IsNumeric(oldVal) And IsNumeric(newVal) Then
b = (Val(oldVal) = Val(newVal))
ElseIf IsDate(oldVal) And IsDate(newVal) Then
b = (CDate(oldVal) = CDate(newVal))
Else
b = (oldVal.ToString() = newVal.ToString())
End If
If Not b Then
'do something
End If
```
Or use IIf like this:
```
If Not CBool(IIf(IsNumeric(oldVal) And IsNumeric(newVal),
(Val(oldVal) = Val(newVal)),
IIf(IsDate(oldVal) And IsDate(newVal),
(CDate(oldVal) = CDate(newVal)),
(oldVal.ToString() = newVal.ToString())))) Then
'do something
End If
``` | You've basically described the standard behaviour of VB.Net if you use `Option Strict Off`? So just use `Option Strict Off` and then write `a = b`
In fact I recommend you do not do this as it is very likely to introduce bugs :) Can you explain why you need this behaviour? |
3,913,574 | As the title implies, I want to compare two objects whose type may be diffrent.
For eg,
I expects 'true' for comparing 1000.0(Decimal) with 1000(Double) .
Similary, it should return true if I compare 10(string) and 10(double) .
I tried to compare using Object.Equals() , but it did NOT work.It return false if two objects have different data types.
```
Dim oldVal As Object ' assgin some value
Dim newVal As Object 'assgin some value
If Not Object.Equals(oldVal,newVal) Then
'do something
End If
```
**Edit:**
Could it be possible if I do the below?
```
1.check the type of oldVal
2.Covert the type of newVal to oldVal
3.Compare.
``` | 2010/10/12 | [
"https://Stackoverflow.com/questions/3913574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364412/"
] | Try this:
```
Dim oldVal As Object 'assgin some value
Dim newVal As Object 'assgin some value
Dim b As Boolean = False
If IsNumeric(oldVal) And IsNumeric(newVal) Then
b = (Val(oldVal) = Val(newVal))
ElseIf IsDate(oldVal) And IsDate(newVal) Then
b = (CDate(oldVal) = CDate(newVal))
Else
b = (oldVal.ToString() = newVal.ToString())
End If
If Not b Then
'do something
End If
```
Or use IIf like this:
```
If Not CBool(IIf(IsNumeric(oldVal) And IsNumeric(newVal),
(Val(oldVal) = Val(newVal)),
IIf(IsDate(oldVal) And IsDate(newVal),
(CDate(oldVal) = CDate(newVal)),
(oldVal.ToString() = newVal.ToString())))) Then
'do something
End If
``` | there are a couple of ways you could do this, below is the one i feel that is closest to what you're looking for, though personally I dont think its a good way to structure your solution.
```
Dim fooObj As New Foo
Dim barObj As New Bar
fooObj.Value = 10
barObj.Value = 10
System.Diagnostics.Debug.WriteLine(barObj.Equals(fooObj))
System.Diagnostics.Debug.WriteLine(barObj.Equals(barObj))
System.Diagnostics.Debug.WriteLine(barObj.Equals(10))
System.Diagnostics.Debug.WriteLine(barObj.Equals(20))
System.Diagnostics.Debug.WriteLine(barObj.Equals("10"))
System.Diagnostics.Debug.WriteLine(barObj.Equals("20"))
System.Diagnostics.Debug.WriteLine(Object.Equals(barObj, 10))
```
```
Public Class Foo
Public Value As Integer
End Class
Public Class Bar
Public Value As Integer
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If TypeOf obj Is Bar Then
Dim compareBar As Bar = DirectCast(obj, Bar)
Return MyClass.Value = compareBar.Value
ElseIf TypeOf obj Is Foo Then
Dim compareFoo As Foo = DirectCast(obj, Foo)
Return MyClass.Value = compareFoo.Value
ElseIf TypeOf obj Is Integer Then
Dim compareInt As Integer = DirectCast(obj, Integer)
Return MyClass.Value = compareInt
ElseIf TypeOf obj Is String Then
Dim compareString As String = DirectCast(obj, String)
Return MyClass.Value.ToString() = compareString
End If
Return False
End Function
End Class
``` |
49,748,378 | I am currently creating a math's quiz for kids in python tkinter. In this quiz i have 3 different 'pages' as per say. A start page, a quiz page and a score page for when the quiz is finished. In my start page, i have three different difficulties of the quiz the user can choose from. How do i essentially clear elements of the window from the start page such as my label's and button's once that button "EASY" or "HARD" is clicked so i can start the quiz? | 2018/04/10 | [
"https://Stackoverflow.com/questions/49748378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9623512/"
] | You could use a tabbed view and switch the tabs according to the difficulty selected (see tkinter notebooks <https://docs.python.org/3.1/library/tkinter.ttk.html#notebook>)
Or you could have the quiz in their selected difficulty in their own windows. | I would suggest you to use different frames that can be pushed on top of each other. Have a look at this answer [Switch between two frames in tkinter](https://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter). |
49,748,378 | I am currently creating a math's quiz for kids in python tkinter. In this quiz i have 3 different 'pages' as per say. A start page, a quiz page and a score page for when the quiz is finished. In my start page, i have three different difficulties of the quiz the user can choose from. How do i essentially clear elements of the window from the start page such as my label's and button's once that button "EASY" or "HARD" is clicked so i can start the quiz? | 2018/04/10 | [
"https://Stackoverflow.com/questions/49748378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9623512/"
] | If you put all your widgets in one frame, inside the window, like this:
```
root=Tk()
main=Frame(root)
main.pack()
widget=Button(main, text='whatever', command=dosomething)
widget.pack()
etc.
```
Then you can clear the screen like this:
```
main.destroy()
main=Frame(root)
```
Or in a button:
```
def clear():
global main, root
main.destroy()
main=Frame(root)
main.pack()
clearbtn=Button(main, text='clear', command=clear)
clearbtn.pack()
```
To clear the screen.
You can also just create a new window the same way as you created `root`(not recommended) or create a `toplevel` instance, which is better for creating multiple but essentially the same.
You can also use `grid_forget()`:
```
w=Label(root, text='whatever')
w.grid(options)
w.grid_forget()
```
Will create w, but the remove it from the screen, ready to be put back on with the same options. | I would suggest you to use different frames that can be pushed on top of each other. Have a look at this answer [Switch between two frames in tkinter](https://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter). |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | Keywords aren't changed and their meaning is explained. But almost everything else is in Spanish, because concepts are taught in Spanish and have their own Spanish terminology, and exercises reflect that. I mean, if the lesson was about trees or stacks, it would be taught in terms of "árboles" and "pilas", and the programs would have their classes "Arbol", "Nodo" and "Pila".
And the comments would also be in Spanish, because nobody is testing your English (neither you the teacher's!) but whether you understand what the code does and can explain it.
In a professional setting, I think, English is more prevalent. Especially now, when international teams are more common. When I last worked in a Spanish-speaking firm, some 10 years ago, we did almost everything is Spanish. | I learned programming in French. Since French is of the same root it is fair to assume it is the same in Spanish. I followed programming courses in highschool in my native country as well (Colombia, where spanish is spoken) and it was the same as in France.
>
> **Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?**
>
>
>
Yes they usually do. If you don't have english proficiency or at least some basic knowledge you won't have access to most internet based resources for that programming language. Most importantly the documentation that is not always translated into spanish. Of course there are some exceptions in which they use a spanish tutorial book and that's all they need, but those, as said, are exceptions.
>
> **Do they teach you what English keywords mean?**
>
>
>
In my case sometimes they did, even if we already knew english. They would only teach the meaning if it is really relevant to the method or procedure it is referring to. For instance the method String.isNullOrEmpty().
>
> **Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?**
>
>
>
In my case I wasn't taught anything about it. That I had freedom to choose Spanish or english (or French) as long as I stick with it throughout the program. It is not confusing since the program would be for Spanish-speaking programmers. Specially if the keywords are highlighted in different colors as the methods and variables (in most languages and editors anyway). Blue for public, private, static, void, string, int, etc... and black for names made by you.
>
> **Lastly, can you get/do you use, things like Javadocs in Spanish?**
>
>
>
Depends, if what you are looking for is easy to find then spanish, or more complicated in english. There are more chances of finding it in english than in spanish. In the case of JavaDoc, for making a custom documentation it depends on the public that will read it. Spanish for spanish speakers and english for all others. As for the standard documentation I'm not sure if there is such a documentation in spanish for java.
As a last note, all these are personal thoughts based on personal experiences. I am not talking for all cases and don't pretend to either.
Keep in mind that this greatly depends on the teaching style of the institution and the skills of the students, sometimes the students will have only a rudimentary knowledge of english and english classes are given separately to fix this, but while that is done everything related to programming is done in their native language(as it happens in France) |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | I'm a Mexican telecommunications engineer, and here's how it went for me:
>
> Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?
>
>
>
Usually not, but it's a *very* good idea to start with some cursory knowledge of English.
>
> Do they teach you what English keywords mean?
>
>
>
They usually do, but it depends entirely on how kind is the instructor.
>
> Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?
>
>
>
Again, this depends on the instructor. Back in college some professors used variables in Spanish, and some used them in English. As long as your tongue choice is always consistent you should have no trouble.
>
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
Usually only for basic stuff. In fact, a lot of Mexican engineering students struggle because all the documentations and manuals are in English only and they don't speak English. | This is from a long time ago. After I learned to program in ANSII Basic I once started reading a book called "Basic in Spanish" I threw it away the very first day since it didn't make sense to relearn every single keyword in Spanish. |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | How it looks in Spain:
>
> Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?
>
>
>
Not in Spain. Obviously it's a plus if someone can, but most people don't understand English and it's not a requirement. All of terminology is translated.
>
> Do they teach you what English keywords mean?
>
>
>
They teach what they mean in programming, usually not what the word would mean in casual English.
>
> Are you taught to use English names for variables, classes, methods etc or Spanish ones
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
This depends of the level on which you're studding. If it's B.Sc. or just a programming course, then they will teach you to have everything in Spanish. If you're studding Ph.D. and in some M.Sc., they will teach you to have everything in English, as you're expected to present some of your work on international conferences. | This is an old question, but still relevant I think, and I just came across it today.
**Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?**
Most other answers here say you don't need to know English as a prerequisite. Although I'm sure it varies widely from university to university, at my university, UNED in Spain, they do expect you to have some level of English. [Here](http://portal.uned.es/portal/page?_pageid=93,28740213&_dad=portal&_schema=PORTAL&idContenido=6) it says
>
> Es deseable un nivel básico/intermedio del idioma inglés. Especialmente la comprensión lectora del inglés permitirá el manejo de la abundante bibliografía existente en esta lengua. El alumno podrá encontrar algunas asignaturas con libros en inglés.
>
>
>
I had a couple classes where the textbook was in English. And on more than one occasion a professor gave additional material, or what have you, in English and the students were expected to be able to comprehend it. As a native English speaker, I had no problem with it, but there were others who complained about it.
**Do they teach you what English keywords mean?**
In my experience they do not teach you what the keywords mean, but rather how to use them. However, most are basic enough to look up in a dictionary and have a good understanding.
**Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?**
We weren't really taught anything in regard to this. I'd say most just used Spanish for variable names, classes, methods, and for comments. I used English variables, classes, and methods, but comments in Spanish (for school work). I did ask my professors on a couple of times, and they usually all said that the way I did it was fine and probably preferred, since you'll find English in the "real world" more often than programs written in Spanish. I just find it easier and more natural to use English for variables, classes, and methods because all the other keywords are English. Also you come across issues like pluralizing variables and other things that I can't remember right know where English seems a little more convenient.
**Lastly, can you get/do you use, things like Javadocs in Spanish?**
Not sure if you can get it in Spanish. However, my recommendation would be to use the English. Even if you're not comfortable in English at first, force yourself. A lot of the same words and phrases are reused in lots of different situations, and pretty soon you'll find it easier. Then you'll have the added benefit of access to all the tutorials and example in English, which is a pretty big deal. |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | I learned to program in Spanish, in Peru.
>
> Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?
>
>
>
No, they don't expect you to know English. I'm very sure on this point. Sometimes even teachers don't know English. On the other hand, most people can read documentation in English, sometimes with the help of Google Translator (which is very good for technical stuff). The best programmer at my work doesn't know English and he has more than 16 years of experience. Sure, he knows the meaning of a lot of words.
>
> Do they teach you what English keywords mean?
>
>
>
I learned by reading magazines about programming written in Spanish (this kind of magazine was very popular in the 90s). They don't mention the translation but explain the use and give examples ("IF sirve para expresar sentencias condicionales"). I give lectures on "Scientific programming" (MATLAB and R) and I do mention the meaning of English words, but just the first time.
>
> Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?
>
>
>
For work, I use names in Spanish and comments in English. I think is a bit confusing if you share the code with non-Spanish speakers, I'm trying to improve that for lots of reasons, particularly because I don't like to avoid "tildes". Also, I'm using Java for my PhD and my advisor does the opposite: variables/methods/classes in English, comments in French (she's French). For lectures, I use variables and function/methods names and comments in Spanish cause knowledge of English is not a requisite to learn programming (and for most people programming it's hard enough).
>
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
I learned java a couple of years ago using books in Spanish. There are very good documentation in Spanish to learn for most programming languages. But when looking for help in internet, It's almost sure it will be in English. Now I prefer to use documentation in English, but mostly because I really want to improve my English. As a final remark, all students who do internships at my lab are encouraged to learn English and we provide them documentation in English, despite there are good translations in Spanish. | This is from a long time ago. After I learned to program in ANSII Basic I once started reading a book called "Basic in Spanish" I threw it away the very first day since it didn't make sense to relearn every single keyword in Spanish. |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | Keywords aren't changed and their meaning is explained. But almost everything else is in Spanish, because concepts are taught in Spanish and have their own Spanish terminology, and exercises reflect that. I mean, if the lesson was about trees or stacks, it would be taught in terms of "árboles" and "pilas", and the programs would have their classes "Arbol", "Nodo" and "Pila".
And the comments would also be in Spanish, because nobody is testing your English (neither you the teacher's!) but whether you understand what the code does and can explain it.
In a professional setting, I think, English is more prevalent. Especially now, when international teams are more common. When I last worked in a Spanish-speaking firm, some 10 years ago, we did almost everything is Spanish. | From DO (Dominican Republic)
============================
>
> Do courses in Spanish speaking countries expect some knowledge of
> English as a prerequisite?
>
>
>
Formally, no. Some technical courses (outside universities) use to accept anyone no matter their English (spoken, read, or written). Some are consequent and use translated versions of official prog. languages documentation. Others just present the student with the problem of having to read some technical source in English.
>
> Do they teach you what English keywords mean?
>
>
>
Of course, in DO we do not use literal translation for every keyword, we do tend to talk (pronounce) keywords in their native form (a while-loop is pronounced as an native English speaker will do, we do no use to literally translate it to "el bucle mientras")
>
> Are you taught to use English names for variables, classes, methods
> etc or Spanish ones (Confusing?!)?
>
>
>
You can be surprised, I started my career in a firm doing outsourcing work for a company in the USA, so we were required to write all documentation, and sources (variables, classes, methods, etc.) in English. When I leave this company get in touch with "funny" stuff: mixed languages in both sources and documentation files.
TLDR; Here in DO the 1995+ generation of developers do tent to accept that English is the "lingua franca" in software development, so they use to write everything in English. This is not always the case for programmers formed in the 80's.
>
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
It is possible, but less usual in recent years (2000's)
Hope this help, it will be interesting to see some stats if you are doing some kind of research. |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | I learned to program in Spanish, in Peru.
>
> Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?
>
>
>
No, they don't expect you to know English. I'm very sure on this point. Sometimes even teachers don't know English. On the other hand, most people can read documentation in English, sometimes with the help of Google Translator (which is very good for technical stuff). The best programmer at my work doesn't know English and he has more than 16 years of experience. Sure, he knows the meaning of a lot of words.
>
> Do they teach you what English keywords mean?
>
>
>
I learned by reading magazines about programming written in Spanish (this kind of magazine was very popular in the 90s). They don't mention the translation but explain the use and give examples ("IF sirve para expresar sentencias condicionales"). I give lectures on "Scientific programming" (MATLAB and R) and I do mention the meaning of English words, but just the first time.
>
> Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?
>
>
>
For work, I use names in Spanish and comments in English. I think is a bit confusing if you share the code with non-Spanish speakers, I'm trying to improve that for lots of reasons, particularly because I don't like to avoid "tildes". Also, I'm using Java for my PhD and my advisor does the opposite: variables/methods/classes in English, comments in French (she's French). For lectures, I use variables and function/methods names and comments in Spanish cause knowledge of English is not a requisite to learn programming (and for most people programming it's hard enough).
>
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
I learned java a couple of years ago using books in Spanish. There are very good documentation in Spanish to learn for most programming languages. But when looking for help in internet, It's almost sure it will be in English. Now I prefer to use documentation in English, but mostly because I really want to improve my English. As a final remark, all students who do internships at my lab are encouraged to learn English and we provide them documentation in English, despite there are good translations in Spanish. | I learned programming in French. Since French is of the same root it is fair to assume it is the same in Spanish. I followed programming courses in highschool in my native country as well (Colombia, where spanish is spoken) and it was the same as in France.
>
> **Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?**
>
>
>
Yes they usually do. If you don't have english proficiency or at least some basic knowledge you won't have access to most internet based resources for that programming language. Most importantly the documentation that is not always translated into spanish. Of course there are some exceptions in which they use a spanish tutorial book and that's all they need, but those, as said, are exceptions.
>
> **Do they teach you what English keywords mean?**
>
>
>
In my case sometimes they did, even if we already knew english. They would only teach the meaning if it is really relevant to the method or procedure it is referring to. For instance the method String.isNullOrEmpty().
>
> **Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?**
>
>
>
In my case I wasn't taught anything about it. That I had freedom to choose Spanish or english (or French) as long as I stick with it throughout the program. It is not confusing since the program would be for Spanish-speaking programmers. Specially if the keywords are highlighted in different colors as the methods and variables (in most languages and editors anyway). Blue for public, private, static, void, string, int, etc... and black for names made by you.
>
> **Lastly, can you get/do you use, things like Javadocs in Spanish?**
>
>
>
Depends, if what you are looking for is easy to find then spanish, or more complicated in english. There are more chances of finding it in english than in spanish. In the case of JavaDoc, for making a custom documentation it depends on the public that will read it. Spanish for spanish speakers and english for all others. As for the standard documentation I'm not sure if there is such a documentation in spanish for java.
As a last note, all these are personal thoughts based on personal experiences. I am not talking for all cases and don't pretend to either.
Keep in mind that this greatly depends on the teaching style of the institution and the skills of the students, sometimes the students will have only a rudimentary knowledge of english and english classes are given separately to fix this, but while that is done everything related to programming is done in their native language(as it happens in France) |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | Keywords aren't changed and their meaning is explained. But almost everything else is in Spanish, because concepts are taught in Spanish and have their own Spanish terminology, and exercises reflect that. I mean, if the lesson was about trees or stacks, it would be taught in terms of "árboles" and "pilas", and the programs would have their classes "Arbol", "Nodo" and "Pila".
And the comments would also be in Spanish, because nobody is testing your English (neither you the teacher's!) but whether you understand what the code does and can explain it.
In a professional setting, I think, English is more prevalent. Especially now, when international teams are more common. When I last worked in a Spanish-speaking firm, some 10 years ago, we did almost everything is Spanish. | This is an old question, but still relevant I think, and I just came across it today.
**Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?**
Most other answers here say you don't need to know English as a prerequisite. Although I'm sure it varies widely from university to university, at my university, UNED in Spain, they do expect you to have some level of English. [Here](http://portal.uned.es/portal/page?_pageid=93,28740213&_dad=portal&_schema=PORTAL&idContenido=6) it says
>
> Es deseable un nivel básico/intermedio del idioma inglés. Especialmente la comprensión lectora del inglés permitirá el manejo de la abundante bibliografía existente en esta lengua. El alumno podrá encontrar algunas asignaturas con libros en inglés.
>
>
>
I had a couple classes where the textbook was in English. And on more than one occasion a professor gave additional material, or what have you, in English and the students were expected to be able to comprehend it. As a native English speaker, I had no problem with it, but there were others who complained about it.
**Do they teach you what English keywords mean?**
In my experience they do not teach you what the keywords mean, but rather how to use them. However, most are basic enough to look up in a dictionary and have a good understanding.
**Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?**
We weren't really taught anything in regard to this. I'd say most just used Spanish for variable names, classes, methods, and for comments. I used English variables, classes, and methods, but comments in Spanish (for school work). I did ask my professors on a couple of times, and they usually all said that the way I did it was fine and probably preferred, since you'll find English in the "real world" more often than programs written in Spanish. I just find it easier and more natural to use English for variables, classes, and methods because all the other keywords are English. Also you come across issues like pluralizing variables and other things that I can't remember right know where English seems a little more convenient.
**Lastly, can you get/do you use, things like Javadocs in Spanish?**
Not sure if you can get it in Spanish. However, my recommendation would be to use the English. Even if you're not comfortable in English at first, force yourself. A lot of the same words and phrases are reused in lots of different situations, and pretty soon you'll find it easier. Then you'll have the added benefit of access to all the tutorials and example in English, which is a pretty big deal. |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | I learned programming in French. Since French is of the same root it is fair to assume it is the same in Spanish. I followed programming courses in highschool in my native country as well (Colombia, where spanish is spoken) and it was the same as in France.
>
> **Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?**
>
>
>
Yes they usually do. If you don't have english proficiency or at least some basic knowledge you won't have access to most internet based resources for that programming language. Most importantly the documentation that is not always translated into spanish. Of course there are some exceptions in which they use a spanish tutorial book and that's all they need, but those, as said, are exceptions.
>
> **Do they teach you what English keywords mean?**
>
>
>
In my case sometimes they did, even if we already knew english. They would only teach the meaning if it is really relevant to the method or procedure it is referring to. For instance the method String.isNullOrEmpty().
>
> **Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?**
>
>
>
In my case I wasn't taught anything about it. That I had freedom to choose Spanish or english (or French) as long as I stick with it throughout the program. It is not confusing since the program would be for Spanish-speaking programmers. Specially if the keywords are highlighted in different colors as the methods and variables (in most languages and editors anyway). Blue for public, private, static, void, string, int, etc... and black for names made by you.
>
> **Lastly, can you get/do you use, things like Javadocs in Spanish?**
>
>
>
Depends, if what you are looking for is easy to find then spanish, or more complicated in english. There are more chances of finding it in english than in spanish. In the case of JavaDoc, for making a custom documentation it depends on the public that will read it. Spanish for spanish speakers and english for all others. As for the standard documentation I'm not sure if there is such a documentation in spanish for java.
As a last note, all these are personal thoughts based on personal experiences. I am not talking for all cases and don't pretend to either.
Keep in mind that this greatly depends on the teaching style of the institution and the skills of the students, sometimes the students will have only a rudimentary knowledge of english and english classes are given separately to fix this, but while that is done everything related to programming is done in their native language(as it happens in France) | This is from a long time ago. After I learned to program in ANSII Basic I once started reading a book called "Basic in Spanish" I threw it away the very first day since it didn't make sense to relearn every single keyword in Spanish. |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | I'm a Mexican telecommunications engineer, and here's how it went for me:
>
> Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?
>
>
>
Usually not, but it's a *very* good idea to start with some cursory knowledge of English.
>
> Do they teach you what English keywords mean?
>
>
>
They usually do, but it depends entirely on how kind is the instructor.
>
> Are you taught to use English names for variables, classes, methods etc or Spanish ones (Confusing?!)?
>
>
>
Again, this depends on the instructor. Back in college some professors used variables in Spanish, and some used them in English. As long as your tongue choice is always consistent you should have no trouble.
>
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
Usually only for basic stuff. In fact, a lot of Mexican engineering students struggle because all the documentations and manuals are in English only and they don't speak English. | From DO (Dominican Republic)
============================
>
> Do courses in Spanish speaking countries expect some knowledge of
> English as a prerequisite?
>
>
>
Formally, no. Some technical courses (outside universities) use to accept anyone no matter their English (spoken, read, or written). Some are consequent and use translated versions of official prog. languages documentation. Others just present the student with the problem of having to read some technical source in English.
>
> Do they teach you what English keywords mean?
>
>
>
Of course, in DO we do not use literal translation for every keyword, we do tend to talk (pronounce) keywords in their native form (a while-loop is pronounced as an native English speaker will do, we do no use to literally translate it to "el bucle mientras")
>
> Are you taught to use English names for variables, classes, methods
> etc or Spanish ones (Confusing?!)?
>
>
>
You can be surprised, I started my career in a firm doing outsourcing work for a company in the USA, so we were required to write all documentation, and sources (variables, classes, methods, etc.) in English. When I leave this company get in touch with "funny" stuff: mixed languages in both sources and documentation files.
TLDR; Here in DO the 1995+ generation of developers do tent to accept that English is the "lingua franca" in software development, so they use to write everything in English. This is not always the case for programmers formed in the 80's.
>
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
It is possible, but less usual in recent years (2000's)
Hope this help, it will be interesting to see some stats if you are doing some kind of research. |
1,395 | This question is for anyone who has learned programming in a Spanish speaking country.
Seeing as though the key words for programming languages like Java, C, Python etc are all in English I have a couple of questions:
* Do courses in Spanish speaking countries expect some knowledge of
English as a prerequisite?
* Do they teach you what English keywords mean?
* Are you taught to use English names for variables, classes, methods
etc or Spanish ones (Confusing?!)?
* Lastly, can you get/do you use, things like Javadocs in Spanish?
Thanks = ) | 2012/01/16 | [
"https://spanish.stackexchange.com/questions/1395",
"https://spanish.stackexchange.com",
"https://spanish.stackexchange.com/users/312/"
] | How it looks in Spain:
>
> Do courses in Spanish speaking countries expect some knowledge of English as a prerequisite?
>
>
>
Not in Spain. Obviously it's a plus if someone can, but most people don't understand English and it's not a requirement. All of terminology is translated.
>
> Do they teach you what English keywords mean?
>
>
>
They teach what they mean in programming, usually not what the word would mean in casual English.
>
> Are you taught to use English names for variables, classes, methods etc or Spanish ones
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
This depends of the level on which you're studding. If it's B.Sc. or just a programming course, then they will teach you to have everything in Spanish. If you're studding Ph.D. and in some M.Sc., they will teach you to have everything in English, as you're expected to present some of your work on international conferences. | From DO (Dominican Republic)
============================
>
> Do courses in Spanish speaking countries expect some knowledge of
> English as a prerequisite?
>
>
>
Formally, no. Some technical courses (outside universities) use to accept anyone no matter their English (spoken, read, or written). Some are consequent and use translated versions of official prog. languages documentation. Others just present the student with the problem of having to read some technical source in English.
>
> Do they teach you what English keywords mean?
>
>
>
Of course, in DO we do not use literal translation for every keyword, we do tend to talk (pronounce) keywords in their native form (a while-loop is pronounced as an native English speaker will do, we do no use to literally translate it to "el bucle mientras")
>
> Are you taught to use English names for variables, classes, methods
> etc or Spanish ones (Confusing?!)?
>
>
>
You can be surprised, I started my career in a firm doing outsourcing work for a company in the USA, so we were required to write all documentation, and sources (variables, classes, methods, etc.) in English. When I leave this company get in touch with "funny" stuff: mixed languages in both sources and documentation files.
TLDR; Here in DO the 1995+ generation of developers do tent to accept that English is the "lingua franca" in software development, so they use to write everything in English. This is not always the case for programmers formed in the 80's.
>
> Lastly, can you get/do you use, things like Javadocs in Spanish?
>
>
>
It is possible, but less usual in recent years (2000's)
Hope this help, it will be interesting to see some stats if you are doing some kind of research. |
27,612,785 | I have a bunch of different show times in a database and want to display the correct time based on the users time zone by creating an offset.
I'm getting the users time zone offset from GMT and converting that to hours first.
```
NSTimeZone.localTimeZone().secondsFromGMT / 60 / 60
```
Then I need to find a way to add the hours to the date object.. that is where I/m struggling.
```
let formatter = NSDateFormatter()
formatter.dateFormat = "HH:mm"
let date = formatter.dateFromString(timeAsString)
println("date: \(date!)")
```
Then I'm creating a string from the date to use in a label, to have it easy to read with the AM / PM.
```
formatter.dateFormat = "H:mm"
formatter.timeStyle = .ShortStyle
let formattedDateString = formatter.stringFromDate(date!)
println("formattedDateString: \(formattedDateString)")
```
I just can't seem to find out how to add/subtract hours. I've split the string up but it sometimes goes negative and won't work. Maybe I'm going about this wrong.
Thanks for any help.
Keith | 2014/12/23 | [
"https://Stackoverflow.com/questions/27612785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3712837/"
] | I would use the [dateByAddingTimeInterval](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/index.html%23//apple_ref/occ/instm/NSDate/dateByAddingTimeInterval:) function to add and subtract hours. Add a to the dateFormat string to print am or pm.
```
var showTimeStr = "00:00 PM" //show time in GMT as String
let formatter = NSDateFormatter()
formatter.dateFormat = "hh:mm a"
let showTime = formatter.dateFromString(showTimeStr)
showTime.dateByAddingTimeInterval(3600) //Add number of hours in seconds, subtract to take away time
showTimeStr = formatter.stringFromDate(showTime)
``` | Here is my final code, combined with b.Morgans answer. I believe it's all working now.
```
let offsetTime = NSTimeInterval(NSTimeZone.localTimeZone().secondsFromGMT)
var showTimeStr = "05:00 PM" //show time in GMT as String
let formatter = NSDateFormatter()
formatter.dateFormat = "h:mm a"
let showTime = formatter.dateFromString(showTimeStr)
let finalTime = showTime?.dateByAddingTimeInterval(offsetTime) //Add number of hours in seconds, subtract to take away time
showTimeStr = formatter.stringFromDate(finalTime!)
``` |
27,612,785 | I have a bunch of different show times in a database and want to display the correct time based on the users time zone by creating an offset.
I'm getting the users time zone offset from GMT and converting that to hours first.
```
NSTimeZone.localTimeZone().secondsFromGMT / 60 / 60
```
Then I need to find a way to add the hours to the date object.. that is where I/m struggling.
```
let formatter = NSDateFormatter()
formatter.dateFormat = "HH:mm"
let date = formatter.dateFromString(timeAsString)
println("date: \(date!)")
```
Then I'm creating a string from the date to use in a label, to have it easy to read with the AM / PM.
```
formatter.dateFormat = "H:mm"
formatter.timeStyle = .ShortStyle
let formattedDateString = formatter.stringFromDate(date!)
println("formattedDateString: \(formattedDateString)")
```
I just can't seem to find out how to add/subtract hours. I've split the string up but it sometimes goes negative and won't work. Maybe I'm going about this wrong.
Thanks for any help.
Keith | 2014/12/23 | [
"https://Stackoverflow.com/questions/27612785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3712837/"
] | If you want to convert a show time which is stored as a string in GMT, and you want to show it in the user's local time zone, you should *not* be manually adjusting the `NSDate`/`Date` objects. You should be simply using the appropriate time zones with the formatter. For example, in Swift 3:
```
let gmtTimeString = "5:00 PM"
let formatter = DateFormatter()
formatter.dateFormat = "h:mm a"
formatter.timeZone = TimeZone(secondsFromGMT: 0) // original string in GMT
guard let date = formatter.date(from: gmtTimeString) else {
print("can't convert time string")
return
}
formatter.timeZone = TimeZone.current // go back to user's timezone
let localTimeString = formatter.string(from: date)
```
Or in Swift 2:
```
let formatter = NSDateFormatter()
formatter.dateFormat = "h:mm a"
formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) // original string in GMT
let date = formatter.dateFromString(gmtTimeString)
formatter.timeZone = NSTimeZone.localTimeZone() // go back to user's timezone
let localTimeString = formatter.stringFromDate(date!)
``` | I would use the [dateByAddingTimeInterval](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/index.html%23//apple_ref/occ/instm/NSDate/dateByAddingTimeInterval:) function to add and subtract hours. Add a to the dateFormat string to print am or pm.
```
var showTimeStr = "00:00 PM" //show time in GMT as String
let formatter = NSDateFormatter()
formatter.dateFormat = "hh:mm a"
let showTime = formatter.dateFromString(showTimeStr)
showTime.dateByAddingTimeInterval(3600) //Add number of hours in seconds, subtract to take away time
showTimeStr = formatter.stringFromDate(showTime)
``` |
27,612,785 | I have a bunch of different show times in a database and want to display the correct time based on the users time zone by creating an offset.
I'm getting the users time zone offset from GMT and converting that to hours first.
```
NSTimeZone.localTimeZone().secondsFromGMT / 60 / 60
```
Then I need to find a way to add the hours to the date object.. that is where I/m struggling.
```
let formatter = NSDateFormatter()
formatter.dateFormat = "HH:mm"
let date = formatter.dateFromString(timeAsString)
println("date: \(date!)")
```
Then I'm creating a string from the date to use in a label, to have it easy to read with the AM / PM.
```
formatter.dateFormat = "H:mm"
formatter.timeStyle = .ShortStyle
let formattedDateString = formatter.stringFromDate(date!)
println("formattedDateString: \(formattedDateString)")
```
I just can't seem to find out how to add/subtract hours. I've split the string up but it sometimes goes negative and won't work. Maybe I'm going about this wrong.
Thanks for any help.
Keith | 2014/12/23 | [
"https://Stackoverflow.com/questions/27612785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3712837/"
] | If you want to convert a show time which is stored as a string in GMT, and you want to show it in the user's local time zone, you should *not* be manually adjusting the `NSDate`/`Date` objects. You should be simply using the appropriate time zones with the formatter. For example, in Swift 3:
```
let gmtTimeString = "5:00 PM"
let formatter = DateFormatter()
formatter.dateFormat = "h:mm a"
formatter.timeZone = TimeZone(secondsFromGMT: 0) // original string in GMT
guard let date = formatter.date(from: gmtTimeString) else {
print("can't convert time string")
return
}
formatter.timeZone = TimeZone.current // go back to user's timezone
let localTimeString = formatter.string(from: date)
```
Or in Swift 2:
```
let formatter = NSDateFormatter()
formatter.dateFormat = "h:mm a"
formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) // original string in GMT
let date = formatter.dateFromString(gmtTimeString)
formatter.timeZone = NSTimeZone.localTimeZone() // go back to user's timezone
let localTimeString = formatter.stringFromDate(date!)
``` | Here is my final code, combined with b.Morgans answer. I believe it's all working now.
```
let offsetTime = NSTimeInterval(NSTimeZone.localTimeZone().secondsFromGMT)
var showTimeStr = "05:00 PM" //show time in GMT as String
let formatter = NSDateFormatter()
formatter.dateFormat = "h:mm a"
let showTime = formatter.dateFromString(showTimeStr)
let finalTime = showTime?.dateByAddingTimeInterval(offsetTime) //Add number of hours in seconds, subtract to take away time
showTimeStr = formatter.stringFromDate(finalTime!)
``` |
46,672 | As a puzzle author, I often write puzzles with red ink and then test-solve them with pencil. What would be the most efficient way to remove the pencil and blue gridlines from the paper to leave only the red puzzle clues behind? | 2015/01/31 | [
"https://graphicdesign.stackexchange.com/questions/46672",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/26073/"
] | As one who has typeset a thick mathematical book (written by various contributors), I would make two points in favour of Computer Modern.
First, the lower-case italic *v* and the lower-case Greek *ν* are clearly distinguished.
Second, parentheses rise higher than ascending letters, so that items in parentheses look more fully enclosed than in other fonts (e.g. Times Roman).
It is sometimes said that headings in Computer Modern make it too obvious that a document was typeset in (La)TeX. But this is easily overcome by setting headings in a contrasting font, e.g. using the "sectsty" package. When Computer Modern is used as a body font -- if I may lapse into opinion -- I find it reasonably neutral.
### P.S. (23 January 2020)
I typeset **[this paper](https://doi.org/10.5281/zenodo.3563468)** in a version of Computer Modern, using the `sectsty` package to set headings in sans-serif, plus the `helvet` package to change the standard sans-serif typeface to the Helvetica-like "Nimbus Sans L". The relevant lines from the preamble are:
```
⋮
\usepackage{cmlgc,amssymb,amsmath}
\DeclareTextCommandDefault{\textbullet}{\ensuremath{\bullet}}
\usepackage[scaled]{helvet}
\usepackage[T1]{fontenc}
⋮
\usepackage{sectsty}
\allsectionsfont{\sffamily\raggedright}
⋮
```
Notes:
* The appearance of the preview is somewhat browser-dependent; you might need to download the PDF in order to see it correctly.
* If your setup uses cm-super fonts by default (my latest setup doesn't), then you won't need the `cmlgc` package.
* *Mea culpa*: I was using the `cmlgc` version of Computer Modern for the first time, only to discover later that it does not scale optimally. If you use `lmodern` instead, you get a significant increase in the width, and a barely discernible increase in the darkness, of footnote-sized characters. One possible reason for using `lmodern` instead of cm-super is that `lmodern` gives a lower `\textasciitilde`.
* Modifying `\textbullet` sometimes gets rid of font-error messages.
* The `scaled` option to `helvet` adjusts the size so as to allow mixing with the serif font in text.
* The `\allsectionsfont` command, provided by `sectsty`, modifies all section headings at once (which is probably what you want).
* Yes, apparently `helvet` needs to come before `sectsty`. | Yes it is! It's well-designed as a text font, and it has small caps and text figures. But it was designed a long time ago and there are a few oddities: - and – are at very different heights and some modern currency symbols are a problem, the € was clearly not added by the font's original designer and ₹ is missing (a common test of fonts to see if they've been remastered recently, that one, by the way). And it has some bonuses many pro fonts don't: the upright italic can allow more creative typography, and I really like the "classical" italic with serifs at the entrance to characters and the non-extended bold, both feel very practical and modern to me, maybe better than the defaults, while the wider standard bold looks great in headings, and in tracked out small caps too.
A few possible alternatives. [STIX Two Text](https://www.stixfonts.org/) is based on Times New Roman, so it's a lot more anonymous, less defined by the style of the nineteenth century, and because it's based on the smaller sizes of Times New Roman's metal type it's particularly good for small sizes. It's free. [Commercial Type's Brunel](https://commercialclassics.com/catalogue/brunel) is in the same style, but designed for high-style fashion magazines. So it's got optical sizes for super-large headings, and pushes the design further with bolder-than-bold weights, tons of flourished characters and [piles of niceties](https://commercialclassics.com/uploads/4800048/156320577664/Brunel_Text-family.pdf) like small-cap, proportional and tabular figures. [HTF's Surveyor is similar](https://www.typography.com/fonts/surveyor/how-to-use), and it's particularly strong in the lightest styles, although if it matters to you it doesn't have text figures. |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I've seen this particular problem many times, and a lot of it has to do with how Windows handles DPI scaling.
Since you are using a Retina MBP - which has an extremely high resolution, you'll want Parallels to manage the DPI of your Windows VM. You can do this under your Virtual Machine's configuration, Hardware, Video Options, and select "Best for Retina".

The next time you reboot, Windows will have its DPI set to 199% (why not 200% I'm not sure).
The only trick to this is when you connect to an external display and you want to show your Parallels VM there. Windows can't change it's DPI without a full logout / login - so if you change displays you'll have to log out of Windows and log back in.
The next problem is that Windows does DPI scaling differently - *some programs do not respect Windows DPI scaling*. It's very bad practices for developers, but some of them always assume a fixed number of points-per-inch, like 96. Windows does its best to fix these issues by bitmap scaling the Window, and translating input, but it won't ever be perfect and it will look like a JPG that's 200% zoomed. It all depends on the program you are using. As unfortunate as it sounds, the best browser on Windows for retina resolution / DPI is Internet Explorer 10. | I had the exact same problem. I went a different route, and decided to sacrifice the nice high-DPI of the Retina for a scaled solution that makes everything look right.
1. In Parallels VM Config → Hardware → Video → Resolution
Use: **Scaled**
Not: Best for Retina, More Space
2. Restart VM
3. Windows Display Settings → Set Resolution: **1280x800** + Apply
4. Windows Display Settings → "Make text and other items larger or smaller"
Use: Smaller (100%)
Late-2013 rMBP 13.3″ with Parallels 9.0.23350 and Windows 7 |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I've seen this particular problem many times, and a lot of it has to do with how Windows handles DPI scaling.
Since you are using a Retina MBP - which has an extremely high resolution, you'll want Parallels to manage the DPI of your Windows VM. You can do this under your Virtual Machine's configuration, Hardware, Video Options, and select "Best for Retina".

The next time you reboot, Windows will have its DPI set to 199% (why not 200% I'm not sure).
The only trick to this is when you connect to an external display and you want to show your Parallels VM there. Windows can't change it's DPI without a full logout / login - so if you change displays you'll have to log out of Windows and log back in.
The next problem is that Windows does DPI scaling differently - *some programs do not respect Windows DPI scaling*. It's very bad practices for developers, but some of them always assume a fixed number of points-per-inch, like 96. Windows does its best to fix these issues by bitmap scaling the Window, and translating input, but it won't ever be perfect and it will look like a JPG that's 200% zoomed. It all depends on the program you are using. As unfortunate as it sounds, the best browser on Windows for retina resolution / DPI is Internet Explorer 10. | All my coworkers had the same problem. In Parallels 9, you can set for every VM if it should be **scaled**, **best for retina** or **more space**. As DPI scaling under Windows is inherently broken, as application developers have to support this, and many just don't, it's not useful you can configure this at all, which is why more options don't always mean better software (looking at you Parallels). In versions before, Parallels didn't let you choose the wrong things, and didn't have the wrong defaults.

You need to open the VM, go to the Virtual Machine menu item in the Macs menu bar, go to Hardware -> Graphics -> and click on scaled, restart your VM, in the Windows VM, go to Start -> Control Panel -> Display Settings -> click the link "Make text and other items larger or smaller" -> set it to 100%
 |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I've seen this particular problem many times, and a lot of it has to do with how Windows handles DPI scaling.
Since you are using a Retina MBP - which has an extremely high resolution, you'll want Parallels to manage the DPI of your Windows VM. You can do this under your Virtual Machine's configuration, Hardware, Video Options, and select "Best for Retina".

The next time you reboot, Windows will have its DPI set to 199% (why not 200% I'm not sure).
The only trick to this is when you connect to an external display and you want to show your Parallels VM there. Windows can't change it's DPI without a full logout / login - so if you change displays you'll have to log out of Windows and log back in.
The next problem is that Windows does DPI scaling differently - *some programs do not respect Windows DPI scaling*. It's very bad practices for developers, but some of them always assume a fixed number of points-per-inch, like 96. Windows does its best to fix these issues by bitmap scaling the Window, and translating input, but it won't ever be perfect and it will look like a JPG that's 200% zoomed. It all depends on the program you are using. As unfortunate as it sounds, the best browser on Windows for retina resolution / DPI is Internet Explorer 10. | I have a new solution for this,set the video properties to "Scaled" and the video memory to 256MB.

One's you do this , go back to your windows--> Control Panel --> Display --> Set it to Smaller(100%).
check the Screen Resolution now it shows 1436\*756 on a Mac Book pro 15.6 Retina.
This is done automatically , do not set it manually. |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I've seen this particular problem many times, and a lot of it has to do with how Windows handles DPI scaling.
Since you are using a Retina MBP - which has an extremely high resolution, you'll want Parallels to manage the DPI of your Windows VM. You can do this under your Virtual Machine's configuration, Hardware, Video Options, and select "Best for Retina".

The next time you reboot, Windows will have its DPI set to 199% (why not 200% I'm not sure).
The only trick to this is when you connect to an external display and you want to show your Parallels VM there. Windows can't change it's DPI without a full logout / login - so if you change displays you'll have to log out of Windows and log back in.
The next problem is that Windows does DPI scaling differently - *some programs do not respect Windows DPI scaling*. It's very bad practices for developers, but some of them always assume a fixed number of points-per-inch, like 96. Windows does its best to fix these issues by bitmap scaling the Window, and translating input, but it won't ever be perfect and it will look like a JPG that's 200% zoomed. It all depends on the program you are using. As unfortunate as it sounds, the best browser on Windows for retina resolution / DPI is Internet Explorer 10. | The solution of this problem is here... Just forget about all the old advises and read this.
I've MacBook Pro Retina 15"
The problem's started when I've setup Parallel Desktop 9 and installed WIN 8.1, after that I've installed the Parallels Tools .. Than .. on WIN ... the screen resolution is SO high because of the Retina setting on MAC .. and microscopic context menus as will, I cannot use the WIN like this ..
I tried to play with WIN settings and screen resolution and MAC screen resolution .. nothing gonna be help
I've forced to uninstall Parallels Tools to disconnect the relation between MAC screen resolution and WIN screen resolution, BUT I've lost the Audio driver and the Networking between MAC and WIN, Until I found the solution.
I've just get know how to fix this problem 100%
It's So easy ..
1- Uninstall Parallels Tools ( On WIN )
2- Update Parallel 9 to the latest update (13-7-2014) or more "important".
3- Shut down the WIN ( Not logout )
4- Exit full screen of Parallel Desktop BUT don't close the Parallel window
5- On MAC .. select the Parallel window than ..: Virtual Machine .. Configure .. select Hardware page .. Video .. remove the check box of " Enable Retina resolution "
6- Install Parallels Tools again .. and That's it .. Enjoy |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I had the exact same problem. I went a different route, and decided to sacrifice the nice high-DPI of the Retina for a scaled solution that makes everything look right.
1. In Parallels VM Config → Hardware → Video → Resolution
Use: **Scaled**
Not: Best for Retina, More Space
2. Restart VM
3. Windows Display Settings → Set Resolution: **1280x800** + Apply
4. Windows Display Settings → "Make text and other items larger or smaller"
Use: Smaller (100%)
Late-2013 rMBP 13.3″ with Parallels 9.0.23350 and Windows 7 | All my coworkers had the same problem. In Parallels 9, you can set for every VM if it should be **scaled**, **best for retina** or **more space**. As DPI scaling under Windows is inherently broken, as application developers have to support this, and many just don't, it's not useful you can configure this at all, which is why more options don't always mean better software (looking at you Parallels). In versions before, Parallels didn't let you choose the wrong things, and didn't have the wrong defaults.

You need to open the VM, go to the Virtual Machine menu item in the Macs menu bar, go to Hardware -> Graphics -> and click on scaled, restart your VM, in the Windows VM, go to Start -> Control Panel -> Display Settings -> click the link "Make text and other items larger or smaller" -> set it to 100%
 |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I had the exact same problem. I went a different route, and decided to sacrifice the nice high-DPI of the Retina for a scaled solution that makes everything look right.
1. In Parallels VM Config → Hardware → Video → Resolution
Use: **Scaled**
Not: Best for Retina, More Space
2. Restart VM
3. Windows Display Settings → Set Resolution: **1280x800** + Apply
4. Windows Display Settings → "Make text and other items larger or smaller"
Use: Smaller (100%)
Late-2013 rMBP 13.3″ with Parallels 9.0.23350 and Windows 7 | I have a new solution for this,set the video properties to "Scaled" and the video memory to 256MB.

One's you do this , go back to your windows--> Control Panel --> Display --> Set it to Smaller(100%).
check the Screen Resolution now it shows 1436\*756 on a Mac Book pro 15.6 Retina.
This is done automatically , do not set it manually. |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I had the exact same problem. I went a different route, and decided to sacrifice the nice high-DPI of the Retina for a scaled solution that makes everything look right.
1. In Parallels VM Config → Hardware → Video → Resolution
Use: **Scaled**
Not: Best for Retina, More Space
2. Restart VM
3. Windows Display Settings → Set Resolution: **1280x800** + Apply
4. Windows Display Settings → "Make text and other items larger or smaller"
Use: Smaller (100%)
Late-2013 rMBP 13.3″ with Parallels 9.0.23350 and Windows 7 | The solution of this problem is here... Just forget about all the old advises and read this.
I've MacBook Pro Retina 15"
The problem's started when I've setup Parallel Desktop 9 and installed WIN 8.1, after that I've installed the Parallels Tools .. Than .. on WIN ... the screen resolution is SO high because of the Retina setting on MAC .. and microscopic context menus as will, I cannot use the WIN like this ..
I tried to play with WIN settings and screen resolution and MAC screen resolution .. nothing gonna be help
I've forced to uninstall Parallels Tools to disconnect the relation between MAC screen resolution and WIN screen resolution, BUT I've lost the Audio driver and the Networking between MAC and WIN, Until I found the solution.
I've just get know how to fix this problem 100%
It's So easy ..
1- Uninstall Parallels Tools ( On WIN )
2- Update Parallel 9 to the latest update (13-7-2014) or more "important".
3- Shut down the WIN ( Not logout )
4- Exit full screen of Parallel Desktop BUT don't close the Parallel window
5- On MAC .. select the Parallel window than ..: Virtual Machine .. Configure .. select Hardware page .. Video .. remove the check box of " Enable Retina resolution "
6- Install Parallels Tools again .. and That's it .. Enjoy |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I have a new solution for this,set the video properties to "Scaled" and the video memory to 256MB.

One's you do this , go back to your windows--> Control Panel --> Display --> Set it to Smaller(100%).
check the Screen Resolution now it shows 1436\*756 on a Mac Book pro 15.6 Retina.
This is done automatically , do not set it manually. | All my coworkers had the same problem. In Parallels 9, you can set for every VM if it should be **scaled**, **best for retina** or **more space**. As DPI scaling under Windows is inherently broken, as application developers have to support this, and many just don't, it's not useful you can configure this at all, which is why more options don't always mean better software (looking at you Parallels). In versions before, Parallels didn't let you choose the wrong things, and didn't have the wrong defaults.

You need to open the VM, go to the Virtual Machine menu item in the Macs menu bar, go to Hardware -> Graphics -> and click on scaled, restart your VM, in the Windows VM, go to Start -> Control Panel -> Display Settings -> click the link "Make text and other items larger or smaller" -> set it to 100%
 |
86,573 | I'm using Parallels on my mac. But when I open a software the font are so small, it's very weird. Can anyone help me out!!!

The picture above is when I open up my chrome, how can I fix it? | 2013/03/24 | [
"https://apple.stackexchange.com/questions/86573",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/26496/"
] | I have a new solution for this,set the video properties to "Scaled" and the video memory to 256MB.

One's you do this , go back to your windows--> Control Panel --> Display --> Set it to Smaller(100%).
check the Screen Resolution now it shows 1436\*756 on a Mac Book pro 15.6 Retina.
This is done automatically , do not set it manually. | The solution of this problem is here... Just forget about all the old advises and read this.
I've MacBook Pro Retina 15"
The problem's started when I've setup Parallel Desktop 9 and installed WIN 8.1, after that I've installed the Parallels Tools .. Than .. on WIN ... the screen resolution is SO high because of the Retina setting on MAC .. and microscopic context menus as will, I cannot use the WIN like this ..
I tried to play with WIN settings and screen resolution and MAC screen resolution .. nothing gonna be help
I've forced to uninstall Parallels Tools to disconnect the relation between MAC screen resolution and WIN screen resolution, BUT I've lost the Audio driver and the Networking between MAC and WIN, Until I found the solution.
I've just get know how to fix this problem 100%
It's So easy ..
1- Uninstall Parallels Tools ( On WIN )
2- Update Parallel 9 to the latest update (13-7-2014) or more "important".
3- Shut down the WIN ( Not logout )
4- Exit full screen of Parallel Desktop BUT don't close the Parallel window
5- On MAC .. select the Parallel window than ..: Virtual Machine .. Configure .. select Hardware page .. Video .. remove the check box of " Enable Retina resolution "
6- Install Parallels Tools again .. and That's it .. Enjoy |
41,061 | Older French texts often use defunct spellings, such as *-oi* instead of *-ai* in verb conjugations or spellings that contain consonants that were later dropped, like in *doubter*. When these texts are read aloud by modern French speakers, are these words read as if they were written with the modern spelling, or is there generally some attempt to pronounce the words according the old spelling? In other words, does one read *déchiroit* as *déchirait* and *laissoit* as *laissait* in the following?
>
> Pendant que la guerre civile déchiroit la France, sous le regne de Charles IX, l'amour ne laissoit pas de trouver sa place parmi tant de désordres, et d'en causer beaucoup dans son empire.
>
>
>
If yes, does this change with even older texts, where the text cannot be made to fit the conventions of modern French simply by modifying certain (relatively predictable) spellings? For example, at the beginning of *Roman de Fauvel*, does one read *Sui entrez en merencolie* (or *Sui entres en milencolie*, in some other versions) as *Suis entré en mélancolie*? | 2020/01/27 | [
"https://french.stackexchange.com/questions/41061",
"https://french.stackexchange.com",
"https://french.stackexchange.com/users/4082/"
] | I'm no expert in old French so I can't tell you if we *should*, but we'd definitely pronounce it as it is written, but following the pronunciation rules of modern French.
So "*déchiroit*" would be pronounced as "*déchiroit*" and "*entrez*" as "*entré*". That's what a native would say naturally, but I have no idea if that's how they should.
I say "would" because it's really not something we do often, and it would most likely be in the context of studying old texts with a French or history professor (that could probably correct us). We'd be hesitant over the pronunciation of "*doubter*" (*b* or no *b*?) and it would be really hard to guess that "*Sui entres*" should be pronounced "*Suis entré*" (if that's the case).
Again, French speakers today don't know how to pronounce old French. | Cela dépend d'abord de la compétence du lecteur en matière de prononciation ancienne: s'il ne connaît pas les règles anciennes de prononciation, il n'y a aucun risque qu'il les utilise. Son choix reste donc soit de prononcer comme il lit, soit de prononcer comme si le texte était écrit en français moderne. En l'espèce, il me semble que le *-oi-* ne se prononçait d'aucune de ces deux façons.
Cela dépend aussi des importances respectives du fond et de la forme dans le contexte de la lecture. On ne lira pas de la même manière au cours d'une conférence de recherche en littérature ancienne, dans un spectacle moderne avec des vrais morceaux d'ancien français dedans, lors de la représentation d'une ancienne pièce de théâtre ou encore pour illustrer une information historique dans un cadre autre que la littérature. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | This appears to be the autoloading issue. When you bootstrap your app for the test suite you must initialise your autoloader, which doesn't seem to be happening, as something doesn't get found. The easiest way would be to use Composer to manage the PHPUnit dependency and autoload your classes via the `autoload` directive. See the the `psr-4` part in [documentation](https://getcomposer.org/doc/01-basic-usage.md#autoloading).
Then in your PhpStorm PHPUnit configuration window select `Use custom autoloader` and specify path to your `vendor/autoload.php` script. | The problem isn't that you autoloading phpunit via composer, but that in the composer you use an old version of phpUnit. In my case instead of using 4.0.0 I updated to 4.6.\*. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | This appears to be the autoloading issue. When you bootstrap your app for the test suite you must initialise your autoloader, which doesn't seem to be happening, as something doesn't get found. The easiest way would be to use Composer to manage the PHPUnit dependency and autoload your classes via the `autoload` directive. See the the `psr-4` part in [documentation](https://getcomposer.org/doc/01-basic-usage.md#autoloading).
Then in your PhpStorm PHPUnit configuration window select `Use custom autoloader` and specify path to your `vendor/autoload.php` script. | Sometimes is better an image...
[](https://i.stack.imgur.com/LdxsR.png)
As you can see, you can also use your `phpunit.phar` file. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | This appears to be the autoloading issue. When you bootstrap your app for the test suite you must initialise your autoloader, which doesn't seem to be happening, as something doesn't get found. The easiest way would be to use Composer to manage the PHPUnit dependency and autoload your classes via the `autoload` directive. See the the `psr-4` part in [documentation](https://getcomposer.org/doc/01-basic-usage.md#autoloading).
Then in your PhpStorm PHPUnit configuration window select `Use custom autoloader` and specify path to your `vendor/autoload.php` script. | I've been having this same issue with composer and found using the .phar didnt have any issues. Today I've just realised **slaps forehead** it was just caused by installing phpunit via composer and then not reindexing the vendor folder.
I haven't found that I've had this issue previously when installing new packages with composer but for some reason when installing phpunit it hadn't reindexed the vendor folder causing inconsistencies.
Reindex, everything working normally. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | I will answer my own question in case someone else comes across this issue.
The issue was autoloading PHPUnit via composer and using phpunit.phar. Once I removed the phpunit dependence from composer PHPStorm was able to successfully run all my tests. | The problem isn't that you autoloading phpunit via composer, but that in the composer you use an old version of phpUnit. In my case instead of using 4.0.0 I updated to 4.6.\*. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | I will answer my own question in case someone else comes across this issue.
The issue was autoloading PHPUnit via composer and using phpunit.phar. Once I removed the phpunit dependence from composer PHPStorm was able to successfully run all my tests. | Sometimes is better an image...
[](https://i.stack.imgur.com/LdxsR.png)
As you can see, you can also use your `phpunit.phar` file. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | I will answer my own question in case someone else comes across this issue.
The issue was autoloading PHPUnit via composer and using phpunit.phar. Once I removed the phpunit dependence from composer PHPStorm was able to successfully run all my tests. | I've been having this same issue with composer and found using the .phar didnt have any issues. Today I've just realised **slaps forehead** it was just caused by installing phpunit via composer and then not reindexing the vendor folder.
I haven't found that I've had this issue previously when installing new packages with composer but for some reason when installing phpunit it hadn't reindexed the vendor folder causing inconsistencies.
Reindex, everything working normally. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | Sometimes is better an image...
[](https://i.stack.imgur.com/LdxsR.png)
As you can see, you can also use your `phpunit.phar` file. | The problem isn't that you autoloading phpunit via composer, but that in the composer you use an old version of phpUnit. In my case instead of using 4.0.0 I updated to 4.6.\*. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | The problem isn't that you autoloading phpunit via composer, but that in the composer you use an old version of phpUnit. In my case instead of using 4.0.0 I updated to 4.6.\*. | I've been having this same issue with composer and found using the .phar didnt have any issues. Today I've just realised **slaps forehead** it was just caused by installing phpunit via composer and then not reindexing the vendor folder.
I haven't found that I've had this issue previously when installing new packages with composer but for some reason when installing phpunit it hadn't reindexed the vendor folder causing inconsistencies.
Reindex, everything working normally. |
26,678,824 | Whenever I run phpunit tests from PHPStorm I get an error. I have provided more info below. I am not sure where I have miss configured the setup.
### My Setup
* Ubuntu
* PHPStorm 8.0.1
* PHPUnit 4.3.4
### More Info:
PHPUnit.phar is located at `/usr/local/bin/phpunit.phar`. I have setup PHPUnit path directly in PHPStorm. Tests run from bash with no issues. I have also setup my configuration file `phpunit.xml` in PHPUnit, which is located in the root of my project. The `phpunit.xml` file tells phpunit to load the composer `autoload.php` file.
### PHPUnit Output:
```
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /tmp/ide-phpunit.php --configuration /home/mkelley/projects/CompanyName/phpunit.xml
Testing started at 10:33 AM ...
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /home/mkelley/projects/CompanyName/phpunit.xml
PHP Fatal error: Call to undefined method CompanyNameTests\Boundaries\BoardMemberVotingBoundaryTest::hasExpectationOnOutput() in phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/ResultPrinter.php on line 545
PHP Stack trace:
PHP 1. {main}() /tmp/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /tmp/ide-phpunit.php:500
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /tmp/ide-phpunit.php:243
PHP 4. PHPUnit_TextUI_TestRunner->doRun($suite = *uninitialized*, $arguments = *uninitialized*) phar:///usr/local/bin/phpunit.phar/phpunit/TextUI/Command.php:186
PHP 5. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:423
PHP 6. PHPUnit_Framework_TestSuite->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 7. PHPUnit_Framework_TestCase->run($result = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 8. PHPUnit_Framework_TestResult->run($test = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 9. PHPUnit_Framework_TestResult->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanName/vendor/phpunit/phpunit/src/Framework/TestResult.php:760
PHP 10. PHPUnit_TextUI_ResultPrinter->endTest($test = *uninitialized*, $time = *uninitialized*) /home/mkelley/projects/CompanyName/vendor/phpunit/phpunit/src/Framework/TestResult.php:378
Process finished with exit code 255
```
I have searched Google and was unable to find a similar issue. I appreciate any help!
### EDIT
Here is my phpunit.xml file. PHPStorm is using this as a "Use alternative configuration file"
```
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
``` | 2014/10/31 | [
"https://Stackoverflow.com/questions/26678824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1301804/"
] | Sometimes is better an image...
[](https://i.stack.imgur.com/LdxsR.png)
As you can see, you can also use your `phpunit.phar` file. | I've been having this same issue with composer and found using the .phar didnt have any issues. Today I've just realised **slaps forehead** it was just caused by installing phpunit via composer and then not reindexing the vendor folder.
I haven't found that I've had this issue previously when installing new packages with composer but for some reason when installing phpunit it hadn't reindexed the vendor folder causing inconsistencies.
Reindex, everything working normally. |
17,015 | I have moved into a house with a nice Wolf-range griddle, and I would like to know what the primary advantages of the griddle are over a cast-iron skillet, including, is there anything I can do with a griddle that can not be done with a skillet?
I have found that the primary downside to using the griddle is the time it takes to heat up, so when cooking for one, I would choose the skillet. The primary advantage of the griddle is that it provides a larger, easier cooking space.
Am I missing other major advantages of having a griddle? | 2011/08/21 | [
"https://cooking.stackexchange.com/questions/17015",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/3418/"
] | Yes, you don't have the edge of a pan in the way when going to flip things, but it also means that you don't have a mass of metal there to add as a heat sink, which can help dramatically when pre-heating your pans, as they'll be evenly heated across their bottom more quickly (at least, compared to something of the same material, such as a cast iron skillet)
More importantly, in my opinion, is that without the sides, you don't hold in moist air, so when cooking things like hash browns, you can get a better crust on 'em without steaming them. | I would say the biggest advantage, which you've hinted at, is being able to use a spatula for quick and easy flipping (think pancakes, french toast, etc). Apart from its shape and size, there really is no other difference (even the difference in heat-up time, I've found, is negligible). |
17,015 | I have moved into a house with a nice Wolf-range griddle, and I would like to know what the primary advantages of the griddle are over a cast-iron skillet, including, is there anything I can do with a griddle that can not be done with a skillet?
I have found that the primary downside to using the griddle is the time it takes to heat up, so when cooking for one, I would choose the skillet. The primary advantage of the griddle is that it provides a larger, easier cooking space.
Am I missing other major advantages of having a griddle? | 2011/08/21 | [
"https://cooking.stackexchange.com/questions/17015",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/3418/"
] | I would say the biggest advantage, which you've hinted at, is being able to use a spatula for quick and easy flipping (think pancakes, french toast, etc). Apart from its shape and size, there really is no other difference (even the difference in heat-up time, I've found, is negligible). | I'm going to just use to frying pans ('skillets'). The lack of sides allows stuff to fall off too easily - I fried chopped onions today - and there's no carrying handle - so you can't move the griddle to plate up. The other downer - my griddle's cast iron and it's just cracked while heating it ! |
17,015 | I have moved into a house with a nice Wolf-range griddle, and I would like to know what the primary advantages of the griddle are over a cast-iron skillet, including, is there anything I can do with a griddle that can not be done with a skillet?
I have found that the primary downside to using the griddle is the time it takes to heat up, so when cooking for one, I would choose the skillet. The primary advantage of the griddle is that it provides a larger, easier cooking space.
Am I missing other major advantages of having a griddle? | 2011/08/21 | [
"https://cooking.stackexchange.com/questions/17015",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/3418/"
] | Yes, you don't have the edge of a pan in the way when going to flip things, but it also means that you don't have a mass of metal there to add as a heat sink, which can help dramatically when pre-heating your pans, as they'll be evenly heated across their bottom more quickly (at least, compared to something of the same material, such as a cast iron skillet)
More importantly, in my opinion, is that without the sides, you don't hold in moist air, so when cooking things like hash browns, you can get a better crust on 'em without steaming them. | Surface area is the biggest difference. You can do a much larger job on a griddle than in a skillet. Even 2 or 3 jobs at time, and when you are done there is just the griddle to clean and not several items.
You will also want to pick up a '[bacon press](http://rads.stackoverflow.com/amzn/click/B00004UE7B)' to minimize splatter when you put bacon on your griddle. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.