qid
int64 1
74.7M
| question
stringlengths 15
58.3k
| date
stringlengths 10
10
| metadata
sequence | response_j
stringlengths 4
30.2k
| response_k
stringlengths 11
36.5k
|
---|---|---|---|---|---|
538,868 | I have a question to those who are really proficient in MHD generation. There exist some claims that degree of interaction between flowing molecules (gases) and ions on one hand and flowing molecules (gases) and electrons on other hand is vastly different. Therefore movement of ions in a gas flow will occur much faster than movement of free electrons. If this is correct then why we need to use a strong magnets to separate ions and electrons in MHD generator? If speed of the ions and electrons movement in the same gas flow is vastly different then doesn't charge separation suppose to occur by itself just due to a gas flow? Shouldn't majority of electrons concentrate at the beginning of the duct while many more ions at the end? Then only thing we need to generate current is to put an electrode at the beginning of the duct and another one at the end and let electrons flow from the inside of the duct through the external load to the end of the duct and recombine with ions there? And no need for a magnets. | 2020/03/27 | [
"https://physics.stackexchange.com/questions/538868",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/225219/"
] | In the absence of a magnetic field the velocity of the ions and electrons in a gas will be on average exactly that of the gas.
no net charge will be transferred.
The magnetic field is needed to make the charged particles move differently to the fluid and to separate based on their charge between the electrodes.
MHD works basically the same as a homopolar generator except that the rotor is replaced with a conductive fluid | Can MHD work on "cold plasma"? Is there any efficient and technically feasible ways to create a lot of cold plasma in water vapor for example (which is a one of main component of combustion exhaust)? What about electric discharges or some radiation (lasers, microwaves)? What about dissociating water vapor to ions rater than ionizing it? May it require smaller amount of energy? There are claims that 1% of water vapor are ions at 2500 C. Could electric discharges significantly increase number of positive and negative ions? |
3,665,283 | When looking at dI/dt we have a term gamma\*I, this is the rate in which infectious become recovered.
Why is this dependent on I, the number of infectious people?
Since if you have lots infectious people, wont it take the same amount of time for them to recover as a smaller group of people? So this rate should be a constant?
[](https://i.stack.imgur.com/G9Wsz.png) | 2020/05/08 | [
"https://math.stackexchange.com/questions/3665283",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/534839/"
] | If we have $I$ infected people and the recovery rate of the disease is $\gamma$, then in one time cycle, $\gamma I$ people recover from the infection. The time required for these people to recover is constant; it's just that due to more number of people being infected, more number of people will also recover from the disease in a given duration of time. | Imagine a situation where each infected individual recovered in one day. So when you have $10$ infected individuals you have $10$ recoveries in one day. But when you have $100$ infected, you have $100$ recoveries in one day. The number of recoveries per day
is proportional to the number of infected individuals. |
3,665,283 | When looking at dI/dt we have a term gamma\*I, this is the rate in which infectious become recovered.
Why is this dependent on I, the number of infectious people?
Since if you have lots infectious people, wont it take the same amount of time for them to recover as a smaller group of people? So this rate should be a constant?
[](https://i.stack.imgur.com/G9Wsz.png) | 2020/05/08 | [
"https://math.stackexchange.com/questions/3665283",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/534839/"
] | If we have $I$ infected people and the recovery rate of the disease is $\gamma$, then in one time cycle, $\gamma I$ people recover from the infection. The time required for these people to recover is constant; it's just that due to more number of people being infected, more number of people will also recover from the disease in a given duration of time. | The others have addressed the question, I just want to add to other answers. The term $1/\delta$ reflects the expected (or average) time an infected individual spend being infected. For example, for Covid-19, the expected time for a person to be infected is about 2-3 weeks. This is how you could estimate this rate, by setting 2-3 wks = $1/\delta$, then solve for $\delta$. This is all a consequence of exponential rates in differential equations (e.g. not realistic at all in the long term). |
3,665,283 | When looking at dI/dt we have a term gamma\*I, this is the rate in which infectious become recovered.
Why is this dependent on I, the number of infectious people?
Since if you have lots infectious people, wont it take the same amount of time for them to recover as a smaller group of people? So this rate should be a constant?
[](https://i.stack.imgur.com/G9Wsz.png) | 2020/05/08 | [
"https://math.stackexchange.com/questions/3665283",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/534839/"
] | Imagine a situation where each infected individual recovered in one day. So when you have $10$ infected individuals you have $10$ recoveries in one day. But when you have $100$ infected, you have $100$ recoveries in one day. The number of recoveries per day
is proportional to the number of infected individuals. | The others have addressed the question, I just want to add to other answers. The term $1/\delta$ reflects the expected (or average) time an infected individual spend being infected. For example, for Covid-19, the expected time for a person to be infected is about 2-3 weeks. This is how you could estimate this rate, by setting 2-3 wks = $1/\delta$, then solve for $\delta$. This is all a consequence of exponential rates in differential equations (e.g. not realistic at all in the long term). |
32,965,609 | I have a setup where I use a service to log a user in and autofill the CreatedBy, UpdatedBy, ... fields for my entities. Because of this my SaveChanges method looks like this:
```
public override int SaveChanges()
{
var modifiedEntries = ChangeTracker.Entries()
.Where(x => x.Entity is IAuditableEntity
&& (x.State == EntityState.Added || x.State == EntityState.Modified));
var activeUserId = ActiveUserService.UserId;
var username = Users.First(x => x.Id == activeUserId).UserName;
foreach (var entry in modifiedEntries)
{
IAuditableEntity entity = entry.Entity as IAuditableEntity;
if (String.IsNullOrEmpty(username))
{
throw new AuthenticationException(
"Trying to save entities of type IAuditable while not logged in. Use the IActiveUserService to set a logged in user");
}
if (entity != null)
{
DateTime now = DateTime.Now;
if (entry.State == EntityState.Added)
{
entity.CreatedBy = username;
entity.CreatedAt = now;
}
else
{
base.Entry(entity).Property(x => x.CreatedBy).IsModified = false;
base.Entry(entity).Property(x => x.CreatedAt).IsModified = false;
}
entity.UpdatedBy = username;
entity.UpdatedAt = now;
}
}
return base.SaveChanges();
}
```
The problem is when I'm seeding my database, Autofac isn't running and isn't injecting my services. Is it possible somewhere set a flag of some sort that when I'm seeding my database I use a default username or something? | 2015/10/06 | [
"https://Stackoverflow.com/questions/32965609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/980087/"
] | In your code, if there is no user logged in (so no `activeUserId`) it will break with an exception on `First()`:
```
var username = Users.First(x => x.Id == activeUserId).UserName;
```
And so the line:
```
if (String.IsNullOrEmpty(username))
```
will never be true.
I would take a nullable variable into the method: `SaveChanges(int? activeUserId = null)`, and when called by your Seed-method it will be null, and you can handle that to set the username into SYSTEM. But for all your other code you can supply the id of the user, and handle that.
Edit: to summary: the method itself should not check if the user is logged in, do that someplace else. | My current work-around is creating an other SaveChanges-method when seeding the database which sets a default user.
```
internal int SaveChangesWithDefaultUser()
{
var modifiedEntries = ChangeTracker.Entries()
.Where(x => x.Entity is IAuditableEntity
&& (x.State == EntityState.Added || x.State == EntityState.Modified));
var username = "SYSTEM";
foreach (var entry in modifiedEntries)
{
IAuditableEntity entity = entry.Entity as IAuditableEntity;
if (entity != null)
{
DateTime now = DateTime.Now;
if (entry.State == EntityState.Added)
{
entity.CreatedBy = username;
entity.CreatedAt = now;
}
else
{
base.Entry(entity).Property(x => x.CreatedBy).IsModified = false;
base.Entry(entity).Property(x => x.CreatedAt).IsModified = false;
}
entity.UpdatedBy = username;
entity.UpdatedAt = now;
}
}
return base.SaveChanges();
}
``` |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I have made it run for these dependencies:
```
def poiVersion='3.9'
compile 'org.apache.poi:poi:'+poiVersion
compile 'org.apache.poi:poi-ooxml:'+poiVersion
compile 'org.apache.poi:poi-ooxml-schemas:'+poiVersion
```
When I try for others it does not work:
3.10 : is not known to maven central
3.11 : fails, with exact the error in this case !!!
Conclusion POI 3.9 works !!!! | I use 3.7 but have you try adding
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.8</version>
</dependency>
``` |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I tried using `poi 3.10`, `3.11` and `3.12 beta` with Grails and get this error as well.
After downloading and including <http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/poi/ooxml-schemas/1.0/ooxml-schemas-1.0.jar> the error is gone. | I use 3.7 but have you try adding
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.8</version>
</dependency>
``` |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I used poi with version 3.12. The following dependency is also required:
`compile 'org.apache.poi:ooxml-schemas:1.1'`
see also <http://poi.apache.org/faq.html#faq-N10025> | I use 3.7 but have you try adding
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.8</version>
</dependency>
``` |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I used poi with version 3.12. The following dependency is also required:
`compile 'org.apache.poi:ooxml-schemas:1.1'`
see also <http://poi.apache.org/faq.html#faq-N10025> | I have made it run for these dependencies:
```
def poiVersion='3.9'
compile 'org.apache.poi:poi:'+poiVersion
compile 'org.apache.poi:poi-ooxml:'+poiVersion
compile 'org.apache.poi:poi-ooxml-schemas:'+poiVersion
```
When I try for others it does not work:
3.10 : is not known to maven central
3.11 : fails, with exact the error in this case !!!
Conclusion POI 3.9 works !!!! |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I have made it run for these dependencies:
```
def poiVersion='3.9'
compile 'org.apache.poi:poi:'+poiVersion
compile 'org.apache.poi:poi-ooxml:'+poiVersion
compile 'org.apache.poi:poi-ooxml-schemas:'+poiVersion
```
When I try for others it does not work:
3.10 : is not known to maven central
3.11 : fails, with exact the error in this case !!!
Conclusion POI 3.9 works !!!! | This is happening due to inconsistency is the poi jars.
You can download latest jars and it will start working.
you can add latest jar files for all below:
Commons-compress ,
ooxml-schemas ,
poi-scratchpad ,
poi-ooxml ,
poi ,
poi-ooxml-schemas ,
dom4j ,
poi-excelant |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I used poi with version 3.12. The following dependency is also required:
`compile 'org.apache.poi:ooxml-schemas:1.1'`
see also <http://poi.apache.org/faq.html#faq-N10025> | I tried using `poi 3.10`, `3.11` and `3.12 beta` with Grails and get this error as well.
After downloading and including <http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/poi/ooxml-schemas/1.0/ooxml-schemas-1.0.jar> the error is gone. |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I tried using `poi 3.10`, `3.11` and `3.12 beta` with Grails and get this error as well.
After downloading and including <http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/poi/ooxml-schemas/1.0/ooxml-schemas-1.0.jar> the error is gone. | This is happening due to inconsistency is the poi jars.
You can download latest jars and it will start working.
you can add latest jar files for all below:
Commons-compress ,
ooxml-schemas ,
poi-scratchpad ,
poi-ooxml ,
poi ,
poi-ooxml-schemas ,
dom4j ,
poi-excelant |
10,330,593 | I'm using apache POI for reading **xlsx** files by adding below dependencies
```
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.5.0</version>
</dependency>
```
I'm getting following exception while running with jetty plugin even if deployed in tomcat.
```
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
... 186 more
```
I removed the xmlbeans dependency as the maven will automatically download poi dependencies , still the same exception.Any help? | 2012/04/26 | [
"https://Stackoverflow.com/questions/10330593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/801631/"
] | I used poi with version 3.12. The following dependency is also required:
`compile 'org.apache.poi:ooxml-schemas:1.1'`
see also <http://poi.apache.org/faq.html#faq-N10025> | This is happening due to inconsistency is the poi jars.
You can download latest jars and it will start working.
you can add latest jar files for all below:
Commons-compress ,
ooxml-schemas ,
poi-scratchpad ,
poi-ooxml ,
poi ,
poi-ooxml-schemas ,
dom4j ,
poi-excelant |
50,400,559 | I am working project with ace-1.3-master template and try to instal button dropdown who I put in most the bottom on the page of HTML.
[](https://i.stack.imgur.com/1ruZt.jpg)
My problem is the button not display fully of it's content and user need to scrolling manually html page to see whole of the button content . how I can make it automaticly without scrolling.
The button position
[](https://i.stack.imgur.com/xG6Da.jpg) | 2018/05/17 | [
"https://Stackoverflow.com/questions/50400559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639849/"
] | result = client.query("SELECT P\_askbid\_midprice1 FROM DCIX\_OB WHERE time > '2018-01-01'")
this should work | you might be able to use [Pinform](https://github.com/sinarezaei/pinform) which is some kind of ORM/OSTM (Object time series mapping) for InfluxDB.
It can help with designing the schema and building normal or aggregation queries.
```
cli.get_fields_as_series(OHLC,
field_aggregations={'close': [AggregationMode.MEAN]},
tags={'symbol': 'AAPL'},
time_range=(start_datetime, end_datetime),
group_by_time_interval='10d')
```
Disclaimer: I am the author of this library |
52,745,013 | I'm trying to dynamically allocate a character array in c++ using smart pointers based on the user input like
```
std::cout<<"Input a word: ";
std::cin>>std::unique_ptr<char[]>ch_array(new char[]);
```
So when the user inputs the string it only consumes the necessary amount of bytes. Since it keeps giving me an error is there any other workaround to achieve such results ? | 2018/10/10 | [
"https://Stackoverflow.com/questions/52745013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9381647/"
] | Once an error is "caught," it won't propagate up. You'll need to throw something after you've caught the error once if you want it to go up any further. Something like:
```
try {
await function1();
await function2();
await function3().catch(err => {
function3ErrorHandler(err);
throw err;
});
} catch (err) {
generalErrorHandler(err);
}
``` | The catch block in your outer method will not catch the exception thrown from `function3`, if it is already catched within `fuction3`. |
52,745,013 | I'm trying to dynamically allocate a character array in c++ using smart pointers based on the user input like
```
std::cout<<"Input a word: ";
std::cin>>std::unique_ptr<char[]>ch_array(new char[]);
```
So when the user inputs the string it only consumes the necessary amount of bytes. Since it keeps giving me an error is there any other workaround to achieve such results ? | 2018/10/10 | [
"https://Stackoverflow.com/questions/52745013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9381647/"
] | Once an error is "caught," it won't propagate up. You'll need to throw something after you've caught the error once if you want it to go up any further. Something like:
```
try {
await function1();
await function2();
await function3().catch(err => {
function3ErrorHandler(err);
throw err;
});
} catch (err) {
generalErrorHandler(err);
}
``` | [](https://i.stack.imgur.com/8dr9E.png)
It will trigger first:
```
await function3().catch(err => { /*...*/ })
```
Before triggering:
```
} catch (err) { /*...*/ }
``` |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | This is called polymorphism and it's one of the most powerful aspects of Java.
Polymorphism allows you to treat different objects the same.
It's a great way to create re-usable, flexible code.
Unfortunately it's a part of Java that new programmers often take awhile to understand.
The example you've provided involves inheritance (extending a class).
Another way to enjoy the benefits of polymorphism is to use interfaces.
Different classes that implement the same interface can be treated the same:
```
class Dog extends Animal implements Talker {
public void speak() {
System.out.println("Woof woof");
}
}
class Programmer implements Talker {
public void speak() {
System.out.println("Polymorphism rocks!");
}
}
interface Talker {
public void speak();
}
public static void testIt() {
List<Talker> talkerList = new ArrayList<Talker>();
talkerList.add(new Dog());
talkerList.add(new Programmer());
for (Talker t : talkerList) {
t.speak();
}
}
``` | Simply putting all `Cows` are `Animals`. So JAVA understands that when `Cow extends Animal`, a Cow can also be called as Animal.
This is Polymorphism as others have pointed out. You can extend `Animal` with `Dog` and say that Dog is also an Animal. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | This is basically a concept of standardization.
We know that each animal have some common features. Let us take an example of eating and sleeping, but each animal can have different way of eating or sleeping ... then we can define
```
public abstract class Animal
{
public abstract void Eat();
public abstract void Sleep();
}
//Now Define them in various classes..
public class Cow extends Animal
{
pubic void Eat()
{
//process of eating grass
}
public void Sleep()
{
//process of sleeping
}
}
public class Lion extends Animal
{
public void Eat()
{
//process of eating flesh
}
public void Sleep()
{
//process of sleep
}
}
```
Now you do not have to define different objects to different classes... just use Animal and call generally
```
public class MyClass
{
public static void main(String[] args)
{
Animal _animal = new //think the type of animal is coming dynamically
//you can simply call
_animal.Eat();
_animal.Sleep();
// irrespective of checking that what can be the animal type, it also reduces many if else
}
}
``` | Simply putting all `Cows` are `Animals`. So JAVA understands that when `Cow extends Animal`, a Cow can also be called as Animal.
This is Polymorphism as others have pointed out. You can extend `Animal` with `Dog` and say that Dog is also an Animal. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | This is basically a concept of standardization.
We know that each animal have some common features. Let us take an example of eating and sleeping, but each animal can have different way of eating or sleeping ... then we can define
```
public abstract class Animal
{
public abstract void Eat();
public abstract void Sleep();
}
//Now Define them in various classes..
public class Cow extends Animal
{
pubic void Eat()
{
//process of eating grass
}
public void Sleep()
{
//process of sleeping
}
}
public class Lion extends Animal
{
public void Eat()
{
//process of eating flesh
}
public void Sleep()
{
//process of sleep
}
}
```
Now you do not have to define different objects to different classes... just use Animal and call generally
```
public class MyClass
{
public static void main(String[] args)
{
Animal _animal = new //think the type of animal is coming dynamically
//you can simply call
_animal.Eat();
_animal.Sleep();
// irrespective of checking that what can be the animal type, it also reduces many if else
}
}
``` | This is an inheritance 101 question.
It allows objects that share common functionality to be treated alike.
It also allows specific implementations to be supplied at runtime that are subclasses of an abstract type.
I could probably ramble on for ages. Perhaps thus question is just too broad to answer here. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | This is at the heart of polymorphism and abstraction. For example, it means that I can write:
```
public void handleData(InputStream input) {
...
}
```
... and handle *any* kind of input stream, whether that's from a file, network, in-memory etc. Or likewise, if you've got a `List<String>`, you can ask for element 0 of it regardless of the implementation, etc.
The ability to treat an instance of a subclass as an instance of a superclass is called [Liskov's Substitution Principle](http://en.wikipedia.org/wiki/Liskov_substitution_principle). It allows for loose coupling and code reuse.
Also read the [Polymorphism part of the Java tutorial](http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html) for more information. | In another class/method you might want to use different implementations of the same interface. Following your example, you might have something like:
```
public void feed( Animal animal ) {
animal.getHome().insertFood(animal.getFavFood());
}
```
Now you can implement the details in your animal classes and don't have to extend this method anytime you add a new animal to your programm.
So in some cases you need the common interface in order not to implement a method for each implementation, whereas on other occasions, you will need to use the explicit implementation. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | On a simpler note, this enables polymorphism. For example you can have several objects that derive from Animal and all are handle similar.
You could have something like:
```
Animal[] myAnimal = {new Cow(), new Dog(), new Cat()};
foreach (Animal animal in myAnimal)
animal.Feed();
```
The Feed() method must then be overriden within each child class.
By the way, code is C#-like but concept is the same in Java. | Simply putting all `Cows` are `Animals`. So JAVA understands that when `Cow extends Animal`, a Cow can also be called as Animal.
This is Polymorphism as others have pointed out. You can extend `Animal` with `Dog` and say that Dog is also an Animal. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | On a simpler note, this enables polymorphism. For example you can have several objects that derive from Animal and all are handle similar.
You could have something like:
```
Animal[] myAnimal = {new Cow(), new Dog(), new Cat()};
foreach (Animal animal in myAnimal)
animal.Feed();
```
The Feed() method must then be overriden within each child class.
By the way, code is C#-like but concept is the same in Java. | In another class/method you might want to use different implementations of the same interface. Following your example, you might have something like:
```
public void feed( Animal animal ) {
animal.getHome().insertFood(animal.getFavFood());
}
```
Now you can implement the details in your animal classes and don't have to extend this method anytime you add a new animal to your programm.
So in some cases you need the common interface in order not to implement a method for each implementation, whereas on other occasions, you will need to use the explicit implementation. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | On a simpler note, this enables polymorphism. For example you can have several objects that derive from Animal and all are handle similar.
You could have something like:
```
Animal[] myAnimal = {new Cow(), new Dog(), new Cat()};
foreach (Animal animal in myAnimal)
animal.Feed();
```
The Feed() method must then be overriden within each child class.
By the way, code is C#-like but concept is the same in Java. | This is an inheritance 101 question.
It allows objects that share common functionality to be treated alike.
It also allows specific implementations to be supplied at runtime that are subclasses of an abstract type.
I could probably ramble on for ages. Perhaps thus question is just too broad to answer here. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | This is at the heart of polymorphism and abstraction. For example, it means that I can write:
```
public void handleData(InputStream input) {
...
}
```
... and handle *any* kind of input stream, whether that's from a file, network, in-memory etc. Or likewise, if you've got a `List<String>`, you can ask for element 0 of it regardless of the implementation, etc.
The ability to treat an instance of a subclass as an instance of a superclass is called [Liskov's Substitution Principle](http://en.wikipedia.org/wiki/Liskov_substitution_principle). It allows for loose coupling and code reuse.
Also read the [Polymorphism part of the Java tutorial](http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html) for more information. | On a simpler note, this enables polymorphism. For example you can have several objects that derive from Animal and all are handle similar.
You could have something like:
```
Animal[] myAnimal = {new Cow(), new Dog(), new Cat()};
foreach (Animal animal in myAnimal)
animal.Feed();
```
The Feed() method must then be overriden within each child class.
By the way, code is C#-like but concept is the same in Java. |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | This is at the heart of polymorphism and abstraction. For example, it means that I can write:
```
public void handleData(InputStream input) {
...
}
```
... and handle *any* kind of input stream, whether that's from a file, network, in-memory etc. Or likewise, if you've got a `List<String>`, you can ask for element 0 of it regardless of the implementation, etc.
The ability to treat an instance of a subclass as an instance of a superclass is called [Liskov's Substitution Principle](http://en.wikipedia.org/wiki/Liskov_substitution_principle). It allows for loose coupling and code reuse.
Also read the [Polymorphism part of the Java tutorial](http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html) for more information. | This is basically a concept of standardization.
We know that each animal have some common features. Let us take an example of eating and sleeping, but each animal can have different way of eating or sleeping ... then we can define
```
public abstract class Animal
{
public abstract void Eat();
public abstract void Sleep();
}
//Now Define them in various classes..
public class Cow extends Animal
{
pubic void Eat()
{
//process of eating grass
}
public void Sleep()
{
//process of sleeping
}
}
public class Lion extends Animal
{
public void Eat()
{
//process of eating flesh
}
public void Sleep()
{
//process of sleep
}
}
```
Now you do not have to define different objects to different classes... just use Animal and call generally
```
public class MyClass
{
public static void main(String[] args)
{
Animal _animal = new //think the type of animal is coming dynamically
//you can simply call
_animal.Eat();
_animal.Sleep();
// irrespective of checking that what can be the animal type, it also reduces many if else
}
}
``` |
13,640,833 | I wonder why it is allowed to have different type of object reference?
For example;
```
Animal cow = new Cow();
```
Can you please give an example where it is useful to use different type of object reference?
**Edit:**`Cow extends Animal` | 2012/11/30 | [
"https://Stackoverflow.com/questions/13640833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002790/"
] | This is at the heart of polymorphism and abstraction. For example, it means that I can write:
```
public void handleData(InputStream input) {
...
}
```
... and handle *any* kind of input stream, whether that's from a file, network, in-memory etc. Or likewise, if you've got a `List<String>`, you can ask for element 0 of it regardless of the implementation, etc.
The ability to treat an instance of a subclass as an instance of a superclass is called [Liskov's Substitution Principle](http://en.wikipedia.org/wiki/Liskov_substitution_principle). It allows for loose coupling and code reuse.
Also read the [Polymorphism part of the Java tutorial](http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html) for more information. | This is an inheritance 101 question.
It allows objects that share common functionality to be treated alike.
It also allows specific implementations to be supplied at runtime that are subclasses of an abstract type.
I could probably ramble on for ages. Perhaps thus question is just too broad to answer here. |
14,212,032 | >
> **Possible Duplicate:**
>
> [I would like to control Form1 from Form2](https://stackoverflow.com/questions/3146576/i-would-like-to-control-form1-from-form2)
>
>
>
I'm a newbie to `C#` and I can't find the answer I'm looking for in google, so I'm hoping someone here could help me. I'm only practicing to transfer data *(or pass, call it however you want)* from a form to another.
Here's what I have:
I have 2 forms - `Form1` and `Form2`.
`Form1` contains a textbox (named `txtForm1`) and a button (named `btnForm1`).
`Form2` contains a textbox (named `txtForm2`) and a button (named `btnForm2`).
After running the application, by clicking the button `btnForm1`, the user opens `Form2`. The text that the user writes in the textbox (`txtForm2`) should be transfered to the textbox (`txtForm1`, which button is disabled) in `Form1`.
How can I do this transfer?
Edited:
Okay i need to be clear that this is all the code i have:
**Form1** (button which opens **Form2**):
```
private void btnForm1_Click(object sender, EventArgs e)
{
new Form2().Show();
}
```
**Form2** (button which closes **Form2**):
```
private void btnForm2_Click(object sender, EventArgs e)
{
this.Close();
}
```
I have NOTHING ELSE. (I'm a total newbie) | 2013/01/08 | [
"https://Stackoverflow.com/questions/14212032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1957558/"
] | Make a public variable and pass it the value from your text box and then onto your second form.
```
public static string myVar;
myVar = txtForm2.Text;
```
and when you return to the first form:
`txtForm1.Text = Form2.myVar;` | Try this ;)
On Form1:
```
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2(textBox1.Text);
frm2.Show();
this.Hide();
}
```
On form2:
```
public partial class Form2 : Form
{
public string textBoxValue;
public Form2()
{
InitializeComponent();
}
public Form2(string textBoxValue)
{
InitializeComponent();
this.textBoxValue = textBoxValue;
}
private void Form2_Load(object sender, EventArgs e)
{
textBox2.Text = textBoxValue;
}
``` |
14,212,032 | >
> **Possible Duplicate:**
>
> [I would like to control Form1 from Form2](https://stackoverflow.com/questions/3146576/i-would-like-to-control-form1-from-form2)
>
>
>
I'm a newbie to `C#` and I can't find the answer I'm looking for in google, so I'm hoping someone here could help me. I'm only practicing to transfer data *(or pass, call it however you want)* from a form to another.
Here's what I have:
I have 2 forms - `Form1` and `Form2`.
`Form1` contains a textbox (named `txtForm1`) and a button (named `btnForm1`).
`Form2` contains a textbox (named `txtForm2`) and a button (named `btnForm2`).
After running the application, by clicking the button `btnForm1`, the user opens `Form2`. The text that the user writes in the textbox (`txtForm2`) should be transfered to the textbox (`txtForm1`, which button is disabled) in `Form1`.
How can I do this transfer?
Edited:
Okay i need to be clear that this is all the code i have:
**Form1** (button which opens **Form2**):
```
private void btnForm1_Click(object sender, EventArgs e)
{
new Form2().Show();
}
```
**Form2** (button which closes **Form2**):
```
private void btnForm2_Click(object sender, EventArgs e)
{
this.Close();
}
```
I have NOTHING ELSE. (I'm a total newbie) | 2013/01/08 | [
"https://Stackoverflow.com/questions/14212032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1957558/"
] | In your Form2 you should have some like:
```
private void btnForm2_Click(object sender, EventArgs e)
{
this.Hide();
}
public String GettxtForm2()
{
return txtForm2.Text;
}
```
Now in form1 you can acces that txtForm2 with something like:
```
Form2 form2 = new Form2();
//on click btnForm1 show that form2 where you can edit the txtForm2
private void btnForm1_Click(object sender, EventArgs e)
{
form2.Show();
}
//after you save the txtForm2 when you will focus back to form1 the txtForm1 will get the value from txtForm2
private void Form1_Enter(object sender, EventArgs e)
{
txtForm1.Text = Form2.GettxtForm2();
}
```
You can easy modify the events where all this logic can occur... | Try this ;)
On Form1:
```
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2(textBox1.Text);
frm2.Show();
this.Hide();
}
```
On form2:
```
public partial class Form2 : Form
{
public string textBoxValue;
public Form2()
{
InitializeComponent();
}
public Form2(string textBoxValue)
{
InitializeComponent();
this.textBoxValue = textBoxValue;
}
private void Form2_Load(object sender, EventArgs e)
{
textBox2.Text = textBoxValue;
}
``` |
14,212,032 | >
> **Possible Duplicate:**
>
> [I would like to control Form1 from Form2](https://stackoverflow.com/questions/3146576/i-would-like-to-control-form1-from-form2)
>
>
>
I'm a newbie to `C#` and I can't find the answer I'm looking for in google, so I'm hoping someone here could help me. I'm only practicing to transfer data *(or pass, call it however you want)* from a form to another.
Here's what I have:
I have 2 forms - `Form1` and `Form2`.
`Form1` contains a textbox (named `txtForm1`) and a button (named `btnForm1`).
`Form2` contains a textbox (named `txtForm2`) and a button (named `btnForm2`).
After running the application, by clicking the button `btnForm1`, the user opens `Form2`. The text that the user writes in the textbox (`txtForm2`) should be transfered to the textbox (`txtForm1`, which button is disabled) in `Form1`.
How can I do this transfer?
Edited:
Okay i need to be clear that this is all the code i have:
**Form1** (button which opens **Form2**):
```
private void btnForm1_Click(object sender, EventArgs e)
{
new Form2().Show();
}
```
**Form2** (button which closes **Form2**):
```
private void btnForm2_Click(object sender, EventArgs e)
{
this.Close();
}
```
I have NOTHING ELSE. (I'm a total newbie) | 2013/01/08 | [
"https://Stackoverflow.com/questions/14212032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1957558/"
] | in `Form1`:
```
public void SetTextboxText(String text)
{
txtForm1.Text = text;
}
private void btnForm1_Click(object sender, EventArgs e)
{
var frm = new Form2(this); // pass parent form (this) in constructor
frm.Show();
}
```
in `Form2`:
```
Form _parentForm;
public Form2(Form form)
{
_parentForm = form;
}
private void txtForm2_TextChanged(object sender, EventArgs e)
{
_parentForm.SetTextboxText(txtForm2.Text); // change Form1.txtForm1.Text
}
``` | Try this ;)
On Form1:
```
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2(textBox1.Text);
frm2.Show();
this.Hide();
}
```
On form2:
```
public partial class Form2 : Form
{
public string textBoxValue;
public Form2()
{
InitializeComponent();
}
public Form2(string textBoxValue)
{
InitializeComponent();
this.textBoxValue = textBoxValue;
}
private void Form2_Load(object sender, EventArgs e)
{
textBox2.Text = textBoxValue;
}
``` |
3,913,250 | I have a special situation where I need to query a service to get information for n users at a specific time each day. The problem is that if I do this all at once it will put the service offline / crash it.
So to overcome this it would be better to run this for x number of users every 10 seconds or so until x = n and then stop.
I could setup 1 cron script that runs daily and another that runs every 10 seconds. The daily script would set a value in the DB to 1 ('start query') for example (default would be 0 for off), where then the second script (run every 10 seconds) checks this database value for 1. Upon finding the setting set to true it then iterates through the users querying the service x users at a time and incrementing another column in the same DB table to keep track of where in the list it is at.
The problem with this solution (well according to me) is that the 2nd script that runs every 10secs has to query the DB each time to find out if the 'start query' setting is set to 1. This can be quite processor heavy. Does anyone have a better solution?
**NB: Code is written in PHP - cannot use sleep due to max execution time of php scripts on server**
I could equally do this in python, is there a max execution for limit on cgi scripts? | 2010/10/12 | [
"https://Stackoverflow.com/questions/3913250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338547/"
] | Why not just have one cron script that runs daily, and just calls the other script every ten seconds until the other script says it's done (e.g. returns a value that says "nothing more to process")?
Or one script that runs daily and just runs through the chunks of users in a loop, sleep()ing every X users...
Bear in mind that when using the [CLI version of PHP](http://www.php.net/manual/en/features.commandline.introduction.php) you're not constrained by execution time limits, and you can interact with cron, and other shell scripts quite nicely, using standard error and output streams, etc.
For example, for the first approach, you don't even have to use PHP for the "controlling" script -- a very simple shell script that just loops, calling your PHP script and then sleeping, and checking for a "success" return value (as returned by the PHP script's [exit](http://php.net/manual/en/function.exit.php)() function) would be fine. | You could use 'at' in combination with 'cron'. Set up a cron job that runs a single task once a day, and that task is (I don't have a UNIX box in front of me at the moment, so there may be the odd syntax error).
```
0 9 * * * at now + 10 secs /path/to/shellscript 1
```
The argument being the run count. When the shellscript runs, it reschedules itself to run, incrementing the run count, so you could have:
```
#!/bin/ksh
integer i
let i=1+$1
if [[ $i -lt 11 ]]
then
at now + 10 secs /path/to/shellscript $i
# do everything else the script needs to do
fi
```
**NOTE:** This solution also assumes 'at' can go down to per-second times (not sure if that's possible or not; may depend on the implementation). If it doesn't this solution's probably null and void from the off :-) In which case you're better off having one script that does stuff and sleeps (as per Matt Gibson's answer). |
3,913,250 | I have a special situation where I need to query a service to get information for n users at a specific time each day. The problem is that if I do this all at once it will put the service offline / crash it.
So to overcome this it would be better to run this for x number of users every 10 seconds or so until x = n and then stop.
I could setup 1 cron script that runs daily and another that runs every 10 seconds. The daily script would set a value in the DB to 1 ('start query') for example (default would be 0 for off), where then the second script (run every 10 seconds) checks this database value for 1. Upon finding the setting set to true it then iterates through the users querying the service x users at a time and incrementing another column in the same DB table to keep track of where in the list it is at.
The problem with this solution (well according to me) is that the 2nd script that runs every 10secs has to query the DB each time to find out if the 'start query' setting is set to 1. This can be quite processor heavy. Does anyone have a better solution?
**NB: Code is written in PHP - cannot use sleep due to max execution time of php scripts on server**
I could equally do this in python, is there a max execution for limit on cgi scripts? | 2010/10/12 | [
"https://Stackoverflow.com/questions/3913250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338547/"
] | Why not just have one cron script that runs daily, and just calls the other script every ten seconds until the other script says it's done (e.g. returns a value that says "nothing more to process")?
Or one script that runs daily and just runs through the chunks of users in a loop, sleep()ing every X users...
Bear in mind that when using the [CLI version of PHP](http://www.php.net/manual/en/features.commandline.introduction.php) you're not constrained by execution time limits, and you can interact with cron, and other shell scripts quite nicely, using standard error and output streams, etc.
For example, for the first approach, you don't even have to use PHP for the "controlling" script -- a very simple shell script that just loops, calling your PHP script and then sleeping, and checking for a "success" return value (as returned by the PHP script's [exit](http://php.net/manual/en/function.exit.php)() function) would be fine. | multiple ways to do this:
* Have a script that runs part of the job, putting all data in a variable that you serialize the data and the state. I have implemented a scheduler controller for code igniter to fetch metro routes one at the time <http://www.younelan.com/index.php?&repository=DCExplorer> . It may be more complex than what you are looking but may give you an idea on how to have multiple tasks run at various intervals, breaking them up into smaller parts
* run the script from the command line either through cron or manually - no suffering of timeouts |
3,913,250 | I have a special situation where I need to query a service to get information for n users at a specific time each day. The problem is that if I do this all at once it will put the service offline / crash it.
So to overcome this it would be better to run this for x number of users every 10 seconds or so until x = n and then stop.
I could setup 1 cron script that runs daily and another that runs every 10 seconds. The daily script would set a value in the DB to 1 ('start query') for example (default would be 0 for off), where then the second script (run every 10 seconds) checks this database value for 1. Upon finding the setting set to true it then iterates through the users querying the service x users at a time and incrementing another column in the same DB table to keep track of where in the list it is at.
The problem with this solution (well according to me) is that the 2nd script that runs every 10secs has to query the DB each time to find out if the 'start query' setting is set to 1. This can be quite processor heavy. Does anyone have a better solution?
**NB: Code is written in PHP - cannot use sleep due to max execution time of php scripts on server**
I could equally do this in python, is there a max execution for limit on cgi scripts? | 2010/10/12 | [
"https://Stackoverflow.com/questions/3913250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338547/"
] | You could use 'at' in combination with 'cron'. Set up a cron job that runs a single task once a day, and that task is (I don't have a UNIX box in front of me at the moment, so there may be the odd syntax error).
```
0 9 * * * at now + 10 secs /path/to/shellscript 1
```
The argument being the run count. When the shellscript runs, it reschedules itself to run, incrementing the run count, so you could have:
```
#!/bin/ksh
integer i
let i=1+$1
if [[ $i -lt 11 ]]
then
at now + 10 secs /path/to/shellscript $i
# do everything else the script needs to do
fi
```
**NOTE:** This solution also assumes 'at' can go down to per-second times (not sure if that's possible or not; may depend on the implementation). If it doesn't this solution's probably null and void from the off :-) In which case you're better off having one script that does stuff and sleeps (as per Matt Gibson's answer). | multiple ways to do this:
* Have a script that runs part of the job, putting all data in a variable that you serialize the data and the state. I have implemented a scheduler controller for code igniter to fetch metro routes one at the time <http://www.younelan.com/index.php?&repository=DCExplorer> . It may be more complex than what you are looking but may give you an idea on how to have multiple tasks run at various intervals, breaking them up into smaller parts
* run the script from the command line either through cron or manually - no suffering of timeouts |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | **Explanation**
In a C function, all of your local variable declarations happen straight away. Essentially, the compiler translates your code into:
```
int a;
int b;
// start of function
a = 9;
b = a + b;
// end of function
```
So you can see, that there is always a variable `b`, it exists for the whole runtime of the function.
In Python, this doesn't happen. `b` does not exist until it is assigned to for the first time.
The Python interpreter runs the code `a+b` before it runs `b = <the result of a+b>`. If you think about what it's doing with that intermediate result you get something equivalent to:
```
a = 9;
intermediate_value = a + b
b = intermediate_value
```
It is now clear that you are using `b` before it is defined.
**Philosophy**
This comes down to the difference between a static language like C, and a dynamic language like Python. In a dynamic language, a lot of things that are done compile time in a static language are done at runtime instead. Such things can even include modifying the code of the running program itself. (In theory, with unfettered access to the computer's memory, you could do this in C too; but on all modern operating systems, this is impossible).
Have a read of this page <http://en.wikipedia.org/wiki/Dynamic_programming_language> for more information. | The philosophy is that people who program in C know what they are doing, and you can get a lot of efficiency gain out of allowing undefined behavior, in this case with an uninitialized variable.
[This article](http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html) specifically mentions the example of uninitialized variables and why it allows performance gains.
### Use of an uninitialized variable:
>
> This is commonly known as source of problems in C programs and there
> are many tools to catch these: from compiler warnings to static and
> dynamic analyzers. This improves performance by not requiring that all
> variables be zero initialized when they come into scope (as Java
> does). For most scalar variables, this would cause little overhead,
> but stack arrays and malloc'd memory would incur a memset of the
> storage, which could be quite costly, particularly since the storage
> is usually completely overwritten.
>
>
> |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | The philosophy is that people who program in C know what they are doing, and you can get a lot of efficiency gain out of allowing undefined behavior, in this case with an uninitialized variable.
[This article](http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html) specifically mentions the example of uninitialized variables and why it allows performance gains.
### Use of an uninitialized variable:
>
> This is commonly known as source of problems in C programs and there
> are many tools to catch these: from compiler warnings to static and
> dynamic analyzers. This improves performance by not requiring that all
> variables be zero initialized when they come into scope (as Java
> does). For most scalar variables, this would cause little overhead,
> but stack arrays and malloc'd memory would incur a memset of the
> storage, which could be quite costly, particularly since the storage
> is usually completely overwritten.
>
>
> | Appendix J (which is non-normative) suggests that the behavior is *undefined*:
>
> The value of an object with automatic storage duration is used while it is
> indeterminate (6.2.4, 6.7.9, 6.8).
>
although I can't find explicit language in any of the referenced sections to support that (then again, my blood caffeine content is a bit low this morning, so I may be missing it).
If the behavior *is* undefined, then the compiler isn't required to issue a diagnostic. |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | **Explanation**
In a C function, all of your local variable declarations happen straight away. Essentially, the compiler translates your code into:
```
int a;
int b;
// start of function
a = 9;
b = a + b;
// end of function
```
So you can see, that there is always a variable `b`, it exists for the whole runtime of the function.
In Python, this doesn't happen. `b` does not exist until it is assigned to for the first time.
The Python interpreter runs the code `a+b` before it runs `b = <the result of a+b>`. If you think about what it's doing with that intermediate result you get something equivalent to:
```
a = 9;
intermediate_value = a + b
b = intermediate_value
```
It is now clear that you are using `b` before it is defined.
**Philosophy**
This comes down to the difference between a static language like C, and a dynamic language like Python. In a dynamic language, a lot of things that are done compile time in a static language are done at runtime instead. Such things can even include modifying the code of the running program itself. (In theory, with unfettered access to the computer's memory, you could do this in C too; but on all modern operating systems, this is impossible).
Have a read of this page <http://en.wikipedia.org/wiki/Dynamic_programming_language> for more information. | In effect, you will get 4 bytes of memory (assuming an `int` is 4 bytes) that keep whatever was there in the first place, then have that value added to the value of `b` . You can read more about C's undefined behavior here : <http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html> |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | In effect, you will get 4 bytes of memory (assuming an `int` is 4 bytes) that keep whatever was there in the first place, then have that value added to the value of `b` . You can read more about C's undefined behavior here : <http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html> | Appendix J (which is non-normative) suggests that the behavior is *undefined*:
>
> The value of an object with automatic storage duration is used while it is
> indeterminate (6.2.4, 6.7.9, 6.8).
>
although I can't find explicit language in any of the referenced sections to support that (then again, my blood caffeine content is a bit low this morning, so I may be missing it).
If the behavior *is* undefined, then the compiler isn't required to issue a diagnostic. |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | **Explanation**
In a C function, all of your local variable declarations happen straight away. Essentially, the compiler translates your code into:
```
int a;
int b;
// start of function
a = 9;
b = a + b;
// end of function
```
So you can see, that there is always a variable `b`, it exists for the whole runtime of the function.
In Python, this doesn't happen. `b` does not exist until it is assigned to for the first time.
The Python interpreter runs the code `a+b` before it runs `b = <the result of a+b>`. If you think about what it's doing with that intermediate result you get something equivalent to:
```
a = 9;
intermediate_value = a + b
b = intermediate_value
```
It is now clear that you are using `b` before it is defined.
**Philosophy**
This comes down to the difference between a static language like C, and a dynamic language like Python. In a dynamic language, a lot of things that are done compile time in a static language are done at runtime instead. Such things can even include modifying the code of the running program itself. (In theory, with unfettered access to the computer's memory, you could do this in C too; but on all modern operating systems, this is impossible).
Have a read of this page <http://en.wikipedia.org/wiki/Dynamic_programming_language> for more information. | I'm surprised that GCC doesn't spit out any warnings about the use of an uninitialized variable there (compiling with `-Wall -Wpedantic` didn't give me anything). With that being said, though, C makes absolutely no assumptions about what you're doing.
Suppose, for example, you're developing for an embedded system, and, for some strange reason, you know exactly what value your stack-allocated memory holds before you initialize it -- then it's a feature. C won't stand in your way if your system to work in a way that the language developers didn't expect, and that's a good thing. It means that you know almost everything going on under the hood, so you can reason effectively about how performant your code will be.
Additionally, C doesn't have any notion of a namespace, so there's no namespace lookup to perform. Any compiler warnings about something like that stem from the compiler developer's efforts --- there's nothing in the language that distinguishes between an initialized and an uninitialzed variable. |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | **Explanation**
In a C function, all of your local variable declarations happen straight away. Essentially, the compiler translates your code into:
```
int a;
int b;
// start of function
a = 9;
b = a + b;
// end of function
```
So you can see, that there is always a variable `b`, it exists for the whole runtime of the function.
In Python, this doesn't happen. `b` does not exist until it is assigned to for the first time.
The Python interpreter runs the code `a+b` before it runs `b = <the result of a+b>`. If you think about what it's doing with that intermediate result you get something equivalent to:
```
a = 9;
intermediate_value = a + b
b = intermediate_value
```
It is now clear that you are using `b` before it is defined.
**Philosophy**
This comes down to the difference between a static language like C, and a dynamic language like Python. In a dynamic language, a lot of things that are done compile time in a static language are done at runtime instead. Such things can even include modifying the code of the running program itself. (In theory, with unfettered access to the computer's memory, you could do this in C too; but on all modern operating systems, this is impossible).
Have a read of this page <http://en.wikipedia.org/wiki/Dynamic_programming_language> for more information. | One thing that you can do thanks to the semantics, that the variable exists right after its name ends, is a nice circular list initialization:
```
struct node {
struct node *next;
void *data;
}
struct node circular = { .next = &circular, .data = NULL };
```
This would not be possible to initialize like that, if we couldn't refer to `circular` to take its address, even though we're inside the initializer expression for `circular`! |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | **Explanation**
In a C function, all of your local variable declarations happen straight away. Essentially, the compiler translates your code into:
```
int a;
int b;
// start of function
a = 9;
b = a + b;
// end of function
```
So you can see, that there is always a variable `b`, it exists for the whole runtime of the function.
In Python, this doesn't happen. `b` does not exist until it is assigned to for the first time.
The Python interpreter runs the code `a+b` before it runs `b = <the result of a+b>`. If you think about what it's doing with that intermediate result you get something equivalent to:
```
a = 9;
intermediate_value = a + b
b = intermediate_value
```
It is now clear that you are using `b` before it is defined.
**Philosophy**
This comes down to the difference between a static language like C, and a dynamic language like Python. In a dynamic language, a lot of things that are done compile time in a static language are done at runtime instead. Such things can even include modifying the code of the running program itself. (In theory, with unfettered access to the computer's memory, you could do this in C too; but on all modern operating systems, this is impossible).
Have a read of this page <http://en.wikipedia.org/wiki/Dynamic_programming_language> for more information. | Appendix J (which is non-normative) suggests that the behavior is *undefined*:
>
> The value of an object with automatic storage duration is used while it is
> indeterminate (6.2.4, 6.7.9, 6.8).
>
although I can't find explicit language in any of the referenced sections to support that (then again, my blood caffeine content is a bit low this morning, so I may be missing it).
If the behavior *is* undefined, then the compiler isn't required to issue a diagnostic. |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | I'm surprised that GCC doesn't spit out any warnings about the use of an uninitialized variable there (compiling with `-Wall -Wpedantic` didn't give me anything). With that being said, though, C makes absolutely no assumptions about what you're doing.
Suppose, for example, you're developing for an embedded system, and, for some strange reason, you know exactly what value your stack-allocated memory holds before you initialize it -- then it's a feature. C won't stand in your way if your system to work in a way that the language developers didn't expect, and that's a good thing. It means that you know almost everything going on under the hood, so you can reason effectively about how performant your code will be.
Additionally, C doesn't have any notion of a namespace, so there's no namespace lookup to perform. Any compiler warnings about something like that stem from the compiler developer's efforts --- there's nothing in the language that distinguishes between an initialized and an uninitialzed variable. | Appendix J (which is non-normative) suggests that the behavior is *undefined*:
>
> The value of an object with automatic storage duration is used while it is
> indeterminate (6.2.4, 6.7.9, 6.8).
>
although I can't find explicit language in any of the referenced sections to support that (then again, my blood caffeine content is a bit low this morning, so I may be missing it).
If the behavior *is* undefined, then the compiler isn't required to issue a diagnostic. |
24,446,638 | Why the following behavior is allowed by most implementations of C ? If we a use a variable itself to define it, like this:
```
#include <stdio.h>
int main()
{
int a = 9;
int b = ( a +b );
printf("%d",b);
}
```
I know that the **garbage** value of `b` will be used but there should be some compile time warnings . It sounds a little weird to me. In languages like Python it is illegal to do such stuff :
```
>>> b = 9
>>> a = a + b
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a = a + b
NameError: name 'a' is not defined
```
I guess Python does not put a variable to the current namespace until it is *well-defined* (i.e. it has a value within the current scope) while in C the above statement breaks like this:
```
int b = 9;
int a; // put to namespace or whatever a lookup table with garbage value
a = a + b;
```
It would be nice if anyone points out the philosophy behind this. | 2014/06/27 | [
"https://Stackoverflow.com/questions/24446638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679770/"
] | One thing that you can do thanks to the semantics, that the variable exists right after its name ends, is a nice circular list initialization:
```
struct node {
struct node *next;
void *data;
}
struct node circular = { .next = &circular, .data = NULL };
```
This would not be possible to initialize like that, if we couldn't refer to `circular` to take its address, even though we're inside the initializer expression for `circular`! | Appendix J (which is non-normative) suggests that the behavior is *undefined*:
>
> The value of an object with automatic storage duration is used while it is
> indeterminate (6.2.4, 6.7.9, 6.8).
>
although I can't find explicit language in any of the referenced sections to support that (then again, my blood caffeine content is a bit low this morning, so I may be missing it).
If the behavior *is* undefined, then the compiler isn't required to issue a diagnostic. |
50,829,399 | I cloned a website using the duplicator plugin and made changes to it. When logged in as admin I see the changes but when I use an incognito browser it still shows the cloned version (old version). I can see the changes when I do a hard refresh of the browser, but refreshing again reverts to the old copy. I tried emptying the cache, deleting cookies, deleting cache folder on `wp-content` but nothing seems to work?
I don't have any caching plugins installed.
The css changes seem to take effect, but the old pages are still loading.
It seems like the pages are somehow cached somewhere.
I had the hosting support check and they updated the A records but it still somehow doesn't fix the issue.
It's in a shared hosting on hostgator
Thank you. | 2018/06/13 | [
"https://Stackoverflow.com/questions/50829399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4206751/"
] | (finally know how to use this) Actually found the solution thanks to a friend.
The "peer chaincode invoke " doesn't have the flag "peerAddresses". The code given on the Hyperledger fabric tutorial documentation might be outdated or incorrect.
This can be seen in the Reference documentation : <https://hyperledger-fabric.readthedocs.io/en/release-1.1/commands/peerchaincode.html>
So removing peerAddresses and writing something like this might solve the error.
```
peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}'
``` | Problem was resolved by changing chaincode instantiation by changing "and" to "or".
Since I had skipped the environment variables step, default was peer0.org1 (i.e. org1MSP). Nothing was set for org2MSP. Thus it was in no position to award permissions in the first place.
```
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
``` |
73,302,997 | I have two repositories. A and B.
Inside A, I have a docker image. Let's say it's name is `ghcr.io/org/a`
Inside B, I have an action that wants to use this package. Both repos are private.
Here's my action code:
```
- name: Log in to GitHub Container Repository
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull the image
run: |
docker pull ghcr.io/org/a:latest
```
As you can see first I log into ghcr.io and I get the `Login succeeded` message. Then I want to pull the image from my other repo.
But I get this error:
>
> Error response from daemon: denied
>
>
>
However, when I login into ghcr.io from my own machine, I have access to both repositories and I can pull any image from any private repository of mine.
Why GitHub Action from B can not pull image from A in spite of being logged in? | 2022/08/10 | [
"https://Stackoverflow.com/questions/73302997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17810064/"
] | You need to check if `active` includes `"c1"`.
```js
const menu = [
{
name: "Home",
icon: "ri-home-4-line",
layoutCode: "",
active: ["h1"]
},
{
name: "Cust",
layoutCode: "",
icon: "ri-user-2-fill",
active: ["c1", "c2"]
}
];
const result = menu.filter(m => m.active.includes("c1"));
console.log(result);
``` | `active`is an array. Try:
```
json_menu.menu.filter(record => record.active.includes('c1'))
``` |
73,302,997 | I have two repositories. A and B.
Inside A, I have a docker image. Let's say it's name is `ghcr.io/org/a`
Inside B, I have an action that wants to use this package. Both repos are private.
Here's my action code:
```
- name: Log in to GitHub Container Repository
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull the image
run: |
docker pull ghcr.io/org/a:latest
```
As you can see first I log into ghcr.io and I get the `Login succeeded` message. Then I want to pull the image from my other repo.
But I get this error:
>
> Error response from daemon: denied
>
>
>
However, when I login into ghcr.io from my own machine, I have access to both repositories and I can pull any image from any private repository of mine.
Why GitHub Action from B can not pull image from A in spite of being logged in? | 2022/08/10 | [
"https://Stackoverflow.com/questions/73302997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17810064/"
] | You need to check if `active` includes `"c1"`.
```js
const menu = [
{
name: "Home",
icon: "ri-home-4-line",
layoutCode: "",
active: ["h1"]
},
{
name: "Cust",
layoutCode: "",
icon: "ri-user-2-fill",
active: ["c1", "c2"]
}
];
const result = menu.filter(m => m.active.includes("c1"));
console.log(result);
``` | You can use `includes` instead of `===`
```
json_menu.menu.filter(record => record.active.includes('c1'))
``` |
73,302,997 | I have two repositories. A and B.
Inside A, I have a docker image. Let's say it's name is `ghcr.io/org/a`
Inside B, I have an action that wants to use this package. Both repos are private.
Here's my action code:
```
- name: Log in to GitHub Container Repository
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull the image
run: |
docker pull ghcr.io/org/a:latest
```
As you can see first I log into ghcr.io and I get the `Login succeeded` message. Then I want to pull the image from my other repo.
But I get this error:
>
> Error response from daemon: denied
>
>
>
However, when I login into ghcr.io from my own machine, I have access to both repositories and I can pull any image from any private repository of mine.
Why GitHub Action from B can not pull image from A in spite of being logged in? | 2022/08/10 | [
"https://Stackoverflow.com/questions/73302997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17810064/"
] | You need to check if `active` includes `"c1"`.
```js
const menu = [
{
name: "Home",
icon: "ri-home-4-line",
layoutCode: "",
active: ["h1"]
},
{
name: "Cust",
layoutCode: "",
icon: "ri-user-2-fill",
active: ["c1", "c2"]
}
];
const result = menu.filter(m => m.active.includes("c1"));
console.log(result);
``` | json\_menu.menu.filter(record => record.active.includes('c1'))
use includes function to check item in array |
28,078,047 | I'm writing a very simple contact form that will allow blue collar workers to submit safety concern notices over our intranet. Contact form is displayed in HTML and asks for a Name, a From email, and the message to be sent. It always sends to our safety email.
The server and port are correct. It's an Exchange 2010 server, and we're using TSL. The server is configured to be able to receive email 'anonymously'. I can connect through the telnet command but I receive a "501 5.5.4 Invalid domain name" error when I try to send mail through the comment box.
```
define("EMAIL_SUBJECT", "Safety Concerns");
define("EMAIL_TO", "email");
// SMTP Configuration
define("SMTP_SERVER", 'server');
define("SMTP_PORT", 25);
// define("UPLOAD_DIR", '/var/www/tmp/'); // Default php upload dir
// main method. It's the first method called
function main($contactForm) {
// Checks if something was sent to the contact form, if not, do nothing
if (!$contactForm->isDataSent()) {
return;
}
// validates the contact form and initialize the errors
$contactForm->validate();
$errors = array();
// If the contact form is not valid:
if (!$contactForm->isValid()) {
// gets the error in the array $errors
$errors = $contactForm->getErrors();
} else {
// If the contact form is valid:
try {
// send the email created with the contact form
$result = sendEmail($contactForm);
// after the email is sent, redirect and "die".
// We redirect to prevent refreshing the page which would resend the form
header("Location: ./success.php");
die();
} catch (Exception $e) {
// an error occured while sending the email.
// Log the error and add an error message to display to the user.
error_log('An error happened while sending email contact form: ' . $e->getMessage());
$errors['oops'] = 'Ooops! an error occured while sending your email! Please try again later!';
}
}
return $errors;
}
// Sends the email based on the information contained in the contact form
function sendEmail($contactForm) {
// Email part will create the email information needed to send an email based on
// what was inserted inside the contact form
$emailParts = new EmailParts($contactForm);
// This is the part where we initialize Swiftmailer with
// all the info initialized by the EmailParts class
$emailMessage = Swift_Message::newInstance()
->setSubject($emailParts->getSubject())
->setFrom($emailParts->getFrom())
->setTo($emailParts->getTo())
->setBody($emailParts->getBodyMessage());
// If an attachment was included, add it to the email
// if ($contactForm->hasAttachment()) {
// $attachmentPath = $contactForm->getAttachmentPath();
// $emailMessage->attach(Swift_Attachment::fromPath($attachmentPath));
//}
// Another Swiftmailer configuration..
$transport = Swift_SmtpTransport::newInstance(SMTP_SERVER, SMTP_PORT, 'tls');
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($emailMessage);
return $result;
}
// Initialize the ContactForm with the information of the form and the possible uploaded file.
$contactForm = new ContactForm($_POST, $_FILES);
// Call the "main" method. It will return a list of errors.
$errors = main($contactForm);
require_once("./views/contactForm.php");
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28078047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4470820/"
] | The answer is simple, if mail host field has an FQDN defined(xx.yy.com) instead of an IP address, the server should be able to resolve the FQDN. Else it would trigger an error called Invalid domain name.
Hope this helps! | Basically, for SMTP "greetings", Swiftmailer is doing :
```
$response = $this->executeCommand(
sprintf("EHLO %s\r\n", $this->domain), [250]
);
```
and this 'Domain' value comes from `$_SERVER['SERVER_NAME']`.
So you just have to change `server_name` value in nginx or `ServerName` in Apache (maybe also use `UseCanonicalName on` in Apache), and make sure that you don't also have a port number like X.X.X.X:8888 (Exchange doesn't like it).
I read that it can also be caused by `\r\n` (try with only "\n" if the first solution doesn't work).
And to make sure about what you send, just debug SMTP by printing `$command` and `$response` from `executeCommand(...)` (`Swift_Transport_AbstractSmtpTransport.php` & `Swift_Transport_EsmtpTransport.php`) to log files. |
28,078,047 | I'm writing a very simple contact form that will allow blue collar workers to submit safety concern notices over our intranet. Contact form is displayed in HTML and asks for a Name, a From email, and the message to be sent. It always sends to our safety email.
The server and port are correct. It's an Exchange 2010 server, and we're using TSL. The server is configured to be able to receive email 'anonymously'. I can connect through the telnet command but I receive a "501 5.5.4 Invalid domain name" error when I try to send mail through the comment box.
```
define("EMAIL_SUBJECT", "Safety Concerns");
define("EMAIL_TO", "email");
// SMTP Configuration
define("SMTP_SERVER", 'server');
define("SMTP_PORT", 25);
// define("UPLOAD_DIR", '/var/www/tmp/'); // Default php upload dir
// main method. It's the first method called
function main($contactForm) {
// Checks if something was sent to the contact form, if not, do nothing
if (!$contactForm->isDataSent()) {
return;
}
// validates the contact form and initialize the errors
$contactForm->validate();
$errors = array();
// If the contact form is not valid:
if (!$contactForm->isValid()) {
// gets the error in the array $errors
$errors = $contactForm->getErrors();
} else {
// If the contact form is valid:
try {
// send the email created with the contact form
$result = sendEmail($contactForm);
// after the email is sent, redirect and "die".
// We redirect to prevent refreshing the page which would resend the form
header("Location: ./success.php");
die();
} catch (Exception $e) {
// an error occured while sending the email.
// Log the error and add an error message to display to the user.
error_log('An error happened while sending email contact form: ' . $e->getMessage());
$errors['oops'] = 'Ooops! an error occured while sending your email! Please try again later!';
}
}
return $errors;
}
// Sends the email based on the information contained in the contact form
function sendEmail($contactForm) {
// Email part will create the email information needed to send an email based on
// what was inserted inside the contact form
$emailParts = new EmailParts($contactForm);
// This is the part where we initialize Swiftmailer with
// all the info initialized by the EmailParts class
$emailMessage = Swift_Message::newInstance()
->setSubject($emailParts->getSubject())
->setFrom($emailParts->getFrom())
->setTo($emailParts->getTo())
->setBody($emailParts->getBodyMessage());
// If an attachment was included, add it to the email
// if ($contactForm->hasAttachment()) {
// $attachmentPath = $contactForm->getAttachmentPath();
// $emailMessage->attach(Swift_Attachment::fromPath($attachmentPath));
//}
// Another Swiftmailer configuration..
$transport = Swift_SmtpTransport::newInstance(SMTP_SERVER, SMTP_PORT, 'tls');
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($emailMessage);
return $result;
}
// Initialize the ContactForm with the information of the form and the possible uploaded file.
$contactForm = new ContactForm($_POST, $_FILES);
// Call the "main" method. It will return a list of errors.
$errors = main($contactForm);
require_once("./views/contactForm.php");
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28078047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4470820/"
] | Just to add to [Dilraj Rajan](https://stackoverflow.com/a/45822669/10907864) answer.
Do not add the `http://` or `https://` prefix to your URL when defining your **FQDN** (Fully Qualified Domain Name).
**That is**;
Do not define **FQDN** like this `http://example.com`'
Rather define **FQDN** like this: `example.com`
You can also opt to use the `Public IP Address` of the application server rather.
That's all.
**I hope this helps**. | Basically, for SMTP "greetings", Swiftmailer is doing :
```
$response = $this->executeCommand(
sprintf("EHLO %s\r\n", $this->domain), [250]
);
```
and this 'Domain' value comes from `$_SERVER['SERVER_NAME']`.
So you just have to change `server_name` value in nginx or `ServerName` in Apache (maybe also use `UseCanonicalName on` in Apache), and make sure that you don't also have a port number like X.X.X.X:8888 (Exchange doesn't like it).
I read that it can also be caused by `\r\n` (try with only "\n" if the first solution doesn't work).
And to make sure about what you send, just debug SMTP by printing `$command` and `$response` from `executeCommand(...)` (`Swift_Transport_AbstractSmtpTransport.php` & `Swift_Transport_EsmtpTransport.php`) to log files. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | Actually, scratch that. Do this: edit /etc/gdm3/custom.conf and uncomment the line:
#WaylandEnable=false
The issue also doesn't seem to appear in a fresh install of Ubuntu 18.10.
Go [here](https://bugs.launchpad.net/ubuntu/+source/gdm3/+bug/1798790) and press the affects me button to raise awareness. Feel free to provide information/logs needed by the developers in the comments. Thank you.
Removing the nvidia proprietary drivers seems to fix the issue. Go into recovery mode by pressing Shift during boot and run `sudo apt-get remove --purge nvidia-*` Say goodbye to gaming, though. I have filled a bug in [Launchpad](https://bugs.launchpad.net/ubuntu/+source/gdm3/+bug/1798790</strike). You might want to press the "affects me" button. Thank you. | I had the same issue on Zorin 15 - which is based on Ubuntu 18. Fortunately, I can still SSH to the box.
I simply did **sudo apt-get remove gnome-shell** and then **sudo apt-get install gnome-shell** |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | My Ubuntu is 18.04.2 LTS, and I got the exactly the same problem. I tried many ways searched from google but failed.
The final solution for me is (which I don't know why it works):
1. First you need to login after "Started bpfilter".
Type: your\_username→enter→password,
Then you will get a terminal which is the same as the one you open in GUI when it works. Actually now you can control you computer with it.
2. `sudo apt-get install lightdm`, Enter to confirm installation.
3. In my case, after the installation of "lightdm", there will be a popup GUI which asks you for confirming something as default setting with two choice, "gdm" and "lightdm". While, I still choose the "gdm" here(don't ask me why, I am also confused).
4. Restart. My GUI come back! and I tried restart again which proved the problem is solved. (Even I am still googleing "what is gdm and lightdm?").
5. Open terminal and type `sudo apt-get remove lightdm` to remove the lightdm (I am sorry~) | Installing LightDM worked for me. I'm on an iMac late 2013 with Ubuntu 19.04 and kernel 5.0.0-23-generic. I installed SLiM first, but since I run a two-monitor setup, the login screen was just messed up. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | On Ubuntu 18.10. kernel 4.18.0-12-generic, GNOME Shell 3.30.1 - X11, since a Dec 9 update, login kept hanging on `Started bpfilter` -- I think a possible conflict between systemd and bpfilter (I think managed by the kernel.) The following suggested fixes had no effect on my system:
1. Removing nVidia drivers (my laptop uses Intel graphics, no nVida drivers installed, so this recommendation didn't apply,)
2. Reverting to previous kernel 4.18.0-11-generic,
3. Disabling Wayland in gdm3,
4. Switching to LightDM display manager (identical hang.) I tried SLiM because it claimed not to require systemd, and it now enables normal login for me. Debian-branded, but allows changing the login background to something generic.
### My fix procedure:
In Recovery Mode, select `<Enable Networking>` (this allows APT to connect online while in Recovery Mode,) then select `<Drop to Shell Prompt>`. Run (as root -- enter `whoami` to verify)
```
apt update && apt install slim
```
to install SLiM. To switch the display manager to SLiM, in Recovery Mode run (as root):
```
dpkg-reconfigure gdm3
```
then select SLiM, then 'restart now'.
---
SLiM will probably be a temporary recourse; with Ubuntu's continuing development I think systemd will be integral, so I've kept GDM3 and LightDM installed, in case a future kernel or systemd update fixes this issue.
This boot hang seems to be an upstream issue reported by users on other distros besides Ubuntu as well, Arch Linux especially. | I had the same issue on Zorin 15 - which is based on Ubuntu 18. Fortunately, I can still SSH to the box.
I simply did **sudo apt-get remove gnome-shell** and then **sudo apt-get install gnome-shell** |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | On Ubuntu 18.10. kernel 4.18.0-12-generic, GNOME Shell 3.30.1 - X11, since a Dec 9 update, login kept hanging on `Started bpfilter` -- I think a possible conflict between systemd and bpfilter (I think managed by the kernel.) The following suggested fixes had no effect on my system:
1. Removing nVidia drivers (my laptop uses Intel graphics, no nVida drivers installed, so this recommendation didn't apply,)
2. Reverting to previous kernel 4.18.0-11-generic,
3. Disabling Wayland in gdm3,
4. Switching to LightDM display manager (identical hang.) I tried SLiM because it claimed not to require systemd, and it now enables normal login for me. Debian-branded, but allows changing the login background to something generic.
### My fix procedure:
In Recovery Mode, select `<Enable Networking>` (this allows APT to connect online while in Recovery Mode,) then select `<Drop to Shell Prompt>`. Run (as root -- enter `whoami` to verify)
```
apt update && apt install slim
```
to install SLiM. To switch the display manager to SLiM, in Recovery Mode run (as root):
```
dpkg-reconfigure gdm3
```
then select SLiM, then 'restart now'.
---
SLiM will probably be a temporary recourse; with Ubuntu's continuing development I think systemd will be integral, so I've kept GDM3 and LightDM installed, in case a future kernel or systemd update fixes this issue.
This boot hang seems to be an upstream issue reported by users on other distros besides Ubuntu as well, Arch Linux especially. | If you are using **ubuntu 18.10** on **VirtualBox** and have been playing with settings of the virtual machine, it might help to set **Settings->Display->Enable 3d acceleration** back on. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | I just had the same set of symptoms with the best results from the previous post:
1. Recovery Mode
2. apt-get install slim
3. dpkg-reconfigure gdm3
4. reboot | Installing LightDM worked for me. I'm on an iMac late 2013 with Ubuntu 19.04 and kernel 5.0.0-23-generic. I installed SLiM first, but since I run a two-monitor setup, the login screen was just messed up. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | Ok, I might get downvoted to oblivion and get my answer privilege taken away because this is only an improvement (Or I would like to think so) but I have to answer this.
**Note:** this is an improvement over @zanna 's answer in this same thread, but I don't have comment privilege yet so I'm posting this as a separate answer.
If you have followed **@zanna 's** answer in this thread and you are using SLiM display manager, and you have decided you don't like this very much/would like to go back to gdm3 (No Unity dock and takes away most of the useful functionalities in Ubuntu, you cannot even tap-to-click without a lot of tinkering around) *maybe this will help you get back to gdm3.*
The 'Started BPFilter' bug happens mostly in Ubuntu 18.04 (and I've also seen a few cases in 18.10). Go on, Install SLiM as @zanna has suggested and check if that works.
**Note 2:** there are a couple of answers in other thread suggesting you use LightDM. It has not worked for me. I reached the login screen and I was forever re-directed to the *same screen* even if I input the right credentials. You are free to go play around using the command line from there (Ctrl + Alt + Del or something) but here is a thread on why that wouldn't probably work.
Thread (Even LightDM doesn't work for me, Is there no respite!): [[https://www.reddit.com/r/Ubuntu/comments/9hagsd/ubuntu\_1804\_just\_keeps\_returning\_to\_login\_screen/]](https://www.reddit.com/r/Ubuntu/comments/9hagsd/ubuntu_1804_just_keeps_returning_to_login_screen/)
**Note 3:** (If you have come this far, I take it you have also gotten rid of your Nvidia Drivers, which for most of you did not exist to begin with! [Yeah, I did the purge too only to find they don't exist]).
**Solution:** (Not really, since you need to move away from 18.04).
1. As the top answer has suggested, in /etc/gdm3/custom.conf uncomment the line that says
#WaylandEnable=false
Once you do it
2. Do
`sudo do-release-upgrade`
This should get you the next immediate Ubuntu version. However, this is not the Development version (*which actually works with gdm3 for me*).
So next, do:
`sudo do-release-upgrade -d` (-d flag for development branch).
This will ask you to edit a text file and change the version from LTS to normal (Follow the error message!).
Once this is done, go into recovery, and do:
dpkg-reconfigure gdm3 and choose gdm3 this time (Don't choose SLiM/ LightDM).
That is it! Tada! Everything works now! | Installing LightDM worked for me. I'm on an iMac late 2013 with Ubuntu 19.04 and kernel 5.0.0-23-generic. I installed SLiM first, but since I run a two-monitor setup, the login screen was just messed up. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | I just had the same set of symptoms with the best results from the previous post:
1. Recovery Mode
2. apt-get install slim
3. dpkg-reconfigure gdm3
4. reboot | If you are using **ubuntu 18.10** on **VirtualBox** and have been playing with settings of the virtual machine, it might help to set **Settings->Display->Enable 3d acceleration** back on. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | My Ubuntu is 18.04.2 LTS, and I got the exactly the same problem. I tried many ways searched from google but failed.
The final solution for me is (which I don't know why it works):
1. First you need to login after "Started bpfilter".
Type: your\_username→enter→password,
Then you will get a terminal which is the same as the one you open in GUI when it works. Actually now you can control you computer with it.
2. `sudo apt-get install lightdm`, Enter to confirm installation.
3. In my case, after the installation of "lightdm", there will be a popup GUI which asks you for confirming something as default setting with two choice, "gdm" and "lightdm". While, I still choose the "gdm" here(don't ask me why, I am also confused).
4. Restart. My GUI come back! and I tried restart again which proved the problem is solved. (Even I am still googleing "what is gdm and lightdm?").
5. Open terminal and type `sudo apt-get remove lightdm` to remove the lightdm (I am sorry~) | I had the same problem and found out that I caused it by editing the banner section in the file
```
/etc/gdm3/greeter.dconf-defaults.
```
I had to make the lines for *banner, message and comment* again and it did not hang anymore. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | I had the same problem and found out that I caused it by editing the banner section in the file
```
/etc/gdm3/greeter.dconf-defaults.
```
I had to make the lines for *banner, message and comment* again and it did not hang anymore. | Installing LightDM worked for me. I'm on an iMac late 2013 with Ubuntu 19.04 and kernel 5.0.0-23-generic. I installed SLiM first, but since I run a two-monitor setup, the login screen was just messed up. |
1,084,550 | Today I have updated from my Ubuntu 18.04 to 18.10 by software upgrade app ( coudn't wait till tomorrow ). It took a bit of time, but at the end of it I was asked to restart my PC. Upon restarting, I get to boot runtime.
The boot log on screen passed numerous processes like gnome manager and stopped on "Started bpfilter". I waited 15 min., but nothing changed. Tried to restart the PC manually two times, but the result was still the same.
The interesting bit for me, after the message, it seems like an instance of terminal is given to me, - I can freely write letters. Though commands like cd, ls are not working.
[](https://i.stack.imgur.com/hptYB.jpg)
My GPU is NVidia GTX 1060, CPU Intel i5-7500. I dual boot along with Windows 10.
What would be your recommendations to fix this or debug what could be wrong? | 2018/10/17 | [
"https://askubuntu.com/questions/1084550",
"https://askubuntu.com",
"https://askubuntu.com/users/883002/"
] | I just had the same set of symptoms with the best results from the previous post:
1. Recovery Mode
2. apt-get install slim
3. dpkg-reconfigure gdm3
4. reboot | I had the same issue on Zorin 15 - which is based on Ubuntu 18. Fortunately, I can still SSH to the box.
I simply did **sudo apt-get remove gnome-shell** and then **sudo apt-get install gnome-shell** |
5,802,555 | I'm trying to **reduce the padding** between the fields of my ExtJS form.
I am able to change the style of the **field data** with the style tag in the Items collection like this:

```
//form right
var simple_form_right = new Ext.FormPanel({
frame:true,
labelWidth: 90,
labelAlign: 'right',
title: 'Orderer Information',
bodyStyle:'padding:5px 5px 0 0',
width: 300,
height: 600,
autoScroll: true,
itemCls: 'form_row',
defaultType: 'displayfield',
items: [{
fieldLabel: 'Customer Type',
name: 'customerType',
style: 'padding:0px;font-size:7pt',
labelStyle: 'padding:0px',
allowBlank: false,
value: 'Company'
},{
fieldLabel: 'Company',
name: 'company',
value: 'The Ordering Company Inc.'
},{
fieldLabel: 'Last Name',
name: 'lastName',
value: 'Smith'
}, {
...
```
**But how do I access the style of the label as well, something like styleLabel or labelStyle, etc.?** | 2011/04/27 | [
"https://Stackoverflow.com/questions/5802555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | There's [`labelPad`](http://dev.sencha.com/deploy/ext-3.3.1/docs/source/Form.html#cfg-Ext.form.FormPanel-labelPad) which defaults to 5px apparently, and [`labelStyle`](http://dev.sencha.com/deploy/ext-3.3.1/docs/source/Component.html#cfg-Ext.Component-labelStyle) if you need more than that. | You can make use of the `labelStyle` property available for form fields.
Here is an example:
```
items: [{
fieldLabel: 'Company',
name: 'company',
labelStyle: 'padding: 10px 10px;'
}]
``` |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | Here's a list of thing I used to get familiar with DX controlls:
1. As [Aseem Gautam](https://stackoverflow.com/questions/2499140/starting-in-devexpress/2499186#2499186)'s answer web casts gives good overall prospective
2. To get more detailed picture you can look through few sample apps
3. DX documentation, knowledge base
4. And finally you could ask for assistance the DevXpress support team | Best is to watch the online webcasts. |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | Here's a list of thing I used to get familiar with DX controlls:
1. As [Aseem Gautam](https://stackoverflow.com/questions/2499140/starting-in-devexpress/2499186#2499186)'s answer web casts gives good overall prospective
2. To get more detailed picture you can look through few sample apps
3. DX documentation, knowledge base
4. And finally you could ask for assistance the DevXpress support team | Professional DevExpress ASP.NET Controls by Wrox
<http://www.wrox.com/WileyCDA/WroxTitle/Professional-DevExpress-ASP-NET-Controls.productCd-0470500832.html> |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | Best is to watch the online webcasts. | I would recommend the devexpress site as the best source. They even have online demos that will help a lot. |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | you can find some demonstration here :
<http://demos.devexpress.com/ASP/> | I would recommend the devexpress site as the best source. They even have online demos that will help a lot. |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | you can find some demonstration here :
<http://demos.devexpress.com/ASP/> | <https://www.devexpress.com/ClientCenter/Downloads/#Documentation>
 |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | <https://www.devexpress.com/ClientCenter/Downloads/#Documentation>
 | View the [online videos](http://tv.devexpress.com/) at the Developer Express site. |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | Professional DevExpress ASP.NET Controls by Wrox
<http://www.wrox.com/WileyCDA/WroxTitle/Professional-DevExpress-ASP-NET-Controls.productCd-0470500832.html> | View the [online videos](http://tv.devexpress.com/) at the Developer Express site. |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | Here's a list of thing I used to get familiar with DX controlls:
1. As [Aseem Gautam](https://stackoverflow.com/questions/2499140/starting-in-devexpress/2499186#2499186)'s answer web casts gives good overall prospective
2. To get more detailed picture you can look through few sample apps
3. DX documentation, knowledge base
4. And finally you could ask for assistance the DevXpress support team | <https://www.devexpress.com/ClientCenter/Downloads/#Documentation>
 |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | you can find some demonstration here :
<http://demos.devexpress.com/ASP/> | Best is to watch the online webcasts. |
2,499,140 | I am looking at integrating DevExpress to a webapp Im doing in asp.net C#.
Finding it difficult to get a good article or book on how to begin. any where to find these? | 2010/03/23 | [
"https://Stackoverflow.com/questions/2499140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/291743/"
] | Best is to watch the online webcasts. | View the [online videos](http://tv.devexpress.com/) at the Developer Express site. |
10,733,795 | in Firefox-preferences you can select if passwords should be stored and if fields should be auto-filled. If I visit the site of my bank I wondered how it is handled that I won't be asked if I want to store password or username!?
Which markup is necessary to prevent auto-fill or auto-complete in webforms? Thanks in advance. | 2012/05/24 | [
"https://Stackoverflow.com/questions/10733795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1342614/"
] | ```
<form autocomplete="off">
```
Doesn't work on ff3 though, as far as I remember
<https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion> | I'm adding this bit for a different point of view. Why not honeypot it stop chrome from botting your fields. It appears to work cross browser for me. Worth a shot.
<http://benjaminjshore.info/2014/05/chrome-auto-fill-honey-pot-hack.html> |
30,644,566 | I want to fade in 4 div boxes, one by one.
In css they have the opacity = 0.
Here my JavaScript code:
```
function fadeIn() {
var box = new Array(
document.getElementById('skill1'),
document.getElementById('skill2'),
document.getElementById('skill3'),
document.getElementById('skill4')
);
var pagePosition = window.pageYOffset;
if (pagePosition >= 1000) {
for (var i = 0; i < box.length; i++) {
setTimeout(function(i) {
box[i].style.opacity = "1";
}, i * 500);
}
}
}
```
Well, the function has to start if you scroll the page to the position 1000px and called in the body-tag:
Without the setTimeout it works, but with this function the console says:
```
Uncaught TypeError: Cannot read property 'style' of undefined
```
I'm a beginner and want to understand JS, so please don't provide an answer using jQuery. | 2015/06/04 | [
"https://Stackoverflow.com/questions/30644566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4973774/"
] | By the time your your timeout runs, the loop has finished processing, so `i` will always be the last iteration. You need a closure:
```
for(var i = 0; i < box.length; i++) {
(function(index) {
setTimeout(function() {
box[index].style.opacity = "1";
}, index*500);
})(i)
}
``` | The problem is the scope. When anonymous function executes inside timeout `i` variable has the last value of the `i` in the iteration. There are two solutions:
1) Use an [IIFE](http://benalman.com/news/2010/11/immediately-invoked-function-expression/):
```
for (var i = 0; i < box.length; i++) {
(function (i) {
setTimeout(function (i) {
box[i].style.opacity = "1";
}, i * 500);
})(i);
}
```
```js
for (var i = 0; i < 5; i++) {
(function(i) {
setTimeout(function() {
console.log(i);//prints out 0 1 2 3 4
}, i * 500)
})(i);
}
```
2) Using [let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let):
```
for (let i = 0; i < box.length; i++) {
setTimeout(function (i) {
box[i].style.opacity = "1";
}, i * 500);
}
```
```js
"use strict";
for (let i = 0; i < 5; i++) {
setTimeout(function() {
console.log(i)
}, i * 500)
}
```
>
> The let statement declares a block scope local variable, optionally
> initializing it to a value.
>
>
>
Keep in mind `let` is feature fo ecmaScript 6. |
66,503 | I watched a [video](https://www.youtube.com/watch?v=mICxKmCjF-4) that said that Republicans pushed the nation to the right. But I am getting the sense that Republicans are in a sense "maxed out" in pushing to the right ideologically.
Are Democrats moving left pushing the United States as a whole to the left? | 2021/07/18 | [
"https://politics.stackexchange.com/questions/66503",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/29035/"
] | It is a bit misguided to cast this as a Republican/Democrat issue, since the origins of it go back before the [Southern Strategy](https://en.wikipedia.org/wiki/Southern_strategy), where a large cohort of historically Democratic southern segregationists switched to the Republican party, reversing the conservative/liberal poles and laying the foundation for the modern (Rightist) GOP.
The US has been on a protracted slide towards social-liberal values since the late 1950s, in part due to post-WW-II ideology which held the US as the primary source and protector of (small 'd') democratic values for the world at large. Put simply, the idea that the US protected the weak against oppression solidified in the American consciousness, and that attitude contributed to the successes of the Civil Rights movement, Feminism, gay rights, union movements, and other ostensibly leftist (social-liberal) projects. Conservatives — or more specifically, fundamentalist Christians, economic (free market) adventurists, and white ethno-nationalists, all for very different reasons — have been fighting rear-guard actions against these sociopolitical changes, trying to preserve elements of the 1950s social order. They all pulled together under the GOP 'Big Tent' sometime in the 70s or early 80s (certainly by the era of the [Moral Majority](https://en.wikipedia.org/wiki/Moral_Majority) movement), despite having little in common except their opposition to progressive social changes.
It isn't that the Democrats have been pushing the nation to the left. The nation as a whole has been moving somewhat left: towards a more secular, technological, cosmopolitan society. The Democratic party has followed that trend while the GOP has steadfastly rejected it.
Up to this point, we see the normal push-me-pull-you struggle between progressivism and conservatism, a struggle that normally slows down change to a manageable level without really stopping it. However, the modern aggrieved political polarization is best described as an advancing [decompensation](https://en.wikipedia.org/wiki/Decompensation#Psychology) on the fringes of the far Right over their repeated failures to stop or reverse these social changes. I mean, there are always those who decompensate in society, effectively losing connection with reality and retreating into an enclosed bubble where they can maintain an alternate version of reality. Think the [Branch Davidians](https://en.wikipedia.org/wiki/Branch_Davidians), various New Age cults, the isolationist militia movements of the 80s and 90s, the odd and sundry revolutionary groups that have popped up over the years... But beginning with the collapse of the HW Bush administration (under the mortgage lending crisis) and the nomination and then election of an African American president, large segments of the far Right lost their footing in reality under the stress, insisting that how *they* viewed the US was reality, and that the Democrats and liberals must have done something horrible to make the US *not* fit the way the Right perceives it. Add the FOX Network's propaganda paradigm and the tendency of social media to fracture into like-minded enclaves, and perfect conditions were created for a persistent, globally-scaled decompensation.
In short, the far Right now insists that *their* perspective is true and right, even if it involves Satan worshiping pedophiles, Jewish space lasers, massive undetectable election fraud, and secret nefarious plots lying behind a global pandemic. And they've reduced themselves to obstructionist, unfocussed guerrilla tactics. It isn't that they've 'maxed out' on Rightist ideology, but more that they've lost themselves in such a thoroughly alternate reality that conventional Rightist ideology is too much part of the real world that they are rejecting. They cannot **be** old-school Rightists without acknowledging that the ongoing social changes are (small 'd') democratically legitimate, and they cannot accept the legitimacy of these changes. So *conventional* Rightism has to go with all the rest. | There is definitely a reformist movement within the Democratic party (Bernie, Taylor, et. al.) that pushes towards a more socially responsive government to address prevailing socio-economic problems, including: public health, education, climate change, incentive to the alternative energy industry, minimum wage, etc. These are problems that the free-market system and traditional government actions have consistently fail to solve viably, or at most have provided temporary relief for. This form of government involvement is in direct opposition to the conservative’s small government ideal (as proposed by Reagan).
However, there is lots of misinformation and disinformation regarding this reformist movement. First, the conservatives try to characterize them as radical left, marxist-lennist, etc. Yet, their policies are more social-democratic than radical; i.e., they are not proposing the abolition of private ownership, but the redistribution of wealth through taxes, etc., to solve these problems. Thus, their classification as marxist-lennist, radical left is improper (even if any of its members are or manifest themselves in support of such oppressive regimens as the Cuban one and against the US embargo). |
66,503 | I watched a [video](https://www.youtube.com/watch?v=mICxKmCjF-4) that said that Republicans pushed the nation to the right. But I am getting the sense that Republicans are in a sense "maxed out" in pushing to the right ideologically.
Are Democrats moving left pushing the United States as a whole to the left? | 2021/07/18 | [
"https://politics.stackexchange.com/questions/66503",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/29035/"
] | There is definitely a reformist movement within the Democratic party (Bernie, Taylor, et. al.) that pushes towards a more socially responsive government to address prevailing socio-economic problems, including: public health, education, climate change, incentive to the alternative energy industry, minimum wage, etc. These are problems that the free-market system and traditional government actions have consistently fail to solve viably, or at most have provided temporary relief for. This form of government involvement is in direct opposition to the conservative’s small government ideal (as proposed by Reagan).
However, there is lots of misinformation and disinformation regarding this reformist movement. First, the conservatives try to characterize them as radical left, marxist-lennist, etc. Yet, their policies are more social-democratic than radical; i.e., they are not proposing the abolition of private ownership, but the redistribution of wealth through taxes, etc., to solve these problems. Thus, their classification as marxist-lennist, radical left is improper (even if any of its members are or manifest themselves in support of such oppressive regimens as the Cuban one and against the US embargo). | I think it's pretty clear that they are. What policy issues have Republicans and the right conclusively won in the past ~100 years? Pretty much just gun rights as far as I can tell, and even there one can make an argument they've lost at least some ground. Abortion, gay marriage, the welfare state, drug legalization, environmentalism, healthcare, all of these topics have seen right wing defeats over and over again. |
66,503 | I watched a [video](https://www.youtube.com/watch?v=mICxKmCjF-4) that said that Republicans pushed the nation to the right. But I am getting the sense that Republicans are in a sense "maxed out" in pushing to the right ideologically.
Are Democrats moving left pushing the United States as a whole to the left? | 2021/07/18 | [
"https://politics.stackexchange.com/questions/66503",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/29035/"
] | That would depend entirely on what you mean by left and right.
If you wanted to measure "push to the right" in terms of, say "fiscal responsibility", it is trivial to find plenty of people who will argue that the GOP did not push the USA to the right in the slightest.
If you look at the ACA and it's acceptance by a majority of Americans, it can easily be argued to represent how Democrats pushed the USA to the left.
And plenty of examples to argue the opposite exist.
What truly happened is that there has been a significant shift in values of the GOP, where it has embraced some more extremist elements. Calling the integration of these extremist elements, which are ranging from Tea Party to QAnon - with Proud Boys and others in between - "Pushed to the right" is one way to look at it. But if you define the political right as traditional Conservatives, I'd argue the GOP and the USA as a whole has drifted away from them.
At the same time, there has been a comparatively smaller shift in values of the Democratic Party. Sure, you can break that down and pick some elements with which you can argue that it has moved to the left *on those elements*, but by focusing on others you could also argue the other way.
To complicate things further, if we look at right/left as purely conservative/progressive, the simplified goal of conservatives is not to change things "back" to some mythical past\*, but to preserve things as they are, while the goal of progressives is to embrace change. In theory, whenever progressives establish a change that does work (e.g. ACA), within a few years it will be conservatives fighting to preserve that change. Which makes it near impossible to undisputedly claim a country moved more to the left, or to the right, absent a truly earth shattering shift in public sentiment.
---
\*1. [that's not being conservative](https://www.openculture.com/2018/10/yale-professor-jason-stanley-identifies-three-essential-features-of-fascism.html), and 2. [it's disputed if that's right wing or not](https://politics.stackexchange.com/questions/24665/is-fascism-left-or-right-wing). | There is definitely a reformist movement within the Democratic party (Bernie, Taylor, et. al.) that pushes towards a more socially responsive government to address prevailing socio-economic problems, including: public health, education, climate change, incentive to the alternative energy industry, minimum wage, etc. These are problems that the free-market system and traditional government actions have consistently fail to solve viably, or at most have provided temporary relief for. This form of government involvement is in direct opposition to the conservative’s small government ideal (as proposed by Reagan).
However, there is lots of misinformation and disinformation regarding this reformist movement. First, the conservatives try to characterize them as radical left, marxist-lennist, etc. Yet, their policies are more social-democratic than radical; i.e., they are not proposing the abolition of private ownership, but the redistribution of wealth through taxes, etc., to solve these problems. Thus, their classification as marxist-lennist, radical left is improper (even if any of its members are or manifest themselves in support of such oppressive regimens as the Cuban one and against the US embargo). |
66,503 | I watched a [video](https://www.youtube.com/watch?v=mICxKmCjF-4) that said that Republicans pushed the nation to the right. But I am getting the sense that Republicans are in a sense "maxed out" in pushing to the right ideologically.
Are Democrats moving left pushing the United States as a whole to the left? | 2021/07/18 | [
"https://politics.stackexchange.com/questions/66503",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/29035/"
] | It is a bit misguided to cast this as a Republican/Democrat issue, since the origins of it go back before the [Southern Strategy](https://en.wikipedia.org/wiki/Southern_strategy), where a large cohort of historically Democratic southern segregationists switched to the Republican party, reversing the conservative/liberal poles and laying the foundation for the modern (Rightist) GOP.
The US has been on a protracted slide towards social-liberal values since the late 1950s, in part due to post-WW-II ideology which held the US as the primary source and protector of (small 'd') democratic values for the world at large. Put simply, the idea that the US protected the weak against oppression solidified in the American consciousness, and that attitude contributed to the successes of the Civil Rights movement, Feminism, gay rights, union movements, and other ostensibly leftist (social-liberal) projects. Conservatives — or more specifically, fundamentalist Christians, economic (free market) adventurists, and white ethno-nationalists, all for very different reasons — have been fighting rear-guard actions against these sociopolitical changes, trying to preserve elements of the 1950s social order. They all pulled together under the GOP 'Big Tent' sometime in the 70s or early 80s (certainly by the era of the [Moral Majority](https://en.wikipedia.org/wiki/Moral_Majority) movement), despite having little in common except their opposition to progressive social changes.
It isn't that the Democrats have been pushing the nation to the left. The nation as a whole has been moving somewhat left: towards a more secular, technological, cosmopolitan society. The Democratic party has followed that trend while the GOP has steadfastly rejected it.
Up to this point, we see the normal push-me-pull-you struggle between progressivism and conservatism, a struggle that normally slows down change to a manageable level without really stopping it. However, the modern aggrieved political polarization is best described as an advancing [decompensation](https://en.wikipedia.org/wiki/Decompensation#Psychology) on the fringes of the far Right over their repeated failures to stop or reverse these social changes. I mean, there are always those who decompensate in society, effectively losing connection with reality and retreating into an enclosed bubble where they can maintain an alternate version of reality. Think the [Branch Davidians](https://en.wikipedia.org/wiki/Branch_Davidians), various New Age cults, the isolationist militia movements of the 80s and 90s, the odd and sundry revolutionary groups that have popped up over the years... But beginning with the collapse of the HW Bush administration (under the mortgage lending crisis) and the nomination and then election of an African American president, large segments of the far Right lost their footing in reality under the stress, insisting that how *they* viewed the US was reality, and that the Democrats and liberals must have done something horrible to make the US *not* fit the way the Right perceives it. Add the FOX Network's propaganda paradigm and the tendency of social media to fracture into like-minded enclaves, and perfect conditions were created for a persistent, globally-scaled decompensation.
In short, the far Right now insists that *their* perspective is true and right, even if it involves Satan worshiping pedophiles, Jewish space lasers, massive undetectable election fraud, and secret nefarious plots lying behind a global pandemic. And they've reduced themselves to obstructionist, unfocussed guerrilla tactics. It isn't that they've 'maxed out' on Rightist ideology, but more that they've lost themselves in such a thoroughly alternate reality that conventional Rightist ideology is too much part of the real world that they are rejecting. They cannot **be** old-school Rightists without acknowledging that the ongoing social changes are (small 'd') democratically legitimate, and they cannot accept the legitimacy of these changes. So *conventional* Rightism has to go with all the rest. | I think it's pretty clear that they are. What policy issues have Republicans and the right conclusively won in the past ~100 years? Pretty much just gun rights as far as I can tell, and even there one can make an argument they've lost at least some ground. Abortion, gay marriage, the welfare state, drug legalization, environmentalism, healthcare, all of these topics have seen right wing defeats over and over again. |
66,503 | I watched a [video](https://www.youtube.com/watch?v=mICxKmCjF-4) that said that Republicans pushed the nation to the right. But I am getting the sense that Republicans are in a sense "maxed out" in pushing to the right ideologically.
Are Democrats moving left pushing the United States as a whole to the left? | 2021/07/18 | [
"https://politics.stackexchange.com/questions/66503",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/29035/"
] | That would depend entirely on what you mean by left and right.
If you wanted to measure "push to the right" in terms of, say "fiscal responsibility", it is trivial to find plenty of people who will argue that the GOP did not push the USA to the right in the slightest.
If you look at the ACA and it's acceptance by a majority of Americans, it can easily be argued to represent how Democrats pushed the USA to the left.
And plenty of examples to argue the opposite exist.
What truly happened is that there has been a significant shift in values of the GOP, where it has embraced some more extremist elements. Calling the integration of these extremist elements, which are ranging from Tea Party to QAnon - with Proud Boys and others in between - "Pushed to the right" is one way to look at it. But if you define the political right as traditional Conservatives, I'd argue the GOP and the USA as a whole has drifted away from them.
At the same time, there has been a comparatively smaller shift in values of the Democratic Party. Sure, you can break that down and pick some elements with which you can argue that it has moved to the left *on those elements*, but by focusing on others you could also argue the other way.
To complicate things further, if we look at right/left as purely conservative/progressive, the simplified goal of conservatives is not to change things "back" to some mythical past\*, but to preserve things as they are, while the goal of progressives is to embrace change. In theory, whenever progressives establish a change that does work (e.g. ACA), within a few years it will be conservatives fighting to preserve that change. Which makes it near impossible to undisputedly claim a country moved more to the left, or to the right, absent a truly earth shattering shift in public sentiment.
---
\*1. [that's not being conservative](https://www.openculture.com/2018/10/yale-professor-jason-stanley-identifies-three-essential-features-of-fascism.html), and 2. [it's disputed if that's right wing or not](https://politics.stackexchange.com/questions/24665/is-fascism-left-or-right-wing). | It is a bit misguided to cast this as a Republican/Democrat issue, since the origins of it go back before the [Southern Strategy](https://en.wikipedia.org/wiki/Southern_strategy), where a large cohort of historically Democratic southern segregationists switched to the Republican party, reversing the conservative/liberal poles and laying the foundation for the modern (Rightist) GOP.
The US has been on a protracted slide towards social-liberal values since the late 1950s, in part due to post-WW-II ideology which held the US as the primary source and protector of (small 'd') democratic values for the world at large. Put simply, the idea that the US protected the weak against oppression solidified in the American consciousness, and that attitude contributed to the successes of the Civil Rights movement, Feminism, gay rights, union movements, and other ostensibly leftist (social-liberal) projects. Conservatives — or more specifically, fundamentalist Christians, economic (free market) adventurists, and white ethno-nationalists, all for very different reasons — have been fighting rear-guard actions against these sociopolitical changes, trying to preserve elements of the 1950s social order. They all pulled together under the GOP 'Big Tent' sometime in the 70s or early 80s (certainly by the era of the [Moral Majority](https://en.wikipedia.org/wiki/Moral_Majority) movement), despite having little in common except their opposition to progressive social changes.
It isn't that the Democrats have been pushing the nation to the left. The nation as a whole has been moving somewhat left: towards a more secular, technological, cosmopolitan society. The Democratic party has followed that trend while the GOP has steadfastly rejected it.
Up to this point, we see the normal push-me-pull-you struggle between progressivism and conservatism, a struggle that normally slows down change to a manageable level without really stopping it. However, the modern aggrieved political polarization is best described as an advancing [decompensation](https://en.wikipedia.org/wiki/Decompensation#Psychology) on the fringes of the far Right over their repeated failures to stop or reverse these social changes. I mean, there are always those who decompensate in society, effectively losing connection with reality and retreating into an enclosed bubble where they can maintain an alternate version of reality. Think the [Branch Davidians](https://en.wikipedia.org/wiki/Branch_Davidians), various New Age cults, the isolationist militia movements of the 80s and 90s, the odd and sundry revolutionary groups that have popped up over the years... But beginning with the collapse of the HW Bush administration (under the mortgage lending crisis) and the nomination and then election of an African American president, large segments of the far Right lost their footing in reality under the stress, insisting that how *they* viewed the US was reality, and that the Democrats and liberals must have done something horrible to make the US *not* fit the way the Right perceives it. Add the FOX Network's propaganda paradigm and the tendency of social media to fracture into like-minded enclaves, and perfect conditions were created for a persistent, globally-scaled decompensation.
In short, the far Right now insists that *their* perspective is true and right, even if it involves Satan worshiping pedophiles, Jewish space lasers, massive undetectable election fraud, and secret nefarious plots lying behind a global pandemic. And they've reduced themselves to obstructionist, unfocussed guerrilla tactics. It isn't that they've 'maxed out' on Rightist ideology, but more that they've lost themselves in such a thoroughly alternate reality that conventional Rightist ideology is too much part of the real world that they are rejecting. They cannot **be** old-school Rightists without acknowledging that the ongoing social changes are (small 'd') democratically legitimate, and they cannot accept the legitimacy of these changes. So *conventional* Rightism has to go with all the rest. |
66,503 | I watched a [video](https://www.youtube.com/watch?v=mICxKmCjF-4) that said that Republicans pushed the nation to the right. But I am getting the sense that Republicans are in a sense "maxed out" in pushing to the right ideologically.
Are Democrats moving left pushing the United States as a whole to the left? | 2021/07/18 | [
"https://politics.stackexchange.com/questions/66503",
"https://politics.stackexchange.com",
"https://politics.stackexchange.com/users/29035/"
] | That would depend entirely on what you mean by left and right.
If you wanted to measure "push to the right" in terms of, say "fiscal responsibility", it is trivial to find plenty of people who will argue that the GOP did not push the USA to the right in the slightest.
If you look at the ACA and it's acceptance by a majority of Americans, it can easily be argued to represent how Democrats pushed the USA to the left.
And plenty of examples to argue the opposite exist.
What truly happened is that there has been a significant shift in values of the GOP, where it has embraced some more extremist elements. Calling the integration of these extremist elements, which are ranging from Tea Party to QAnon - with Proud Boys and others in between - "Pushed to the right" is one way to look at it. But if you define the political right as traditional Conservatives, I'd argue the GOP and the USA as a whole has drifted away from them.
At the same time, there has been a comparatively smaller shift in values of the Democratic Party. Sure, you can break that down and pick some elements with which you can argue that it has moved to the left *on those elements*, but by focusing on others you could also argue the other way.
To complicate things further, if we look at right/left as purely conservative/progressive, the simplified goal of conservatives is not to change things "back" to some mythical past\*, but to preserve things as they are, while the goal of progressives is to embrace change. In theory, whenever progressives establish a change that does work (e.g. ACA), within a few years it will be conservatives fighting to preserve that change. Which makes it near impossible to undisputedly claim a country moved more to the left, or to the right, absent a truly earth shattering shift in public sentiment.
---
\*1. [that's not being conservative](https://www.openculture.com/2018/10/yale-professor-jason-stanley-identifies-three-essential-features-of-fascism.html), and 2. [it's disputed if that's right wing or not](https://politics.stackexchange.com/questions/24665/is-fascism-left-or-right-wing). | I think it's pretty clear that they are. What policy issues have Republicans and the right conclusively won in the past ~100 years? Pretty much just gun rights as far as I can tell, and even there one can make an argument they've lost at least some ground. Abortion, gay marriage, the welfare state, drug legalization, environmentalism, healthcare, all of these topics have seen right wing defeats over and over again. |
41,130,231 | There might come some follow up questions for this (and yes this is homework), but we have to solve a maze in my Java programming class (complete beginner) with using a recursive method. Now my problem is not the actual solving (yet, I am sure it will soon be my problem), but the fact that we have been given a part of the code by the teacher and there is some stuff in it that I have absolutely no clue what it is, or what it means.
Yes, I could ask my teacher, but I really don't like this guy and I am really just trying to learn Java and get some college credit points.
```
public class MazeSolver {
public static void main(String[] args) {
int[][] mArr = {
{2, 1, 1, 1, 0, 1, 1, 1},
{1, 1, 0, 1, 0, 1, 1, 0},
{0, 1, 1, 0, 1, 1, 1, 1},
{0, 0, 1, 1, 1, 0, 1, 0},
{1, 0, 0, 0, 1, 0, 1, 1},
{0, 0, 0, 0, 1, 1, 0, 1},
{0, 0, 0, 0, 0, 1, 1, 3}
};
boolean result = solve(mArr, 0, 0); // i = 0, j = 0: Point of entry in the upper left corner
String str = (result) ? "" : " nicht";
System.out.println("Das Labyrinth ist" + str + " loesbar");
}
static boolean solve(int[][] mArr, int i, int j) {
return false;
}
static void print(int[][] mArr) {
System.out.println();
for (int[] arr : mArr) {
for (int n : arr) {
System.out.print(n + " ");
}
System.out.println();
}
System.out.println();
}
}
```
Ok, so my problem is this line: boolean result = solve(mArr, 0, 0); // i = 0, j = 0: Point of entry in the upper left corner .
I am assuming this means that result is the result of the method which I am still to define, but what is `(mArr, 0, 0)`? I am guessing that is supposed to give the location in the maze but I thought that a location in an array is i.e. `mArr [0][0]`. And how does the program know that 0 and 0 is i and j or is that something that I need to tell it at some point? | 2016/12/13 | [
"https://Stackoverflow.com/questions/41130231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4311126/"
] | It seems that there is a `Zoomed` type family that is used to specify what kind of "effect" we will have when we zoom. In some cases, the `Zoomed` type instance for a monad transformer appears to piggyback on the `Zoomed` for the underlying monad, for example
```
type Zoomed (ReaderT * e m) = Zoomed m
```
Given that `Alteration` and `BufAction` are just newtypes over a state transformer, perhaps we could do the same:
```
{-# language TypeFamilies #-}
{-# language UndecidableInstances #-}
{-# language MultiParamTypeClasses #-}
type instance Zoomed BufAction = Zoomed (StateT Buffer IO)
```
Then we must provide the `Zoom` instance. `Zoom` is a multi-parameter typeclass and the four parameters seem to be *original monad*, *zoomed out monad*, *original state*, *zoomed out state*:
```
instance Zoom BufAction Alteration Buffer Store where
zoom f (BufAction a) = Alteration (zoom f a)
```
We just unwrap `BufAction`, zoom with the underlying monad, and wrap as `Alteration`.
This basic test typechecks:
```
foo :: Alteration ()
foo = zoom (editor.buffers.traversed) (return () :: BufAction ())
```
---
I believe you could avoid defining the `Zoom` instance and have a special-purpose `zoomBufActionToAlteration` function
```
zoomBufActionToAlteration :: LensLike' (Zoomed (StateT Buffer IO) a) Store Buffer
-> BufAction a
-> Alteration a
zoomBufActionToAlteration f (BufAction a) = Alteration (zoom f a)
```
But then if you have a lot of different zoomable things it can be a chore to remember the name of each zoom funcion. That's where the typeclass can help. | As additional to the answer @danidiaz.
---
Basically, you can avoid `Zoom` instance by this way:
```
bufDo :: BufAction () -> Alteration ()
bufDo = Alteration . zoom (editor . buffers . traverse) . runBufAction
``` |
10,505,139 | I want to give users some formatting options like Reddit or stackOverFlow do, but want to keep it in PHP. How can parse a string in PHP such that it recognizes patterns like `**[anything here]**`?
explode() doesn't seem to solve the problem as elegantly as I'd like. Should I just use nested ifs and fors based on explode()'s output? Is there a better solution here? | 2012/05/08 | [
"https://Stackoverflow.com/questions/10505139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1382662/"
] | This has already been done countless times by others, I'd recommend using existing libraries.
For example, you can use Markdown: <http://michelf.com/projects/php-markdown/> | Check regular expressions:
```
$string = '*bold* or _underscored_ or even /italic/ ..';
// italic
$string = preg_replace('~/([^/]+)/~', '<i>$1</i>', $string);
// bold
$string = preg_replace('/\*([^\*]+)\*/', '<b>$1</b>', $string);
// underscore
$string = preg_replace('/_([^_]+)_/', '<u>$1</u>', $string);
echo $string;
```
output:
```
<b>bold</b> or <u>underscored</u> or even <i>italic</i> ..
```
or use a BBCode parser. |
32,989,494 | I have a json string as shown below
```
{
"college": {
"id": "RPD4007",
"address": "#302, 1 st cross"
},
"deparment": {
"department1": {
"name": {
"maths": {
"chapter": 1,
"name": "algebra",
"module_id": "01"
},
"electronics": {
"chapter": 1,
"name": "ec",
"module_id": "01"
}
}
},
"department2": {
"name": {
"english": {
"chapter": 2,
"name": "algebra",
"module_id": "02"
},
"electrical": {
"chapter": 2,
"name": "algebra",
"module_id": "02"
}
}
}
}
}
```
I have tried to convert this json sring to json object ,
```
string json_string = EntityUtils.toString(response.getEntity());
jObj = new JSONObject(json_string);//json object
JSONObject object = jobj.getJSONObject("college");
```
But the jobj output I got is in reverse order of json string .Like below,
```
{
"college": {
"id": "RPD4007",
"address": "#302, 1 st cross"
},
"deparment": {
"department2": {
"name": {
"electrical": {
"chapter": 2,
"name": "algebra",
"module_id": "02"
},
"english": {
"chapter": 2,
"name": "algebra",
"module_id": "02"
}
}
},
"department1": {
"name": {
"electronics": {
"chapter": 1,
"name": "ec",
"module_id": "01"
},
"maths": {
"chapter": 1,
"name": "algebra",
"module_id": "01"
}
}
}
}
}
```
How to get it in same order as it is? | 2015/10/07 | [
"https://Stackoverflow.com/questions/32989494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4136289/"
] | I think you are making jsonObject for two times.
Just do something like this
you have String that contains JSON DATA
Make an object for that which you did
```
string json_string = EntityUtils.toString(response.getEntity());
jObj = new JSONObject(json_string);//json object
```
then make a loop to get the object inside that object using
```
String college = jobj.getString("college");
``` | The answers here: [JSON order mixed up](https://stackoverflow.com/a/4920304/4201441)
As a consequence, JSON libraries are free to rearrange the order of the elements as they see fit. This is not a bug. |
3,657,996 | I encountered a exercise problem listed below:
The probability that a driver will have an accident in 1 month is 0.02. Find the probability that he will have 3 accidents in 100 months.
I am thinking of a random variable that will best describe the situation. It seems that I should pick exponential random variable, but it looks like can also be a pdf with linear function of time. Can anyone tell me what is the best choice to model this situation? | 2020/05/04 | [
"https://math.stackexchange.com/questions/3657996",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/676553/"
] | Let $X\_i$ describe "having an accident the $i$th month". It's a Bernoulli B(0.02). Set $$S\_{100}=X\_1+...+X\_{100}.$$
$S\_{100}$ is a binomial $Bin(100,0.02)$. You wish to estimate
$$\mathbb P(S\_{100}=3).$$
That can be compute brute force, or using Poisson approximation. | Thank Lulu for give me hints about how to proceed with Poisson random variable
I am using Poisson Random Variable to solve this problem (will attempt using Binomial brute force method later)
Given that
$$p\_{X}(1)=e^{-\lambda }\frac{\lambda ^{1}}{1!}=0.02$$
We are looking for the probability when n = 100, k=3, $\lambda=np = 2$
$$p\_{X}(100)=e^{-2}\frac{2 ^{3}}{3!}\approx 0.18$$
Using Binomial approximation with $\lambda=np=2, n=100, k=3, p=0.02$ we have
$$\frac{n!}{k!(n-k)!}p^{k}(1-p)^{n-k}=\frac{100!}{3!97!}(0.02)^{3}(0.98)97\approx 0.18$$ |
3,657,996 | I encountered a exercise problem listed below:
The probability that a driver will have an accident in 1 month is 0.02. Find the probability that he will have 3 accidents in 100 months.
I am thinking of a random variable that will best describe the situation. It seems that I should pick exponential random variable, but it looks like can also be a pdf with linear function of time. Can anyone tell me what is the best choice to model this situation? | 2020/05/04 | [
"https://math.stackexchange.com/questions/3657996",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/676553/"
] | This answer is implementing the Binomial brute force method described above:
Let $X\_{i}$ be number of accidents in a month, and we have
$$p\_{X\_{i}}(k)=\frac{n!}{k!(n-k)!}p^{k}(1-p)^{n-k}$$
Also, we are given that $p\_{X\_{1}}(1)=\frac{1!}{1!(1-1)!}p^{1}(1-p)^{0}=p=0.02$
We are looking for $S\_{100}=X\_{1}+X\_{2}+...+X\_{100}$
$$P(S\_{100}=k)=\binom{100}{k}p^{k}(1-p)^{n-k}$$
With k=3,
$$P(S\_{100}=3)=\binom{100}{3}(0.02)^{3}(0.98)^{97}=0.18$$
Using poisson approximation for Binomial random variable, we have:
$$\lim\_{n\rightarrow \infty }\binom{100}{k}p^{k}(1-p)^{n-k}=\frac{\lambda ^{k}e^{-\lambda }}{k!}=\frac{2 ^{3}e^{-2}}{3!}=0.18$$ | Thank Lulu for give me hints about how to proceed with Poisson random variable
I am using Poisson Random Variable to solve this problem (will attempt using Binomial brute force method later)
Given that
$$p\_{X}(1)=e^{-\lambda }\frac{\lambda ^{1}}{1!}=0.02$$
We are looking for the probability when n = 100, k=3, $\lambda=np = 2$
$$p\_{X}(100)=e^{-2}\frac{2 ^{3}}{3!}\approx 0.18$$
Using Binomial approximation with $\lambda=np=2, n=100, k=3, p=0.02$ we have
$$\frac{n!}{k!(n-k)!}p^{k}(1-p)^{n-k}=\frac{100!}{3!97!}(0.02)^{3}(0.98)97\approx 0.18$$ |
63,931,616 | I am doing colab, and I found something weird see this:
pd.head()
[](https://i.stack.imgur.com/kSo3v.png)
But I want to do like this:
[](https://i.stack.imgur.com/Gue6H.png)
Any solution for this problem?
Thank you! | 2020/09/17 | [
"https://Stackoverflow.com/questions/63931616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5027619/"
] | Unless you are printing a dataframe using `print` google colab automatically displays the data in table format. If in some cases it doesn't you can force it to show using [`display`](https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html)
You can use `display` form ipython to print mutiple tables.
```
from IPython.display import HTML, display
display(df1)
display(df2)
```
[](https://i.stack.imgur.com/xHyOn.png)
You can also use `google.colab.data_table` extension to show a table with more functionality.
```
%load_ext google.colab.data_table
from IPython.display import HTML, display
display(df1)
display(df2)
```
[](https://i.stack.imgur.com/p0tlu.png) | Add:
At the first time %load\_ext google.colab.data\_table doesn't work.
So do `%load_ext google.colab.data_table` first,
And fo `%unload_ext google.colab.data_table`
then do `pd.head()` will works well ! |
19,598,262 | I've been struggling to install jekyll on my mac, don't know much about ruby or configuring/debugging these messages.
I'm getting the following when running "sudo gem install jekyll"
```
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR="
make: *** No rule to make target `/include/universal-darwin13/ruby/config.h', needed by `porter.o'. Stop.
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/fast-stemmer-1.0.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/fast-stemmer-1.0.2/ext/gem_make.out
```
"gcc --version" returns the following:
```
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
``` | 2013/10/25 | [
"https://Stackoverflow.com/questions/19598262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2023195/"
] | use this command :
```
$ sudo xcode-select -r
```
then
```
$ sudo gem install jekyll
```
Hope this help you. | Besides upgrading xcode, as rayrashmi suggested, you have to actually *open* it so the command-line tools are properly installed.
(I am assuming you installed the command-line tools from xcode before upgrading to mavericks, if you haven't they're under `Preferences → Downloads → Components`, [official info here](http://jekyllrb.com/docs/installation/).)
Then, just upgrade gem if you haven't already done so and install jekyll and any other library you were using, like pigments.
As they say, "worked for me." |
309,857 | I have ubuntu 12.10 and I can't play dvd movies. I tried every kmplayer vlc gnomeVLC could not read the file (Input/output error).
```
File reading failed:
VLC could not read the file (Input/output error).
File reading failed:
VLC could not read the file (Input/output error).
Your input can't be opened:
VLC is unable to open the MRL 'dvd:///media/ahsidddiqui/Ubuntu%20OEM%2012.10%20amd64%20UALinux/'. Check the log for details.
Your input can't be opened:
VLC is unable to open the MRL 'dvd:///media/ahsidddiqui/Ubuntu%20OEM%2012.10%20amd64%20UALinux/'. Check the log for details.
``` | 2013/06/18 | [
"https://askubuntu.com/questions/309857",
"https://askubuntu.com",
"https://askubuntu.com/users/168327/"
] | This might be caused by not having the correct codecs installed. To be able to play DVDs on Ubuntu, there are a few things you need to do first:
1. Install `ubuntu-restricted-extras`, either through the software center or the terminal using the following command: `sudo apt-get install ubuntu-restricted-extras`
2. Install libdvdcss using the following command in the terminal:
`sudo /usr/share/doc/libdvdread4/install-css.sh`
You can read more about playing DVDs on the [Community Help Wiki](https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs) | You need Medibuntu for this - here is documentation - what to do :
<https://help.ubuntu.com/community/Medibuntu> |
309,857 | I have ubuntu 12.10 and I can't play dvd movies. I tried every kmplayer vlc gnomeVLC could not read the file (Input/output error).
```
File reading failed:
VLC could not read the file (Input/output error).
File reading failed:
VLC could not read the file (Input/output error).
Your input can't be opened:
VLC is unable to open the MRL 'dvd:///media/ahsidddiqui/Ubuntu%20OEM%2012.10%20amd64%20UALinux/'. Check the log for details.
Your input can't be opened:
VLC is unable to open the MRL 'dvd:///media/ahsidddiqui/Ubuntu%20OEM%2012.10%20amd64%20UALinux/'. Check the log for details.
``` | 2013/06/18 | [
"https://askubuntu.com/questions/309857",
"https://askubuntu.com",
"https://askubuntu.com/users/168327/"
] | For Ubuntu `16.04` i needed to do some more. I needed to install `libdvdread4` and `libdvdcss` The first one can be installed through `apt`. For the latter one the installation steps are written in detail in
`/usr/share/doc/libdvdread4/README.css` or [here](https://www.videolan.org/developers/libdvdcss.html). After adding these two libs i was able to play original dvd`s on my laptop. | You need Medibuntu for this - here is documentation - what to do :
<https://help.ubuntu.com/community/Medibuntu> |
309,857 | I have ubuntu 12.10 and I can't play dvd movies. I tried every kmplayer vlc gnomeVLC could not read the file (Input/output error).
```
File reading failed:
VLC could not read the file (Input/output error).
File reading failed:
VLC could not read the file (Input/output error).
Your input can't be opened:
VLC is unable to open the MRL 'dvd:///media/ahsidddiqui/Ubuntu%20OEM%2012.10%20amd64%20UALinux/'. Check the log for details.
Your input can't be opened:
VLC is unable to open the MRL 'dvd:///media/ahsidddiqui/Ubuntu%20OEM%2012.10%20amd64%20UALinux/'. Check the log for details.
``` | 2013/06/18 | [
"https://askubuntu.com/questions/309857",
"https://askubuntu.com",
"https://askubuntu.com/users/168327/"
] | This might be caused by not having the correct codecs installed. To be able to play DVDs on Ubuntu, there are a few things you need to do first:
1. Install `ubuntu-restricted-extras`, either through the software center or the terminal using the following command: `sudo apt-get install ubuntu-restricted-extras`
2. Install libdvdcss using the following command in the terminal:
`sudo /usr/share/doc/libdvdread4/install-css.sh`
You can read more about playing DVDs on the [Community Help Wiki](https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs) | For Ubuntu `16.04` i needed to do some more. I needed to install `libdvdread4` and `libdvdcss` The first one can be installed through `apt`. For the latter one the installation steps are written in detail in
`/usr/share/doc/libdvdread4/README.css` or [here](https://www.videolan.org/developers/libdvdcss.html). After adding these two libs i was able to play original dvd`s on my laptop. |
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 10