qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
64,512,359 | so I tried to run `npm start` on my react app.
But It's not running, instead it responds like this:
['/Users/macintoshhd/iCloud Drive (Archive)/Documents/Abu Abdillatief/Self Study/vetme/src/.' were found.](https://i.stack.imgur.com/wuNl3.png)
Can anybody help? In previous projects everything runs fine, and I tried t... | 2020/10/24 | [
"https://Stackoverflow.com/questions/64512359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13003387/"
] | I face the problem also, and found this link <https://github.com/facebook/create-react-app/issues/9902>
There mentioned that your directory path shouldn't have any space, since the last react update.
```
C:\Desktop\React App (BootCamp)\myApp> npm start
```
After I removed the space from the directory path, it still... | It's very weird, I had the same issue with a new project I created and there is no way to make it work.
The solution for me was to copy all the files from a working project (instead of creating a new react app) and then it ran fine. |
64,512,359 | so I tried to run `npm start` on my react app.
But It's not running, instead it responds like this:
['/Users/macintoshhd/iCloud Drive (Archive)/Documents/Abu Abdillatief/Self Study/vetme/src/.' were found.](https://i.stack.imgur.com/wuNl3.png)
Can anybody help? In previous projects everything runs fine, and I tried t... | 2020/10/24 | [
"https://Stackoverflow.com/questions/64512359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13003387/"
] | I face the problem also, and found this link <https://github.com/facebook/create-react-app/issues/9902>
There mentioned that your directory path shouldn't have any space, since the last react update.
```
C:\Desktop\React App (BootCamp)\myApp> npm start
```
After I removed the space from the directory path, it still... | Having the same problem... it happens to me when I run create-react-app in a particular folder. it doesn't happens when I run it a in a new directory.. still trying to figure it out. |
64,512,359 | so I tried to run `npm start` on my react app.
But It's not running, instead it responds like this:
['/Users/macintoshhd/iCloud Drive (Archive)/Documents/Abu Abdillatief/Self Study/vetme/src/.' were found.](https://i.stack.imgur.com/wuNl3.png)
Can anybody help? In previous projects everything runs fine, and I tried t... | 2020/10/24 | [
"https://Stackoverflow.com/questions/64512359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13003387/"
] | I face the problem also, and found this link <https://github.com/facebook/create-react-app/issues/9902>
There mentioned that your directory path shouldn't have any space, since the last react update.
```
C:\Desktop\React App (BootCamp)\myApp> npm start
```
After I removed the space from the directory path, it still... | anyway..
I tried to move around this new react app folder to any path that doesn't contain `archive` in its directory, it runs well (even though its parent folders has space in its name).
But, my previous projects are located inside a path which contains `archive`, it runs fine too, so I'm not sure if these are due t... |
64,512,359 | so I tried to run `npm start` on my react app.
But It's not running, instead it responds like this:
['/Users/macintoshhd/iCloud Drive (Archive)/Documents/Abu Abdillatief/Self Study/vetme/src/.' were found.](https://i.stack.imgur.com/wuNl3.png)
Can anybody help? In previous projects everything runs fine, and I tried t... | 2020/10/24 | [
"https://Stackoverflow.com/questions/64512359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13003387/"
] | I face the problem also, and found this link <https://github.com/facebook/create-react-app/issues/9902>
There mentioned that your directory path shouldn't have any space, since the last react update.
```
C:\Desktop\React App (BootCamp)\myApp> npm start
```
After I removed the space from the directory path, it still... | I have the same problem when I created a new app recently using create-react-app tool. Maybe the problem is the path of the folder which includes the react app is too long, or some special characters in the path. When I put my app into a new folder which has a short and simple path, it works. A new problem caused by ne... |
64,512,359 | so I tried to run `npm start` on my react app.
But It's not running, instead it responds like this:
['/Users/macintoshhd/iCloud Drive (Archive)/Documents/Abu Abdillatief/Self Study/vetme/src/.' were found.](https://i.stack.imgur.com/wuNl3.png)
Can anybody help? In previous projects everything runs fine, and I tried t... | 2020/10/24 | [
"https://Stackoverflow.com/questions/64512359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13003387/"
] | I face the problem also, and found this link <https://github.com/facebook/create-react-app/issues/9902>
There mentioned that your directory path shouldn't have any space, since the last react update.
```
C:\Desktop\React App (BootCamp)\myApp> npm start
```
After I removed the space from the directory path, it still... | I guess this is a problem with the new version of React (it has been updated from 16.13.1 to 17. \*\*. \*\*).
I took from my old file "package.json" " `" dependencies ": {" react ":" ^ 16.13.1 "," react-dom ":" ^ 16.13.1 "," react-scripts ":" 3.4. 3 "...}`, removed all files from "src" but did not touch "app.js" and "... |
64,512,359 | so I tried to run `npm start` on my react app.
But It's not running, instead it responds like this:
['/Users/macintoshhd/iCloud Drive (Archive)/Documents/Abu Abdillatief/Self Study/vetme/src/.' were found.](https://i.stack.imgur.com/wuNl3.png)
Can anybody help? In previous projects everything runs fine, and I tried t... | 2020/10/24 | [
"https://Stackoverflow.com/questions/64512359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13003387/"
] | I face the problem also, and found this link <https://github.com/facebook/create-react-app/issues/9902>
There mentioned that your directory path shouldn't have any space, since the last react update.
```
C:\Desktop\React App (BootCamp)\myApp> npm start
```
After I removed the space from the directory path, it still... | According to the git hub issue, they mentioned "your directory path shouldn't have any space" but in my case it still do not work, Once I move to app to Desktop and `npm install` and `npm start`, It worked fine but I have no idea what was happening under the hood. |
108,939 | I have an air pump that currently runs on AC, but I want to run on a solar/battery system that's 12V DC. The internals of the pump include a transformer to reduce voltage from 120 (I haven't been able to test the output voltage yet). From there, there is a magnet which powers a lever that squeezes a bellow. The magnet ... | 2014/05/02 | [
"https://electronics.stackexchange.com/questions/108939",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/41240/"
] | I'm imagining this to be a low-volume reciprocating pump like those used for aerating aquariums?
If so then you may be better off just replacing the air pump with one that uses a 12V DC motor. These are commonly available, such as here <http://www.robotshop.com/en/sfe-air-pump.html> and <http://www.ebay.com/itm/12V-D... | Many Dc pumps tend to use a brushed motor that has a reduced life expectancy by design.
I love the reliability of ac pumps like the tetra aquarium pumps they sell pump service kits for the diaphragms for only 18$. Instead of tossing a 80$ DC pump as it reaches the failure point.
Tetras design is a simple electro magne... |
11,234,162 | I am trying to incorporate normalization into my database design, some of the explanations available on the internet have got me slightly confused - and I'm not sure if I'm going in the right direction here?
So far I have:
users:
```
id
username
password
```
userprofilesettings:
```
id
userid
active
dateof... | 2012/06/27 | [
"https://Stackoverflow.com/questions/11234162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476650/"
] | address will get an own table
```
contactinfo
==========
id
userid
idaddress
postcode
email
tel
address
==========
idaddress
street
houseNumber
postalCode
city
country
```
...
good basics : <http://databases.about.com/od/specificproducts/a/normalization.htm> | ```
**userbusinessinfo**
id
userid
businessname
tags
```
What does tags hold? It sounds like more than one value, in which case you should have a `UserBusinessInfoTags` table. You should also use camel case for fields and proper case for table names for clarity of reading.
```
**UserBusinessInfoTags**
id
userBusines... |
11,234,162 | I am trying to incorporate normalization into my database design, some of the explanations available on the internet have got me slightly confused - and I'm not sure if I'm going in the right direction here?
So far I have:
users:
```
id
username
password
```
userprofilesettings:
```
id
userid
active
dateof... | 2012/06/27 | [
"https://Stackoverflow.com/questions/11234162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476650/"
] | address will get an own table
```
contactinfo
==========
id
userid
idaddress
postcode
email
tel
address
==========
idaddress
street
houseNumber
postalCode
city
country
```
...
good basics : <http://databases.about.com/od/specificproducts/a/normalization.htm> | Normalisation is about reducing the number of times a particular piece of data will be stored. You can go too far with normalisation as the more normalised your database is the less performant it will be.
In the extreme cases of a flat file vs fully normalised you would be getting a single record from one sql hit vs p... |
49,392,263 | So in angularjs you had the possibility to define a directive and bind the html template to an already existing controller. In principal this meant you could reuse the controller for multiple directives, therefore for multiple templates.
```
angular
.module('App')
.component('Name', {
templateUrl: 'some.html',
... | 2018/03/20 | [
"https://Stackoverflow.com/questions/49392263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6534650/"
] | Define `templateUrl` as a function
----------------------------------
You can specify `templateUrl` as a string representing the URL **or as a function** which takes two arguments `tElement` and `tAttrs`.
The function takes the following arguments:
* `tElement` - template element - The element where the directive ha... | There must be some directive in angularjs as ng-if or something like that.
In Angular 4 you can do this as one of way as
```
<div *ngIf="x === 1"></div>
<div *ngIf="x === 2"></div>
```
And you can pass the value of x according to your need.
Added Solution
```
import { Component, Input } from '@angular/core';
impo... |
49,392,263 | So in angularjs you had the possibility to define a directive and bind the html template to an already existing controller. In principal this meant you could reuse the controller for multiple directives, therefore for multiple templates.
```
angular
.module('App')
.component('Name', {
templateUrl: 'some.html',
... | 2018/03/20 | [
"https://Stackoverflow.com/questions/49392263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6534650/"
] | After more research it still seems that the best solution I could come up with is using inheritance.
<https://coryrylan.com/blog/angular-component-inheritance-and-template-swapping>
He has a rather nice description of it
Thank you to all who helped me ;) | There must be some directive in angularjs as ng-if or something like that.
In Angular 4 you can do this as one of way as
```
<div *ngIf="x === 1"></div>
<div *ngIf="x === 2"></div>
```
And you can pass the value of x according to your need.
Added Solution
```
import { Component, Input } from '@angular/core';
impo... |
49,392,263 | So in angularjs you had the possibility to define a directive and bind the html template to an already existing controller. In principal this meant you could reuse the controller for multiple directives, therefore for multiple templates.
```
angular
.module('App')
.component('Name', {
templateUrl: 'some.html',
... | 2018/03/20 | [
"https://Stackoverflow.com/questions/49392263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6534650/"
] | Define `templateUrl` as a function
----------------------------------
You can specify `templateUrl` as a string representing the URL **or as a function** which takes two arguments `tElement` and `tAttrs`.
The function takes the following arguments:
* `tElement` - template element - The element where the directive ha... | ```
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LoadingComponent } from './loading.component'
@NgModule({
imports: [
CommonModule
],
declarations: [LoadingComponent],
exports: [LoadingComponent]
})
export class LoadingModule { }
```
IN this case am planning to ... |
49,392,263 | So in angularjs you had the possibility to define a directive and bind the html template to an already existing controller. In principal this meant you could reuse the controller for multiple directives, therefore for multiple templates.
```
angular
.module('App')
.component('Name', {
templateUrl: 'some.html',
... | 2018/03/20 | [
"https://Stackoverflow.com/questions/49392263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6534650/"
] | After more research it still seems that the best solution I could come up with is using inheritance.
<https://coryrylan.com/blog/angular-component-inheritance-and-template-swapping>
He has a rather nice description of it
Thank you to all who helped me ;) | ```
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LoadingComponent } from './loading.component'
@NgModule({
imports: [
CommonModule
],
declarations: [LoadingComponent],
exports: [LoadingComponent]
})
export class LoadingModule { }
```
IN this case am planning to ... |
5,878,240 | When using Grails, when creating the WAR archive, I would like to apply a filter to all Javascript & CSS files : the yui-compressor mimifier. Is there a nice ways to achieve that with Grails ? | 2011/05/04 | [
"https://Stackoverflow.com/questions/5878240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84978/"
] | I know this is answered, but if you do want to do it yourself, without installing plugins, look at:
<http://www.milan-ramaiya.com/2010/09/15/compressing-javascript-and-css-using-yui-compressor-during-grails-build/>
This will do it only when the war is built, and also shows you how to make changes to the warred files. | The [UiPerformance plugin](http://www.grails.org/plugin/ui-performance) supports minification using YUI compressor. I don't know whether it can be enabled only when running the `grails war` task, but it can be enabled/disabled on a per-environment basis.
If you really want the minification to happen only when creating... |
84,093 | One of the core philosophies present in Apocalypse World and related games is the idea that (as a GM) one should never plan anything in advance. Okay, it's quite a bit more nuanced than that; you're actively encouraged to plan without sticking to your prep, there are certain specific ways in which you're explicitly all... | 2016/07/14 | [
"https://rpg.stackexchange.com/questions/84093",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/21148/"
] | I can't imagine running any campaign that isn't improvisational to some degree. I am running a Dungeon World campaign which is more traditional in campaign design because my players come from more of a D&D background, so I'm working from that perspective. That works fine- effectively my fronts are running in a sandbox ... | **TL;DR:**
This answer will not cite experience, because overall, this is not my play style, and when I do want to play something high-prep, I play something else. That being said, I will try to use the rules to prove that the expressed play style of yourself is not beyond what Dungeon World can cater to, because Dunge... |
73,048,137 | I am creating a wrapper for firecracker.
To start a VM with firecracker on command line, you have to pass a socket file to the `firecracker` executable. Something like this:
```
firecracker --api-sock /path/to/file.socket
```
Then from another terminal, you can make requests to this server/socket something like thi... | 2022/07/20 | [
"https://Stackoverflow.com/questions/73048137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/939986/"
] | To do this, you'll need to override the Transport used by your `http.Client` to configure a function for it to use to create a connection to the socket:
```golang
client := http.Client{
Transport: &http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
return net.DialContex... | Extending to this [answer](https://stackoverflow.com/a/73050944), you can keep the http defaults by cloning default transport
```
defaultTransport, ok := http.DefaultTransport.(*http.Transport)
if !ok {
panic("http.DefaultTransport is not a *http.Transport")
}
unixTransport := defaultTransp... |
271 | I'm asking this in light of the [Beta site closure announcements](https://cogsci.meta.stackexchange.com/questions/268/reflections-on-april-25th-2012-beta-site-closures-announcement) question, but I don't want to steal its thunder.
Realizing that we share at least some of the subject matter in common with the proposal ... | 2012/04/26 | [
"https://cogsci.meta.stackexchange.com/questions/271",
"https://cogsci.meta.stackexchange.com",
"https://cogsci.meta.stackexchange.com/users/31/"
] | I had a look at the sample questions on Area 51. They generally concern neural imaging, and processing neural data, etc. I think these questions are on topic at the moment at Cogsci.SE under the broad heading of neuroscience.
I'd be happy for the word neuroinformatics to be added to the list of acceptable topics in th... | While I like the idea I do want to raise a couple of concerns.
As it is [we already have somewhat of an overlap with Biology.SE when it comes to neuroscience](https://biology.stackexchange.com/questions/tagged/neuroscience). There are two existing meta posts about where to draw the line:
* [Are questions about neurob... |
271 | I'm asking this in light of the [Beta site closure announcements](https://cogsci.meta.stackexchange.com/questions/268/reflections-on-april-25th-2012-beta-site-closures-announcement) question, but I don't want to steal its thunder.
Realizing that we share at least some of the subject matter in common with the proposal ... | 2012/04/26 | [
"https://cogsci.meta.stackexchange.com/questions/271",
"https://cogsci.meta.stackexchange.com",
"https://cogsci.meta.stackexchange.com/users/31/"
] | I had a look at the sample questions on Area 51. They generally concern neural imaging, and processing neural data, etc. I think these questions are on topic at the moment at Cogsci.SE under the broad heading of neuroscience.
I'd be happy for the word neuroinformatics to be added to the list of acceptable topics in th... | My take on this (which was rather cross-posted on the area51 site) is that it's a good idea, but that "Cognitive Science" is too limiting a name. Our lab would do very well to have a place to discuss stuff like this, but we do affective neuroscience, and a smattering of perception research and neurodegenerative disease... |
52,138,464 | I was using RStudio for a long time and it was ok with me, but before one day when I try to compile a code, it gives this message "R encountered a fatal error" and it forces me to restart RStudio again and the problem still.
the code I used just call two libraries:
```
library(Rtsne)
library(ggplot2)
```
And this I... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52138464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8919443/"
] | This issue can occur in many instances and the causes might be multiple. I run a very large dataset relating to the single cell transcriptome, and the error can occur unexpectedly and randomly. Sometimes this will happen but can be fixed after restart the session, sometimes this will not happen running the same code. | I experienced the same "R session aborted" after updating R. I thought it was R's fault, then I tested the script in terminal and everything worked fine. I tried reinstalling Rstudio (same version) and it still failed.
The issue was solved by installing the lastest Rstudio from `https://dailies.rstudio.com/`. |
52,138,464 | I was using RStudio for a long time and it was ok with me, but before one day when I try to compile a code, it gives this message "R encountered a fatal error" and it forces me to restart RStudio again and the problem still.
the code I used just call two libraries:
```
library(Rtsne)
library(ggplot2)
```
And this I... | 2018/09/02 | [
"https://Stackoverflow.com/questions/52138464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8919443/"
] | This issue can occur in many instances and the causes might be multiple. I run a very large dataset relating to the single cell transcriptome, and the error can occur unexpectedly and randomly. Sometimes this will happen but can be fixed after restart the session, sometimes this will not happen running the same code. | I have encountered this problem when running the first chunk in every RMD file I create, specifically when clicking the 'run current chunk' arrow sign.
One way to avoid this is to run the first chunk after highlighting the code in lines, and simply clicking the 'run selected lines' command on the top right-hand corner... |
2,865,000 | I recently started studying about global maxima and minima.
The extreme value theorem proves the existence of global maxima and minima for a continuous function in a closed interval.This theorem is actually, pretty much intuitive and looks like a basic property of a continuous function.
Has it got any applications ot... | 2018/07/28 | [
"https://math.stackexchange.com/questions/2865000",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/571257/"
] | The Extreme Value Theorem sits in the middle of a chain of theorems, where each theorem is proved using the last.
LUB Property $\rightarrow$ Monotone bounded convergence $\rightarrow$ Bolzano-Weierstrass $\rightarrow$ EVT $\rightarrow$ IVT $\rightarrow$ Rolle's Theorem $\rightarrow$ MVT, Cauchy's MVT $\rightarrow$ Int... | Well the extreme value theorem is very nice for bounding how fast your functions can grow. Given an arbitrary $f \in (a,b)$ that is continuous, we may not guarantee that it's bounded. Indeed, take $f = \frac{1}{x}$, then it's continuous on $(0,1)$, but not bounded.
Here's one example of how useful this theorem is: Let... |
71,695,196 | I have a very small test base, with 5 documents and 4 arguments. I want to update these documents when importing a new file (add new fields, replace old values with new ones) during the JSON file import process.
[](https://i.stack.imgur.com/NUclS.png)... | 2022/03/31 | [
"https://Stackoverflow.com/questions/71695196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744714/"
] | I think the best way to do this is to not update these documents but replace them.
I'm assuming your date fields can be used as unique identifiers.
```
def update_and_add_with_json(self, file_path):
""" The function update all documents in collection databases using JSON file """
file_data = json.load(open(... | Yes, exactly, it works in a similar way. Might be useful to someone
```
def update_and_add_with_json(self, data, key):
""" The function update all documents in collection databases using JSON file """
with open(data) as file:
file_data = json.load(file)
key = key
try... |
83,821 | Can characters hold their initiative (or simply wait until another acts) in order to coordinate with each other, like to perfectly strike the enemy in sync? Would there be any mechanical benefit from doing so? | 2016/07/08 | [
"https://rpg.stackexchange.com/questions/83821",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/23099/"
] | **Yes, either through Delay or Ready**
>
> Delay
>
>
> By choosing to delay, you take no action and then act normally on whatever initiative count you decide to act. When you delay, you voluntarily reduce your own initiative result for the rest of the combat. When your new, lower initiative count comes up later in ... | There are two mechanics that do what you want: [Readying, and Delaying](http://www.d20srd.org/srd/combat/specialInitiativeActions.htm).
Both of these actions allow characters to manipulate their own initiative order.
As to benefits... Yes, there absolutely are. Both mechanical and narrative. Readying and Delaying bot... |
83,821 | Can characters hold their initiative (or simply wait until another acts) in order to coordinate with each other, like to perfectly strike the enemy in sync? Would there be any mechanical benefit from doing so? | 2016/07/08 | [
"https://rpg.stackexchange.com/questions/83821",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/23099/"
] | **Yes, either through Delay or Ready**
>
> Delay
>
>
> By choosing to delay, you take no action and then act normally on whatever initiative count you decide to act. When you delay, you voluntarily reduce your own initiative result for the rest of the combat. When your new, lower initiative count comes up later in ... | Yes, the game defines two [special initiative actions](http://www.d20srd.org/srd/combat/specialInitiativeActions.htm) for this purpose:
* Delay: when your initiative count comes up, you voluntarily decide to lower it, i.e. you let someone else go first. This change is permanent, so if you do this you will go after any... |
16,792,981 | I have different users, some of them are plain users, and a few are admins.
What I need is that the admins can login as any of the other users by just clicking a button in the user list.
What I have so far is:
index.blade.php (the users list):
```
<a href='{{URL::route('users.loginas', array('id' => $user->id))}}'>L... | 2013/05/28 | [
"https://Stackoverflow.com/questions/16792981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1590024/"
] | You can make your LAMP server stack accessible from the internet by forwarding ports from your external internet connection to the computer the server stack is running on. If you're doing this at home, you can usually handle port forwarding from the admin interface for your router/modem.
Alternatively, [WebRTC](http:/... | Browser does not permit raw sockets.
You can not create a socket from browser, because it would be security hole.
For example you download a page from internet and script on this page opened all sockets on your computer.
Websockets it is technology on top of TCP protocol.
Using Websockets you can connect two browsers ... |
65,895,925 | I was wondering how to save an array of objects to a NSUserDefault. I've read about encoding the data array, but was unsure about how the process works.
This is my array:
```
//EventData class with EventDataArray
class EventData {
static var EventDataArray: [EventModel] = []
}
```
And this is my data model:
... | 2021/01/26 | [
"https://Stackoverflow.com/questions/65895925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12946687/"
] | To save a structure in UserDefaults you need to first encode it to be able to save it as Data. So you need to make your custom structure conform to Codable:
```
struct Event: Codable {
let id: UUID
let name: String
let start, end: Date
let fromTime, toTime: String
let color: Color
init(id: UUID... | Simply use:
`UserDefaults().set(try? PropertyListEncoder().encode(EventDataArray), forKey: "eventDataPersisted")` (of course, feel free to name the key whatever you want).
Also, as a rule of thumb, variable names typically follow [camelCase](https://medium.com/better-programming/string-case-styles-camel-pascal-snake-a... |
68,099,745 | I have the following `pd.DataFrame`
```
from datetime import datetime
df1 = pd.DataFrame(
data=[[0, 0, 1], [0, 1, 1], [1, 1, 0], [1, 1, 0], [0, 0, 1], [0, 1, 1], [1, 1, 0], [1, 1, 0]],
index=[
datetime(2020, 1, 1, 1, 10), datetime(2020, 1, 1, 1, 15), datetime(2020, 1, 1, 1, 20), datetime(2020, 1, 1, 1,... | 2021/06/23 | [
"https://Stackoverflow.com/questions/68099745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803908/"
] | One solution:
just get the first 1 value in each row:
```
df1[df1.cumsum(axis=1)!=1] = 0
```
set a temporary date col
```
df1["date"] = df1.index.date
```
set any duplicated rows to 0
```
df1[df1.duplicated()] = 0
```
get rid of the temporary date column
```
df1.drop("date", axis=1, inplace=True)
```
This ... | You can use boolean masking or [`df.where`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.where.html). Then use [`pd.Series.first_valid_idnex`](https://pandas.pydata.org/docs/reference/api/pandas.Series.first_valid_index.html) in `groupby`.
```
def func(g):
vals = np.zeros(g.shape)
idx = g.in... |
50,615,020 | I'm creating an application and I want to create a label which when clicked, will open an "openFileDialog", the user will select a .jpg or .png image, and then this selected image will be copied to a predefined directory (specific folder).
For now, I have a separate label-button which when clicked, opens an "openFile... | 2018/05/31 | [
"https://Stackoverflow.com/questions/50615020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9619957/"
] | Try
```
pictureBox3.Image.Save(specific_folder + "\\" + f.SafeFileName);
```
as follow:
```
private void addlabel_MouseClick(object sender, MouseEventArgs e)
{
Image File;
OpenFileDialog f = new OpenFileDialog();
f.Filter = "Image files (*.jpg, *.png) | *.jpg; *.png";
if (f.ShowDialog() == DialogRe... | Something like
```
if (f.ShowDialog() == DialogResult.OK)
{
File = Image.FromFile(f.FileName);
pictureBox3.Image = File;
File.Copy(f.FileName, @"C:\MyDestination\" + f.SafeFileName;
}
```
See <https://msdn.microsoft.com/en-us/library/c6cfw35a(v=vs.110).aspx> and <https://msdn.micr... |
7,030,364 | My team is building a mobile website using jQuery Mobile, and as we are nearing the release date performance is becoming more of a concern. One observation I've made is that we have lots of calls to `live()` and `delegate()` throughout our code; but in fact, to my knowledge, we are only *ever* using these methods to at... | 2011/08/11 | [
"https://Stackoverflow.com/questions/7030364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/105570/"
] | I haven't measured anything, but `live` is likely to be faster than `bind` for larger numbers of elements, since `bind` needs to affect every element.
If you `bind` an event to 200 elements, jQuery needs to loop through all of those elements and call `addEventListener` on each one.
If you `live` an event to 200 ele... | `bind` is used to bind he event directly on the element. So the event will be attached only if the element exists where as `live` and `delegate` are used for dynamic elements also. It depends on your use but live and delegate provide better performance than `bind` |
7,030,364 | My team is building a mobile website using jQuery Mobile, and as we are nearing the release date performance is becoming more of a concern. One observation I've made is that we have lots of calls to `live()` and `delegate()` throughout our code; but in fact, to my knowledge, we are only *ever* using these methods to at... | 2011/08/11 | [
"https://Stackoverflow.com/questions/7030364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/105570/"
] | It depends on how you use it but delegate offers the best performance (not necessarily in terms of speed only but overall) in most cases:
<http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/> | `bind` is used to bind he event directly on the element. So the event will be attached only if the element exists where as `live` and `delegate` are used for dynamic elements also. It depends on your use but live and delegate provide better performance than `bind` |
7,030,364 | My team is building a mobile website using jQuery Mobile, and as we are nearing the release date performance is becoming more of a concern. One observation I've made is that we have lots of calls to `live()` and `delegate()` throughout our code; but in fact, to my knowledge, we are only *ever* using these methods to at... | 2011/08/11 | [
"https://Stackoverflow.com/questions/7030364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/105570/"
] | I did a simple benchmark against the three. Generally speaking, Delegate is the most efficient. The exception is when the element being bound to is static and known. Even with multiple static elements, bind consistently outperformed Delegate. Bind does have more initial overhead, but Delegate has more event-time overhe... | `bind` is used to bind he event directly on the element. So the event will be attached only if the element exists where as `live` and `delegate` are used for dynamic elements also. It depends on your use but live and delegate provide better performance than `bind` |
74,092,082 | I wonder why an **element has attributes of .class1 and .class2, but not .class1.class2. Please explain.** If the parent has .class1 and the element has .class2, then the element is supposed to have both classes. It has, but can't be selected using .class1.class2. In contrast, if the parent has .class1 and .class2, the... | 2022/10/17 | [
"https://Stackoverflow.com/questions/74092082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4335480/"
] | Well, something like this:
```
@Composable
fun NiaApp(
windowSizeClass: WindowSizeClass,
appState: NiaAppState = rememberNiaAppState(windowSizeClass) ) {
NiaTheme {
background(appState)() {
Scaffold(
...
) { padding ->
... | just cut your `Background` composable function and paste it outside of the `NiaApp` composable function
```
@Composable
fun NiaApp(
windowSizeClass: WindowSizeClass,
appState: NiaAppState = rememberNiaAppState(windowSizeClass)
) {
NiaTheme {
background {
Scaffold(
...
... |
74,092,082 | I wonder why an **element has attributes of .class1 and .class2, but not .class1.class2. Please explain.** If the parent has .class1 and the element has .class2, then the element is supposed to have both classes. It has, but can't be selected using .class1.class2. In contrast, if the parent has .class1 and .class2, the... | 2022/10/17 | [
"https://Stackoverflow.com/questions/74092082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4335480/"
] | You can try this:
```
@Composable
fun NiaApp(
windowSizeClass: WindowSizeClass,
appState: NiaAppState = rememberNiaAppState(windowSizeClass)
) {
NiaTheme {
Background(appState) {
Scaffold(
...
) { padding ->
Row(
...
... | just cut your `Background` composable function and paste it outside of the `NiaApp` composable function
```
@Composable
fun NiaApp(
windowSizeClass: WindowSizeClass,
appState: NiaAppState = rememberNiaAppState(windowSizeClass)
) {
NiaTheme {
background {
Scaffold(
...
... |
74,092,082 | I wonder why an **element has attributes of .class1 and .class2, but not .class1.class2. Please explain.** If the parent has .class1 and the element has .class2, then the element is supposed to have both classes. It has, but can't be selected using .class1.class2. In contrast, if the parent has .class1 and .class2, the... | 2022/10/17 | [
"https://Stackoverflow.com/questions/74092082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4335480/"
] | You can try this:
```
@Composable
fun NiaApp(
windowSizeClass: WindowSizeClass,
appState: NiaAppState = rememberNiaAppState(windowSizeClass)
) {
NiaTheme {
Background(appState) {
Scaffold(
...
) { padding ->
Row(
...
... | Well, something like this:
```
@Composable
fun NiaApp(
windowSizeClass: WindowSizeClass,
appState: NiaAppState = rememberNiaAppState(windowSizeClass) ) {
NiaTheme {
background(appState)() {
Scaffold(
...
) { padding ->
... |
8,571,363 | >
> **Possible Duplicate:**
>
> [What is the fastest way to swap values in C?](https://stackoverflow.com/questions/36906/what-is-the-fastest-way-to-swap-values-in-c)
>
>
>
I need to exchange values of two integers (for example x and y)
This is the simplest way:
```
int temp = x;
x = y;
y = temp;
```
and I a... | 2011/12/20 | [
"https://Stackoverflow.com/questions/8571363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/987244/"
] | it is posible with **XOR** "**^**" operator:
```
a = a^b;
b = a^b;
a = a^b;
``` | Well in the second option you use 2 variables instead of 3 in the 1st option, this means you allocate less memory. |
1,063,775 | Lets put it in parts.
I got a socket receiving data OK and I got it in the `\x31\x31\x31` format.
I know that I can get the same number, ripping the `\x` with something like
```
for i in data: print hex(ord(i))
```
so I got `31` in each case.
But if I want to add 1 to the data (so it shall be "`32 32 32`")to sen... | 2009/06/30 | [
"https://Stackoverflow.com/questions/1063775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | use the struct module
unpack and get the 3 values in abc
`(a, b, c) = struct.unpack(">BBB", your_string)`
then
`a, b, c = a+1, b+1, c+1`
and pack into the response
`response = struct.pack(">BBB", a, b, c)`
see the struct module in python documentation for more details | The opposite of ord() would be chr().
So you could do this to add one to it:
```
newchar = chr(ord(i) + 1)
```
To use that in your example:
```
newdata = ''
for i in data:
newdata += chr(ord(i) + 1)
print repr(newdata)
```
But if you really wanted to work in hex strings, you can use encode() and decode():
... |
1,063,775 | Lets put it in parts.
I got a socket receiving data OK and I got it in the `\x31\x31\x31` format.
I know that I can get the same number, ripping the `\x` with something like
```
for i in data: print hex(ord(i))
```
so I got `31` in each case.
But if I want to add 1 to the data (so it shall be "`32 32 32`")to sen... | 2009/06/30 | [
"https://Stackoverflow.com/questions/1063775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The "\x31" is not a format but the text representation of the binary data. As you mention ord() will convert one byte of binary data into an int, so you can do maths on it.
To convert it back to binary data in a string, you can use chr() if it's on just one integer. If it's many, you can use the %c formatting characte... | use the struct module
unpack and get the 3 values in abc
`(a, b, c) = struct.unpack(">BBB", your_string)`
then
`a, b, c = a+1, b+1, c+1`
and pack into the response
`response = struct.pack(">BBB", a, b, c)`
see the struct module in python documentation for more details |
1,063,775 | Lets put it in parts.
I got a socket receiving data OK and I got it in the `\x31\x31\x31` format.
I know that I can get the same number, ripping the `\x` with something like
```
for i in data: print hex(ord(i))
```
so I got `31` in each case.
But if I want to add 1 to the data (so it shall be "`32 32 32`")to sen... | 2009/06/30 | [
"https://Stackoverflow.com/questions/1063775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | use the struct module
unpack and get the 3 values in abc
`(a, b, c) = struct.unpack(">BBB", your_string)`
then
`a, b, c = a+1, b+1, c+1`
and pack into the response
`response = struct.pack(">BBB", a, b, c)`
see the struct module in python documentation for more details | OMG, what a fast answering! :D
I think that i was stuck on the ">B" parameter to struct, as i used "h" and that sample parameters (newbie on struct.pack talking!)
Tried the encode/decode thing but socket on the other side receive them as numbers, not the "\x" representation it wanted.
I really enjoy the simplicity o... |
1,063,775 | Lets put it in parts.
I got a socket receiving data OK and I got it in the `\x31\x31\x31` format.
I know that I can get the same number, ripping the `\x` with something like
```
for i in data: print hex(ord(i))
```
so I got `31` in each case.
But if I want to add 1 to the data (so it shall be "`32 32 32`")to sen... | 2009/06/30 | [
"https://Stackoverflow.com/questions/1063775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The "\x31" is not a format but the text representation of the binary data. As you mention ord() will convert one byte of binary data into an int, so you can do maths on it.
To convert it back to binary data in a string, you can use chr() if it's on just one integer. If it's many, you can use the %c formatting characte... | The opposite of ord() would be chr().
So you could do this to add one to it:
```
newchar = chr(ord(i) + 1)
```
To use that in your example:
```
newdata = ''
for i in data:
newdata += chr(ord(i) + 1)
print repr(newdata)
```
But if you really wanted to work in hex strings, you can use encode() and decode():
... |
1,063,775 | Lets put it in parts.
I got a socket receiving data OK and I got it in the `\x31\x31\x31` format.
I know that I can get the same number, ripping the `\x` with something like
```
for i in data: print hex(ord(i))
```
so I got `31` in each case.
But if I want to add 1 to the data (so it shall be "`32 32 32`")to sen... | 2009/06/30 | [
"https://Stackoverflow.com/questions/1063775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The "\x31" is not a format but the text representation of the binary data. As you mention ord() will convert one byte of binary data into an int, so you can do maths on it.
To convert it back to binary data in a string, you can use chr() if it's on just one integer. If it's many, you can use the %c formatting characte... | OMG, what a fast answering! :D
I think that i was stuck on the ">B" parameter to struct, as i used "h" and that sample parameters (newbie on struct.pack talking!)
Tried the encode/decode thing but socket on the other side receive them as numbers, not the "\x" representation it wanted.
I really enjoy the simplicity o... |
36,976,373 | I have 2 buttons, when first button is clicked, it runs an infinite loop and I want it to stop when i click the second button.
What is the proper way to do this since I'm new on using java.
I know this wrong but I just want to make clear what I'm trying to do
```
private void button1_buttonActionPerformed(java.awt.ev... | 2016/05/02 | [
"https://Stackoverflow.com/questions/36976373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6244162/"
] | define a flag variable like;
```
boolean isBUttonClicked = false;
```
and in your `while loop`
use if statement like
```
while(true){
if(isButtonClicked){
isButtonClicked = false;
break;
}else{
//do your job
}
}
```
in the second button `action performed method`
use isButtonClicked and ... | Declare a static variable like this `boolean flag=false` outside the button methods.
Then inside button 1,
`private void button1_buttonActionPerformed(java.awt.event.ActionEvent evt) {
while( !flag ) {} }`
and inside button2,
`private void button1_buttonActionPerformed(java.awt.event.ActionEvent evt) {
flag = true... |
36,976,373 | I have 2 buttons, when first button is clicked, it runs an infinite loop and I want it to stop when i click the second button.
What is the proper way to do this since I'm new on using java.
I know this wrong but I just want to make clear what I'm trying to do
```
private void button1_buttonActionPerformed(java.awt.ev... | 2016/05/02 | [
"https://Stackoverflow.com/questions/36976373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6244162/"
] | Try this
```
boolean sthap = false;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new Thread(new Runnable() {
@Override
public void run() {
while (!sthap) {
System.out.println("run");
}
}
}).start();
}
private void jButt... | Declare a static variable like this `boolean flag=false` outside the button methods.
Then inside button 1,
`private void button1_buttonActionPerformed(java.awt.event.ActionEvent evt) {
while( !flag ) {} }`
and inside button2,
`private void button1_buttonActionPerformed(java.awt.event.ActionEvent evt) {
flag = true... |
35,838,308 | I have a requirement where I need to throttle by shaping (queuing) inbound traffic when client app sends more than 1000 requests in a 5 sec time span.
The solution I followed is:
I have a camel:throttle setting max requests to 1000 and timespan to 5 sec. When threshold is exceeded I am catching throttle exception and ... | 2016/03/07 | [
"https://Stackoverflow.com/questions/35838308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4588276/"
] | In another SO [thread](https://stackoverflow.com/questions/14258755/activemq-throttling-consumer) the winning answers promotes the following solution:
```
from("activemq:queueA").throttle(10).to("activemq:queueB")
```
To me this solution only makes sense, if you define a prefetch limit, without which the consumer wo... | You can enable scheduled delivery of ActiveMQ and then set in your Camel Route AMQ\_SCHEDULED\_DELAY header and then send your exchange to a queue. This will result to introducing a delay of AMQ\_SCHEDULED\_DELAY millis before the message appears in the queue (i.e. be available for consumption).
Check this: <http://ac... |
42,348 | I'm working on a system that takes the customers credit card information before sending it to the processor. It requires me to ask the customer for cc#, CVV, date, one at a time and send that to my server between each request (https, no cookies, cache, or sessions used). How should I keep track of the data between requ... | 2013/09/13 | [
"https://security.stackexchange.com/questions/42348",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/30762/"
] | First up, I **strongly recommend you offload your PCI-DSS compliance obligations** entirely by moving the responsibility to capture and process payment credentials over to the payment gateway provider. Most payment providers host the payment capture pages for their clients for this reason. This allows you to simply pas... | You can check and try [OSSEC](http://www.ossec.net/) (Open Source Security) which is a host-based intrusion detection system. Being open source is a plus for security and it helps with PCI.
It is said:
>
> OSSEC helps customers meet specific compliance requirements such as
> PCI, HIPAA etc. It lets customers detect... |
42,348 | I'm working on a system that takes the customers credit card information before sending it to the processor. It requires me to ask the customer for cc#, CVV, date, one at a time and send that to my server between each request (https, no cookies, cache, or sessions used). How should I keep track of the data between requ... | 2013/09/13 | [
"https://security.stackexchange.com/questions/42348",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/30762/"
] | First up, I **strongly recommend you offload your PCI-DSS compliance obligations** entirely by moving the responsibility to capture and process payment credentials over to the payment gateway provider. Most payment providers host the payment capture pages for their clients for this reason. This allows you to simply pas... | It is compliant to keep them in memory during the transaction. It is safer (from a compliance Pov) and easier that storing them temporarily in a database.
PCI DSS 3.0 provides now guidance to protect Sensitive Data in memory while being processed to avoid data leakage in crash dumps.
Best practice is to use a library... |
42,348 | I'm working on a system that takes the customers credit card information before sending it to the processor. It requires me to ask the customer for cc#, CVV, date, one at a time and send that to my server between each request (https, no cookies, cache, or sessions used). How should I keep track of the data between requ... | 2013/09/13 | [
"https://security.stackexchange.com/questions/42348",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/30762/"
] | It is compliant to keep them in memory during the transaction. It is safer (from a compliance Pov) and easier that storing them temporarily in a database.
PCI DSS 3.0 provides now guidance to protect Sensitive Data in memory while being processed to avoid data leakage in crash dumps.
Best practice is to use a library... | You can check and try [OSSEC](http://www.ossec.net/) (Open Source Security) which is a host-based intrusion detection system. Being open source is a plus for security and it helps with PCI.
It is said:
>
> OSSEC helps customers meet specific compliance requirements such as
> PCI, HIPAA etc. It lets customers detect... |
83,835 | I use `save_post` hook, and I have to know inside this hook function, whether it is a publishing ( `draft to publish` ) or is it an updating, like `publish to publish` or `draft to draft`.
Is there a way to check it?
I can not use `draft_to_publish` hook for this, and I'll explain why:
The users ask questions on ... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16331/"
] | You can hook on `save_post` or `publish_post` hook in each post and publish in other blogs. You must use the function [`switch_to_blog()`](http://codex.wordpress.org/WPMU_Functions/switch_to_blog) to switch in other blog and then use `[wp_insert_post()][2]` to save a post inside this blog; do this for each blog.
Alte... | You can use the WordPress XMLRPC API.
<http://codex.wordpress.org/XML-RPC_WordPress_API>
Alternatively, take a look at the following plugin: <https://wordpress.org/plugins/syndicate-out/installation/> |
16,119,479 | The main problem is that the user cant login the site without the remember the option. I have modified login function to check the user access and redirect to their particular action but it doesn't work id the user don't choose the remember me option at the time of login.Here is my code of login action..
```
if(isset(... | 2013/04/20 | [
"https://Stackoverflow.com/questions/16119479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1376985/"
] | This line is important
```
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);
return true;
}
```
make sure your execution enters this bloc... Try var\_dump() to debug the error code
... | Just to reply if someone is having the same problem yet.
It could well be just that you have a space in your sessions name in config/main.php
Remove spaces in name and set 'cookieMode' => 'allow' or 'cookieMode' => 'only'.
Then clear your cookies and it should be working without remember me. |
25,036,288 | I'm really baffled after reading [PhoneGap on iOS with absolute path URLs for assets](https://stackoverflow.com/questions/9073953/phonegap-on-ios-with-absolute-path-urls-for-assets)
and have a couple of questions:
* Does Phonegap supports root relative path? For instance [Ionic framework](http://ionicframework.com/) f... | 2014/07/30 | [
"https://Stackoverflow.com/questions/25036288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2470533/"
] | Basically in phone gap development everything that concerns your code resides in the **www** folder.
```
-myApp
-www
-index.html
-img
-js
-css
-libraries
-templates
```
The best would be to just refer the files as `js/file.js` and `css/file.css` i.e relative to index.html.
Ro... | I stumbled upon this old thread while trying to solve the same/similar challenge with images not rendering on the device but, oddly, would render when running with a live server or with the Chrome browser.
If you're reading this, the filespec to your image is also case-sensitive. Chrome doesn't care, but Cordova (Phon... |
25,036,288 | I'm really baffled after reading [PhoneGap on iOS with absolute path URLs for assets](https://stackoverflow.com/questions/9073953/phonegap-on-ios-with-absolute-path-urls-for-assets)
and have a couple of questions:
* Does Phonegap supports root relative path? For instance [Ionic framework](http://ionicframework.com/) f... | 2014/07/30 | [
"https://Stackoverflow.com/questions/25036288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2470533/"
] | Basically in phone gap development everything that concerns your code resides in the **www** folder.
```
-myApp
-www
-index.html
-img
-js
-css
-libraries
-templates
```
The best would be to just refer the files as `js/file.js` and `css/file.css` i.e relative to index.html.
Ro... | Refer this link
<https://github.com/apache/cordova-ios/issues/883#issuecomment-643657781>
you can add prefrence tag in config.xml lik this
```
<preference name="scheme" value="app" />
```
In cardova & phonegap they use custom protocol(app://) for refering to file available locally. |
25,036,288 | I'm really baffled after reading [PhoneGap on iOS with absolute path URLs for assets](https://stackoverflow.com/questions/9073953/phonegap-on-ios-with-absolute-path-urls-for-assets)
and have a couple of questions:
* Does Phonegap supports root relative path? For instance [Ionic framework](http://ionicframework.com/) f... | 2014/07/30 | [
"https://Stackoverflow.com/questions/25036288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2470533/"
] | I stumbled upon this old thread while trying to solve the same/similar challenge with images not rendering on the device but, oddly, would render when running with a live server or with the Chrome browser.
If you're reading this, the filespec to your image is also case-sensitive. Chrome doesn't care, but Cordova (Phon... | Refer this link
<https://github.com/apache/cordova-ios/issues/883#issuecomment-643657781>
you can add prefrence tag in config.xml lik this
```
<preference name="scheme" value="app" />
```
In cardova & phonegap they use custom protocol(app://) for refering to file available locally. |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You can use a short list comprehension to extract the numbers from a given line. Since the ranges you listed seem to be inclusive on both ends, we need to add one to end interval (j) below.
```
for line in myfile:
i, j = [int(n) for n in line.split("-")]
for x in range(i, j + 1):
# do things
```
If y... | I believe that you can match the pattern using [capturing groups](https://www.regular-expressions.info/brackets.html) using Regex and add it into your list.
Regex: <https://regex101.com/r/f1Ghff/1>
```
(\d+)\-(\d+)
```
Explanation:
```
1st Capturing Group (\d+)
\d+ matches a digit (equal to [0-9])
+ Quantifier — ... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You're very close, you just need to append the list [`range()`](https://docs.python.org/3/library/functions.html#func-range):
```
data = []
with open("file.txt") as f:
for line in f:
start, end = map(int, line.split("-"))
data.append(list(range(start, end + 1)))
print(data)
# [[1, 2, 3, 4, 5, 6, 7... | How about something like this?
Of course, it has no error checking, so you'd want to be mindful of the quality of your input data.
```
data = []
with open('file.txt','r') as myfile:
for line in myfile:
# Split the line and force conversion to int
start_int, end_int = map(int, line.split('-'))
... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | If you just want to print the ranges, you can use this:
```
with open('file.txt', 'r') as myfile:
for line in myfile:
nums = [int(i) for i in line.split('-')]
nums[1] += 1 # more on this in a second
my_range = range(*nums) # the * unpacks the two numbers into two arguments
print([... | How about something like this?
Of course, it has no error checking, so you'd want to be mindful of the quality of your input data.
```
data = []
with open('file.txt','r') as myfile:
for line in myfile:
# Split the line and force conversion to int
start_int, end_int = map(int, line.split('-'))
... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You can use a short list comprehension to extract the numbers from a given line. Since the ranges you listed seem to be inclusive on both ends, we need to add one to end interval (j) below.
```
for line in myfile:
i, j = [int(n) for n in line.split("-")]
for x in range(i, j + 1):
# do things
```
If y... | You just need to extract the start and end index from each line and use it in `range` to create your list
```
data = []
with open('file.txt','r') as myfile:
for line in myfile:
start,end = [int(item) for item in line.split('-')]
li = list(range(start ,end+1))
data.append(li)
print(data)
`... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You can use a short list comprehension to extract the numbers from a given line. Since the ranges you listed seem to be inclusive on both ends, we need to add one to end interval (j) below.
```
for line in myfile:
i, j = [int(n) for n in line.split("-")]
for x in range(i, j + 1):
# do things
```
If y... | You're very close, you just need to append the list [`range()`](https://docs.python.org/3/library/functions.html#func-range):
```
data = []
with open("file.txt") as f:
for line in f:
start, end = map(int, line.split("-"))
data.append(list(range(start, end + 1)))
print(data)
# [[1, 2, 3, 4, 5, 6, 7... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You just need to extract the start and end index from each line and use it in `range` to create your list
```
data = []
with open('file.txt','r') as myfile:
for line in myfile:
start,end = [int(item) for item in line.split('-')]
li = list(range(start ,end+1))
data.append(li)
print(data)
`... | I believe that you can match the pattern using [capturing groups](https://www.regular-expressions.info/brackets.html) using Regex and add it into your list.
Regex: <https://regex101.com/r/f1Ghff/1>
```
(\d+)\-(\d+)
```
Explanation:
```
1st Capturing Group (\d+)
\d+ matches a digit (equal to [0-9])
+ Quantifier — ... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You can use a short list comprehension to extract the numbers from a given line. Since the ranges you listed seem to be inclusive on both ends, we need to add one to end interval (j) below.
```
for line in myfile:
i, j = [int(n) for n in line.split("-")]
for x in range(i, j + 1):
# do things
```
If y... | How about something like this?
Of course, it has no error checking, so you'd want to be mindful of the quality of your input data.
```
data = []
with open('file.txt','r') as myfile:
for line in myfile:
# Split the line and force conversion to int
start_int, end_int = map(int, line.split('-'))
... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You just need to extract the start and end index from each line and use it in `range` to create your list
```
data = []
with open('file.txt','r') as myfile:
for line in myfile:
start,end = [int(item) for item in line.split('-')]
li = list(range(start ,end+1))
data.append(li)
print(data)
`... | How about something like this?
Of course, it has no error checking, so you'd want to be mindful of the quality of your input data.
```
data = []
with open('file.txt','r') as myfile:
for line in myfile:
# Split the line and force conversion to int
start_int, end_int = map(int, line.split('-'))
... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | You're very close, you just need to append the list [`range()`](https://docs.python.org/3/library/functions.html#func-range):
```
data = []
with open("file.txt") as f:
for line in f:
start, end = map(int, line.split("-"))
data.append(list(range(start, end + 1)))
print(data)
# [[1, 2, 3, 4, 5, 6, 7... | I believe that you can match the pattern using [capturing groups](https://www.regular-expressions.info/brackets.html) using Regex and add it into your list.
Regex: <https://regex101.com/r/f1Ghff/1>
```
(\d+)\-(\d+)
```
Explanation:
```
1st Capturing Group (\d+)
\d+ matches a digit (equal to [0-9])
+ Quantifier — ... |
55,850,794 | I have a text file formatted like so
```
1-8
10-12
14-45
48-50
```
How do I go about getting the range of each line?
```
1, 2, 3, 4, 5, 6, 7, 8
10, 11, 12
```
I've tried splitting the file to get each number into a list. 1, 8, 10, 12, 14, 45, 48, 50, but I'm not sure how to translate that into the start and end n... | 2019/04/25 | [
"https://Stackoverflow.com/questions/55850794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410996/"
] | If you just want to print the ranges, you can use this:
```
with open('file.txt', 'r') as myfile:
for line in myfile:
nums = [int(i) for i in line.split('-')]
nums[1] += 1 # more on this in a second
my_range = range(*nums) # the * unpacks the two numbers into two arguments
print([... | I believe that you can match the pattern using [capturing groups](https://www.regular-expressions.info/brackets.html) using Regex and add it into your list.
Regex: <https://regex101.com/r/f1Ghff/1>
```
(\d+)\-(\d+)
```
Explanation:
```
1st Capturing Group (\d+)
\d+ matches a digit (equal to [0-9])
+ Quantifier — ... |
12,214,326 | I am new in python and I making a new code and I need a little help
Main file :
```
import os
import time
import sys
import app
import dbg
import dbg
import me
sys.path.append("lib")
class TraceFile:
def write(self, msg):
dbg.Trace(msg)
class TraceErrorFile:
def write(self, msg):
dbg.TraceE... | 2012/08/31 | [
"https://Stackoverflow.com/questions/12214326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638487/"
] | Why not doing this: define a method in the module you import and call this method 5 times in a loop with a certain `time.sleep(x)` in each iteration.
Edit:
Consider this is your module to import (e.g. `very_good_module.py`):
```
def interesting_action():
print "Wow, I did not expect this! This is a very good mod... | ```
#my_module.py (print hello once)
print "hello"
#main (print hello n times)
import time
import my_module # this will print hello
import my_module # this will not print hello
reload(my_module) # this will print hello
for i in xrange(n-2):
reload(my_module) #this will print hello n-2 times
time.sleep(seconds... |
118,667 | I'm working on an atmospheric/minimalist piece for Pierrot ensemble. I have the following figure in the piano part. I know that while the tempo is rather brisk (it's in 6/8 time, dotted quarter note = 80) it is not terribly difficult. But I'm wondering how many bars of this a professional-level pianist can maintain wit... | 2021/11/21 | [
"https://music.stackexchange.com/questions/118667",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/79947/"
] | At 80 dotted quarter notes per minute I run into two problems:
1. Fingers getting twisted up and
2. Losing count of the repetitions.
As a skilled amateur, after a few minutes of practice, I played 12 bars before getting tangled up. After a fingering adjustment, I played 20-or-so bars before losing count. I don't see ... | As a sideways answer, consider one of my favorite pieces: [the seventh movement of Ligeti's *Musica ricercata*](https://youtu.be/BmuK8Wtux6Q). (See a faster performance [here.](https://youtu.be/oXsRlMneOS0))
In this movement, the left hand has a rather rapid ostinato that lasts for over three minutes (!). It's a littl... |
118,667 | I'm working on an atmospheric/minimalist piece for Pierrot ensemble. I have the following figure in the piano part. I know that while the tempo is rather brisk (it's in 6/8 time, dotted quarter note = 80) it is not terribly difficult. But I'm wondering how many bars of this a professional-level pianist can maintain wit... | 2021/11/21 | [
"https://music.stackexchange.com/questions/118667",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/79947/"
] | As a sideways answer, consider one of my favorite pieces: [the seventh movement of Ligeti's *Musica ricercata*](https://youtu.be/BmuK8Wtux6Q). (See a faster performance [here.](https://youtu.be/oXsRlMneOS0))
In this movement, the left hand has a rather rapid ostinato that lasts for over three minutes (!). It's a littl... | You should be perfectly fine. Most professional pianists have probably played other really hard pieces with very fast trills / runs, for example Chopin & Liszt Etudes and Rachmaninoff's Etudes-Tableaux / Concertos ([Rachmaninoff Piano Concerto 3, 3rd movement](https://www.youtube.com/watch?v=wkci_fyEot8)) so they shoul... |
118,667 | I'm working on an atmospheric/minimalist piece for Pierrot ensemble. I have the following figure in the piano part. I know that while the tempo is rather brisk (it's in 6/8 time, dotted quarter note = 80) it is not terribly difficult. But I'm wondering how many bars of this a professional-level pianist can maintain wit... | 2021/11/21 | [
"https://music.stackexchange.com/questions/118667",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/79947/"
] | As a sideways answer, consider one of my favorite pieces: [the seventh movement of Ligeti's *Musica ricercata*](https://youtu.be/BmuK8Wtux6Q). (See a faster performance [here.](https://youtu.be/oXsRlMneOS0))
In this movement, the left hand has a rather rapid ostinato that lasts for over three minutes (!). It's a littl... | Like Aaron, I'm a skilled amateur, and had little difficulty picking up your passage. After experimenting with a couple of different fingerings, I could keep it up pretty much indefinitely at 80 with little to no fatigue. But hopefully, this is accompanying something a bit less repetitious, because otherwise, like Aaro... |
118,667 | I'm working on an atmospheric/minimalist piece for Pierrot ensemble. I have the following figure in the piano part. I know that while the tempo is rather brisk (it's in 6/8 time, dotted quarter note = 80) it is not terribly difficult. But I'm wondering how many bars of this a professional-level pianist can maintain wit... | 2021/11/21 | [
"https://music.stackexchange.com/questions/118667",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/79947/"
] | At 80 dotted quarter notes per minute I run into two problems:
1. Fingers getting twisted up and
2. Losing count of the repetitions.
As a skilled amateur, after a few minutes of practice, I played 12 bars before getting tangled up. After a fingering adjustment, I played 20-or-so bars before losing count. I don't see ... | You should be perfectly fine. Most professional pianists have probably played other really hard pieces with very fast trills / runs, for example Chopin & Liszt Etudes and Rachmaninoff's Etudes-Tableaux / Concertos ([Rachmaninoff Piano Concerto 3, 3rd movement](https://www.youtube.com/watch?v=wkci_fyEot8)) so they shoul... |
118,667 | I'm working on an atmospheric/minimalist piece for Pierrot ensemble. I have the following figure in the piano part. I know that while the tempo is rather brisk (it's in 6/8 time, dotted quarter note = 80) it is not terribly difficult. But I'm wondering how many bars of this a professional-level pianist can maintain wit... | 2021/11/21 | [
"https://music.stackexchange.com/questions/118667",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/79947/"
] | At 80 dotted quarter notes per minute I run into two problems:
1. Fingers getting twisted up and
2. Losing count of the repetitions.
As a skilled amateur, after a few minutes of practice, I played 12 bars before getting tangled up. After a fingering adjustment, I played 20-or-so bars before losing count. I don't see ... | Like Aaron, I'm a skilled amateur, and had little difficulty picking up your passage. After experimenting with a couple of different fingerings, I could keep it up pretty much indefinitely at 80 with little to no fatigue. But hopefully, this is accompanying something a bit less repetitious, because otherwise, like Aaro... |
26,454,049 | ### My Problem:
`document.getElementById("values").innerHTML` does not write anything. If I try to do `document.getElementById("values").innerHTML = "stuff";` (just with a String) - nothing happens.
What am I doing wrong here?
### HTML:
```
<form onsubmit="save_entry();return false;">
<label for="i_km">Kilometer:... | 2014/10/19 | [
"https://Stackoverflow.com/questions/26454049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3858659/"
] | This does work!
```
function show_entry(){
var content = '';
content = content + '<table><th>Kilometer</th><th>Getankt</th>';
for(var i = 0; i < localStorage.length/2; i++)
{
var temp_km = "k"+i;
var temp_f = "F"+i;
content = content + "<tr>";
content = content + "<td>"+localStorage.ge... | Each time you do
```
document.getElementById("values").innerHTML = "...";
```
you will replace the html inside the div with ID 'values'
So calling it multiple times with different values doesn't make sense.
You would either call it once and setting the whole innerHTML at once, like this
```
document.getElementById... |
26,454,049 | ### My Problem:
`document.getElementById("values").innerHTML` does not write anything. If I try to do `document.getElementById("values").innerHTML = "stuff";` (just with a String) - nothing happens.
What am I doing wrong here?
### HTML:
```
<form onsubmit="save_entry();return false;">
<label for="i_km">Kilometer:... | 2014/10/19 | [
"https://Stackoverflow.com/questions/26454049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3858659/"
] | This does work!
```
function show_entry(){
var content = '';
content = content + '<table><th>Kilometer</th><th>Getankt</th>';
for(var i = 0; i < localStorage.length/2; i++)
{
var temp_km = "k"+i;
var temp_f = "F"+i;
content = content + "<tr>";
content = content + "<td>"+localStorage.ge... | `innherHTML` is an attribute, so everytime you write `document.getElementById('id').innerHTML = '...'` you are actually changing the value of `innerHTML` to that thing, not concatenating it.
So writing `document.getElementById("values").innerHTML = "<table><th>Kilometers</th><th>Tanked</th>"'` changes the value of `in... |
5,692,046 | Let's say I want to use AJAX to retrieve a json file from an untrusted different domain.
I then parse the response as a javascript object without any script evaluation.
(A cookie is not sent with my request.)
I don't understand why the browser prevents me from doing this.
I understand that if I were to evaluate the r... | 2011/04/17 | [
"https://Stackoverflow.com/questions/5692046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286098/"
] | >
> ... you have no intention of evaluating the response as a script?
>
>
>
Firstly, browser security has no way of determining what you *intend to* do.
Second, the same source / origin restrictions are designed prevent other things as well: e.g. see
<http://blogs.msdn.com/b/ieinternals/archive/2009/08/28/explai... | Cross-domain AJAX is possible, but the remote server needs to support [CORS](http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing) and there may be certain header restrictions.
JSONP is not necessary for most applications. If the remote server does not support CORS, then you're stuck with the same-origin garbage... |
17,126 | From NPR: [One Prediction Of Sochi Doom That Hasn't Happened](http://www.npr.org/templates/transcript/transcript.php?storyId=271566098)
The passage describes a snowmaker company put in many snow-making-machines and man-made lakes to insure Sochi has enough snow at the course to hold the Winter Olympic games. The follo... | 2014/02/07 | [
"https://ell.stackexchange.com/questions/17126",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/3335/"
] | The phrase 'marginal conditions' here is used to describe **the weather** as in previous sentence, there is the note of 'Mother Nature'. And it is all about *maintaining* condition with enough snow for skiing.
As Jim commented, that's the weather condition right on the edge between acceptable and unacceptable.
I cou... | Marginal conditions are very strange conditions, not normal (gaussian, as most natural phenomena).
That could be much more frequent than normal or much less frequent.
For example snowing every day for a whole year would be marginal.
Marginal conditions are very unlikely to happen and can't be calculated accuratel... |
67,902,313 | Hi I have install fresh app vue3 typescript + vite , my problem after building the image and spin the container. I cannot access the localhost:3000, the browser will just display
>
> The connection was reset
>
>
>
```
docker run --rm -it -v %cd%/:/app/src -p 3000:3000 myvitets
```
Dockerfile
```
FROM node:14... | 2021/06/09 | [
"https://Stackoverflow.com/questions/67902313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/589973/"
] | I had the same problem and the below works for me.
In package.json, change the scripts
**From**
`"dev": "vite"`
**To**
`"dev": "vite --host 0.0.0.0"` | First: in the package.json add --host tag
```
"scripts": {
"dev": "vite --host",
"build": "vite build",
"preview": "vite preview --port 4173",
"test:unit": "vitest --environment jsdom"
},
```
Second: in the vite.config.js add the server port
```
// https://vitejs.dev/config/
export default defin... |
10,231,779 | A customer sent me a crash log from an iOS 5.0.1 (9A405) device. I'm running Xcode 4.2 on Snow Leopard. The system parts of the crash log call stack fail to symbolicate, and it seems that they're relevant to the crash; there are no iOS 5.0.1 symbols in Xcode. I don't have a 5.0.1 device, and I don't think I can install... | 2012/04/19 | [
"https://Stackoverflow.com/questions/10231779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219159/"
] | There are links to the 5.0.1 firmware are as follows:
* iPhone 4S [here](http://appldnld.apple.com/iPhone4/041-3305.20111109.Bghy6/iPhone4,1_5.0.1_9A405_Restore.ipsw)
* iPhone 4 (GSM) [here](http://appldnld.apple.com/iPhone4/041-3309.20111109.64rtg/iPhone3,1_5.0.1_9A405_Restore.ipsw)
* iPhone 4 (CDMA) [here](http://ap... | Sorry, but if you haven't saved your SHSH blobs you can't restore an older version of iOS..
I recommend you to save your blobs with TinyUmbrella from now, so this doesn't happen again. |
13,340,856 | I have some code like:
```
if '@' in line and line == l:
lineMatch = True
line = line.strip('\n')
line = line.split('@')[1]
line = line + '<br>\n'
labels.append(line)
```
I do not want to append a line to a label if it has `p4port` in it. Is there something like `unless` in Python, that would all... | 2012/11/12 | [
"https://Stackoverflow.com/questions/13340856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795998/"
] | What about 'not in'?:
```
if 'p4port' not in line:
labels.append(line)
```
Also i guess that you code can be modified then to:
```
if '@' in line and line == l and 'p4port' not in line:
lineMatch = True
labels.append(line.strip('\n').split('@')[1] + '<br>\n')
``` | There's no "unless" statement, but you can always write:
```
if not some_condition:
# do something
```
There's also the `not in` operator as Artsiom mentioned - so for your code, you'd write:
```
if '@' in line and line == l:
lineMatch = True
line = line.strip('\n')
line = line.split('@')[1]
lin... |
13,340,856 | I have some code like:
```
if '@' in line and line == l:
lineMatch = True
line = line.strip('\n')
line = line.split('@')[1]
line = line + '<br>\n'
labels.append(line)
```
I do not want to append a line to a label if it has `p4port` in it. Is there something like `unless` in Python, that would all... | 2012/11/12 | [
"https://Stackoverflow.com/questions/13340856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795998/"
] | What about 'not in'?:
```
if 'p4port' not in line:
labels.append(line)
```
Also i guess that you code can be modified then to:
```
if '@' in line and line == l and 'p4port' not in line:
lineMatch = True
labels.append(line.strip('\n').split('@')[1] + '<br>\n')
``` | The error you're getting in your (rather drastically) edited question is telling you that the variable `lineMatch` doesn't exist - which means the conditions you specified for setting it weren't met. It might help to add a line like `LineMatch = False` as the first line inside your outer `for` loop (before the first `i... |
13,340,856 | I have some code like:
```
if '@' in line and line == l:
lineMatch = True
line = line.strip('\n')
line = line.split('@')[1]
line = line + '<br>\n'
labels.append(line)
```
I do not want to append a line to a label if it has `p4port` in it. Is there something like `unless` in Python, that would all... | 2012/11/12 | [
"https://Stackoverflow.com/questions/13340856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795998/"
] | There's no "unless" statement, but you can always write:
```
if not some_condition:
# do something
```
There's also the `not in` operator as Artsiom mentioned - so for your code, you'd write:
```
if '@' in line and line == l:
lineMatch = True
line = line.strip('\n')
line = line.split('@')[1]
lin... | The error you're getting in your (rather drastically) edited question is telling you that the variable `lineMatch` doesn't exist - which means the conditions you specified for setting it weren't met. It might help to add a line like `LineMatch = False` as the first line inside your outer `for` loop (before the first `i... |
517,545 | ```
IF(B4-40<0,0,(B4-40))
```
Above is my formula to show only positive numbers above 40 in the given cell. If my hours are, let's say, 35, I do not want a value of -5; I want the cell value to be 0. Why is this not working? | 2012/12/10 | [
"https://superuser.com/questions/517545",
"https://superuser.com",
"https://superuser.com/users/179367/"
] | >
> Above is my formula to show only positive numbers above 40 in the
> given cell. If my hours are ...lets say 35, I do not want a value of
> -5, I want the cell value to be 0. Why is this not working?
>
>
>
I see no reason for that formula to work. Ensure the value stored in B4 is an integer and not a string. ... | It works for me, I get 0 for values less than 35 or 35, what version of excel you are using?
You can also check type of each of your cell that could cause potential issues. |
517,545 | ```
IF(B4-40<0,0,(B4-40))
```
Above is my formula to show only positive numbers above 40 in the given cell. If my hours are, let's say, 35, I do not want a value of -5; I want the cell value to be 0. Why is this not working? | 2012/12/10 | [
"https://superuser.com/questions/517545",
"https://superuser.com",
"https://superuser.com/users/179367/"
] | You are missing an `=` in front of the formula. Without it Excel will interpret it as text.
```
=IF((B4-40)<0,0,(B4-40))
``` | It works for me, I get 0 for values less than 35 or 35, what version of excel you are using?
You can also check type of each of your cell that could cause potential issues. |
517,545 | ```
IF(B4-40<0,0,(B4-40))
```
Above is my formula to show only positive numbers above 40 in the given cell. If my hours are, let's say, 35, I do not want a value of -5; I want the cell value to be 0. Why is this not working? | 2012/12/10 | [
"https://superuser.com/questions/517545",
"https://superuser.com",
"https://superuser.com/users/179367/"
] | Your original formula as you have shown it is missing the "=" (equals) sign at the beginning of the formula. Without the "=" sign, the formula will be shown as text.
I also don't see a reason why that formula isn't working for you, assuming you do have the "=" sign at the beginning of the formula. I would have writte... | It works for me, I get 0 for values less than 35 or 35, what version of excel you are using?
You can also check type of each of your cell that could cause potential issues. |
517,545 | ```
IF(B4-40<0,0,(B4-40))
```
Above is my formula to show only positive numbers above 40 in the given cell. If my hours are, let's say, 35, I do not want a value of -5; I want the cell value to be 0. Why is this not working? | 2012/12/10 | [
"https://superuser.com/questions/517545",
"https://superuser.com",
"https://superuser.com/users/179367/"
] | >
> Above is my formula to show only positive numbers above 40 in the
> given cell. If my hours are ...lets say 35, I do not want a value of
> -5, I want the cell value to be 0. Why is this not working?
>
>
>
I see no reason for that formula to work. Ensure the value stored in B4 is an integer and not a string. ... | Your original formula as you have shown it is missing the "=" (equals) sign at the beginning of the formula. Without the "=" sign, the formula will be shown as text.
I also don't see a reason why that formula isn't working for you, assuming you do have the "=" sign at the beginning of the formula. I would have writte... |
517,545 | ```
IF(B4-40<0,0,(B4-40))
```
Above is my formula to show only positive numbers above 40 in the given cell. If my hours are, let's say, 35, I do not want a value of -5; I want the cell value to be 0. Why is this not working? | 2012/12/10 | [
"https://superuser.com/questions/517545",
"https://superuser.com",
"https://superuser.com/users/179367/"
] | You are missing an `=` in front of the formula. Without it Excel will interpret it as text.
```
=IF((B4-40)<0,0,(B4-40))
``` | Your original formula as you have shown it is missing the "=" (equals) sign at the beginning of the formula. Without the "=" sign, the formula will be shown as text.
I also don't see a reason why that formula isn't working for you, assuming you do have the "=" sign at the beginning of the formula. I would have writte... |
68,140,475 | I'm trying to write a PHP UnitTest for my `AddHandler::class` in Mezzio (Zend Expressive) but I'm not sure I've done it right or wrong. Although the Test passes but I'm not really convinced that's the way to do it. The requirement is to basically mock the output of service `(new CrmApiService())->getUsers()` and `(new ... | 2021/06/26 | [
"https://Stackoverflow.com/questions/68140475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2845144/"
] | I found the solution, I made the return type of my custom validation function nullable, so that I can return null. Thank you guys.
```
static Widget buildUserInput(
{String? hint,
String? labelText,
TextAlign textAlign = TextAlign.start,
required Function(String? val) onSaved,
Function(St... | The question is not clear. So if you want to use Flutter Form(). You need a form key = GlobalKey(). And if you want to get a warning when having an invalid You cant return ''. It will have a red warning when your value invalid.
```
Form(
key: GlobalKey<FormState>()
child: TextFormField(
validato... |
68,140,475 | I'm trying to write a PHP UnitTest for my `AddHandler::class` in Mezzio (Zend Expressive) but I'm not sure I've done it right or wrong. Although the Test passes but I'm not really convinced that's the way to do it. The requirement is to basically mock the output of service `(new CrmApiService())->getUsers()` and `(new ... | 2021/06/26 | [
"https://Stackoverflow.com/questions/68140475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2845144/"
] | This is a question i struggled with so I hope I can help some people out.
After I migrated my project to null safety I was getting this error :
>
> Error: The argument type 'String Function(String)' can't be assigned
> to the parameter type 'String? Function(String?)?'
>
>
>
It means my function should return a n... | The question is not clear. So if you want to use Flutter Form(). You need a form key = GlobalKey(). And if you want to get a warning when having an invalid You cant return ''. It will have a red warning when your value invalid.
```
Form(
key: GlobalKey<FormState>()
child: TextFormField(
validato... |
68,140,475 | I'm trying to write a PHP UnitTest for my `AddHandler::class` in Mezzio (Zend Expressive) but I'm not sure I've done it right or wrong. Although the Test passes but I'm not really convinced that's the way to do it. The requirement is to basically mock the output of service `(new CrmApiService())->getUsers()` and `(new ... | 2021/06/26 | [
"https://Stackoverflow.com/questions/68140475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2845144/"
] | I found the solution, I made the return type of my custom validation function nullable, so that I can return null. Thank you guys.
```
static Widget buildUserInput(
{String? hint,
String? labelText,
TextAlign textAlign = TextAlign.start,
required Function(String? val) onSaved,
Function(St... | You can follow this example to solve your issue.
Suppose this is my TextFormField for Email Validation:-
```
TextFormField(
decoration: InputDecoration(
labelText: 'EMAIL',
labelStyle: TextStyle(
fontFamily: 'Trueno',
fontSize: 12.0,
... |
68,140,475 | I'm trying to write a PHP UnitTest for my `AddHandler::class` in Mezzio (Zend Expressive) but I'm not sure I've done it right or wrong. Although the Test passes but I'm not really convinced that's the way to do it. The requirement is to basically mock the output of service `(new CrmApiService())->getUsers()` and `(new ... | 2021/06/26 | [
"https://Stackoverflow.com/questions/68140475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2845144/"
] | This is a question i struggled with so I hope I can help some people out.
After I migrated my project to null safety I was getting this error :
>
> Error: The argument type 'String Function(String)' can't be assigned
> to the parameter type 'String? Function(String?)?'
>
>
>
It means my function should return a n... | You can follow this example to solve your issue.
Suppose this is my TextFormField for Email Validation:-
```
TextFormField(
decoration: InputDecoration(
labelText: 'EMAIL',
labelStyle: TextStyle(
fontFamily: 'Trueno',
fontSize: 12.0,
... |
68,140,475 | I'm trying to write a PHP UnitTest for my `AddHandler::class` in Mezzio (Zend Expressive) but I'm not sure I've done it right or wrong. Although the Test passes but I'm not really convinced that's the way to do it. The requirement is to basically mock the output of service `(new CrmApiService())->getUsers()` and `(new ... | 2021/06/26 | [
"https://Stackoverflow.com/questions/68140475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2845144/"
] | I found the solution, I made the return type of my custom validation function nullable, so that I can return null. Thank you guys.
```
static Widget buildUserInput(
{String? hint,
String? labelText,
TextAlign textAlign = TextAlign.start,
required Function(String? val) onSaved,
Function(St... | This is a question i struggled with so I hope I can help some people out.
After I migrated my project to null safety I was getting this error :
>
> Error: The argument type 'String Function(String)' can't be assigned
> to the parameter type 'String? Function(String?)?'
>
>
>
It means my function should return a n... |
4,839,586 | I have a class in java "Main.class", wrote and stored in %TEMP%. When executing the class through VB.Net Shell, eg:
```
Shell("cmd.exe /k java %TEMP%\Main.class")
```
Also when trying to execute manually through CMD: "java %TEMP%\Main.class", I am returned with:
```
Exception in thread "main" java.lang.NoClassDefFo... | 2011/01/29 | [
"https://Stackoverflow.com/questions/4839586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577478/"
] | You need to add -classpath to it. Basically the Java interpreter does not know where to find this "Main" class. | Try this,
```
Shell("java.exe -cp .;" & Environment.GetEnvironmentVariable("TEMP") & " Main")
```
OR
```
Dim args As String = String.Format("-cp .;{0} {1}", Environment.GetEnvironmentVariable("TEMP"), "Main")
Dim procInfo As New ProcessStartInfo
procInfo.FileName = "java.exe"
procInfo.Arguments = args
Di... |
4,839,586 | I have a class in java "Main.class", wrote and stored in %TEMP%. When executing the class through VB.Net Shell, eg:
```
Shell("cmd.exe /k java %TEMP%\Main.class")
```
Also when trying to execute manually through CMD: "java %TEMP%\Main.class", I am returned with:
```
Exception in thread "main" java.lang.NoClassDefFo... | 2011/01/29 | [
"https://Stackoverflow.com/questions/4839586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577478/"
] | [CoolBean's solution](https://stackoverflow.com/questions/4839586/execute-java-class-from-vb-net/4839610#4839610) *should* work. Something like
```
Shell("cmd.exe /k java -classpath %TEMP% Main")
```
Since you can (and are supposed to) omit the .class extension. And like CoolBeans said, you set the directory your cl... | Try this,
```
Shell("java.exe -cp .;" & Environment.GetEnvironmentVariable("TEMP") & " Main")
```
OR
```
Dim args As String = String.Format("-cp .;{0} {1}", Environment.GetEnvironmentVariable("TEMP"), "Main")
Dim procInfo As New ProcessStartInfo
procInfo.FileName = "java.exe"
procInfo.Arguments = args
Di... |
11,241,139 | I am using iCarousel as shownh [here](http://github.com/nicklockwood/iCarousel) with carousel type Liner Carousel and implemented delete functionalty .I am able to delete the image in carousel and when I attempt to delete any other iomage in the visible screen It is moved to carousel frame and deleted.
I need to del... | 2012/06/28 | [
"https://Stackoverflow.com/questions/11241139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1039505/"
] | You shouldn't delete the item at the carousel.currentItemIndex because that is not the item corresponding to the button you clicked, that's just the currently centred item in the carousel.
To get the correct item index for the button you clicked, do this:
```
-(void)deleteButtonClicked:(id)sender
{
//get the inde... | Try this:
```
NSInteger index = carousel.currentItemIndex;
[carousel removeItemAtIndex:index animated:YES];
[imagesArray removeObjectAtIndex:index];
```
add this also:
```
- (void)awakeFromNib
{
if (self) {
//set up carousel data
wrap = NO;
}
}
```
or make your
`carousel... |
22,703,300 | In my PhpStorm, the file `index.php`, doesn't look like a PHP script, but a plain text file. How can I fix it?
 | 2014/03/28 | [
"https://Stackoverflow.com/questions/22703300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2434934/"
] | **Follow this steps:**
Open PHPStorm settings by using `Ctrl+Alt+S`
1. In search box type **File types**
2. Select file types option from left side panel
3. Find `PHP Files (PHP)` from Recognized file types
4. Check for `.php` extension in below area (Registered Patterns). If not found add PHP.
 | 2014/03/28 | [
"https://Stackoverflow.com/questions/22703300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2434934/"
] | * **Settings | File Types | Text files**
* Find and remove **unwanted** pattern there -- I expect this to be `index.php` or very similar
Similar SO questions:
* [PHPStorm renders a particular file name as plain text](https://stackoverflow.com/questions/14614223/phpstorm-renders-a-particular-file-name-as-plain-text)
*... | Right click on index.php and select "Mark as PHP".
(This option is there on PHPStorm 7.x, I'm not sure about 6.) |
22,703,300 | In my PhpStorm, the file `index.php`, doesn't look like a PHP script, but a plain text file. How can I fix it?
 | 2014/03/28 | [
"https://Stackoverflow.com/questions/22703300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2434934/"
] | * **Settings | File Types | Text files**
* Find and remove **unwanted** pattern there -- I expect this to be `index.php` or very similar
Similar SO questions:
* [PHPStorm renders a particular file name as plain text](https://stackoverflow.com/questions/14614223/phpstorm-renders-a-particular-file-name-as-plain-text)
*... | **Follow this steps:**
Open PHPStorm settings by using `Ctrl+Alt+S`
1. In search box type **File types**
2. Select file types option from left side panel
3. Find `PHP Files (PHP)` from Recognized file types
4. Check for `.php` extension in below area (Registered Patterns). If not found add PHP.
![enter image descrip... |
56,744,461 | Inside an \*ngFor loop, I want an HTML element to randomly display itself...50/50 chance.
Here is what I thought would work:
```
<span *ngIf="Math.random() < 0.5">test</span>
```
But I get error:
```
BookingPageComponent.html:139 ERROR TypeError: Cannot read property 'random' of undefined
```
What am I doing wro... | 2019/06/24 | [
"https://Stackoverflow.com/questions/56744461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/495332/"
] | `Math` class is not available on evaluated expressions, but are available inside your component class.
So you can create a method:
```
public showRandomly(bias) {
return Math.rand() < bias;
}
```
Then use it in your ngIf:
```
<span *ngIf="showRandomly (0.5)">test</span>
```
Note that this random will run eve... | you can't run that in the template. You can call a function in your component that calls `Math.Random`
example:
`<span *ngIf="randomMath() < 0.5">test</span>`
in your component:
`randomMath() { return Math.random() }` |
56,744,461 | Inside an \*ngFor loop, I want an HTML element to randomly display itself...50/50 chance.
Here is what I thought would work:
```
<span *ngIf="Math.random() < 0.5">test</span>
```
But I get error:
```
BookingPageComponent.html:139 ERROR TypeError: Cannot read property 'random' of undefined
```
What am I doing wro... | 2019/06/24 | [
"https://Stackoverflow.com/questions/56744461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/495332/"
] | `Math` class is not available on evaluated expressions, but are available inside your component class.
So you can create a method:
```
public showRandomly(bias) {
return Math.rand() < bias;
}
```
Then use it in your ngIf:
```
<span *ngIf="showRandomly (0.5)">test</span>
```
Note that this random will run eve... | Math class is not available natively on expression but you can do like that in your TS file:
simply write
`Math: Math = Math;`
and you keep your template
```
<span *ngIf="Math.random() < 0.5">test</span>
```
But it's recommanded to add a new function like below:
```
<span *ngIf="isVisible()">test</span>
```
In... |
71,598,728 | I have a resources file containing a global variable which is dependent on another global variable.
```
${VAR1} ${EMPTY}
${VAR2} some_value/${VAR1}.json
```
In my testcase I set the value for `${VAR1}` using the `set global variable` keyword
```
set global variable ${VAR1} foo
log ${VAR1}
log ${VAR2}
```... | 2022/03/24 | [
"https://Stackoverflow.com/questions/71598728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1877988/"
] | You can iterate over a list of association names and call `has_one` with all the parameters on each item. `send(association)` is needed to call an association scope as a method.
```rb
ASSOCIATIONS = [:t1_for_self_order, :shipping_charges_for_t1, :t2_for_self_order, :shipping_charges_for_t2, :minimum_value_for_gifting,... | Try extracting the common attributes, something like
```
relationship_attributes = { as: :source, dependent: :destroy, inverse_of: :source, class_name: 'Spree::PriceMapping' }
has_one :t1_for_self_order, -> { t1_for_self_order }, relationship_attributes
has_one :shipping_charges_for_t1, -> { shipping_charges_for_t1 }... |
27,023,641 | I am creating an unordered list that contains images and text, and would like each item to be 1/3rd the width with a margin, evenly spaced. I can't figure out how to ensure, in a responsive website, the items are always exactly 1/3rd the width, including margins. Percentages seem to not remain consistent across browser... | 2014/11/19 | [
"https://Stackoverflow.com/questions/27023641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1851765/"
] | Here is a cross-browser solution. I have added an html5 structure if you need to include images in your list.
```css
/* the two following properties modify the box-model so that padding is removed from the width instead of being added */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inhe... | Try this: <http://jsfiddle.net/j13889cx/>
I've added a `div` element wrapping everything inside each `li` element called `.ul-wrap`.
This allows you to add any margin/padding you'd like because `.ul-wrap` is a block element.
Try changing `.ul-wrap`'s margin or padding. |
27,023,641 | I am creating an unordered list that contains images and text, and would like each item to be 1/3rd the width with a margin, evenly spaced. I can't figure out how to ensure, in a responsive website, the items are always exactly 1/3rd the width, including margins. Percentages seem to not remain consistent across browser... | 2014/11/19 | [
"https://Stackoverflow.com/questions/27023641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1851765/"
] | There's a couple of ways to tackle this, but the easiest CSS solution is to use inline-blocks for the `li` elements. Now the issue with inline-block is, they will take whitespace into account, breaking your layout, but there are two easy solutions for this in the markup:
1. HTML comments between the `li` elements;
2. ... | Here is a cross-browser solution. I have added an html5 structure if you need to include images in your list.
```css
/* the two following properties modify the box-model so that padding is removed from the width instead of being added */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inhe... |
27,023,641 | I am creating an unordered list that contains images and text, and would like each item to be 1/3rd the width with a margin, evenly spaced. I can't figure out how to ensure, in a responsive website, the items are always exactly 1/3rd the width, including margins. Percentages seem to not remain consistent across browser... | 2014/11/19 | [
"https://Stackoverflow.com/questions/27023641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1851765/"
] | There's a couple of ways to tackle this, but the easiest CSS solution is to use inline-blocks for the `li` elements. Now the issue with inline-block is, they will take whitespace into account, breaking your layout, but there are two easy solutions for this in the markup:
1. HTML comments between the `li` elements;
2. ... | Try this: <http://jsfiddle.net/j13889cx/>
I've added a `div` element wrapping everything inside each `li` element called `.ul-wrap`.
This allows you to add any margin/padding you'd like because `.ul-wrap` is a block element.
Try changing `.ul-wrap`'s margin or padding. |
26,555,757 | I'm a jQuery noob and I haven't been able to find what I want in the documentation, perhaps because I do not know what to search for. I need to get ALL values of a dropdown list.
I am currently doing:
```
<select id="cars" multiple="multiple" class="form-control">
<option value="volvo">Volvo</option>
<option valu... | 2014/10/24 | [
"https://Stackoverflow.com/questions/26555757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1472409/"
] | If you want to do something like get all the values and put them in an array, you could do:
```
$("#cars option").map(function(){ return this.value }).get()
``` | `$('#cars option')` would return all the `<option>` elements. |
26,555,757 | I'm a jQuery noob and I haven't been able to find what I want in the documentation, perhaps because I do not know what to search for. I need to get ALL values of a dropdown list.
I am currently doing:
```
<select id="cars" multiple="multiple" class="form-control">
<option value="volvo">Volvo</option>
<option valu... | 2014/10/24 | [
"https://Stackoverflow.com/questions/26555757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1472409/"
] | If you want to do something like get all the values and put them in an array, you could do:
```
$("#cars option").map(function(){ return this.value }).get()
``` | selector
```
$('#cars option')
```
will give you list of options. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.