qid
int64
1
74.7M
question
stringlengths
15
55.4k
date
stringlengths
10
10
metadata
sequencelengths
3
3
response_j
stringlengths
2
32.4k
response_k
stringlengths
9
40.5k
45,003,631
I have a column where a date store in ddmmyy format (e.g. 151216). How can I convert it to yyyy-mm-dd format (e.g 2016-12-15) for calculating a date difference from the current date? I try using DATE\_FORMAT function but its not appropriate for this.
2017/07/10
[ "https://Stackoverflow.com/questions/45003631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2231075/" ]
If you want to get the date difference, you can use `to_days()` after converting the string to a date using `str_to_date()`: ``` select to_days(curdate()) - to_days(str_to_date(col, '%d%m%y')) ``` or `datediff()`: ``` select datediff(curdate(), str_to_date(col, '%d%m%y')) ``` or `timestampdiff()`: ``` select timestampdiff(day, str_to_date(col, '%d%m%y'), curdate()) ```
You can use the function, `STR_TO_DATE()` for this. ``` STR_TO_DATE('151216', '%d%m%y') ``` A query would look something like: ``` select foo.bar from foo where STR_TO_DATE(foo.baz, '%d%m%y') < CURDATE() ``` Note: Since both `STR_TO_DATE()` and `CURDATE()` return date objects, there's no reason to change the actual display format of the date. For this function, we just need to format it. If you wanted to display it in your query, you could use something like ``` DATE_FORMAT(STR_TO_DATE(foo.baz, '%d%m%y'), '%Y-%m-%d') ``` To get the difference, we can simply subtract time ``` select to_days(CURDATE() - STR_TO_DATE(foo.baz, '%d%m%y')) as diff from foo ``` If you wanted to only select rows that have a difference of a specified amount, you can put the whole `to_days(...)` bit in your where clause.
45,003,631
I have a column where a date store in ddmmyy format (e.g. 151216). How can I convert it to yyyy-mm-dd format (e.g 2016-12-15) for calculating a date difference from the current date? I try using DATE\_FORMAT function but its not appropriate for this.
2017/07/10
[ "https://Stackoverflow.com/questions/45003631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2231075/" ]
You can use the function, `STR_TO_DATE()` for this. ``` STR_TO_DATE('151216', '%d%m%y') ``` A query would look something like: ``` select foo.bar from foo where STR_TO_DATE(foo.baz, '%d%m%y') < CURDATE() ``` Note: Since both `STR_TO_DATE()` and `CURDATE()` return date objects, there's no reason to change the actual display format of the date. For this function, we just need to format it. If you wanted to display it in your query, you could use something like ``` DATE_FORMAT(STR_TO_DATE(foo.baz, '%d%m%y'), '%Y-%m-%d') ``` To get the difference, we can simply subtract time ``` select to_days(CURDATE() - STR_TO_DATE(foo.baz, '%d%m%y')) as diff from foo ``` If you wanted to only select rows that have a difference of a specified amount, you can put the whole `to_days(...)` bit in your where clause.
``` SELECT STR_TO_DATE('151216', '%d%m%y') FROM `table` ``` use this '%d%m%y'
45,003,631
I have a column where a date store in ddmmyy format (e.g. 151216). How can I convert it to yyyy-mm-dd format (e.g 2016-12-15) for calculating a date difference from the current date? I try using DATE\_FORMAT function but its not appropriate for this.
2017/07/10
[ "https://Stackoverflow.com/questions/45003631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2231075/" ]
If you want to get the date difference, you can use `to_days()` after converting the string to a date using `str_to_date()`: ``` select to_days(curdate()) - to_days(str_to_date(col, '%d%m%y')) ``` or `datediff()`: ``` select datediff(curdate(), str_to_date(col, '%d%m%y')) ``` or `timestampdiff()`: ``` select timestampdiff(day, str_to_date(col, '%d%m%y'), curdate()) ```
``` SELECT STR_TO_DATE('151216', '%d%m%y') FROM `table` ``` use this '%d%m%y'
31,648,275
I need to serialize a object class: ``` public class DigitalInput { private String id; private Date timestamp; private String matter; private String comment; private String channelId; private List<IndexableProperty> otherProps; ... } ``` And I receive this JSON: ``` { "timestamp":"2015-07-27T10:47:53.765Z", "matter":"aleatory-1", "comment":"aleatory comment-1", "channelId":null, "property_aleatoryString":"account-1@domain.com", "property_aleatoryNumber":6.3573580981989274E17, "property_aleatoryDouble":1.2, "property_aleatoryDate":"2015-07-27T08:03:01.9892765Z" } ``` So, I need to set all property\_\* properties inside the otherProps list as `IndexableProperty` objects. I've created a Deserializer to do that: ``` public class DigitalInputDeserializer extends JsonDeserializer<DigitalInput> { @Override public DigitalInput deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = p.getCodec().readTree(p); String id = node.get("_id").asText(); Date timestamp = Instant.parse(node.get("timestamp").asText()).toDate(); String matter = node.get("matter").asText(); String description = node.get("comment").asText(); String channelId = node.get("channelId").asText(); ... // I don't know how to deserialize property_* like fields in a list return new DigitalInput(id, channelId, timestamp, matter, description); } } ``` **EDIT** I've added next, the configuration of ObjectMapper: ``` @ApplicationScoped public class JacksonApplicationResources { protected ObjectMapper mapper; @PostConstruct protected void initialize_resources() throws IllegalStateException { this.mapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); // Chanel module.addDeserializer(Channel.class, new ChannelDeserializer()); module.addSerializer(Channel.class, new ChannelSerializer()); module.addDeserializer(DigitalInput.class, new DigitalInputDeserializer()); module.addSerializer(DigitalInput.class, new DigitalInputSerializer()); this.mapper.registerModule(module); } public ObjectMapper getMapper() { return this.mapper; } } ```
2015/07/27
[ "https://Stackoverflow.com/questions/31648275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3227319/" ]
Have you look at `Multibinder`? This is example directly from [API](http://google.github.io/guice/api-docs/latest/javadoc/com/google/inject/multibindings/Multibinder.html) ``` public class SnacksModule extends AbstractModule { protected void configure() { Multibinder<Snack> multibinder = Multibinder.newSetBinder(binder(), Snack.class); multibinder.addBinding().toInstance(new Twix()); multibinder.addBinding().toProvider(SnickersProvider.class); multibinder.addBinding().to(Skittles.class); } } ```
If you wanted to do something like this: ``` baseClass obj1; obj1.add(new classAbc); obj2.add(new classDef); bind(interface1.class).toInstance(obj1); ``` You could, but only if your `baseClass` is of the *Composite pattern* (where objects can also act as containers for other objects). Otherwise, you'll need to provide your alternatives in another container, like a List: ``` List<Interface1> interfaceList = new ArrayList<>(); interfaceList.add(new classAbc()); interfaceList.add(new classDef()); bind(new TypeLiteral<List<Interface1>>() {}).toInstance(interfaceList); ``` Though with that solution above: 1. It won't pick up on dependencies of implementors `classAbc`, `classDef`, etc. 2. It creates all of these dependencies pre-emptively, whether they're needed or not. 3. The list is mutable, so someone else can affect the permanently-kept list. Instead, a manual simulation of Multibinding might look like this [untested]: ``` public class YourModule extends AbstractModule { @Override public void configure() {} @Provides Set<Interface1> createSet(ClassAbc abc, ClassDef def) { return ImmutableSet.of(abc, def); } // Provider<ClassAbc> can't usually be cast to Provider<Interface1> @SuppressWarnings @Provides Set<Provider<Interface1>> createProviderSet( Provider<ClassAbc> abc, Provider<ClassDef> def) { return ImmutableSet.of( (Provider<Interface1>) abc, (Provider<Interface1>) def); } } ```
26,731,856
Our parallel Fortran program is running more than twice slower after updating the OS to Ubuntu 14.04 and rebuilding with Gfortran 4.8.2. To measure which parts of the code were slowed down is unfortunately not possible any more (not without downgrading the OS) since I did not save any profiling information for gprof when compiling under the old OS. Because the program does lots of matrix inversions, my guess is that one library (LAPACK?) or programming interface (OpenMP?) has been updated between Ubuntu 12 and 14 in a way that slows down everything. I believe this is a general problem which could be already known to somebody here. Which is the solution to get back to a fast Fortran code, besides downgrading back to Ubuntu 12 or 13? All libraries were installed from the repositories with apg-get and thus,they should have be also upgraded when I upgraded the system with `apt-get dist-upgrade`, I could, however, check if they are indeed the latest versions and/or build them from scratch. I followed Steabert's advice and profiled the present code: I recompiled with `gfortran -pg` and checked the performance with `gprof`. The program was suspiciously slow when calling some old F77 subroutines, which I translated to f90 without performance improvement. I played with the suggested flags and compared the time of one program iteration: Flags `-fno-aggressive-loop-optimizations`, `-llapack` and `-lblas` did not yield any significant performance improvement. Flags `-latlas`, `-llapack_latlas` and `-lf77blas` did not compile (`/usr/bin/ld: cannot find -lf77blas`, etc.), even though the libraries exist and are in the right path. Both the compiler flags playing and performance analysis suggest that my first guess (the slowing down being related to matrix inversions, LAPACK, etc.) was wrong. It rather seems that the slowing down is in a part of the code where no heavy linear algebra is performed. Using `objdump my_exec -s` I have found out that my program was originally compiled with gfortran 4.6.3 before the OS upgrade. Instead of using the present gfortran (4.8.2). I could try now to compile the code with the old compiler.
2014/11/04
[ "https://Stackoverflow.com/questions/26731856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4213557/" ]
Probably this is not 100% a satisfactory answer, but it solved my performance problem. So here it is: I decided to use GDB (Valgrid did not work for me): I compiled with the flag -g, executed with “gdb myprogramname”, typed “run” in the GDB prompt to execute the program, paused with ctr+C, checked what the threads were doing with “info threads” and continued with “continue”. I did this several times, randomly, to make some kind of statistic where the program was spending most of the time. This soon confirmed what gprof found before, i.e., that my program was investing lots of time in the function I translated to f90. However, now I also found out that the mathematical operation which was taking particularly long time inside this function was exponentiation, as suggested by the call to the C function e\_powf.c. My function (the equation of state of sea water) has lots of high order polynomials with terms like `T**3`, `T**4`. To avoid calling e\_powf.c and see if this improved the performance of the code I changed all the terms of the type `T**2` to `T*T`; `T**3` to `T*T*T`, etc. Here is a function's extract how it was before: ``` ! RW = 999.842594 + 6.793952E-2*T - 9.095290E-3*T**2+ 1.001685E-4*T**3 - 1.120083E-6*T**4 + 6.536332E-9*T**5 ``` and how it is now: ``` RW = 999.842594 + 6.793952E-2*T - 9.095290E-3*T*T+ 1.001685E-4*T*T*T - 1.120083E-6*T*T*T*T + 6.536332E-9*T*T*T*T*T ``` As a result, my program is running again twice as fast (i.e., like before I upgraded the OS). While this solves my performance problem, I cannot be 100% sure if it is really related to the OS upgrade or compiler change from 4.6.3 to 4.8.2. Though the present performance being similar to the pre-OS-upgrade really suggests it should be. Unfortunately, “locate e\_powf” does not yield any results in my system, it seems as if the function is a binary part of the gfortran compiler, but the source code is not given along. By googling, it seems that e\_powf.c itself does not seem to have been updated lately (I guess, by such occurrences in Internet like <http://koala.cs.pub.ro/lxr/#glibc/sysdeps/ieee754/flt-32/e_powf.c>), so if something changed from Ubuntu 12 to 14 or from gfortran 4.6.3 to 4.8.2 it seems rather something subtle in the way this function is used. Because I found in internet some discussions about if using `T*T` instead of `T**2` , etc should bring some performance improvement and most of the people seem skeptic about it (for instance: <http://computer-programming-forum.com/49-fortran/6b042075d8c77a4b.htm> ; or a closed question in stackoverflow: [Tips and tricks on improving Fortran code performance](https://stackoverflow.com/questions/7779701/tips-and-tricks-on-improving-fortran-code-performance)) I double checked my finding, so I can say I'm pretty much sure that using products of a variable (and avoiding like this calling e\_powf.c) is faster than exponentiation, at least with gfortran 4.8.2 (which ever the reason). Thanks a lot for all of you who commented, surely it helped me a lot and I learned plenty!
``` RW = 999.842594 + 6.793952E-2*T - 9.095290E-3*T*T+ 1.001685E-4*T*T*T - 1.120083E-6*T*T*T*T + 6.536332E-9*T*T*T*T*T ``` IF you need further improvement you can write above line as: ``` T2=T*T T3=T2*T T4=T3*T T5=T4*T RW=999.842594 + 6.793952E-2*T - 9.095290E-3*T2+ 1.001685E-4*T3 - 1.120083E-6*T4 + 6.536332E-9*T5 ```
20,742,668
The idea is to compare two jars and see if they were generated from same source and compare if they're identical at Binary/Byte code level. Also if they're both compiled with the same compiler i.e. Eclipse JDT or JIT etc compiler. I've looked at Apache Common BCEL, but it only does comparison after decomposing the original byte-code into source code and then it compares it like diff tool; that compares text line-byline, but what I would like is to compare the byte-code without being decomposed/rearranged to source code and then compare. I was looking at how we could compare straight binary/byte code comparison!!!! Free tools/API recommendation would be good :) Ta
2013/12/23
[ "https://Stackoverflow.com/questions/20742668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1257986/" ]
you may try any of these following jar comparator tool as based on yours requirement.. [extradata-product](http://www.extradata.com/products/jarc/) free for personal use [zardiff](http://zipdiff.sourceforge.net/) on sourceforge. [japi-compilance-checker](http://ispras.linuxbase.org/index.php/Java_API_Compliance_Checker) os based [pkgdiff](http://lvc.github.io/pkgdiff/)
I like to use Beyond Compare (beware that it is not a free application) <http://www.scootersoftware.com/>
72,734,474
Unable to load S3-hosted CSV into Spark Dataframe on Jupyter Notebook. I believe I uploaded the 2 required packages with the `os.environ` line below. If I did it incorrectly please show me how to correctly install it. The Jupyter Notebook is hosted on an EC2 instance, which is why I'm trying to pull the CSV from a S3 bucket. Here is my code: ``` import os import pyspark os.environ['PYSPARK_SUBMIT_ARGS'] = '--packages com.amazonaws:aws-java-sdk-pom:1.10.34,org.apache.hadoop:hadoop-aws:2.7.2 pyspark-shell' from pyspark.sql import SparkSession spark = SparkSession.builder.appName('test').getOrCreate() spark ``` Output: [![enter image description here](https://i.stack.imgur.com/QvCBh.png)](https://i.stack.imgur.com/QvCBh.png) Then i do: ``` %%time df = spark.read.csv(f"s3://{AWS_BUCKET}/prices/{ts}_all_prices_{user}.csv", inferSchema = True, header = True) ``` And i get an error of: ``` WARN FileStreamSink: Assume no metadata directory. Error while looking for metadata directory in the path: s3://blah-blah-blah/prices/1655999784.356597_blah_blah_blah.csv. org.apache.hadoop.fs.UnsupportedFileSystemException: No FileSystem for scheme "s3" ```
2022/06/23
[ "https://Stackoverflow.com/questions/72734474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713236/" ]
Here is an example using s3a. ```py import os import pyspark os.environ['PYSPARK_SUBMIT_ARGS'] = '--packages com.amazonaws:aws-java-sdk-pom:1.10.34,org.apache.hadoop:hadoop-aws:2.7.2 pyspark-shell' from pyspark.sql import SQLContext from pyspark import SparkContext sc = SparkContext() sqlContext = SQLContext(sc) filePath = "s3a://yourBucket/yourFile.parquet" df = sqlContext.read.parquet(filePath) # Parquet file read example ``` Here is a more complete example taken from [here](https://mageswaran1989.medium.com/2022-no-filesystem-for-scheme-s3-cbd72c99a50c) to build the spark session with required config. ```py from pyspark.sql import SparkSession def get_spark(): spark = SparkSession.builder.master("local[4]").appName('SparkDelta') \ .config("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension") \ .config("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog") \ .config("spark.hadoop.fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem") \ .config("spark.jars.packages", "io.delta:delta-core_2.12:1.1.0," "org.apache.hadoop:hadoop-aws:3.2.2," "com.amazonaws:aws-java-sdk-bundle:1.12.180") \ .getOrCreate() # This is mandate config on spark session to use AWS S3 spark._jsc.hadoopConfiguration().set("com.amazonaws.services.s3.enableV4", "true") spark._jsc.hadoopConfiguration().set("fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem") spark._jsc.hadoopConfiguration().set("fs.s3a.aws.credentials.provider","com.amazonaws.auth.InstanceProfileCredentialsProvider,com.amazonaws.auth.DefaultAWSCredentialsProviderChain") spark._jsc.hadoopConfiguration().set("fs.AbstractFileSystem.s3a.impl", "org.apache.hadoop.fs.s3a.S3A") # spark.sparkContext.setLogLevel("DEBUG") return spark ```
Try using `s3a` as protocol, you can find more details [here](https://hadoop.apache.org/docs/stable/hadoop-aws/tools/hadoop-aws/index.html). ``` df = spark.read.csv(f"s3a://{AWS_BUCKET}/prices/{ts}_all_prices_{user}.csv", inferSchema = True, header = True) ```
8,545,687
after upgrading to latest version of eclipse **Helios 3.6**, **M2E 1.0** , **WTP 3.2.5** and trying to run my maven project which uses **JSF 2.1.3** and **Spring 3** on **tomcat 7**, i am getting the following exception: ``` java.lang.ClassNotFoundException: javax.servlet.jsp.el.ImplicitObjectELResolver$ImplicitObjects$4 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523) at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2006) at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1969) at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1858) at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1826) at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1812) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1306) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148) at org.apache.catalina.startup.Catalina.start(Catalina.java:621) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450) java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:693) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:243) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Dec 17, 2011 4:56:04 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener java.lang.RuntimeException: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:693) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:243) ... 8 more ``` following is my configuration for maven: ``` <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.1.3</version> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>2.1.3</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> ``` am i missing a jar file, or using an incompatible version of a jar ? please advise, thanks. **UPDATE:** what i get so far is that i get the application to run fine by removing the following dependencies from pom file: ``` <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.el</groupId> <artifactId>javax.el-api</artifactId> <version>2.2.2</version> <scope>provided</scope> </dependency> ``` i think that they were conflicting with the jars provided by the container. **WHAT I NEED TO KNOW:** 1- Do i have to add the dependencies: `javax.servlet.jsp-api` , `javax.el-api` to my pom file as provided or i don't need to add them at all ? 2- If i have to add those two dependencies, then how should i add them properly in a way that they will not conflict with tomcat jars, meaning what version, and should i mark the dependency as provided or not ? and the important question if i have to add them, why i have to do that, what is the importance of adding them since they are provided by the container, what i understand so far, is that i need to add the `javax.servlet-api` dependency and mark it as provided since i am using **servlets** in some classes.
2011/12/17
[ "https://Stackoverflow.com/questions/8545687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/429377/" ]
You should add these dependencies only if you require them in your code meaning that they are required to compile your code. If you don't use JSP or EL classes in your code, you can remove the dependencies. So you can test if you need the dependencies by just removing them. If your code still compiles, you don't need them. :) If you need them, you should definitely add them as `provided` dependencies because the classes are provided by Tomcat during runtime. Just make sure that the versions of the dependencies match the versions provided by Tomcat. Then you won't have any problems. Provided dependencies are just used to compile your code but they are not packaged into the resulting WAR file, which is OK, because Tomcat provides them.
I had a similar problem: I was able to run a project in one computer, but in another one, I was obtaining the ClassNotFoundException described in the question. The only difference between the 2 environments was the version of the tomcat server: 7.0.26 in the working computer and 7.0.16 in the other one. I installed the same version in both computers (7.0.26) and it solved the issue. I hope this answer could be useful to someone.
55,885,621
I'm trying to calculate two numbers and display them but when I click Calculate Total nothing happens and no numbers are displayed. I've been looking for a solution for hours now and just can't figure out why nothing happens when I click the button. If someone could help me out a little bit I'd be very grateful! ```js function calcTotal() { var intValue1 = parseInt(document.GetElementById('Value1').value); var intValue2 = parseInt(document.GetElementById('Value2').value); var strOper = document.GetElementById('operators').value; if (strOper === '+') { document.GetElementById('Total').value = intValue1 + intValue2; else if (strOper === '-') { document.GetElementById('Total').value = intValue1 - intValue2; } else if (strOper === '*') { document.GetElementById('Total').value = intValue1 * intValue2; } else { document.GetElementById('Total').value = intValue1 / intValue2; } } document.getElementById('submit').onclick = calcTotal(); ``` ```html <table class="table1"> <tr> <td class="label"> <label id="lblValue1" for="txtValue1">Value 1:</label> </td> <td class="control"> <input class="formFields" type="text" id="Value1" name="txtValue1" required> </td> </tr> <tr> <td> <select name="dropdown" id="operators"> <option value="+" selected>+</option> <option value="-">-</option> <option value="*">*</option> <option value="/">/</option> </select> </td> </tr> <tr> <td class="label"> <label id="lblValue2" for="txtValue2">Value 2:</label> </td> <td class="control"> <input class="formFields" type="text" id="Value2" name="txtValue2" required> </td> </tr> </table> <hr> <table> <tr> <td class="label"> <label id="lblTotal" for="txtTotal">Total:</label> </td> <td class="control"> <input class="textview" type="text" id="Total" name="txtTotal"> </td> </tr> </table> <table> <tr> <td class="label"> <input id="submit" class="button" name='cmdCalcTotal' type="button" value="Calculate Total" onclick="calcTotal();"> </td> </tr> </table> ``` Thanks in advance!!!!
2019/04/27
[ "https://Stackoverflow.com/questions/55885621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11421201/" ]
You can use [Laravel Queues](https://laravel.com/docs/5.8/queues#introduction) to defer the time consuming part (like api calls) to background jobs. > > Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time. Deferring these time consuming tasks drastically speeds up web requests to your application. > > >
You could consider using **Guzzle's Promises** and sent requests in paralel. The library is located here: <https://github.com/guzzle/promises>. Guzzle client wraps the promises with magic methods like... ```php $promise = $client->getAsync('http://httpbin.org/get'); $promise = $client->deleteAsync('http://httpbin.org/delete'); $promise = $client->headAsync('http://httpbin.org/get'); $promise = $client->optionsAsync('http://httpbin.org/get'); $promise = $client->patchAsync('http://httpbin.org/patch'); $promise = $client->postAsync('http://httpbin.org/post'); $promise = $client->putAsync('http://httpbin.org/put'); ``` ... the documentation for this can be found here: **Guzzle Async Requests:** <http://docs.guzzlephp.org/en/stable/quickstart.html#async-requests> It has a few concepts, like `wait`, `then`, `queue` and `resolve`. Those help you make asynchronous requests while being in full control on what to resolve synchronous. With this it would also be possible to retrieve aggregated results, meaning, for example, that you could query your users-api and your projects-api and wait for some of the results to come back so that you can create one single json response containing the combined data from two sources. This makes it very neat for projects that implement API-gateway.
742,224
Is there anything preventing this from happening? Is it a possible scenario? ns1.edgecastdns.net. 172,800 IN (Internet) A (IPV4 Host Address) 192.16.16.5 ns1.edgecastdns.net. 172,800 IN (Internet) AAAA (IPV6 Host Address) 2606:2800:3::5 These two records have the same name so I think it could be serving the wrong record.
2015/12/10
[ "https://serverfault.com/questions/742224", "https://serverfault.com", "https://serverfault.com/users/326614/" ]
It's always possible that the DNS server could be buggy but it seems unlikely. If you query for a record of a particular type, that's the type you should get. However, it is common for DNS servers to answer questions that haven't been asked as an optimization. In this case, it does appear to supply AAAA records as 'additional answers'. That's perfectly fine. ``` QUESTIONS: ns1.edgecastdns.net, type = A, class = IN ANSWERS: -> ns1.edgecastdns.net internet address = 192.16.16.5 ttl = 3582 ... ADDITIONAL RECORDS: ... -> ns1.edgecastdns.net has AAAA address 2606:2800:3::5 ttl = 63143 ```
In a word: ***NO*** When you ask for an "A" record (IPv4), you will get an "A" answer or nothing. Likewise, when you ask for a "AAAA" record (IPv6), you will get a "AAAA" answer or nothing. (IPv4 and IPv6 are *different* protocols. Just because they share the letters EYE and PEE, doesn't mean they are even remotely compatible.) **Ask for an "A"** ``` ~/[05:35 PM]:host -d -v -t a www.yahoo.com Trying "www.yahoo.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50970 ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 4 ;; QUESTION SECTION: ;www.yahoo.com. IN A ;; ANSWER SECTION: www.yahoo.com. 240 IN CNAME fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com. 30 IN A 98.138.252.30 fd-fp3.wg1.b.yahoo.com. 30 IN A 98.138.253.109 ;; AUTHORITY SECTION: wg1.b.yahoo.com. 55959 IN NS yf4.a1.b.yahoo.net. wg1.b.yahoo.com. 55959 IN NS yf3.a1.b.yahoo.net. wg1.b.yahoo.com. 55959 IN NS yf2.yahoo.com. wg1.b.yahoo.com. 55959 IN NS yf1.yahoo.com. ;; ADDITIONAL SECTION: yf1.yahoo.com. 56036 IN A 68.142.254.15 yf2.yahoo.com. 56036 IN A 68.180.130.15 yf3.a1.b.yahoo.net. 55420 IN A 68.180.130.15 yf4.a1.b.yahoo.net. 55420 IN A 68.180.130.15 ``` You get an "A". (well, CNAME and it's "A"'s) **Ask for a "AAAA"** ``` ~/[05:35 PM]:host -d -v -t aaaa www.yahoo.com Trying "www.yahoo.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7501 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.yahoo.com. IN AAAA ;; ANSWER SECTION: www.yahoo.com. 205 IN CNAME fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com. 49 IN AAAA 2001:4998:44:204::a7 ``` You get a "AAAA". **Ask for "any"** ``` ~/[05:35 PM]:host -d -v -t any fd-fp3.wg1.b.yahoo.com Trying "fd-fp3.wg1.b.yahoo.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17586 ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;fd-fp3.wg1.b.yahoo.com. IN ANY ;; ANSWER SECTION: fd-fp3.wg1.b.yahoo.com. 52 IN A 98.138.253.109 fd-fp3.wg1.b.yahoo.com. 52 IN A 98.138.252.30 fd-fp3.wg1.b.yahoo.com. 52 IN AAAA 2001:4998:44:204::a7 ``` (If I asked for www, I'd get only the lone CNAME.) And if you want to see a "loaded answer"... ``` [root:pts/3{2}]debian1:~/[06:00 PM]:host -d -v -t any gmail.com 8.8.8.8 Trying "gmail.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55161 ;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;gmail.com. IN ANY ;; ANSWER SECTION: gmail.com. 299 IN A 64.233.185.19 gmail.com. 299 IN A 64.233.185.18 gmail.com. 299 IN A 64.233.185.83 gmail.com. 299 IN A 64.233.185.17 gmail.com. 299 IN AAAA 2607:f8b0:4002:c09::12 gmail.com. 3599 IN MX 30 alt3.gmail-smtp-in.l.google.com. gmail.com. 21599 IN NS ns4.google.com. gmail.com. 21599 IN SOA ns1.google.com. dns-admin.google.com. 2015031901 21600 3600 1209600 300 gmail.com. 3599 IN MX 10 alt1.gmail-smtp-in.l.google.com. gmail.com. 3599 IN MX 20 alt2.gmail-smtp-in.l.google.com. gmail.com. 21599 IN NS ns3.google.com. gmail.com. 3599 IN MX 5 gmail-smtp-in.l.google.com. gmail.com. 21599 IN NS ns2.google.com. gmail.com. 3599 IN MX 40 alt4.gmail-smtp-in.l.google.com. gmail.com. 299 IN TXT "v=spf1 redirect=_spf.google.com" gmail.com. 21599 IN NS ns1.google.com. ```
742,224
Is there anything preventing this from happening? Is it a possible scenario? ns1.edgecastdns.net. 172,800 IN (Internet) A (IPV4 Host Address) 192.16.16.5 ns1.edgecastdns.net. 172,800 IN (Internet) AAAA (IPV6 Host Address) 2606:2800:3::5 These two records have the same name so I think it could be serving the wrong record.
2015/12/10
[ "https://serverfault.com/questions/742224", "https://serverfault.com", "https://serverfault.com/users/326614/" ]
It's always possible that the DNS server could be buggy but it seems unlikely. If you query for a record of a particular type, that's the type you should get. However, it is common for DNS servers to answer questions that haven't been asked as an optimization. In this case, it does appear to supply AAAA records as 'additional answers'. That's perfectly fine. ``` QUESTIONS: ns1.edgecastdns.net, type = A, class = IN ANSWERS: -> ns1.edgecastdns.net internet address = 192.16.16.5 ttl = 3582 ... ADDITIONAL RECORDS: ... -> ns1.edgecastdns.net has AAAA address 2606:2800:3::5 ttl = 63143 ```
Just adding a little to the other answers. The others answers are correct regarding what you get in the answer section of your packet. If your client asks for an `A` record in the query, the answer section will only return an `A` record or a `CNAME` which may or may not point to a different record containing an `A` value. This means that it's never possible for the other to *accidentally* be used. *Purposefully* is a different story entirely. Let's take a look at [RFC4213](https://www.rfc-editor.org/rfc/rfc4213#section-2.2): > > DNS resolver libraries on IPv6/IPv4 nodes MUST be capable of > handling both AAAA and A records. However, when a query locates an > AAAA record holding an IPv6 address, and an A record holding an > IPv4 address, the resolver library MAY order the results returned > to the application in order to influence the version of IP packets > used to communicate with that specific node -- IPv6 first, or IPv4 > first. > > > The applications SHOULD be able to specify whether they want IPv4, > IPv6, or both records [RFC3493](https://www.rfc-editor.org/rfc/rfc3596). > That defines which address families the resolver looks up. If > there is not an application choice, or if the application has > requested both, the resolver library MUST NOT filter out any > records. > > > Since most applications try the addresses in the order they are > > returned by the resolver, this can affect the IP version "preference" > of applications. > > > The actual ordering mechanisms are out of scope of this memo. > > Address selection is described at more length in > [RFC3484](https://www.rfc-editor.org/rfc/rfc3484). > > > So to break it down: * An application can ask the resolver library explicitly for an IPv4 or IPv6 based DNS lookup. Many applications don't. * If the system is dual-stack (IPv4 and IPv6), the default is to make no assumption and provide all possible answers. This means explicit lookups for both the `A` and `AAAA` variants of the requested name. * The ordering of the combined IPv4+IPv6 result is a complicated topic (see the linked RFC3484). The IPv6 address will not be used unless your device is IPv6 enabled. If you're using both, then the operating system will make an educated guess about how it wants to order the returned answers (assuming that the application will try to use the first value returned), and then the application will do whatever it wants with the answers in the order they were returned. Complicated? Yes. The long story short is that your OS+application *may* prefer the `AAAA` record that exists, but it will not be an "accident" if that happens, and the remote server (assuming standards compliance) will *never* return an `AAAA` response when an `A` record is requested.
22,619,110
I am trying to get the code of a specific summer note div with multiple ones on a single page. My summer notes are created from a database with php as follows: ``` <div class="tab-content"> <?php $i=-1; foreach($contents as $content): ?> <?php $i++; ?> <div class="tab-pane" id="<?php echo $content->contentName; ?>"> <div class="summernote" data-id="<?php echo $i; ?>"> <?php echo $content->content; ?> </div> </div> <?php endforeach; ?> </div> ``` And then my javascript is: ``` <script> $('.summernote').summernote({ onblur: function(e) { var id = $('.summernote').data('id'); var sHTML = $('.summernote').eq(id).code(); alert(sHTML); } }); </script> ``` It always gets the first `$('.summernote').eq(0).code();` summernote code never the second or third one. What I'm trying to do is when each summernote gets a blur, have that code update in a hidden textarea to submit back to the database. (btw) I am initilizing the summer notes like this: ``` <script> $(document).ready(function() { $('.summernote').summernote({ height: 300, }); }); </script> ```
2014/03/24
[ "https://Stackoverflow.com/questions/22619110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367639/" ]
After selecting all summernote's you need to access their attributes by specifying one element like: ``` <script> $('.summernote').each(function(i, obj) { $(obj).summernote({ onblur: function(e) { var id = $(obj).data('id'); var sHTML = $(obj).code(); alert(sHTML); } }); }); </script> ```
I Finally got the code working for multiple summernote editors and image uploading! To fix > > "undefined" > > > , try: > > var id = $(obj).data('id'); > > > to > > var id= $(obj).attr('id')) > > > Source: <https://github.com/neblina-software/balerocms-enterprise/blob/master/src/main/resources/static/js/app.js> Regards!
22,619,110
I am trying to get the code of a specific summer note div with multiple ones on a single page. My summer notes are created from a database with php as follows: ``` <div class="tab-content"> <?php $i=-1; foreach($contents as $content): ?> <?php $i++; ?> <div class="tab-pane" id="<?php echo $content->contentName; ?>"> <div class="summernote" data-id="<?php echo $i; ?>"> <?php echo $content->content; ?> </div> </div> <?php endforeach; ?> </div> ``` And then my javascript is: ``` <script> $('.summernote').summernote({ onblur: function(e) { var id = $('.summernote').data('id'); var sHTML = $('.summernote').eq(id).code(); alert(sHTML); } }); </script> ``` It always gets the first `$('.summernote').eq(0).code();` summernote code never the second or third one. What I'm trying to do is when each summernote gets a blur, have that code update in a hidden textarea to submit back to the database. (btw) I am initilizing the summer notes like this: ``` <script> $(document).ready(function() { $('.summernote').summernote({ height: 300, }); }); </script> ```
2014/03/24
[ "https://Stackoverflow.com/questions/22619110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367639/" ]
After selecting all summernote's you need to access their attributes by specifying one element like: ``` <script> $('.summernote').each(function(i, obj) { $(obj).summernote({ onblur: function(e) { var id = $(obj).data('id'); var sHTML = $(obj).code(); alert(sHTML); } }); }); </script> ```
To display multiple editors on a page, you need to place more than two `<div>` elements in HTML. **Example:** ``` <div class="summernote">summernote 1</div> <div class="summernote">summernote 2</div> ``` **Then run summernote with jQuery selector.** ``` $(document).ready(function() { $('.summernote').summernote(); }); ``` For more information [click](http://summernote.org/examples/#multiple-editor) Note: Multiple Editor summernote not work with `id`
22,619,110
I am trying to get the code of a specific summer note div with multiple ones on a single page. My summer notes are created from a database with php as follows: ``` <div class="tab-content"> <?php $i=-1; foreach($contents as $content): ?> <?php $i++; ?> <div class="tab-pane" id="<?php echo $content->contentName; ?>"> <div class="summernote" data-id="<?php echo $i; ?>"> <?php echo $content->content; ?> </div> </div> <?php endforeach; ?> </div> ``` And then my javascript is: ``` <script> $('.summernote').summernote({ onblur: function(e) { var id = $('.summernote').data('id'); var sHTML = $('.summernote').eq(id).code(); alert(sHTML); } }); </script> ``` It always gets the first `$('.summernote').eq(0).code();` summernote code never the second or third one. What I'm trying to do is when each summernote gets a blur, have that code update in a hidden textarea to submit back to the database. (btw) I am initilizing the summer notes like this: ``` <script> $(document).ready(function() { $('.summernote').summernote({ height: 300, }); }); </script> ```
2014/03/24
[ "https://Stackoverflow.com/questions/22619110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367639/" ]
After selecting all summernote's you need to access their attributes by specifying one element like: ``` <script> $('.summernote').each(function(i, obj) { $(obj).summernote({ onblur: function(e) { var id = $(obj).data('id'); var sHTML = $(obj).code(); alert(sHTML); } }); }); </script> ```
For anyone looking to use summernote to output multiple content with `foreach`, loop/repetitive statement etc Summernote works for the first output only but you can make it work for others by using the ***class twice***: ``` <div class"summernote summernote"> </div> ``` Provided your script is like this: ``` <script> $(document).ready(function() { $('.summernote').summernote(); }); </script> ```
22,619,110
I am trying to get the code of a specific summer note div with multiple ones on a single page. My summer notes are created from a database with php as follows: ``` <div class="tab-content"> <?php $i=-1; foreach($contents as $content): ?> <?php $i++; ?> <div class="tab-pane" id="<?php echo $content->contentName; ?>"> <div class="summernote" data-id="<?php echo $i; ?>"> <?php echo $content->content; ?> </div> </div> <?php endforeach; ?> </div> ``` And then my javascript is: ``` <script> $('.summernote').summernote({ onblur: function(e) { var id = $('.summernote').data('id'); var sHTML = $('.summernote').eq(id).code(); alert(sHTML); } }); </script> ``` It always gets the first `$('.summernote').eq(0).code();` summernote code never the second or third one. What I'm trying to do is when each summernote gets a blur, have that code update in a hidden textarea to submit back to the database. (btw) I am initilizing the summer notes like this: ``` <script> $(document).ready(function() { $('.summernote').summernote({ height: 300, }); }); </script> ```
2014/03/24
[ "https://Stackoverflow.com/questions/22619110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367639/" ]
After selecting all summernote's you need to access their attributes by specifying one element like: ``` <script> $('.summernote').each(function(i, obj) { $(obj).summernote({ onblur: function(e) { var id = $(obj).data('id'); var sHTML = $(obj).code(); alert(sHTML); } }); }); </script> ```
if you are using summernote inside a textarea in a form and you intend to apply it on multiple textarea(s) on the same form, replace `id=summernote` with `class="summernote"` Dont forget to do the same on your initialisation script ``` <script> $('.summernote').summernote({ height: 200 //just specifies the height of the summernote textarea }); </script> ``` Example ``` <textarea class="summernote" name="valueToBeExtractedBackend" required></textarea> <script> $('.summernote').summernote({ height: 200 }); </script> ```
22,619,110
I am trying to get the code of a specific summer note div with multiple ones on a single page. My summer notes are created from a database with php as follows: ``` <div class="tab-content"> <?php $i=-1; foreach($contents as $content): ?> <?php $i++; ?> <div class="tab-pane" id="<?php echo $content->contentName; ?>"> <div class="summernote" data-id="<?php echo $i; ?>"> <?php echo $content->content; ?> </div> </div> <?php endforeach; ?> </div> ``` And then my javascript is: ``` <script> $('.summernote').summernote({ onblur: function(e) { var id = $('.summernote').data('id'); var sHTML = $('.summernote').eq(id).code(); alert(sHTML); } }); </script> ``` It always gets the first `$('.summernote').eq(0).code();` summernote code never the second or third one. What I'm trying to do is when each summernote gets a blur, have that code update in a hidden textarea to submit back to the database. (btw) I am initilizing the summer notes like this: ``` <script> $(document).ready(function() { $('.summernote').summernote({ height: 300, }); }); </script> ```
2014/03/24
[ "https://Stackoverflow.com/questions/22619110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367639/" ]
To display multiple editors on a page, you need to place more than two `<div>` elements in HTML. **Example:** ``` <div class="summernote">summernote 1</div> <div class="summernote">summernote 2</div> ``` **Then run summernote with jQuery selector.** ``` $(document).ready(function() { $('.summernote').summernote(); }); ``` For more information [click](http://summernote.org/examples/#multiple-editor) Note: Multiple Editor summernote not work with `id`
I Finally got the code working for multiple summernote editors and image uploading! To fix > > "undefined" > > > , try: > > var id = $(obj).data('id'); > > > to > > var id= $(obj).attr('id')) > > > Source: <https://github.com/neblina-software/balerocms-enterprise/blob/master/src/main/resources/static/js/app.js> Regards!
22,619,110
I am trying to get the code of a specific summer note div with multiple ones on a single page. My summer notes are created from a database with php as follows: ``` <div class="tab-content"> <?php $i=-1; foreach($contents as $content): ?> <?php $i++; ?> <div class="tab-pane" id="<?php echo $content->contentName; ?>"> <div class="summernote" data-id="<?php echo $i; ?>"> <?php echo $content->content; ?> </div> </div> <?php endforeach; ?> </div> ``` And then my javascript is: ``` <script> $('.summernote').summernote({ onblur: function(e) { var id = $('.summernote').data('id'); var sHTML = $('.summernote').eq(id).code(); alert(sHTML); } }); </script> ``` It always gets the first `$('.summernote').eq(0).code();` summernote code never the second or third one. What I'm trying to do is when each summernote gets a blur, have that code update in a hidden textarea to submit back to the database. (btw) I am initilizing the summer notes like this: ``` <script> $(document).ready(function() { $('.summernote').summernote({ height: 300, }); }); </script> ```
2014/03/24
[ "https://Stackoverflow.com/questions/22619110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367639/" ]
To display multiple editors on a page, you need to place more than two `<div>` elements in HTML. **Example:** ``` <div class="summernote">summernote 1</div> <div class="summernote">summernote 2</div> ``` **Then run summernote with jQuery selector.** ``` $(document).ready(function() { $('.summernote').summernote(); }); ``` For more information [click](http://summernote.org/examples/#multiple-editor) Note: Multiple Editor summernote not work with `id`
For anyone looking to use summernote to output multiple content with `foreach`, loop/repetitive statement etc Summernote works for the first output only but you can make it work for others by using the ***class twice***: ``` <div class"summernote summernote"> </div> ``` Provided your script is like this: ``` <script> $(document).ready(function() { $('.summernote').summernote(); }); </script> ```
22,619,110
I am trying to get the code of a specific summer note div with multiple ones on a single page. My summer notes are created from a database with php as follows: ``` <div class="tab-content"> <?php $i=-1; foreach($contents as $content): ?> <?php $i++; ?> <div class="tab-pane" id="<?php echo $content->contentName; ?>"> <div class="summernote" data-id="<?php echo $i; ?>"> <?php echo $content->content; ?> </div> </div> <?php endforeach; ?> </div> ``` And then my javascript is: ``` <script> $('.summernote').summernote({ onblur: function(e) { var id = $('.summernote').data('id'); var sHTML = $('.summernote').eq(id).code(); alert(sHTML); } }); </script> ``` It always gets the first `$('.summernote').eq(0).code();` summernote code never the second or third one. What I'm trying to do is when each summernote gets a blur, have that code update in a hidden textarea to submit back to the database. (btw) I am initilizing the summer notes like this: ``` <script> $(document).ready(function() { $('.summernote').summernote({ height: 300, }); }); </script> ```
2014/03/24
[ "https://Stackoverflow.com/questions/22619110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3367639/" ]
To display multiple editors on a page, you need to place more than two `<div>` elements in HTML. **Example:** ``` <div class="summernote">summernote 1</div> <div class="summernote">summernote 2</div> ``` **Then run summernote with jQuery selector.** ``` $(document).ready(function() { $('.summernote').summernote(); }); ``` For more information [click](http://summernote.org/examples/#multiple-editor) Note: Multiple Editor summernote not work with `id`
if you are using summernote inside a textarea in a form and you intend to apply it on multiple textarea(s) on the same form, replace `id=summernote` with `class="summernote"` Dont forget to do the same on your initialisation script ``` <script> $('.summernote').summernote({ height: 200 //just specifies the height of the summernote textarea }); </script> ``` Example ``` <textarea class="summernote" name="valueToBeExtractedBackend" required></textarea> <script> $('.summernote').summernote({ height: 200 }); </script> ```
226,645
Is "lemonade" countable or uncountable? Could I say the following sentence? > > Could you please bring me a lemonade? > > > Or *must* I say "a glass of lemonade" ?
2019/10/03
[ "https://ell.stackexchange.com/questions/226645", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/92124/" ]
"Lemonade" is usually uncountable, but it can be used as a countable noun to mean "a glass of lemonade". It is uncommon, but possible, to treat "lemonade" as a countable noun. This applies not only to lemonade but to most beverages.
> > Or must I say "a glass of lemonade" ? > > > You don't need to. From Collins > > A glass of lemonade can be referred to as *a lemonade*. Example: I'm going to get you a lemonade. > > > Take a look at the following Q and A. > > *What can I get you?* > > > * A diet coke, please! > * A can of diet coke, please! > > > They are both idiomatic. The "a can" or "a glass" is implied.
114,417
Mending a bug in our SAP BW web application, I need to call two javascript functions from the web framework library upon page load. The problem is that each of these functions reloads the page as a side-effect. In addition, I don't have access to modify these functions. Any great ideas on how to execute a piece of code on "real" page load, then another piece of code on the subsequent load caused by this function, and then execute no code the third reload? My best idea so far it to set a cookie on each go to determine what to run. I don't greatly love this solution. Anything better would be very welcome. And by the way, I do realize loading a page three times is absolutely ridiculous, but that's how we roll with SAP.
2008/09/22
[ "https://Stackoverflow.com/questions/114417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4333/" ]
A cookie would work just fine. Or you could modify the query string each time with a "mode=x" or "load=x" parameter. This would present a problem if the user tries to bookmark the final page, though. If that's an option, the cookie solution is fine. I would guess they need cookies enabled to get that far in the app anyway?
A cookie, or pass a query string parameter indicating which javascript function has been run. We had to do something along these lines to trip out a piece of our software. That's really the best I got.
114,417
Mending a bug in our SAP BW web application, I need to call two javascript functions from the web framework library upon page load. The problem is that each of these functions reloads the page as a side-effect. In addition, I don't have access to modify these functions. Any great ideas on how to execute a piece of code on "real" page load, then another piece of code on the subsequent load caused by this function, and then execute no code the third reload? My best idea so far it to set a cookie on each go to determine what to run. I don't greatly love this solution. Anything better would be very welcome. And by the way, I do realize loading a page three times is absolutely ridiculous, but that's how we roll with SAP.
2008/09/22
[ "https://Stackoverflow.com/questions/114417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4333/" ]
A cookie would work just fine. Or you could modify the query string each time with a "mode=x" or "load=x" parameter. This would present a problem if the user tries to bookmark the final page, though. If that's an option, the cookie solution is fine. I would guess they need cookies enabled to get that far in the app anyway?
Use a cookie or set a hidden field value. My vote would be for the field value.
114,417
Mending a bug in our SAP BW web application, I need to call two javascript functions from the web framework library upon page load. The problem is that each of these functions reloads the page as a side-effect. In addition, I don't have access to modify these functions. Any great ideas on how to execute a piece of code on "real" page load, then another piece of code on the subsequent load caused by this function, and then execute no code the third reload? My best idea so far it to set a cookie on each go to determine what to run. I don't greatly love this solution. Anything better would be very welcome. And by the way, I do realize loading a page three times is absolutely ridiculous, but that's how we roll with SAP.
2008/09/22
[ "https://Stackoverflow.com/questions/114417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4333/" ]
A cookie would work just fine. Or you could modify the query string each time with a "mode=x" or "load=x" parameter. This would present a problem if the user tries to bookmark the final page, though. If that's an option, the cookie solution is fine. I would guess they need cookies enabled to get that far in the app anyway?
This might be a cute case for using window.name, 'the property that survives page reloads'.
114,417
Mending a bug in our SAP BW web application, I need to call two javascript functions from the web framework library upon page load. The problem is that each of these functions reloads the page as a side-effect. In addition, I don't have access to modify these functions. Any great ideas on how to execute a piece of code on "real" page load, then another piece of code on the subsequent load caused by this function, and then execute no code the third reload? My best idea so far it to set a cookie on each go to determine what to run. I don't greatly love this solution. Anything better would be very welcome. And by the way, I do realize loading a page three times is absolutely ridiculous, but that's how we roll with SAP.
2008/09/22
[ "https://Stackoverflow.com/questions/114417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4333/" ]
A cookie, or pass a query string parameter indicating which javascript function has been run. We had to do something along these lines to trip out a piece of our software. That's really the best I got.
Use a cookie or set a hidden field value. My vote would be for the field value.
114,417
Mending a bug in our SAP BW web application, I need to call two javascript functions from the web framework library upon page load. The problem is that each of these functions reloads the page as a side-effect. In addition, I don't have access to modify these functions. Any great ideas on how to execute a piece of code on "real" page load, then another piece of code on the subsequent load caused by this function, and then execute no code the third reload? My best idea so far it to set a cookie on each go to determine what to run. I don't greatly love this solution. Anything better would be very welcome. And by the way, I do realize loading a page three times is absolutely ridiculous, but that's how we roll with SAP.
2008/09/22
[ "https://Stackoverflow.com/questions/114417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4333/" ]
A cookie, or pass a query string parameter indicating which javascript function has been run. We had to do something along these lines to trip out a piece of our software. That's really the best I got.
This might be a cute case for using window.name, 'the property that survives page reloads'.
26,933,422
Who can share practical examples of the use of the `GET_LOCK` function? Example function: ``` mysql> SELECT GET_LOCK('b',10); +------------------+ | GET_LOCK('b',10) | +------------------+ | 1 | +------------------+ 1 row in set (0.00 sec) mysql> SELECT IS_FREE_LOCK('b'); +-------------------+ | IS_FREE_LOCK('b') | +-------------------+ | 0 | +-------------------+ 1 row in set (0.00 sec) mysql> SELECT RELEASE_LOCK('b'); +-------------------+ | RELEASE_LOCK('b') | +-------------------+ | 1 | +-------------------+ 1 row in set (0.00 sec) mysql> SELECT IS_FREE_LOCK('b'); +-------------------+ | IS_FREE_LOCK('b') | +-------------------+ | 1 | +-------------------+ 1 row in set (0.00 sec) ``` Thank you.
2014/11/14
[ "https://Stackoverflow.com/questions/26933422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2645137/" ]
This should be enough: ``` self.collectionView.pagingEnabled = YES; ``` Swift version: ``` self.collectionView.pagingEnabled = true ```
If you want your cells to be moved only one at a time then you need to set the frame of cell equals to the collection view and then set the collectionView's paging enabled as below, ``` [collectionView setPagingEnabled:YES]; ``` or ``` collectionView.pagingEnabled=YES; ```
29,214,407
I have a Queue of an abstract class KVP. I queue 2 different objects which inherit from KVP. Everything works fine when I serialize the queue, but since KVP cannot be constructed it fails on deserialization. If it was a single non generic object I could deserialize as dynamic, but I'm not sure how to deserialize a queue that could hold both events and IDs. Sample code: ``` public virtual async Task<bool> LoadFromFile(string FileName, bool addToExistingQueue,bool DeleteFileAfterLoad = true) { try { IFile File = await PCLStorage.FileSystem.Current.LocalStorage.GetFileAsync(FileName); var serializedText = await File.ReadAllTextAsync(); var mQueue = JsonConvert.DeserializeObject<Queue<T>>(serializedText,jss); if (!addToExistingQueue) { _queue = new ConcurrentQueue<T>(); } while (mQueue.Count > 0) { _queue.Enqueue(mQueue.Dequeue()); } if (DeleteFileAfterLoad) { await File.DeleteAsync(); } return true; } catch (Exception ex) { Debug.WriteLine("Could not load File. Exception Message: " + ex.Message); return false; } } public virtual async Task<bool> WriteToFile(string FileName) { try { Debug.WriteLine("Writing File: " + FileName); var File = await FileSystem.Current.LocalStorage.CreateFileAsync(FileName, CreationCollisionOption.ReplaceExisting); var serializedText = JsonConvert.SerializeObject(_queue.ToList(),jss); await File.WriteAllTextAsync(serializedText); return true; } catch (Exception ex) { Debug.WriteLine("Could not write File with exception message: " + ex.Message); return false; } } ```
2015/03/23
[ "https://Stackoverflow.com/questions/29214407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1104177/" ]
You could 1. Enable [TypeNameHandling](http://www.newtonsoft.com/json/help/html/P_Newtonsoft_Json_JsonSerializerSettings_TypeNameHandling.htm) (in both serialization and deserialization): ``` var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; var serializedText= JsonConvert.SerializeObject(mQueue, settings); ``` And then later ``` var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; var mQueue = JsonConvert.DeserializeObject<Queue<T>>(serializedText, settings); ``` This adds an extra `"$type"` property to your polymorphic classes, as is described [here](http://james.newtonking.com/archive/2010/08/13/json-net-3-5-release-8-3-5-final). Before choosing this solution, for a discussion of possible security concerns using `TypeNameHandling`, see [TypeNameHandling caution in Newtonsoft Json](https://stackoverflow.com/q/39565954/3744182) and [How to configure Json.NET to create a vulnerable web API](https://www.alphabot.com/security/blog/2017/net/How-to-configure-Json.NET-to-create-a-vulnerable-web-API.html). 2. Write a custom converter that looks at the actual properties and chooses which derived class to use, as is discussed here: [Deserializing polymorphic json classes without type information using json.net](https://stackoverflow.com/questions/19307752/deserializing-polymorphic-json-classes-without-type-information-using-json-net). This avoids the need for the extra `"$type"` property.
This should work if you use the following setting in the JSON.NET serialiser settings: ``` var settings = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.Auto}; ``` This will encode the object type into the JSON stream, which will help the deserializer determined the specific object type to construct during de-serialization.
18,659,832
I've been wondering, is there a nice way to make `UIButtons` with multi-line `titleLabel` in Interface Builder? I've found none and puttin a separate `UILabel` on top of each button and tracking it's color on press and other events is not very straightforward. Maybe there are better alternatives done in code if there's no such way in IB?
2013/09/06
[ "https://Stackoverflow.com/questions/18659832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1313939/" ]
**Code:** To allow multiple line you can use: ``` button.titleLabel.lineBreakMode = UILineBreakModeWordWrap; button.titleLabel.textAlignment = UITextAlignmentCenter; [button setTitle: @"Line1\nLine2" forState: UIControlStateNormal]; ``` In **iOS 6**, `UILineBreakModeWordWrap` and `UITextAlignmentCenter` are deprecated, so use: ``` button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; button.titleLabel.textAlignment = NSTextAlignmentCenter; ``` **Interface Builder:** * In interface builder select *UIButton* * on the right side Utilities pane under *Attributes Inspector*, you'll see an option for *Line Break* * Choose *Word Wrap*
You can do solely in Interface Builder a couple ways. * First by simply setting the wrap feature. This offers limited customizability though. * For more customizability, change the "Plain Text" to "Attributed Text" and then you can do most things without any code.
18,659,832
I've been wondering, is there a nice way to make `UIButtons` with multi-line `titleLabel` in Interface Builder? I've found none and puttin a separate `UILabel` on top of each button and tracking it's color on press and other events is not very straightforward. Maybe there are better alternatives done in code if there's no such way in IB?
2013/09/06
[ "https://Stackoverflow.com/questions/18659832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1313939/" ]
**Code:** To allow multiple line you can use: ``` button.titleLabel.lineBreakMode = UILineBreakModeWordWrap; button.titleLabel.textAlignment = UITextAlignmentCenter; [button setTitle: @"Line1\nLine2" forState: UIControlStateNormal]; ``` In **iOS 6**, `UILineBreakModeWordWrap` and `UITextAlignmentCenter` are deprecated, so use: ``` button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; button.titleLabel.textAlignment = NSTextAlignmentCenter; ``` **Interface Builder:** * In interface builder select *UIButton* * on the right side Utilities pane under *Attributes Inspector*, you'll see an option for *Line Break* * Choose *Word Wrap*
Just to mention if one does not want word wrap but still want to achieve multi line title on a UIButton it can be done by setting lineBreakMode before numberOfLines, This is because lineBreakMode seems to cancel out numberOfLines set hence we are doing it in this order. Swift: > > button.titleLabel?.lineBreakMode = NSLineBreakMode.byTruncatingTail > > > button.titleLabel?.numberOfLines = 2 > > > button.setTitle(myTitle, for: UIControlState.normal) > > >
18,659,832
I've been wondering, is there a nice way to make `UIButtons` with multi-line `titleLabel` in Interface Builder? I've found none and puttin a separate `UILabel` on top of each button and tracking it's color on press and other events is not very straightforward. Maybe there are better alternatives done in code if there's no such way in IB?
2013/09/06
[ "https://Stackoverflow.com/questions/18659832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1313939/" ]
**Code:** To allow multiple line you can use: ``` button.titleLabel.lineBreakMode = UILineBreakModeWordWrap; button.titleLabel.textAlignment = UITextAlignmentCenter; [button setTitle: @"Line1\nLine2" forState: UIControlStateNormal]; ``` In **iOS 6**, `UILineBreakModeWordWrap` and `UITextAlignmentCenter` are deprecated, so use: ``` button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; button.titleLabel.textAlignment = NSTextAlignmentCenter; ``` **Interface Builder:** * In interface builder select *UIButton* * on the right side Utilities pane under *Attributes Inspector*, you'll see an option for *Line Break* * Choose *Word Wrap*
In the case you are using only plain XCode 9.4: Set Line Break to any option (to enable numberOfLines) in the Attributes inspector: [![The first step in XCode](https://i.stack.imgur.com/Q1Rd1.png)](https://i.stack.imgur.com/Q1Rd1.png) Then you can set KeyPath as ``` titleLabel.numberOfLines ``` in the Identity inspector: [![The second step in XCode](https://i.stack.imgur.com/5oZoM.png)](https://i.stack.imgur.com/5oZoM.png)
18,659,832
I've been wondering, is there a nice way to make `UIButtons` with multi-line `titleLabel` in Interface Builder? I've found none and puttin a separate `UILabel` on top of each button and tracking it's color on press and other events is not very straightforward. Maybe there are better alternatives done in code if there's no such way in IB?
2013/09/06
[ "https://Stackoverflow.com/questions/18659832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1313939/" ]
You can do solely in Interface Builder a couple ways. * First by simply setting the wrap feature. This offers limited customizability though. * For more customizability, change the "Plain Text" to "Attributed Text" and then you can do most things without any code.
Just to mention if one does not want word wrap but still want to achieve multi line title on a UIButton it can be done by setting lineBreakMode before numberOfLines, This is because lineBreakMode seems to cancel out numberOfLines set hence we are doing it in this order. Swift: > > button.titleLabel?.lineBreakMode = NSLineBreakMode.byTruncatingTail > > > button.titleLabel?.numberOfLines = 2 > > > button.setTitle(myTitle, for: UIControlState.normal) > > >
18,659,832
I've been wondering, is there a nice way to make `UIButtons` with multi-line `titleLabel` in Interface Builder? I've found none and puttin a separate `UILabel` on top of each button and tracking it's color on press and other events is not very straightforward. Maybe there are better alternatives done in code if there's no such way in IB?
2013/09/06
[ "https://Stackoverflow.com/questions/18659832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1313939/" ]
In the case you are using only plain XCode 9.4: Set Line Break to any option (to enable numberOfLines) in the Attributes inspector: [![The first step in XCode](https://i.stack.imgur.com/Q1Rd1.png)](https://i.stack.imgur.com/Q1Rd1.png) Then you can set KeyPath as ``` titleLabel.numberOfLines ``` in the Identity inspector: [![The second step in XCode](https://i.stack.imgur.com/5oZoM.png)](https://i.stack.imgur.com/5oZoM.png)
Just to mention if one does not want word wrap but still want to achieve multi line title on a UIButton it can be done by setting lineBreakMode before numberOfLines, This is because lineBreakMode seems to cancel out numberOfLines set hence we are doing it in this order. Swift: > > button.titleLabel?.lineBreakMode = NSLineBreakMode.byTruncatingTail > > > button.titleLabel?.numberOfLines = 2 > > > button.setTitle(myTitle, for: UIControlState.normal) > > >
77,623
knowing that the characteristic of an integral domain is $0$ or a prime number, i want to prove that the characteristic of a finite field $F\_n$ is a prime number, that is $\operatorname{char}(F\_n)\not = 0$. the proof i'm reading uses the fact that within $e,2e,3e,\ldots$ there are two that are necessarily equal $ie=(i+k)e$ so $ke=0$ for some positive $k$. But can i say the following argument: $F\_n=\{0,e,x\_1,\ldots ,x\_{n-2}\}$ ( $e$ is the multiplicative identity ) and since $e\not = 0$ then $e\not = 2e\not =\cdots ,\not = ne$ so we have $n$ distinct elements $ie, i=1,\ldots,n$ of $F\_n$ hence one of them must equal $0$; $ie=0$ for some $i\in \{2,\ldots,n\}$, moreover the trivial field with one element $e=0$ has obviously characteristic $1$. Is there a non-trivial field where $e=0$?
2011/10/31
[ "https://math.stackexchange.com/questions/77623", "https://math.stackexchange.com", "https://math.stackexchange.com/users/10463/" ]
Let $1$ denote the *multiplicative* identity of the field. Then, $1 \neq 0$ where $0$ is the *additive* identity. So every field must have at least two elements: your notion of a field with one element $0$ is not correct. So, since the field contains $1$, it contains $1+1$, $1+1+1$, $1 + 1 + 1 + 1, \ldots, 1 + 1 + \cdots + 1$ (where the last sum has $n$ $1$s in it). All these $n$ sums cannot be distinct since the field has only $n-1$ *nonzero* elements. So, for some distinct $i$ and $j$, the sum of $i$ $1$s must equal the sum of $j$ $1$s, and by subtraction, the sum of $|i-j|$ $1$s must equal $0$. The smallest number of $1$s that sum to $0$ is called the characteristic of the finite field, and the characteristic must be a prime number. This is because if the characteristic were a composite number $ab$, then the sum of $a$ $1$s multiplied by the sum of $b$ $1$s, which equals the sum of $ab$ $1$s by the distributive law, would equal $0$, that is, the product of two nonzero elements would equal $0$, which cannot happen in a field.
I feel as though the answer you are stating is making things more difficult. As you pointed out all integral domains are either characterstic zero or of prime characteristic, and so in particular all fields are of prime characteristic or zero characteristic. But, if a field has characteristic zero you know that it's multiplicative identity has infinite additive order and all finite groups (and thus all finite fields) have no elements of infinite order (for the reason FIRST reason you stated). Another route is, if you know group theory (but this is really overkill compared to the other two arguments) to note that $|\mathbb{F}\_q|\mathbb{F}\_q=0$ by Lagrange's theorem, and so all elements have order dividing $|\mathbb{F}\_q|$. To answer your last question, no, there are no non-trivial examples where $1=0$ since the ONLY ring with such an identity is the zero ring.
33,710,057
So I'm working on implementing an insert method for a binary tree. From what I can tell, the problem is that the changes made in the arguments of the function don't get properly returned back to main(). ``` static void addChild(Child c, Child tree){ if(tree==null){ tree=c; } else{ if(c.cid>tree.cid){ addChild(c, tree.lc); } else if(c.cid<tree.cid){ addChild(c, tree.rc); } } } ``` The Child objects seen above have nothing to do with the children of the nodes in the tree. The tree nodes are Child objects. cid is a field in the Child class which holds an integer. rc is the right child of a node. lc is the left child of a node. Arguments of addChild: @param Child c : the Child to insert into the tree @param Child tree : the root of the tree Basically my question is, shouldn't this be working correctly? When the method completes, the right child and left child of the tree given in the argument are null.
2015/11/14
[ "https://Stackoverflow.com/questions/33710057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4695822/" ]
The recursive method only modifies the local copy on the stack.. Instead you should be passing a pointer or pass a reference to the tree nodes so that when u assign a child in the base case you make changes to the actual parent and not to the local copy (local copy gets destroyed after the function returns)
Your recursive base case: ``` tree = c; ``` won't update the tree. It just reassigns the **tree** parameter's reference in that call scope. It has no effect outside that particular recursive call (stack frame). Here's a walk through of execution: ``` Child tree = new Child(); tree.cid = 0; tree.lc = new Child(); tree.lc.cid = 1; Child c = new Child(); c.cid = 2; addChild(c, tree); // tree != null // c.cid>tree.cid addTree(c, tree.lc); // tree != null // c.cid>tree.cid addTree(c, tree.lc); // tree == null tree = c; // Won't be effective return; return; ``` That locally mutates the **tree** reference and has no effect outside this recursive call. The trick here is to update the parent tree's left or right subtree at this point. ``` static Child addChild(Child c, Child tree){ if(tree==null){ return c; } else{ if(c.cid>tree.cid){ tree.lc = addChild(c, tree.lc); } else if(c.cid<tree.cid){ tree.rc = addChild(c, tree.rc); } return tree; } } ``` Tracing the new version looks like: ``` Child tree = new Child(); tree.cid = 0; tree.lc = new Child(); tree.lc.cid = 1; Child c = new Child(); c.cid = 2; addChild(c, tree); // tree != null // c.cid>tree.cid tree.lc = addTree(c, tree.lc); // tree != null // c.cid>tree.cid tree.lc = addTree(c, tree.lc); // tree == null return c; return tree; return tree; ```
61,850,588
Hi so i have table called products, i have some information there like name,netto price,tax etc. I want to add new records named brutto\_price which is automatically calculated as (netto\_price + netto\_price\*tax) or (netto\_price \*1.22 if tax is null) its not allowed to insert null into netto\_price. (tax could be null). Im doing sth like this ``` alter table products add (brutto_price FLOAT DEFAULT netto_price*1.22 ) UPDATE products SET brutto_price = netto_price + netto_price*tax where tax is not null; ``` but first query is not working (probably because i use record name in this) any idea?
2020/05/17
[ "https://Stackoverflow.com/questions/61850588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13560269/" ]
You can use ``` {(book.authors || []).map(({firstname, lastname}) => `${lastname} ${firstname}`).join(", ")}. ``` This will give you comma separated names ``` <tbody> {books.length === 0 ? <tr align="center"> <td colSpan="6">{this.state.books.length} List is empty.</td> </tr> : books.map((book) => ( <tr key={book.id}> <td>{book.id}</td> <td>{book.title}</td> <td>{(book.authors || []).map(({firstname, lastname}) => `${lastname} ${firstname}`)}</td> <td>{book.description}</td> <td>{book.language}</td> <td>{book.price}</td> <td>{book.action}</td> </tr> )) } </tbody> ```
One of the ways to do that: ``` (book.authors || []).map(author => author.firstname + ' ' + author.lastname).join(', ') ```
288,319
I realized the solution to this problem while I was creating the documentation to ASK this question...so I am posting the answer if for no other reason than to keep me from wasting time on this in the future
2008/11/13
[ "https://Stackoverflow.com/questions/288319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
`toggle()` is pretty buggy at times, i've had it do odd things to checkmarks (unchecking them) and other assorted issues. i'd suggest just handling it using a click event, much less minor annoyances. and this way, you don't have to worry about what state `#lowerDiv` is in in the first place: ``` $('#upperDiv').click(function() { $('#lowerDiv').animate({ 'opacity' : 'toggle', }); }); ```
If the content to be TOGGLEd is displayed (visible) when the page is rendered the functions would be in the following order, if the content is hidden originally then reverse the functions ``` <html> <head> <style> #upperDiv {width:200px; height:20px; text-align:center; cursor:pointer; } #lowerDiv {width:200px; height:20px; background-color:red; border:#206ba4 1px solid;} </style> <script language="Javascript" src="javascript/jquery-1.2.6.min.js"></script> <script type="text/JavaScript"> $(function(){ $('#upperDiv').toggle ( function(){ $("#lowerDiv").hide() ; }, function(){ $("#lowerDiv").show() ; } ); // End toggle }); // End eventlistener </script> </head> <body> <div id="upperDiv" >Upper div</div> <div id="lowerDiv" >Lover Div</div> </body> </html> ```
288,319
I realized the solution to this problem while I was creating the documentation to ASK this question...so I am posting the answer if for no other reason than to keep me from wasting time on this in the future
2008/11/13
[ "https://Stackoverflow.com/questions/288319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
If the content to be TOGGLEd is displayed (visible) when the page is rendered the functions would be in the following order, if the content is hidden originally then reverse the functions ``` <html> <head> <style> #upperDiv {width:200px; height:20px; text-align:center; cursor:pointer; } #lowerDiv {width:200px; height:20px; background-color:red; border:#206ba4 1px solid;} </style> <script language="Javascript" src="javascript/jquery-1.2.6.min.js"></script> <script type="text/JavaScript"> $(function(){ $('#upperDiv').toggle ( function(){ $("#lowerDiv").hide() ; }, function(){ $("#lowerDiv").show() ; } ); // End toggle }); // End eventlistener </script> </head> <body> <div id="upperDiv" >Upper div</div> <div id="lowerDiv" >Lover Div</div> </body> </html> ```
I know this is a really old question, but just for people that are looking for a quick fix this worked for me: a. in the PHP/HTML file: ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/.../jquery.min.js"></script> <script> $(document).ready(function(){ $("#pClick").click(function(){ $("#pText").toggle(); $("#pText").text("..."); }); }); </script> ``` b. in the CSS file: ``` #pText {display: none;} ``` It now works even on the first click. It's a simple, quick answer that I hope will be useful.
288,319
I realized the solution to this problem while I was creating the documentation to ASK this question...so I am posting the answer if for no other reason than to keep me from wasting time on this in the future
2008/11/13
[ "https://Stackoverflow.com/questions/288319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
`toggle()` is pretty buggy at times, i've had it do odd things to checkmarks (unchecking them) and other assorted issues. i'd suggest just handling it using a click event, much less minor annoyances. and this way, you don't have to worry about what state `#lowerDiv` is in in the first place: ``` $('#upperDiv').click(function() { $('#lowerDiv').animate({ 'opacity' : 'toggle', }); }); ```
I know this is a really old question, but just for people that are looking for a quick fix this worked for me: a. in the PHP/HTML file: ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/.../jquery.min.js"></script> <script> $(document).ready(function(){ $("#pClick").click(function(){ $("#pText").toggle(); $("#pText").text("..."); }); }); </script> ``` b. in the CSS file: ``` #pText {display: none;} ``` It now works even on the first click. It's a simple, quick answer that I hope will be useful.
6,312,748
I have the code: ``` var timer:Timer = new Timer(milliseconds, repititions); timer.addEventListener(TimerEvent.TIMER, callback); timer.start(); ``` and if a user click I want to call the callback early. Is there was a way to either force the timer to finish immediately, or stop it and send the `TimerEvent.Timer` on my own? I'm looking for something simple like the tween classes `fforward()`. *EDIT* The Solution was ``` timer.dispatchEvent(new TimerEvent(TimerEvent.TIMER)); ``` I was trying to do `timer.dispatchEvent(new TimerEvent("TIMER"));` which doesn't work.
2011/06/10
[ "https://Stackoverflow.com/questions/6312748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198034/" ]
``` var evt:TimerEvent = new TimerEvent(TimerEvent.TIMER); timer.dispatchEvent(evt); ```
Have button call a function in my example i call it onDoEvent. onDoEvent will then call the timer event callback using the proper "CLICK" event. ``` import fl.controls.Button var milliseconds:int = 3000; var repititions:int = 0; var timer:Timer = new Timer(milliseconds, repititions); timer.addEventListener(TimerEvent.TIMER,onTimerEvent ); var btn_start:Button = new Button( ); btn_start.label = 'start'; btn_start.x = 0; btn_start.addEventListener( MouseEvent.CLICK, onStart ); this.addChild( btn_start ); function onStart( e:Event ):void{ timer.start(); } var btn_stop:Button = new Button( ); btn_stop.label = 'stop'; btn_stop.x = 150; btn_stop.addEventListener( MouseEvent.CLICK, onStop ); this.addChild( btn_stop ); function onStop( e:Event ):void{ timer.stop(); } var btn_doEvent:Button = new Button( ); btn_doEvent.label = 'Trigger Event'; btn_doEvent.x = 300; btn_doEvent.addEventListener( MouseEvent.CLICK, onDoEvent ); this.addChild( btn_doEvent ); function onDoEvent( e:Event ):void{ onTimerEvent( new TimerEvent("CLICK") ); } function onTimerEvent(e:TimerEvent){ trace('TimerEvent was triggered'); } ```
6,312,748
I have the code: ``` var timer:Timer = new Timer(milliseconds, repititions); timer.addEventListener(TimerEvent.TIMER, callback); timer.start(); ``` and if a user click I want to call the callback early. Is there was a way to either force the timer to finish immediately, or stop it and send the `TimerEvent.Timer` on my own? I'm looking for something simple like the tween classes `fforward()`. *EDIT* The Solution was ``` timer.dispatchEvent(new TimerEvent(TimerEvent.TIMER)); ``` I was trying to do `timer.dispatchEvent(new TimerEvent("TIMER"));` which doesn't work.
2011/06/10
[ "https://Stackoverflow.com/questions/6312748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198034/" ]
``` var evt:TimerEvent = new TimerEvent(TimerEvent.TIMER); timer.dispatchEvent(evt); ```
``` var timer:Timer = new Timer(milliseconds, repititions); timer.addEventListener(TimerEvent.TIMER, callback); timer.start(); function callback(e:TimerEvent):void{ //to do what } ``` to call simpliest way, just call the function like this. ``` callback(null); ```
35,298,518
Hi, I have a requirement, i need to modify a ClearQuest schema. This modification is done based on the application name(application\_name field)in the form. For a particular application an additional approval from a group is required. For rest of the application needs to be eliminated. [![enter image description here](https://i.stack.imgur.com/E7NvE.jpg)](https://i.stack.imgur.com/E7NvE.jpg) Is there any way this can be achieved? Thanks
2016/02/09
[ "https://Stackoverflow.com/questions/35298518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3437212/" ]
For just bash commands, it's possible to get system commands to work. For example, in the IRkernel: ``` system("echo 'hi'", intern=TRUE) ``` Output: ``` 'hi' ``` Or to see the first 5 lines of a file: ``` system("head -5 data/train.csv", intern=TRUE) ``` As IPython magics are available in the IPython kernel (but not in the IRkernel), I did a quick check if it was possible to access these using the `rPython` and `PythonInR` libraries. However, the issue is that `get_ipython()` isn't visible to the Python code, so none of the following worked: ``` library("rPython") rPython::python.exec("from IPython import get_ipython; get_ipython().run_cell_magic('writefile', 'test.txt', 'This is a test')") library("PythonInR") PythonInR::pyExec("from IPython import get_ipython; get_ipython().run_cell_magic('head -5 data/test.csv')") ```
A cosmetic improvement to the output of `system` can be obtained by wrapping the call in `cat` and specify `'\n'` as the separator, which displays the output on separate lines instead of separated by whitespaces which is the default for character vectors. This is very useful for commands like `tree`, since the format of the output makes little sense unless separated by newlines. Compare the following for a sample directory named `test`: **Bash** ``` $ tree test test ├── A1.tif ├── A2.tif ├── A3.tif ├── README └── src ├── sample.R └── sample2.R 1 directory, 6 files ``` **R in Jupyter Notebook** `system` only, difficult to comprehend output: ``` > system('tree test', intern=TRUE) 'test' '├── A1.tif' '├── A2.tif' '├── A3.tif' '├── README' '└── src' ' ├── sample.R' ' └── sample2.R' '' '1 directory, 6 files ``` `cat` + `system`, output looks like in bash: ``` > cat(system('tree test', intern=TRUE), sep='\n') test ├── A1.tif ├── A2.tif ├── A3.tif ├── README └── src ├── sample.R └── sample2.R 1 directory, 6 files ``` Note that for commands like `ls`, the above would introduce a newline where outputs are normally separated by a space in bash. You can create a function to save you some typing: ``` > # "jupyter shell" function > js <- function(shell_command){ > cat(system(shell_command, intern=TRUE), sep='\n') > } > > # brief syntax for shell commands > js('tree test') ```
667,040
I have a server machine (A) which has ssh installed, along with a webserver. How do I forward the port with the webserver to my local machine (B). I should be able to browse to `http://localhost:forwardedport` Is this LOCAL or REMOTE port fowarding? Here's what I've tried. ``` ssh -L 8888:name.dnydns-server.com:8888 localhost ssh -L 8888:localhost:8888 name.dnydns-server.com and both of those with username@name.dnydns-server.com ``` What am I doing wrong? **EDIT**: The answers given were factually correct and explained the usage of port forwarding. It turned out that I was using the correct command, rather there was a firewall rule which prevented me from connecting to port 8888 FROM the server itself. I figured this out when I tried to connect to the website while sshed into the remote server.
2013/10/29
[ "https://superuser.com/questions/667040", "https://superuser.com", "https://superuser.com/users/35728/" ]
I guess you first need to get clear on some terms I'll use: **Client** means the machine where you start ssh. This machine is refered to by "local". **Server** means the machine you want to connect to with ssh. This machine is refered to by "remote". **Local port forwarding** with ssh means you connect from your client to your server and thereby open a tunnel so that another program on your client can connect via a local port to a host&port on the server site. The option for this is -L local\_port:remote\_machine:remote\_port. **Remote port forwarding** with ssh means you connect from your client to your server and thereby open a tunnel so that a program on your server can connect via a port on the server to a host&port on the client site. The option for this is -R remote\_port:local\_machine:local\_port. If I understand you correctly, you want a local forwarding, e.g. create a connection to your server name.dnydns-server.com and then connect with your local browser to port 8888 on name.dnydns-server.com. The following command from your list should actually do what you want: ``` ssh -L 8888:localhost:8888 name.dnydns-server.com ``` The first 8888 is the port on your client that your additional program (browser) can connet to. The "localhost" in that line is seen from the end of the tunnel, that is on the server (name.dnydns-server.com). There localhost is the machine itself so it's the one you want. (You could place a different name on the network of your server there to access that) The second 8888 is the port you want to connect to on the server site. If you run your webserver on the standard port 80, you'll have to change this to 80. name.dnydns-server.com is the name of your ssh server where you connect to, which is then the endpoint of the tunnel. I don't know why this line didn't work for you though. Did you quit the ssh? It has to stay connected the whole time for the tunnel to work. Default port on the webserver? Webserver not running? **Edit:** I changed the definition of "client" and "server" to clarify things, so some of the comments don't apply anymore and refer to deleted content.
I am presuming that the server has sshd installed, and listening on the well known default port (22), and that the web server is listening on the well-known default port (80). The assumption is that the server is the server (A) is the 'conduit' through which you want to tunnel to get to the web server. Here's what you need to 'tell' ssh in this case: ``` ssh -L <local port to point your browser toward>:<host name or IP of the web server>:<port that the web server is listening on> <valid user on server>@<server name or ip address> ``` So, here's what I think it should look like based on what I think you're trying to do: ``` ssh -L 8888:web.server.dyndns-server.com:80 youruserid@yourserver ``` Do this, then point your browser to localhost:8888.
33,134,621
I want to compile this code: ``` #include <stdalign.h> #include <stdio.h> #include <stddef.h> int main ( int argc , char ** argv ) { printf ("%zu\n", alignof ( max_align_t )); return 0; } ``` But compiler says that: ``` error: ‘max_align_t’ undeclared". ``` `stddef.h` is included and everything must be ok, isn't it? P.S. I already tried to compile this code under gcc4.8 and gcc4.9, but I have error as described.
2015/10/14
[ "https://Stackoverflow.com/questions/33134621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5444662/" ]
To use a C11 feature you need to tell the compiler to run in C11 compliant mode. For gcc this can be achieved by specifying the option `-std=c11`.
I use a compiler that is natively based on c99 that has a stddef.h that it uses. On my computer I need to use the -std=c11 option and also a header file that apparently corresponds to c11.
53,405,895
I have a table like: ``` id fkey srno remark date 1 A001 1 2 A001 2 3 A002 1 4 A003 1 5 A002 2 ``` I want distinct latest record based on max srno like ``` 2 A001 2 4 A003 1 5 A002 2 ```
2018/11/21
[ "https://Stackoverflow.com/questions/53405895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4337261/" ]
use window function `row_number()` ``` select * from ( select *,row_number() over(PARTITION by fkey order by srno desc) rn from table1 t1 ) t where rn=1 ``` you can write it by using cte ``` with cte as ( select *,row_number() over(PARTITION by fkey order by srno desc) rn from table_name t1 ) select * from cte where rn=1 ```
You can use correlated subquery ``` select * from tablename where srno in (select max(srno) from tablename b where a.fkey=b.fkey) ```
53,405,895
I have a table like: ``` id fkey srno remark date 1 A001 1 2 A001 2 3 A002 1 4 A003 1 5 A002 2 ``` I want distinct latest record based on max srno like ``` 2 A001 2 4 A003 1 5 A002 2 ```
2018/11/21
[ "https://Stackoverflow.com/questions/53405895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4337261/" ]
The best way to do this in Postgres is to use `DISTINCT ON`: ``` SELECT DISTINCT ON (fkey) id, fkey, srno FROM yourTable ORDER BY fkey, srno DESC; ``` [![enter image description here](https://i.stack.imgur.com/LkEyJ.png)](https://i.stack.imgur.com/LkEyJ.png) [Demo ----](https://dbfiddle.uk/?rdbms=postgres_11&fiddle=45e6379feee11ead0fbc1bf8e790a144)
You can use correlated subquery ``` select * from tablename where srno in (select max(srno) from tablename b where a.fkey=b.fkey) ```
53,405,895
I have a table like: ``` id fkey srno remark date 1 A001 1 2 A001 2 3 A002 1 4 A003 1 5 A002 2 ``` I want distinct latest record based on max srno like ``` 2 A001 2 4 A003 1 5 A002 2 ```
2018/11/21
[ "https://Stackoverflow.com/questions/53405895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4337261/" ]
The best way to do this in Postgres is to use `DISTINCT ON`: ``` SELECT DISTINCT ON (fkey) id, fkey, srno FROM yourTable ORDER BY fkey, srno DESC; ``` [![enter image description here](https://i.stack.imgur.com/LkEyJ.png)](https://i.stack.imgur.com/LkEyJ.png) [Demo ----](https://dbfiddle.uk/?rdbms=postgres_11&fiddle=45e6379feee11ead0fbc1bf8e790a144)
use window function `row_number()` ``` select * from ( select *,row_number() over(PARTITION by fkey order by srno desc) rn from table1 t1 ) t where rn=1 ``` you can write it by using cte ``` with cte as ( select *,row_number() over(PARTITION by fkey order by srno desc) rn from table_name t1 ) select * from cte where rn=1 ```
53,405,895
I have a table like: ``` id fkey srno remark date 1 A001 1 2 A001 2 3 A002 1 4 A003 1 5 A002 2 ``` I want distinct latest record based on max srno like ``` 2 A001 2 4 A003 1 5 A002 2 ```
2018/11/21
[ "https://Stackoverflow.com/questions/53405895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4337261/" ]
use window function `row_number()` ``` select * from ( select *,row_number() over(PARTITION by fkey order by srno desc) rn from table1 t1 ) t where rn=1 ``` you can write it by using cte ``` with cte as ( select *,row_number() over(PARTITION by fkey order by srno desc) rn from table_name t1 ) select * from cte where rn=1 ```
You may use a subquery with an `IN` operator ``` with tab(id, fkey, srno) as ( select 1,'A001',1 union all select 2,'A001',2 union all select 3,'A002',1 union all select 4,'A003',1 union all select 5,'A002',2 ) select * from tab where ( fkey, srno ) in ( select fkey, max(srno) from tab group by fkey ); id fkey srno 2 A001 2 4 A003 1 5 A002 2 ``` [***Rextester Demo***](https://rextester.com/KPF2258)
53,405,895
I have a table like: ``` id fkey srno remark date 1 A001 1 2 A001 2 3 A002 1 4 A003 1 5 A002 2 ``` I want distinct latest record based on max srno like ``` 2 A001 2 4 A003 1 5 A002 2 ```
2018/11/21
[ "https://Stackoverflow.com/questions/53405895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4337261/" ]
The best way to do this in Postgres is to use `DISTINCT ON`: ``` SELECT DISTINCT ON (fkey) id, fkey, srno FROM yourTable ORDER BY fkey, srno DESC; ``` [![enter image description here](https://i.stack.imgur.com/LkEyJ.png)](https://i.stack.imgur.com/LkEyJ.png) [Demo ----](https://dbfiddle.uk/?rdbms=postgres_11&fiddle=45e6379feee11ead0fbc1bf8e790a144)
You may use a subquery with an `IN` operator ``` with tab(id, fkey, srno) as ( select 1,'A001',1 union all select 2,'A001',2 union all select 3,'A002',1 union all select 4,'A003',1 union all select 5,'A002',2 ) select * from tab where ( fkey, srno ) in ( select fkey, max(srno) from tab group by fkey ); id fkey srno 2 A001 2 4 A003 1 5 A002 2 ``` [***Rextester Demo***](https://rextester.com/KPF2258)
681,226
I have PHP application that is completely procedural (No PHP Classes). In my case, is there any formal diagrams I can draw to show how my web application that is equivalent to a UML class diagram for OOP based applications. Thanks all
2009/03/25
[ "https://Stackoverflow.com/questions/681226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
[doxygen](http://www.doxygen.org/) can generate call- and caller graphs automatically - if that suits your needs.
You could make some Hatley-Pirbhai models: <http://en.wikipedia.org/wiki/Hatley-Pirbhai_modeling>
681,226
I have PHP application that is completely procedural (No PHP Classes). In my case, is there any formal diagrams I can draw to show how my web application that is equivalent to a UML class diagram for OOP based applications. Thanks all
2009/03/25
[ "https://Stackoverflow.com/questions/681226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
You could make some Hatley-Pirbhai models: <http://en.wikipedia.org/wiki/Hatley-Pirbhai_modeling>
It's not because the implementation (or even the design) is procedural, that the business model is. Though you may not find explicit reference to classes in your code, they may still be there, hidden, scattered through global variables etc, functions manipulating some globals, ... So in order to describe your app, you *may* still be able to use a (conceptual) class diagram.
681,226
I have PHP application that is completely procedural (No PHP Classes). In my case, is there any formal diagrams I can draw to show how my web application that is equivalent to a UML class diagram for OOP based applications. Thanks all
2009/03/25
[ "https://Stackoverflow.com/questions/681226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
[doxygen](http://www.doxygen.org/) can generate call- and caller graphs automatically - if that suits your needs.
It's not because the implementation (or even the design) is procedural, that the business model is. Though you may not find explicit reference to classes in your code, they may still be there, hidden, scattered through global variables etc, functions manipulating some globals, ... So in order to describe your app, you *may* still be able to use a (conceptual) class diagram.
58,267,243
I have problems when sending email, I make registration and verification by email, when on localhost everything runs smoothly, there are no problems, but when I am hosting, the email function cannot, please help ``` $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.gmail.com', 'smtp_port' => 465, 'smtp_user' => 'email@gmail.com', // change it to yours 'smtp_pass' => 'mypassword', // change it to yours 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE ); $message = " <html> <head> <title>Verifikasi Kode</title> </head> <body> <h2>Terima kasih telah berpartisipasi.</h2> <p>Akun anda:</p> <p>Email: ".$email."</p> <p>Untuk melanjutkan pendaftaran, mohon klik link yang kami berikan</p> <h4><a href='".base_url()."register/aktivasi/".$id."'>Activate My Account</a></h4> </body> </html> "; $this->email->initialize($config); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from($config['smtp_user']); $this->email->to($email); $this->email->subject('Signup Verification Email, abcd.com | No reply'); $this->email->message($message); if($this->email->send()){ $this->session->set_flashdata('msg','Kode Aktivasi telah dikirim ke email, mohon di cek'); } else{ $this->session->set_flashdata('msg', $this->email->print_debugger()); } redirect('register',$data); } ``` > > Error : Failed to authenticate password. Error: 534-5.7.14 Please 534-5.7.14 log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 <https://support.google.com/mail/answer/78754> 18sm13749594pfp.100 - gsmtp > > > Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. > > >
2019/10/07
[ "https://Stackoverflow.com/questions/58267243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11944485/" ]
**Tl;dr:** > > You'll see this occur in most templates in the Template Gallery. The > official [Google Documentation](https://developers.google.com/tag-platform/tag-manager/templates/api#createqueue) has nothing to say about it. > However, in my tests, this small change in structure (nesting your > pushes in randomly-named sub-objects) does not affect GTM's ability to > pick up on the event names. So you should be able to use them as they > are. > > > **Detailed response** Even though you see nesting within the dataLayer object, this doesn't translate to nesting within GTM's data model. To test this, consider the following setup: 1. A custom HTML tag that pushes a nested object to the dataLayer ```html <script> var dataLayer = window.dataLayer || []; dataLayer.push({lv:{bl:{event:'test'}}}); </script> ``` 2. A Tag Template that pushes a simple event to the dataLayer ```js const dataLayerPush = require('createQueue')('dataLayer'); dataLayerPush({event:'test'}); data.gtmOnSuccess(); ``` These 2, when fired, will produce seemingly identical results. Check the linked image for details. [Test Events pushed by the Tag Template (1) and Custom HTML Tag (2)](https://i.stack.imgur.com/QP3Np.png) However, if you set up a Custom Event Trigger that listens for `'test'` event names, only the one created by the Tag Template will fire. You can also see that the one created by the Tag Template also has a `gtm.uniqueEventId` key-value pair. The objects are not the same, and they are not treated the same way. You can try to debug further by using the [dataLayer helper](https://github.com/google/data-layer-helper), if that's doable for you. Hope this helps the next person to stumble upon this. I know I needed it.
For a dataLayer push you can use a custom HTML template and trigger it via page view then add the below code ``` <script> window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'test_push' }); </script> ```
1,179
The design of SO/SU/SF is very clean and easy to use, I want to have a similar one to host the Q/A service in my local company, is it open source? or does stack overflow service inc. have the Q/A hosting service?
2010/07/24
[ "https://meta.superuser.com/questions/1179", "https://meta.superuser.com", "https://meta.superuser.com/users/19926/" ]
I'm sorry to say that no, you can't self host. And it is not open source. But there are open source clones exist. One of the example is [cnprog](http://cnprog.com/). You can access the source [here](http://code.google.com/p/cnprog/) and [here](http://github.com/cnprog/CNPROG). After you have the source, you can do anything you want.
Check out [Area 51](http://area51.stackexchange.com/).
4,641,495
I want to make a simple script to post a tweet from a Textbox when the user click on the Submit button, but all using Javascript, without any server-side language. How may I do this?
2011/01/09
[ "https://Stackoverflow.com/questions/4641495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/126353/" ]
What you want to use is Twitter Anywhere, develop by twitter <http://dev.twitter.com/anywhere> This handles all OAuth, create the box and post the tweet.
<http://www.saschakimmel.com/2009/05/how-to-create-a-dynamic-tweet-this-button-with-javascript/> But just change the document.title to the location of your textbox
3,686,778
I'm trying to store an hexadecimal value (\xC1) in MySql Database. When I print that with PHP, i get: xC1lcool instead of the right word. > > INSERT INTO veiculos VALUES (1, 'Ford', 'Ka RoCam Flex', 25850.00, 1998, 1999, 'Vermelho', 15000, '\xC1lcool;Gasolina;GNV', 'Ar-Condicionado;4 portas;Câmbio automático', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'), (2, 'Ford', 'Ka RoCam Flex', 223850.00, 1999, 2001, 'Prata', 10000, '\xC1lcool;GNV', 'Ar-Condicionado;4 portas;Câmbio automático;', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'), (3, 'Ford', 'Fiesta', 21380.00, 1998, 2002, 'Preto', 23043, 'Gasolina', '', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'); > > > How could i do that?
2010/09/10
[ "https://Stackoverflow.com/questions/3686778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444582/" ]
`\x` is not a valid escape sequence. Valid sequences are detailed at <http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html> Quoting the manual: > > For all other escape sequences, > backslash is ignored. That is, the > escaped character is interpreted as if > it was not escaped. For example, “\x” > is just “x”. > > > You can specify a full string in hexadecimal: ``` SELECT 0x61626364 -- Prints abcd ``` If you want to mix both styles, you have to concatenate: ``` SELECT CONCAT('a', 0x6263, 'd') -- Prints abcd ```
Use MySQL [`UNHEX()`](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_unhex) function with [`CONCAT()`](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat). Like this ``` insert into tablename values (CONCAT(UNHEX('C1'), 'other-part-of-string')) ```
3,686,778
I'm trying to store an hexadecimal value (\xC1) in MySql Database. When I print that with PHP, i get: xC1lcool instead of the right word. > > INSERT INTO veiculos VALUES (1, 'Ford', 'Ka RoCam Flex', 25850.00, 1998, 1999, 'Vermelho', 15000, '\xC1lcool;Gasolina;GNV', 'Ar-Condicionado;4 portas;Câmbio automático', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'), (2, 'Ford', 'Ka RoCam Flex', 223850.00, 1999, 2001, 'Prata', 10000, '\xC1lcool;GNV', 'Ar-Condicionado;4 portas;Câmbio automático;', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'), (3, 'Ford', 'Fiesta', 21380.00, 1998, 2002, 'Preto', 23043, 'Gasolina', '', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'); > > > How could i do that?
2010/09/10
[ "https://Stackoverflow.com/questions/3686778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/444582/" ]
`\x` is not a valid escape sequence. Valid sequences are detailed at <http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html> Quoting the manual: > > For all other escape sequences, > backslash is ignored. That is, the > escaped character is interpreted as if > it was not escaped. For example, “\x” > is just “x”. > > > You can specify a full string in hexadecimal: ``` SELECT 0x61626364 -- Prints abcd ``` If you want to mix both styles, you have to concatenate: ``` SELECT CONCAT('a', 0x6263, 'd') -- Prints abcd ```
You can store full binary data, such as an image or pdf in a MySQL database. When you insert the value make sure you do a `"insert ... values(".mysql_real_escape_string($value).")";`. It is recommended that you use the blob datatype for that column, but you can use a varchar if you really want to. After that when you select the data out it will be normal, you don't have to do anything else. In the case of an image, just use a `header(content-type: ...)` and print out the variable normally and the image will be displayed to the end user.
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
You can find the [full incident report here](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf) and this topic is touched upon briefly, but in short they had little to no time to entertain any other options but a full speed landing. > > It was not until the aircraft [was] on the final descent for landing that > the Commander realised they could not reduce the thrust on the number > 1 engine. The speed was not controllable and from that point, there > was no time for the crew to consider other strategy nor procedure to > cope with such emergency situation. > > > and more in the conclusion section... > > **t.** At that stage, there was no time for the flight crew to consider other > strategy nor procedure to cope with such emergency situation. The > flight crew concentrated on flying the aircraft for a safe landing. > > > First off, the engine was throwing errors throughout the flight and they were talking to the maintenance team at other points. Ultimately, the proper steps were taken and everything was done by the book. They were prepared for an engine-out landing. When you have a runaway engine malfunction (or throttle stuck at full) shutting down prior to landing *may* not be the right decision if the running engine provides no immediate safety risk. If you shut down a problematic engine in flight you run the serious risk of not being able to get it started again. Considering that most airports have a bit (or a lot) of extra runway, [EMAS systems](https://en.wikipedia.org/wiki/Engineered_materials_arrestor_system) and often land at the end of the runway, coming in overspeed and burning through your tires and brakes may be safer than cutting the engine and potentially falling short of the runway.
Engine #2 wasn't doing its job either ------------------------------------- Had the situation just been engine #1 stuck at high thrust, with engine 2 normally controllable, than what you describe would be a reasonable response to the situation. However, that was *not* the case with CX780 -- during approach, Engine #2 was stuck at 17% N1 (or rather below idle) and thus delivering effectively nil thrust. As a result, the pilots dared not shut down engine #1 until they were safely stopped on the ground.
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
You can find the [full incident report here](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf) and this topic is touched upon briefly, but in short they had little to no time to entertain any other options but a full speed landing. > > It was not until the aircraft [was] on the final descent for landing that > the Commander realised they could not reduce the thrust on the number > 1 engine. The speed was not controllable and from that point, there > was no time for the crew to consider other strategy nor procedure to > cope with such emergency situation. > > > and more in the conclusion section... > > **t.** At that stage, there was no time for the flight crew to consider other > strategy nor procedure to cope with such emergency situation. The > flight crew concentrated on flying the aircraft for a safe landing. > > > First off, the engine was throwing errors throughout the flight and they were talking to the maintenance team at other points. Ultimately, the proper steps were taken and everything was done by the book. They were prepared for an engine-out landing. When you have a runaway engine malfunction (or throttle stuck at full) shutting down prior to landing *may* not be the right decision if the running engine provides no immediate safety risk. If you shut down a problematic engine in flight you run the serious risk of not being able to get it started again. Considering that most airports have a bit (or a lot) of extra runway, [EMAS systems](https://en.wikipedia.org/wiki/Engineered_materials_arrestor_system) and often land at the end of the runway, coming in overspeed and burning through your tires and brakes may be safer than cutting the engine and potentially falling short of the runway.
From the incident report section 1.1.4: > > a. At 0519 hrs during the descent to a cleared level of FL230, ECAM > messages “ENG 1 CTL SYS FAULT” and “ENG 2 STALL” were annunciated > within a short period of time. According to the Commander, a light > “pop” sound was heard and some “ozone” and “burning” smell was > detected shortly before the ECAM message “ENG 2 STALL” > > > Then later: > > e. At 0530 hrs, when the aircraft was approximately 45 nm southeast > from VHHH and was about to level off at 8,000 ft AMSL, ECAM message > “ENG 1 STALL” was annunciated. > > > So now both engines are out, they started the APU and successfully managed to restart #1: > > h. The crew moved the thrust levers to check the engine control but > there was no direct response from the engines. The No. 1 engine speed > eventually increased to about 74% N1 with the No. 1 thrust lever in > the CLB (climb) detent position. The No. 2 engine speed remained at > sub-idle about 17% N1, with the No. 2 t hrust lever at the IDLE > position. > > > Engine 2 was out of action, producing no power, engine 1 had failed, but was temporarily working although they couldn't adjust power, if they'd shut that down too they'd have been gliding and probably would have crashed with total loss of life. They didn't have the power to climb and had one shot at landing, so they made damn sure they got it on the runway, not a bad landing considering the circumstances. On a humorous note, another example of pilot understatement: > > l. At 0539 hrs, the Commander made another PA advising the passengers > of having “small problem with the engines” with small vibrations and > requesting them to remain seated and follow the directions from the > cabin crew. > > >
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
You can find the [full incident report here](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf) and this topic is touched upon briefly, but in short they had little to no time to entertain any other options but a full speed landing. > > It was not until the aircraft [was] on the final descent for landing that > the Commander realised they could not reduce the thrust on the number > 1 engine. The speed was not controllable and from that point, there > was no time for the crew to consider other strategy nor procedure to > cope with such emergency situation. > > > and more in the conclusion section... > > **t.** At that stage, there was no time for the flight crew to consider other > strategy nor procedure to cope with such emergency situation. The > flight crew concentrated on flying the aircraft for a safe landing. > > > First off, the engine was throwing errors throughout the flight and they were talking to the maintenance team at other points. Ultimately, the proper steps were taken and everything was done by the book. They were prepared for an engine-out landing. When you have a runaway engine malfunction (or throttle stuck at full) shutting down prior to landing *may* not be the right decision if the running engine provides no immediate safety risk. If you shut down a problematic engine in flight you run the serious risk of not being able to get it started again. Considering that most airports have a bit (or a lot) of extra runway, [EMAS systems](https://en.wikipedia.org/wiki/Engineered_materials_arrestor_system) and often land at the end of the runway, coming in overspeed and burning through your tires and brakes may be safer than cutting the engine and potentially falling short of the runway.
Aside from what Unrec. and GdD point out, even if the other engine had been running perfectly... A frequent problem with twin engine airplanes is **[shutting down](https://en.wikipedia.org/wiki/Kegworth_air_disaster) the [wrong](https://en.wikipedia.org/wiki/TransAsia_Airways_Flight_235) engine**. Nobody ever expects or plans to shut down the wrong engine, but it happens anyway. So a crew is very cautious to shutdown an engine that is working.
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
You can find the [full incident report here](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf) and this topic is touched upon briefly, but in short they had little to no time to entertain any other options but a full speed landing. > > It was not until the aircraft [was] on the final descent for landing that > the Commander realised they could not reduce the thrust on the number > 1 engine. The speed was not controllable and from that point, there > was no time for the crew to consider other strategy nor procedure to > cope with such emergency situation. > > > and more in the conclusion section... > > **t.** At that stage, there was no time for the flight crew to consider other > strategy nor procedure to cope with such emergency situation. The > flight crew concentrated on flying the aircraft for a safe landing. > > > First off, the engine was throwing errors throughout the flight and they were talking to the maintenance team at other points. Ultimately, the proper steps were taken and everything was done by the book. They were prepared for an engine-out landing. When you have a runaway engine malfunction (or throttle stuck at full) shutting down prior to landing *may* not be the right decision if the running engine provides no immediate safety risk. If you shut down a problematic engine in flight you run the serious risk of not being able to get it started again. Considering that most airports have a bit (or a lot) of extra runway, [EMAS systems](https://en.wikipedia.org/wiki/Engineered_materials_arrestor_system) and often land at the end of the runway, coming in overspeed and burning through your tires and brakes may be safer than cutting the engine and potentially falling short of the runway.
I could be wrong but reverse thrust from the running engine helped to stop the plane1 as it was approaching at a great speed way over the recommended landing speed, so shutting the running engine off right at approach would have made the plane to overshoot the runway, making the situation worse. --- 1: Source: > > [...] The aircraft then rolled left seven degrees and > pitched down to -2.5 degrees at the second touchdown during which, the lower > cowling of No. 1 engine contacted the runway surface. Spoilers deployed > automatically. **Both engine thrust reversers were selected by the Commander. > Only No. 1 engine thrust reverser was deployed successfully and ECAM message > “ENG 2 REV FAULT” was annunciated.** Maximum manual braking was > applied. ... *[[Accident report](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf), page 26. Engine #1 was the one that was stuck at 74% N1.]* > > >
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
Engine #2 wasn't doing its job either ------------------------------------- Had the situation just been engine #1 stuck at high thrust, with engine 2 normally controllable, than what you describe would be a reasonable response to the situation. However, that was *not* the case with CX780 -- during approach, Engine #2 was stuck at 17% N1 (or rather below idle) and thus delivering effectively nil thrust. As a result, the pilots dared not shut down engine #1 until they were safely stopped on the ground.
From the incident report section 1.1.4: > > a. At 0519 hrs during the descent to a cleared level of FL230, ECAM > messages “ENG 1 CTL SYS FAULT” and “ENG 2 STALL” were annunciated > within a short period of time. According to the Commander, a light > “pop” sound was heard and some “ozone” and “burning” smell was > detected shortly before the ECAM message “ENG 2 STALL” > > > Then later: > > e. At 0530 hrs, when the aircraft was approximately 45 nm southeast > from VHHH and was about to level off at 8,000 ft AMSL, ECAM message > “ENG 1 STALL” was annunciated. > > > So now both engines are out, they started the APU and successfully managed to restart #1: > > h. The crew moved the thrust levers to check the engine control but > there was no direct response from the engines. The No. 1 engine speed > eventually increased to about 74% N1 with the No. 1 thrust lever in > the CLB (climb) detent position. The No. 2 engine speed remained at > sub-idle about 17% N1, with the No. 2 t hrust lever at the IDLE > position. > > > Engine 2 was out of action, producing no power, engine 1 had failed, but was temporarily working although they couldn't adjust power, if they'd shut that down too they'd have been gliding and probably would have crashed with total loss of life. They didn't have the power to climb and had one shot at landing, so they made damn sure they got it on the runway, not a bad landing considering the circumstances. On a humorous note, another example of pilot understatement: > > l. At 0539 hrs, the Commander made another PA advising the passengers > of having “small problem with the engines” with small vibrations and > requesting them to remain seated and follow the directions from the > cabin crew. > > >
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
Engine #2 wasn't doing its job either ------------------------------------- Had the situation just been engine #1 stuck at high thrust, with engine 2 normally controllable, than what you describe would be a reasonable response to the situation. However, that was *not* the case with CX780 -- during approach, Engine #2 was stuck at 17% N1 (or rather below idle) and thus delivering effectively nil thrust. As a result, the pilots dared not shut down engine #1 until they were safely stopped on the ground.
Aside from what Unrec. and GdD point out, even if the other engine had been running perfectly... A frequent problem with twin engine airplanes is **[shutting down](https://en.wikipedia.org/wiki/Kegworth_air_disaster) the [wrong](https://en.wikipedia.org/wiki/TransAsia_Airways_Flight_235) engine**. Nobody ever expects or plans to shut down the wrong engine, but it happens anyway. So a crew is very cautious to shutdown an engine that is working.
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
Engine #2 wasn't doing its job either ------------------------------------- Had the situation just been engine #1 stuck at high thrust, with engine 2 normally controllable, than what you describe would be a reasonable response to the situation. However, that was *not* the case with CX780 -- during approach, Engine #2 was stuck at 17% N1 (or rather below idle) and thus delivering effectively nil thrust. As a result, the pilots dared not shut down engine #1 until they were safely stopped on the ground.
I could be wrong but reverse thrust from the running engine helped to stop the plane1 as it was approaching at a great speed way over the recommended landing speed, so shutting the running engine off right at approach would have made the plane to overshoot the runway, making the situation worse. --- 1: Source: > > [...] The aircraft then rolled left seven degrees and > pitched down to -2.5 degrees at the second touchdown during which, the lower > cowling of No. 1 engine contacted the runway surface. Spoilers deployed > automatically. **Both engine thrust reversers were selected by the Commander. > Only No. 1 engine thrust reverser was deployed successfully and ECAM message > “ENG 2 REV FAULT” was annunciated.** Maximum manual braking was > applied. ... *[[Accident report](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf), page 26. Engine #1 was the one that was stuck at 74% N1.]* > > >
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
From the incident report section 1.1.4: > > a. At 0519 hrs during the descent to a cleared level of FL230, ECAM > messages “ENG 1 CTL SYS FAULT” and “ENG 2 STALL” were annunciated > within a short period of time. According to the Commander, a light > “pop” sound was heard and some “ozone” and “burning” smell was > detected shortly before the ECAM message “ENG 2 STALL” > > > Then later: > > e. At 0530 hrs, when the aircraft was approximately 45 nm southeast > from VHHH and was about to level off at 8,000 ft AMSL, ECAM message > “ENG 1 STALL” was annunciated. > > > So now both engines are out, they started the APU and successfully managed to restart #1: > > h. The crew moved the thrust levers to check the engine control but > there was no direct response from the engines. The No. 1 engine speed > eventually increased to about 74% N1 with the No. 1 thrust lever in > the CLB (climb) detent position. The No. 2 engine speed remained at > sub-idle about 17% N1, with the No. 2 t hrust lever at the IDLE > position. > > > Engine 2 was out of action, producing no power, engine 1 had failed, but was temporarily working although they couldn't adjust power, if they'd shut that down too they'd have been gliding and probably would have crashed with total loss of life. They didn't have the power to climb and had one shot at landing, so they made damn sure they got it on the runway, not a bad landing considering the circumstances. On a humorous note, another example of pilot understatement: > > l. At 0539 hrs, the Commander made another PA advising the passengers > of having “small problem with the engines” with small vibrations and > requesting them to remain seated and follow the directions from the > cabin crew. > > >
Aside from what Unrec. and GdD point out, even if the other engine had been running perfectly... A frequent problem with twin engine airplanes is **[shutting down](https://en.wikipedia.org/wiki/Kegworth_air_disaster) the [wrong](https://en.wikipedia.org/wiki/TransAsia_Airways_Flight_235) engine**. Nobody ever expects or plans to shut down the wrong engine, but it happens anyway. So a crew is very cautious to shutdown an engine that is working.
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
From the incident report section 1.1.4: > > a. At 0519 hrs during the descent to a cleared level of FL230, ECAM > messages “ENG 1 CTL SYS FAULT” and “ENG 2 STALL” were annunciated > within a short period of time. According to the Commander, a light > “pop” sound was heard and some “ozone” and “burning” smell was > detected shortly before the ECAM message “ENG 2 STALL” > > > Then later: > > e. At 0530 hrs, when the aircraft was approximately 45 nm southeast > from VHHH and was about to level off at 8,000 ft AMSL, ECAM message > “ENG 1 STALL” was annunciated. > > > So now both engines are out, they started the APU and successfully managed to restart #1: > > h. The crew moved the thrust levers to check the engine control but > there was no direct response from the engines. The No. 1 engine speed > eventually increased to about 74% N1 with the No. 1 thrust lever in > the CLB (climb) detent position. The No. 2 engine speed remained at > sub-idle about 17% N1, with the No. 2 t hrust lever at the IDLE > position. > > > Engine 2 was out of action, producing no power, engine 1 had failed, but was temporarily working although they couldn't adjust power, if they'd shut that down too they'd have been gliding and probably would have crashed with total loss of life. They didn't have the power to climb and had one shot at landing, so they made damn sure they got it on the runway, not a bad landing considering the circumstances. On a humorous note, another example of pilot understatement: > > l. At 0539 hrs, the Commander made another PA advising the passengers > of having “small problem with the engines” with small vibrations and > requesting them to remain seated and follow the directions from the > cabin crew. > > >
I could be wrong but reverse thrust from the running engine helped to stop the plane1 as it was approaching at a great speed way over the recommended landing speed, so shutting the running engine off right at approach would have made the plane to overshoot the runway, making the situation worse. --- 1: Source: > > [...] The aircraft then rolled left seven degrees and > pitched down to -2.5 degrees at the second touchdown during which, the lower > cowling of No. 1 engine contacted the runway surface. Spoilers deployed > automatically. **Both engine thrust reversers were selected by the Commander. > Only No. 1 engine thrust reverser was deployed successfully and ECAM message > “ENG 2 REV FAULT” was annunciated.** Maximum manual braking was > applied. ... *[[Accident report](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf), page 26. Engine #1 was the one that was stuck at 74% N1.]* > > >
59,303
In the approach phase, engine 1 of [Cathay Pacific flight 780](https://en.wikipedia.org/wiki/Cathay_Pacific_Flight_780) got stuck at about 70% N1 and it forced the crew to do an overspeed landing (230knots). Why didn't they shut it off by turning the fuel pumps off? Is there a backup mechanism if the fuel valve fails like in this scenario?
2019/01/22
[ "https://aviation.stackexchange.com/questions/59303", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/36788/" ]
Aside from what Unrec. and GdD point out, even if the other engine had been running perfectly... A frequent problem with twin engine airplanes is **[shutting down](https://en.wikipedia.org/wiki/Kegworth_air_disaster) the [wrong](https://en.wikipedia.org/wiki/TransAsia_Airways_Flight_235) engine**. Nobody ever expects or plans to shut down the wrong engine, but it happens anyway. So a crew is very cautious to shutdown an engine that is working.
I could be wrong but reverse thrust from the running engine helped to stop the plane1 as it was approaching at a great speed way over the recommended landing speed, so shutting the running engine off right at approach would have made the plane to overshoot the runway, making the situation worse. --- 1: Source: > > [...] The aircraft then rolled left seven degrees and > pitched down to -2.5 degrees at the second touchdown during which, the lower > cowling of No. 1 engine contacted the runway surface. Spoilers deployed > automatically. **Both engine thrust reversers were selected by the Commander. > Only No. 1 engine thrust reverser was deployed successfully and ECAM message > “ENG 2 REV FAULT” was annunciated.** Maximum manual braking was > applied. ... *[[Accident report](https://www.webcitation.org/6Rk7TGDPW?url=http://www.cad.gov.hk/reports/2%20Final%20Report%20-%20CX%20780%202013%2007%20web%20access%20compliant.pdf), page 26. Engine #1 was the one that was stuck at 74% N1.]* > > >
969,292
I develop some program and I encountered to this problem: ![enter image description here](https://i.stack.imgur.com/5reAv.png) We know point **P**, **X**, and angle **a**. Range of angle is <0°,360°> between lines **p** and **o**. How I can determine in which side of line **o** is point **X**? Line **p** is always perpendicular to x axe. I thought that I would use this equation: (**Bx - Ax) \* (Cy - Ay) - (By - Ay) \* (Cx - Ax)** (slope) but second point of line **o** is missing and I have no idea how do this with given angle.
2014/10/11
[ "https://math.stackexchange.com/questions/969292", "https://math.stackexchange.com", "https://math.stackexchange.com/users/183624/" ]
You have two vectors: $X-P$ and $\langle \cos\left(\frac{\pi}{2}-\alpha\right), \sin\left(\frac{\pi}{2}-\alpha\right)\rangle$. $X$ lies below the line if and only if $(X-P) \times \langle \cos\left(\frac{\pi}{2}-\alpha\right), \sin\left(\frac{\pi}{2}-\alpha\right)\rangle$ (when both are regarded as vectors in $\mathbb{R}^3$ with zero third coordinate) points upwards (so that the three form a right-handed system).
Equation for line $o$: $$ u(t) = p + t q $$ for $t \in \mathbb{R}$ with normed direction vector $q = (\sin a, \cos a)^T$ and vector $p = (x, y)^T$. Then $$ v = x-p $$ where $x = (a, b)^T$ (vector $x$, not coordinate $x$; coordinate $a$, not angle $a$) and $v$ is the vector from line $o$, at the end point of $p$, to the end point of $x$. And now we decompose $v$ into two parts: $$ v\_q = (v \cdot q) \, q $$ is the part of $v$ in direction of $q$. Then $$ v\_\perp = v - v\_q $$ is the part of $v$ orthogonal to $o$'s direction vector $q$. It should have a negative $y$ coordinate if $x$'s end point is below the line $o$, if the angle $a$ is non-zero, $a \in (0, 2\pi)$. Otherwise ($a = 0$) check if it's $x$ coordinate is positive. ### Example This is a vector on the line $o$: ``` octave> p = [2, 5]' p = 2 5 ``` Line $o$ has an $60^\circ$ angle $a$ regarding to the $y$-axis: ``` octave> a = 60 * 2 * pi / 360 a = 1.0472 ``` Vector $q$ is a normed direction vector of line $o$: ``` octave> q = [sin(a), cos(a)]' q = 0.86603 0.50000 ``` This is an example vector below the line $o$: ``` octave> x = [4,3]' x = 4 3 ``` Here we have the difference vector $v$ that would lead from $p$ to $x$: ``` octave> v = x - p v = 2 -2 ``` This is $v\_q$, the part of $v$ in direction of $q$: ``` octave> vq = (v' * q) * q vq = 0.63397 0.36603 ``` And this is $v\_\perp$, the part of $v$ orthogonal to $q$: ``` octave> vo = v - vq vo = 1.3660 -2.3660 ``` A test: ``` octave> vo + vq ans = 2.0000 -2.0000 ``` The $y$-coordinate is negative (and $a$ is non-zero): ``` octave> vo(2) ans = -2.3660 ``` We can put the test into an octave function: ``` octave> function res = test(x) > p=[2,5]' > a = 60*2*pi/360 > q = [sin(a), cos(a)]' > v = x - p > vq = (v'*q)*q > vo = v - vq > if (vo(2) == 0) > res = 0 > else > res = vo(2)/abs(vo(2)) > endif > endfunction ``` Some applications: ``` octave> x2 = [ -2, 7]' octave> test(x2) .. ans = 1 ``` which means $x\_2$ is above line $o$. And then ``` octave> test(p) ans = 0 ``` which means $p$ is on the line $o$.
969,292
I develop some program and I encountered to this problem: ![enter image description here](https://i.stack.imgur.com/5reAv.png) We know point **P**, **X**, and angle **a**. Range of angle is <0°,360°> between lines **p** and **o**. How I can determine in which side of line **o** is point **X**? Line **p** is always perpendicular to x axe. I thought that I would use this equation: (**Bx - Ax) \* (Cy - Ay) - (By - Ay) \* (Cx - Ax)** (slope) but second point of line **o** is missing and I have no idea how do this with given angle.
2014/10/11
[ "https://math.stackexchange.com/questions/969292", "https://math.stackexchange.com", "https://math.stackexchange.com/users/183624/" ]
Equation for line $o$: $$ u(t) = p + t q $$ for $t \in \mathbb{R}$ with normed direction vector $q = (\sin a, \cos a)^T$ and vector $p = (x, y)^T$. Then $$ v = x-p $$ where $x = (a, b)^T$ (vector $x$, not coordinate $x$; coordinate $a$, not angle $a$) and $v$ is the vector from line $o$, at the end point of $p$, to the end point of $x$. And now we decompose $v$ into two parts: $$ v\_q = (v \cdot q) \, q $$ is the part of $v$ in direction of $q$. Then $$ v\_\perp = v - v\_q $$ is the part of $v$ orthogonal to $o$'s direction vector $q$. It should have a negative $y$ coordinate if $x$'s end point is below the line $o$, if the angle $a$ is non-zero, $a \in (0, 2\pi)$. Otherwise ($a = 0$) check if it's $x$ coordinate is positive. ### Example This is a vector on the line $o$: ``` octave> p = [2, 5]' p = 2 5 ``` Line $o$ has an $60^\circ$ angle $a$ regarding to the $y$-axis: ``` octave> a = 60 * 2 * pi / 360 a = 1.0472 ``` Vector $q$ is a normed direction vector of line $o$: ``` octave> q = [sin(a), cos(a)]' q = 0.86603 0.50000 ``` This is an example vector below the line $o$: ``` octave> x = [4,3]' x = 4 3 ``` Here we have the difference vector $v$ that would lead from $p$ to $x$: ``` octave> v = x - p v = 2 -2 ``` This is $v\_q$, the part of $v$ in direction of $q$: ``` octave> vq = (v' * q) * q vq = 0.63397 0.36603 ``` And this is $v\_\perp$, the part of $v$ orthogonal to $q$: ``` octave> vo = v - vq vo = 1.3660 -2.3660 ``` A test: ``` octave> vo + vq ans = 2.0000 -2.0000 ``` The $y$-coordinate is negative (and $a$ is non-zero): ``` octave> vo(2) ans = -2.3660 ``` We can put the test into an octave function: ``` octave> function res = test(x) > p=[2,5]' > a = 60*2*pi/360 > q = [sin(a), cos(a)]' > v = x - p > vq = (v'*q)*q > vo = v - vq > if (vo(2) == 0) > res = 0 > else > res = vo(2)/abs(vo(2)) > endif > endfunction ``` Some applications: ``` octave> x2 = [ -2, 7]' octave> test(x2) .. ans = 1 ``` which means $x\_2$ is above line $o$. And then ``` octave> test(p) ans = 0 ``` which means $p$ is on the line $o$.
Another way (renamed the angle as "A" to avoid confussion with the coordinate "a"): if (a-x)\*tan(A)>b-y then X is below the line.
969,292
I develop some program and I encountered to this problem: ![enter image description here](https://i.stack.imgur.com/5reAv.png) We know point **P**, **X**, and angle **a**. Range of angle is <0°,360°> between lines **p** and **o**. How I can determine in which side of line **o** is point **X**? Line **p** is always perpendicular to x axe. I thought that I would use this equation: (**Bx - Ax) \* (Cy - Ay) - (By - Ay) \* (Cx - Ax)** (slope) but second point of line **o** is missing and I have no idea how do this with given angle.
2014/10/11
[ "https://math.stackexchange.com/questions/969292", "https://math.stackexchange.com", "https://math.stackexchange.com/users/183624/" ]
You have two vectors: $X-P$ and $\langle \cos\left(\frac{\pi}{2}-\alpha\right), \sin\left(\frac{\pi}{2}-\alpha\right)\rangle$. $X$ lies below the line if and only if $(X-P) \times \langle \cos\left(\frac{\pi}{2}-\alpha\right), \sin\left(\frac{\pi}{2}-\alpha\right)\rangle$ (when both are regarded as vectors in $\mathbb{R}^3$ with zero third coordinate) points upwards (so that the three form a right-handed system).
Another way (renamed the angle as "A" to avoid confussion with the coordinate "a"): if (a-x)\*tan(A)>b-y then X is below the line.
2,817,849
Is there any PNG-fix for IE 6 and without modifying current HTML, CSS and image name? any javascript way. I can add any thing in `<head>........</head>` but can't modify anythings inside `<body>.....</body>`. in one shot i want to make transparent all png transparent.
2010/05/12
[ "https://Stackoverflow.com/questions/2817849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84201/" ]
As I just learned, [this script](http://code.google.com/p/ie7-js/) will make IE behave like a standards compliant browser, including PNG fixes.
This can be fix in 2 way 1. There is a fix file called png-fix.js, just get from net and include it before your `</body>` tag. 2. Better you can change you png file format into png-8 format via the photo-shop tool.
2,817,849
Is there any PNG-fix for IE 6 and without modifying current HTML, CSS and image name? any javascript way. I can add any thing in `<head>........</head>` but can't modify anythings inside `<body>.....</body>`. in one shot i want to make transparent all png transparent.
2010/05/12
[ "https://Stackoverflow.com/questions/2817849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84201/" ]
As I just learned, [this script](http://code.google.com/p/ie7-js/) will make IE behave like a standards compliant browser, including PNG fixes.
My preferred PNGFix is [DD\_belatedPNG](http://www.dillerdesign.com/experiment/DD_belatedPNG/). It is easy to use, example from the page: ``` <!--[if IE 6]> <script src="DD_belatedPNG.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('.png_bg'); /* string argument can be any CSS selector */ /* .png_bg example is unnecessary */ /* change it to what suits you! */ </script> <![endif]--> ``` You can set that `.png_bg` selector to whatever you see fit. Perhaps you want to replace all of the headings on a page: `DD_belatedPNG.fix('h1,h2,h3');`
2,817,849
Is there any PNG-fix for IE 6 and without modifying current HTML, CSS and image name? any javascript way. I can add any thing in `<head>........</head>` but can't modify anythings inside `<body>.....</body>`. in one shot i want to make transparent all png transparent.
2010/05/12
[ "https://Stackoverflow.com/questions/2817849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84201/" ]
OK here's a question: if you can't modify the HTML, CSS or image at all, what the heck *can* you modify? The raw network stream coming from the server?
This can be fix in 2 way 1. There is a fix file called png-fix.js, just get from net and include it before your `</body>` tag. 2. Better you can change you png file format into png-8 format via the photo-shop tool.
2,817,849
Is there any PNG-fix for IE 6 and without modifying current HTML, CSS and image name? any javascript way. I can add any thing in `<head>........</head>` but can't modify anythings inside `<body>.....</body>`. in one shot i want to make transparent all png transparent.
2010/05/12
[ "https://Stackoverflow.com/questions/2817849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84201/" ]
My preferred PNGFix is [DD\_belatedPNG](http://www.dillerdesign.com/experiment/DD_belatedPNG/). It is easy to use, example from the page: ``` <!--[if IE 6]> <script src="DD_belatedPNG.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('.png_bg'); /* string argument can be any CSS selector */ /* .png_bg example is unnecessary */ /* change it to what suits you! */ </script> <![endif]--> ``` You can set that `.png_bg` selector to whatever you see fit. Perhaps you want to replace all of the headings on a page: `DD_belatedPNG.fix('h1,h2,h3');`
This can be fix in 2 way 1. There is a fix file called png-fix.js, just get from net and include it before your `</body>` tag. 2. Better you can change you png file format into png-8 format via the photo-shop tool.
2,817,849
Is there any PNG-fix for IE 6 and without modifying current HTML, CSS and image name? any javascript way. I can add any thing in `<head>........</head>` but can't modify anythings inside `<body>.....</body>`. in one shot i want to make transparent all png transparent.
2010/05/12
[ "https://Stackoverflow.com/questions/2817849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84201/" ]
OK here's a question: if you can't modify the HTML, CSS or image at all, what the heck *can* you modify? The raw network stream coming from the server?
My preferred PNGFix is [DD\_belatedPNG](http://www.dillerdesign.com/experiment/DD_belatedPNG/). It is easy to use, example from the page: ``` <!--[if IE 6]> <script src="DD_belatedPNG.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('.png_bg'); /* string argument can be any CSS selector */ /* .png_bg example is unnecessary */ /* change it to what suits you! */ </script> <![endif]--> ``` You can set that `.png_bg` selector to whatever you see fit. Perhaps you want to replace all of the headings on a page: `DD_belatedPNG.fix('h1,h2,h3');`
51,619,280
According to this [docs](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.relationaldatabasefacadeextensions.executesqlcommand?view=efcore-2.1) and [this](https://learn.microsoft.com/en-us/ef/core/querying/raw-sql), I should be able to pass an interpolated string to `ExecuteSqlCommandAsync` like this: ``` public async Task DeleteEntries(DateTimeOffset loggedOn) { await myContext.Database.ExecuteSqlCommandAsync( $"DELETE from log_entry WHERE logged_on < '{loggedOn}';" ); } ``` However, it gives me the following error: `Npgsql.PostgresException: '22007: invalid input syntax for type timestamp with time zone: "@p0"'` 1. `loggedOn` is a valid date. 2. Extracting the interpolated string to a temporary variable fixes it, however I am losing input validation for SQL injection attacks. Am i doing something wrong or is this a bug in EFCore? Using latest EFCore 2.1
2018/07/31
[ "https://Stackoverflow.com/questions/51619280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5053000/" ]
As provided by @IvanStoev, the answer was to remove single quotes around the interpolated parameter.
That webpage you refer to, warns you to not have direct values inserted into SQL, that is to use parameters like so: ``` FromSql("EXECUTE dbo.GetMostPopularBlogsForUser @user", user) ``` So, adjust it to your needs and have something like: ``` FromSql("DELETE from log_entry WHERE logged_on < @logged_on", loggedOn.ToString("0")) ``` P.S. do not use double quotes `"` for the table names - either use no quotes or wrap them with `[]` as `[log_entry]`.
39,762,688
How I can open Short Message Service (SMS) window on Android phode with pretyped message text and recipient number. In manuals i found only Phone dialer ``` PhoneDialerService.Call(edtTelephoneNumber.Text) ``` which allow make call, but nothing about sending SMS messages.
2016/09/29
[ "https://Stackoverflow.com/questions/39762688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6760778/" ]
See the class [`SMSManager`](https://d.android.com/reference/android/telephony/SmsManager.html) on Android API. There is a [`sendTextMessage`](https://d.android.com/reference/android/telephony/SmsManager.html#sendTextMessage(java.lang.String,%20java.lang.String,%20java.lang.String,%20android.app.PendingIntent,%20android.app.PendingIntent)) method that you can use: Try some code like this: ``` uses Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNI.Telephony; procedure TForm1.Button1Click(Sender: TObject); var destAdress: JString; smsManager: JSmsManager; begin smsManager := TJSmsManager.JavaClass.getDefault; destAdress := StringToJString('0034123456789'); smsManager.sendTextMessage(destAdress, nil, StringToJString('The message content'), nil, nil); end; ``` You must [add permissions](http://docwiki.embarcadero.com/RADStudio/en/Uses_Permissions) to the project configuration. See the "Send SMS": > > Send SMS - Allows an application to send SMS messages. > > > Regards.
The question asks about launching the SMS window, which I've taken to mean launching the built-in SMS-sending app. It wants a target number and message content sent in. This can be done by asking Android to start an activity using an intent set up to view a carefully crafted SMS-specific URI and containing the required message as an extra field. The primary benefit to invoking the SMS app rather than sending the SMS within your own app is that it does not require additional permissions - the SMS app already has those permissions. I show how to do this in [my old activity launching article](http://blong.com/Articles/DelphiXE6AndroidActivityResult/ActivityResult.htm#SMSActivity) (which was written for Delphi XE6 but is still applicable to all later versions, with a few minor code updates here and there), but for completeness here is a helper unit that does the job: ``` unit SMSHelperU; interface procedure CreateSMS(const Number, Msg: string); implementation uses Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNI.App, Androidapi.JNI.Net, Androidapi.JNI.GraphicsContentViewText, System.SysUtils; function LaunchActivity(const Intent: JIntent): Boolean; overload; var ResolveInfo: JResolveInfo; begin {$IF RTLVersion >= 30} ResolveInfo := TAndroidHelper.Activity.getPackageManager.resolveActivity(Intent, 0); {$ELSE} ResolveInfo := SharedActivity.getPackageManager.resolveActivity(Intent, 0); {$ENDIF} Result := ResolveInfo <> nil; if Result then {$IF RTLVersion >= 30} TAndroidHelper.Activity.startActivity(Intent); {$ELSE} SharedActivity.startActivity(Intent); {$ENDIF} end; procedure CreateSMS(const Number, Msg: string); var Intent: JIntent; URI: Jnet_Uri; begin URI := StrToJURI(Format('smsto:%s', [Number])); Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW, URI); Intent.putExtra(StringToJString('sms_body'), StringToJString(Msg)); LaunchActivity(Intent); end; end. ``` The routine can be called like this: ``` CreateSMS('123456789', 'O HAI2U!'); ``` If you did want to actually send the SMS the unit below does that job but also includes code that self-checks the relevant permission is set for the app: ``` unit AndroidStuff; interface function HasPermission(const Permission: string): Boolean; procedure SendSMS(const Number, Msg: string); implementation uses System.SysUtils, System.UITypes, {$IF RTLVersion >= 31} FMX.DialogService, {$ELSE} FMX.Dialogs, {$ENDIF} FMX.Helpers.Android, Androidapi.Helpers, Androidapi.JNI.App, Androidapi.JNI.JavaTypes, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Telephony; function HasPermission(const Permission: string): Boolean; begin //Permissions listed at http://d.android.com/reference/android/Manifest.permission.html {$IF RTLVersion >= 30} Result := TAndroidHelper.Context.checkCallingOrSelfPermission( {$ELSE} Result := SharedActivityContext.checkCallingOrSelfPermission( {$ENDIF} StringToJString(Permission)) = TJPackageManager.JavaClass.PERMISSION_GRANTED end; procedure SendSMS(const Number, Msg: string); var SmsManager: JSmsManager; begin if not HasPermission('android.permission.SEND_SMS') then {$IF RTLVersion >= 31} TDialogService.MessageDialog('App does not have the SEND_SMS permission', TMsgDlgType.mtError, [TMsgDlgBtn.mbCancel], TMsgDlgBtn.mbCancel, 0, nil) {$ELSE} MessageDlg('App does not have the SEND_SMS permission', TMsgDlgType.mtError, [TMsgDlgBtn.mbCancel], 0) {$ENDIF} else begin SmsManager := TJSmsManager.JavaClass.getDefault; SmsManager.sendTextMessage( StringToJString(Number), nil, StringToJString(Msg), nil, nil); end; end; end. ```
1,911,782
I came across the following question today: > > "In drawing two balls from a box containing 6 red and 4 white balls without replacement, which of the following pairs will be independent?: > > > (a) Red on 1st and red on 2nd draw > (b) Red on 1st and white on 2nd draw > > > I approached this problem by writing down the sample space as {RW, RR, WW, WR} first. Then, let $A$ be the event that red is drawn first and $B$ be the event that red is drawn second; $A$=$({RW}, {RR}) and $B=$({RR}, {WR}) Which gives me $A∩B$={$RR$} Therefore, I get $P(A)=1/2$ $P(B)=1/2$ and $P(A∩B)=1/4$ Which gives me $P(A)P(B)=P(A∩B)$, proving that A and B are independent events. However, clearly, this is nonsense! A and B are absolutely **not** independent events, since the occurrence of A affects the chances of occurrence of B. Where have I gone completely wrong in my reasoning? Edit: My textbook has solved this problem correctly in the following way but I am not interested in the solution to this problem in particular; I want to know where I have made a grave mistake. Please correct me for if I don't understand my mistake, I will continue to commit the **same** mistake in the future as well. Much thanks in advance :) Regards. [![Textbook solution](https://i.stack.imgur.com/FHWgD.jpg)](https://i.stack.imgur.com/FHWgD.jpg)
2016/09/02
[ "https://math.stackexchange.com/questions/1911782", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Let $I$ be a fixed interval $[a,b]$. Then you may let $F=\mathbb{Q} \cap I$ (rationals in $I$) and $G=I\setminus \mathbb{Q}$ (irrationals in $I$), which satisfy all the properties you want. As you point out, there is no 'least next' value, but this is not an issue because your last bullet point doesn't necessitate that such things exist. Instead, it is sufficient for both $F$ and $G$ to be dense in $I$. To answer your last question, nothing changes, we could take $F= (I\cap \mathbb{Q})\cap \{n/2^m \mid \text{$n$ odd integer, $m\geq 0$}\}$ and $G = (I\cap \mathbb{Q}) \setminus \{n/2^m \mid \text{$n$ odd integer, $m\geq 0$}\}$. The elements of $\{n/2^m \mid \text{$n$ odd integer, $m\geq 0$}\}$ are called the dyadic rationals. As far as your function $z(x)$ defined by $$z(x) = \begin{cases} x+1 & x\in F \\ x-1 & x\in G \end{cases}$$ is concerned, it does indeed exist (that's a valid definition above). While it separates $I$, that isn't really a problem.
To summarize what you're asking for: you want a partition of $\mathbb{R}$ into two sets $F$ and $G$, such that there is an element of $F$ between any two elements of $G$ and vice-versa. Certainly this is possible: let $F$ and $G$ be the rationals and the irrationals, respectively. And your zipper-like function is well-defined: $z(x)$ increases rational numbers by $1$ and decreases irrational numbers by $1$, and so it is discontinuous everywhere, even though it is continuous when restricted to either the rationals or the irrationals. Altering the base set from $\mathbb{R}$ to $\mathbb{Q}$ doesn't change any of this. For instance, you can let $F$ be the set of rationals with prime denominators (in lowest terms). Both $F$ and $\mathbb{Q}-F$ are dense on the real line, so they interleave in the way you want.
1,911,782
I came across the following question today: > > "In drawing two balls from a box containing 6 red and 4 white balls without replacement, which of the following pairs will be independent?: > > > (a) Red on 1st and red on 2nd draw > (b) Red on 1st and white on 2nd draw > > > I approached this problem by writing down the sample space as {RW, RR, WW, WR} first. Then, let $A$ be the event that red is drawn first and $B$ be the event that red is drawn second; $A$=$({RW}, {RR}) and $B=$({RR}, {WR}) Which gives me $A∩B$={$RR$} Therefore, I get $P(A)=1/2$ $P(B)=1/2$ and $P(A∩B)=1/4$ Which gives me $P(A)P(B)=P(A∩B)$, proving that A and B are independent events. However, clearly, this is nonsense! A and B are absolutely **not** independent events, since the occurrence of A affects the chances of occurrence of B. Where have I gone completely wrong in my reasoning? Edit: My textbook has solved this problem correctly in the following way but I am not interested in the solution to this problem in particular; I want to know where I have made a grave mistake. Please correct me for if I don't understand my mistake, I will continue to commit the **same** mistake in the future as well. Much thanks in advance :) Regards. [![Textbook solution](https://i.stack.imgur.com/FHWgD.jpg)](https://i.stack.imgur.com/FHWgD.jpg)
2016/09/02
[ "https://math.stackexchange.com/questions/1911782", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Let $I$ be a fixed interval $[a,b]$. Then you may let $F=\mathbb{Q} \cap I$ (rationals in $I$) and $G=I\setminus \mathbb{Q}$ (irrationals in $I$), which satisfy all the properties you want. As you point out, there is no 'least next' value, but this is not an issue because your last bullet point doesn't necessitate that such things exist. Instead, it is sufficient for both $F$ and $G$ to be dense in $I$. To answer your last question, nothing changes, we could take $F= (I\cap \mathbb{Q})\cap \{n/2^m \mid \text{$n$ odd integer, $m\geq 0$}\}$ and $G = (I\cap \mathbb{Q}) \setminus \{n/2^m \mid \text{$n$ odd integer, $m\geq 0$}\}$. The elements of $\{n/2^m \mid \text{$n$ odd integer, $m\geq 0$}\}$ are called the dyadic rationals. As far as your function $z(x)$ defined by $$z(x) = \begin{cases} x+1 & x\in F \\ x-1 & x\in G \end{cases}$$ is concerned, it does indeed exist (that's a valid definition above). While it separates $I$, that isn't really a problem.
Such a partition does exist. Let $F = I \cap \Bbb Q$ and $G = I \setminus F$. It's clear that $F$ and $G$ have empty intersection, and their union is all of $I$. And for any two rational numbers, there's an irrational number between them. The other way around too. Since this is all taking place inside an interval $I$, the middle point that you find is also in $I$.
7,579,300
I have tried several ways to serve my static resources from Plone with XDV: 1. Putting the CSS and images in the Custom folder - files are 404 not found 2. Serving them from Apache and setting the Absolute URL Prefix in the XDV config - works, but any other relatively URL'd links (e.g. PDF files in my content) get prefixed as well and therefore are 404 not found 3. Setting browser:resourceDirectory - 404 not found 4. Setting cmf:registerDirectory - 404 not found Any suggestions? I've turned the log level to DEBUG but this doesn't give me any clues.
2011/09/28
[ "https://Stackoverflow.com/questions/7579300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535071/" ]
You just need to put your css/js in the "static" directory and than use relative path in the index.html. Diazo/XDV will automagically remap relative paths. Or you can also register a resourceDirectory in the usual way and than link files like so "++resource++myresourcedirid/my.css" See an example [here](https://github.com/giacomos/plonetheme.codapress/blob/master/plonetheme/codapress/static/index.html).
I managed to use static content served by Apache using mod\_rewrite and the following rules in Apache Virtual Host configuration. ``` RewriteRule ^/css - [L] RewriteRule ^/img - [L] ``` I have also used Giacomo method for specific Plone content style with the `static` directory in my package which is linked in the "index.html" as "++resource++mypackage.theme/plone.css"
52,417,142
I've got a bug that looks like it's caused by an Event handler being attached a click event: ``` mxpnl.track_links("#pagebody a", "Click.body"); ``` I'd like to watch to see how that Element's event handler is added (and when) I found it in the Chrome Debugger (Dev Tools) > Elements and choose Break on Attribute modifications. Debugger never Breaks. I also selected it's Parent Div (that it is within) and set Debugger (right-click on Element) > break on subtree modifications. Again, it never breaks. What am I doing wrong here?
2018/09/20
[ "https://Stackoverflow.com/questions/52417142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4906/" ]
Adding an event listener isn't an attribute change (often) - rather, generally it's a call to `addEventListener` or an `on`- assignment. So, listening to attribute changes won't work. One option would be to monkeypatch `addEventListener` so that `debugger` runs when `addEventListener` is called with the matching arguments. For example: ```js // snippet might not actually enter the debugger due to embedded sandboxing issues const nativeEventListener = EventTarget.prototype.addEventListener; EventTarget.prototype.addEventListener = function(...args) { if (this.matches('div') && args[0] === 'click') { console.log('listener is being added to a div'); debugger; } nativeEventListener.apply(this, args); } // then, when an event listener is added, you'll be able to intercept the call and debug it: document.querySelector('div').addEventListener('click', () => { console.log('clicked'); }); ``` ```html <div>click me</div> ```
In very simple term if explain then event listeners is just a function which add in an array with reference of string such as "click" and "on" etc.. So when you say..... ``` function myClick1(){ console.log('myclick1 called'); } document.querySelector('mydiv').addEventListener('click', myClick1); function myClick2(){ console.log('myclick2 called'); } document.querySelector('mydiv').addEventListener('click', myClick2); ``` it add the function myClick1 and myClick2 in event listener array for click and execute in sequence as it added. AND YOU CAN USE PROTOTYPE OF EVENT TARGET TO MONKEY PATCH THE EVENT LISTENER ARRAY.
2,493,585
Can anyone help with extracting text from a page in a pdf? ``` <?php $pdf = Zend_Pdf::load('example.pdf'); $page = $pdf->page[0]; ``` I would assume a page method would exist but I could not find anything to let me extract the contents. Example: $page->getContents(); $page->toString(); $page->extractText(); ...Help!!!! This is driving me crazy!
2010/03/22
[ "https://Stackoverflow.com/questions/2493585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/272645/" ]
I agree with Andy that this does not appear to be supported. As an alternative, take a look at [Shaun Farrell's solution to extracting text from a PDF for use with Zend\_Search\_Lucene](http://www.kapustabrothers.com/2008/01/20/indexing-pdf-documents-with-zend_search_lucene/). He uses [XPDF](http://www.foolabs.com/xpdf/), which might also meet your needs.
From [the manual](http://framework.zend.com/manual/en/zend.pdf.html) it doesn't appear that this functionality is supported. Also, new text is written using the [drawText() function](http://framework.zend.com/manual/en/zend.pdf.usage.html), which appears to write images, not plain "decodable" text.
16,766,300
I am developing an applciation which requires to connect to sql database server. I am planning to connect to database directly without using webservice. Let me know if its possible?
2013/05/27
[ "https://Stackoverflow.com/questions/16766300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2361064/" ]
you can directly connect to the sqlite database that is in phone. but you can not directly connect to the remote database like mysql , MSSQL and other database. if you really need to use that database you have to use web service(SOAP or REST), Http request or JSON.
You can't access remote database server without web services. If you want, you can access internal database (sqlite) without any web services. I have a doubt whether you are asking that. For that this [video](http://www.youtube.com/watch?v=j-IV87qQ00M) may be helpful for you.
3,929,368
I really need help with that question, so I'd appreciate a solution with steps because this problem was given for practice and my exam is in a few days so I'd like to understand the steps to the solution. Thank you.
2020/11/30
[ "https://math.stackexchange.com/questions/3929368", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
I think what this question is getting at is that, to be a basis of a vector space, a set of vectors must span the vector space and be linearly independent. If $\pmatrix{x\\y}$ is any element of $\mathbb R^2$, we can solve $\pmatrix{x\\y}=a\pmatrix{1\\2}+b\pmatrix{1\\3}$ to get $a=3x-y$ and $b=y-2x$, so $\pmatrix{x\\y}$ is a linear combination of $\pmatrix{1\\2}$ and $\pmatrix{1\\3}$, so $\pmatrix{1\\2}$ and $\pmatrix{1\\3}$ span $\mathbb R^2$ (so certainly $\pmatrix{1\\2}$, $\pmatrix{1\\3},$ and $\pmatrix{1\\4}$ span $\mathbb R^2$). Indeed, any two linearly independent vectors in $\mathbb R^2$ (which is a $2$-dimensional vector space over $\mathbb R$) will span $\mathbb R^2$ and be a basis. Elements of a basis must be linearly independent, but $(1,4)=2(1,3)-(1,2)$, so the set of three vectors given are not a basis.
**HINT** To spell out the comment hint a bit more, if $U$ spans $\mathbb{R}^2$, and $\vec{b} \in \mathbb{R}^2$, then there must exist $x,y,z \in \mathbb{R}$ such that $$ \vec{b} = x\begin{bmatrix} 1\\2\end{bmatrix} + y\begin{bmatrix} 1\\3\end{bmatrix} + z\begin{bmatrix} 1\\4\end{bmatrix} = \begin{bmatrix} 1 & 1 & 1 \\2 & 3 & 4\end{bmatrix} \begin{bmatrix} x\\y\\z\end{bmatrix} $$ So you have to prove that any $b$ can be generated that way...
3,929,368
I really need help with that question, so I'd appreciate a solution with steps because this problem was given for practice and my exam is in a few days so I'd like to understand the steps to the solution. Thank you.
2020/11/30
[ "https://math.stackexchange.com/questions/3929368", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
**HINT** To spell out the comment hint a bit more, if $U$ spans $\mathbb{R}^2$, and $\vec{b} \in \mathbb{R}^2$, then there must exist $x,y,z \in \mathbb{R}$ such that $$ \vec{b} = x\begin{bmatrix} 1\\2\end{bmatrix} + y\begin{bmatrix} 1\\3\end{bmatrix} + z\begin{bmatrix} 1\\4\end{bmatrix} = \begin{bmatrix} 1 & 1 & 1 \\2 & 3 & 4\end{bmatrix} \begin{bmatrix} x\\y\\z\end{bmatrix} $$ So you have to prove that any $b$ can be generated that way...
For instance, $(1,3)$ is not a multiple of $(1,2)$, so they are independent and span $\Bbb R^2$. But any $3$ vectors in a two-dimensional space are dependent, and so can't form a basis. I have taken as given that $\Bbb R^2$ is two-dimensional, say with basis $e\_1=(1,0)$ and $e\_2=(0,1)$.
3,929,368
I really need help with that question, so I'd appreciate a solution with steps because this problem was given for practice and my exam is in a few days so I'd like to understand the steps to the solution. Thank you.
2020/11/30
[ "https://math.stackexchange.com/questions/3929368", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
I think what this question is getting at is that, to be a basis of a vector space, a set of vectors must span the vector space and be linearly independent. If $\pmatrix{x\\y}$ is any element of $\mathbb R^2$, we can solve $\pmatrix{x\\y}=a\pmatrix{1\\2}+b\pmatrix{1\\3}$ to get $a=3x-y$ and $b=y-2x$, so $\pmatrix{x\\y}$ is a linear combination of $\pmatrix{1\\2}$ and $\pmatrix{1\\3}$, so $\pmatrix{1\\2}$ and $\pmatrix{1\\3}$ span $\mathbb R^2$ (so certainly $\pmatrix{1\\2}$, $\pmatrix{1\\3},$ and $\pmatrix{1\\4}$ span $\mathbb R^2$). Indeed, any two linearly independent vectors in $\mathbb R^2$ (which is a $2$-dimensional vector space over $\mathbb R$) will span $\mathbb R^2$ and be a basis. Elements of a basis must be linearly independent, but $(1,4)=2(1,3)-(1,2)$, so the set of three vectors given are not a basis.
For instance, $(1,3)$ is not a multiple of $(1,2)$, so they are independent and span $\Bbb R^2$. But any $3$ vectors in a two-dimensional space are dependent, and so can't form a basis. I have taken as given that $\Bbb R^2$ is two-dimensional, say with basis $e\_1=(1,0)$ and $e\_2=(0,1)$.
4,924,600
I need to get the full path to a file somewhere on the phone (any location) and play it with MediaPlayer. ive heard of using a file chooser for Android (by launching an intent). In the test code, I just copied a resource to a another file, got the path and passed it to AudioVideoEntry (as i show later, a very simple and thin wrapper around MediaPlayer) Here's the test code I've written: ``` private String ave_path; private String ave_file_name = "my_media_content"; private InputStream ave_fis; private OutputStream ave_fos; public void testAudioVideoEntry() { //get the Activity Module_JournalEntry journalentryactivity = getActivity(); //open an InputStream to a resource file (in this case strokes.mp3) ave_fis = journalentryactivity.getResources().openRawResource(module.jakway.JournalEntry.R.raw.strokes); //open an OutputStream to a new file try { ave_fos = journalentryactivity.openFileOutput(ave_file_name, Context.MODE_PRIVATE); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); assertTrue(false); } catch(Exception e) { assertTrue(false); } //copy the data from the resource into //the OutputStream int data; try { while((data = ave_fis.read()) != -1) { ave_fos.write(data); } assertTrue(true); } catch(Exception e) { assertTrue(false); } //get the full path of the file we wrote to ave_path = journalentryactivity.getFileStreamPath(ave_file_name).toString(); //and construct a new object of AudioVideoEntry with that path AudioVideoEntry ave = new AudioVideoEntry(ave_path); //register an error listener via MediaPlayer's setOnErrorListener ave.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { Log.e("MEDIAPLAYER ERRORS", "what: " + what + " extra: " + extra); assertTrue(false); // TODO Auto-generated method stub return false; } }); ave.prepareMedia(); ave.playMedia(); try { ave_fis.close(); ave_fos.close(); } catch(Exception e) { assertTrue(false); e.printStackTrace(); } ``` AudioVideoEntry is basically a thin wrapper around MediaPlayer that can hold its own path: ``` public class AudioVideoEntry { private String path_to_audio_file; private MediaPlayer mediaplayer; /** * Initialize the internal MediaPlayer * from the String parameter * @param set_path_to_audio_file */ public AudioVideoEntry(String set_path_to_audio_file) { path_to_audio_file = set_path_to_audio_file; mediaplayer = new MediaPlayer(); try { mediaplayer.setDataSource(path_to_audio_file); mediaplayer.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public AudioVideoEntry(FileDescriptor fd) { mediaplayer = new MediaPlayer(); try { mediaplayer.setDataSource(fd); mediaplayer.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * Begin playing media */ public void prepareMedia() { try { mediaplayer.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * play media * don't forget to prepare() if necessary */ public void playMedia() { mediaplayer.start(); } /** * pause the media * can be played later */ public void pauseMedia() { mediaplayer.pause(); } /** * stop media */ public void stopMedia() { mediaplayer.stop(); } public void setOnErrorListener(OnErrorListener listener) { mediaplayer.setOnErrorListener(listener); } } ``` here's the logcat output from the JUnit test (the tests were successful, the actual results - as the logat shows - were not) ``` 02-07 09:40:23.129: ERROR/MediaPlayer(1209): error (1, -2147483648) 02-07 09:40:23.139: WARN/System.err(1209): java.io.IOException: Prepare failed.: status=0x1 02-07 09:40:23.149: WARN/System.err(1209): at android.media.MediaPlayer.prepare(Native Method) 02-07 09:40:23.149: WARN/System.err(1209): at module.jakway.JournalEntry.AudioVideoEntry.<init>(AudioVideoEntry.java:39) 02-07 09:40:23.149: WARN/System.err(1209): at module.jakway.JournalEntry.test.Module_JournalEntryTest.testAudioVideoEntry(Module_JournalEntryTest.java:182) 02-07 09:40:23.149: WARN/System.err(1209): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 09:40:23.149: WARN/System.err(1209): at java.lang.reflect.Method.invoke(Method.java:507) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186) 02-07 09:40:23.159: WARN/System.err(1209): at junit.framework.TestCase.runBare(TestCase.java:127) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult$1.protect(TestResult.java:106) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult.runProtected(TestResult.java:124) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult.run(TestResult.java:109) 02-07 09:40:23.179: WARN/System.err(1209): at junit.framework.TestCase.run(TestCase.java:118) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 02-07 09:40:23.189: WARN/System.err(1209): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 02-07 09:40:23.189: ERROR/MediaPlayer(1209): prepareAsync called in state 0 02-07 09:40:23.189: WARN/System.err(1209): java.lang.IllegalStateException 02-07 09:40:23.189: WARN/System.err(1209): at android.media.MediaPlayer.prepare(Native Method) 02-07 09:40:23.189: WARN/System.err(1209): at module.jakway.JournalEntry.AudioVideoEntry.prepareMedia(AudioVideoEntry.java:79) 02-07 09:40:23.199: WARN/System.err(1209): at module.jakway.JournalEntry.test.Module_JournalEntryTest.testAudioVideoEntry(Module_JournalEntryTest.java:197) 02-07 09:40:23.199: WARN/System.err(1209): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 09:40:23.199: WARN/System.err(1209): at java.lang.reflect.Method.invoke(Method.java:507) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestCase.runBare(TestCase.java:127) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult$1.protect(TestResult.java:106) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult.runProtected(TestResult.java:124) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult.run(TestResult.java:109) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestCase.run(TestCase.java:118) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 02-07 09:40:23.199: WARN/System.err(1209): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 02-07 09:40:23.199: ERROR/MediaPlayer(1209): start called in state 0 02-07 09:40:23.199: ERROR/MediaPlayer(1209): error (-38, 0) ``` Edit: why is MediaPlayer failing? thanks! dragonwrenn
2011/02/07
[ "https://Stackoverflow.com/questions/4924600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450153/" ]
Some points: 1. Do not call `prepare()` twice (once in the constructor and the other explicitly). That could be one of the reasons that the `IllegalStateException` is thrown. 2. Also, is the file that you are trying to play inside the application? If so, why are you trying to create a stream? If the file is already within the application (and within `/res/raw`, you could try and save yourself the hassle of using `prepare()` by creating the mediaplayer object like so: mediaplayer = new MediaPlayer.create(this, R.raw.resource-name here); The create function calls `prepare()` within. 3. You can also try and use the `reset()` function if any one of the stages in the MediaPlayer fails resulting in the MediaPlayer object entering the error state. Using `reset()` would bring it back to Idle state. 4. The last time I had that error `status=0x1` message, it turned out that I had not had the correct permissions set for the files (external storage etc. in Manifest) and some files placed in incorrect folders. You may also want to take a look at that. Let me know in case that does not work, We can try something else. Sriram.
It seems you are calling `prepare()` twice, first in the constructor of `AudioVideoEntry`, and second in the method `prepareMedia()`, that's why it's giving an `IllegalStateException`. If you read carefully the [documentation](http://developer.android.com/reference/android/media/MediaPlayer.html) you can understand the State Diagram and why gives such exceptions.
4,924,600
I need to get the full path to a file somewhere on the phone (any location) and play it with MediaPlayer. ive heard of using a file chooser for Android (by launching an intent). In the test code, I just copied a resource to a another file, got the path and passed it to AudioVideoEntry (as i show later, a very simple and thin wrapper around MediaPlayer) Here's the test code I've written: ``` private String ave_path; private String ave_file_name = "my_media_content"; private InputStream ave_fis; private OutputStream ave_fos; public void testAudioVideoEntry() { //get the Activity Module_JournalEntry journalentryactivity = getActivity(); //open an InputStream to a resource file (in this case strokes.mp3) ave_fis = journalentryactivity.getResources().openRawResource(module.jakway.JournalEntry.R.raw.strokes); //open an OutputStream to a new file try { ave_fos = journalentryactivity.openFileOutput(ave_file_name, Context.MODE_PRIVATE); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); assertTrue(false); } catch(Exception e) { assertTrue(false); } //copy the data from the resource into //the OutputStream int data; try { while((data = ave_fis.read()) != -1) { ave_fos.write(data); } assertTrue(true); } catch(Exception e) { assertTrue(false); } //get the full path of the file we wrote to ave_path = journalentryactivity.getFileStreamPath(ave_file_name).toString(); //and construct a new object of AudioVideoEntry with that path AudioVideoEntry ave = new AudioVideoEntry(ave_path); //register an error listener via MediaPlayer's setOnErrorListener ave.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { Log.e("MEDIAPLAYER ERRORS", "what: " + what + " extra: " + extra); assertTrue(false); // TODO Auto-generated method stub return false; } }); ave.prepareMedia(); ave.playMedia(); try { ave_fis.close(); ave_fos.close(); } catch(Exception e) { assertTrue(false); e.printStackTrace(); } ``` AudioVideoEntry is basically a thin wrapper around MediaPlayer that can hold its own path: ``` public class AudioVideoEntry { private String path_to_audio_file; private MediaPlayer mediaplayer; /** * Initialize the internal MediaPlayer * from the String parameter * @param set_path_to_audio_file */ public AudioVideoEntry(String set_path_to_audio_file) { path_to_audio_file = set_path_to_audio_file; mediaplayer = new MediaPlayer(); try { mediaplayer.setDataSource(path_to_audio_file); mediaplayer.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public AudioVideoEntry(FileDescriptor fd) { mediaplayer = new MediaPlayer(); try { mediaplayer.setDataSource(fd); mediaplayer.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * Begin playing media */ public void prepareMedia() { try { mediaplayer.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * play media * don't forget to prepare() if necessary */ public void playMedia() { mediaplayer.start(); } /** * pause the media * can be played later */ public void pauseMedia() { mediaplayer.pause(); } /** * stop media */ public void stopMedia() { mediaplayer.stop(); } public void setOnErrorListener(OnErrorListener listener) { mediaplayer.setOnErrorListener(listener); } } ``` here's the logcat output from the JUnit test (the tests were successful, the actual results - as the logat shows - were not) ``` 02-07 09:40:23.129: ERROR/MediaPlayer(1209): error (1, -2147483648) 02-07 09:40:23.139: WARN/System.err(1209): java.io.IOException: Prepare failed.: status=0x1 02-07 09:40:23.149: WARN/System.err(1209): at android.media.MediaPlayer.prepare(Native Method) 02-07 09:40:23.149: WARN/System.err(1209): at module.jakway.JournalEntry.AudioVideoEntry.<init>(AudioVideoEntry.java:39) 02-07 09:40:23.149: WARN/System.err(1209): at module.jakway.JournalEntry.test.Module_JournalEntryTest.testAudioVideoEntry(Module_JournalEntryTest.java:182) 02-07 09:40:23.149: WARN/System.err(1209): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 09:40:23.149: WARN/System.err(1209): at java.lang.reflect.Method.invoke(Method.java:507) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186) 02-07 09:40:23.159: WARN/System.err(1209): at junit.framework.TestCase.runBare(TestCase.java:127) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult$1.protect(TestResult.java:106) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult.runProtected(TestResult.java:124) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult.run(TestResult.java:109) 02-07 09:40:23.179: WARN/System.err(1209): at junit.framework.TestCase.run(TestCase.java:118) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 02-07 09:40:23.189: WARN/System.err(1209): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 02-07 09:40:23.189: ERROR/MediaPlayer(1209): prepareAsync called in state 0 02-07 09:40:23.189: WARN/System.err(1209): java.lang.IllegalStateException 02-07 09:40:23.189: WARN/System.err(1209): at android.media.MediaPlayer.prepare(Native Method) 02-07 09:40:23.189: WARN/System.err(1209): at module.jakway.JournalEntry.AudioVideoEntry.prepareMedia(AudioVideoEntry.java:79) 02-07 09:40:23.199: WARN/System.err(1209): at module.jakway.JournalEntry.test.Module_JournalEntryTest.testAudioVideoEntry(Module_JournalEntryTest.java:197) 02-07 09:40:23.199: WARN/System.err(1209): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 09:40:23.199: WARN/System.err(1209): at java.lang.reflect.Method.invoke(Method.java:507) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestCase.runBare(TestCase.java:127) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult$1.protect(TestResult.java:106) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult.runProtected(TestResult.java:124) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult.run(TestResult.java:109) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestCase.run(TestCase.java:118) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 02-07 09:40:23.199: WARN/System.err(1209): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 02-07 09:40:23.199: ERROR/MediaPlayer(1209): start called in state 0 02-07 09:40:23.199: ERROR/MediaPlayer(1209): error (-38, 0) ``` Edit: why is MediaPlayer failing? thanks! dragonwrenn
2011/02/07
[ "https://Stackoverflow.com/questions/4924600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450153/" ]
The second call to MediaPlayer.prepare() (already called once in the AudioVideoEntry ctor) in the AudioVideoEntry.prepareMedia() method was easy to spot as other people have noticed. The harder error to find was the first error. I used an Ogg file for testing. First clue was from davidsparks reply (last one) in [android-platform - Ogg on G1](http://groups.google.com/group/android-platform/browse_thread/thread/73ee9bfcf311763b) > > As long as the files have a .ogg extension, they should play with the > built-in music player. We rely on the file extensions because there is > no centralized file recognizer for the media scanner. > > > Second clue was from [[android-developers] Re: File permission about MediaPlayer](http://www.mail-archive.com/android-developers@googlegroups.com/msg12519.html) > > Due to the Android security model, MediaPlayer does not have root > access rights. It can access the sdcard, but it can't access private > app directories. > > > Your app can explicitly grant MediaPlayer temporary access to secure > files by opening the file and passing the file descriptor to > MediaPlayer using the setDataSource(FileDescriptor fd) method. > > > If you look at the absolute path of the output stream, you see it's in the `/data/data` directory under the app's package name's directory. Excuse the timestamps - I worked backwards to get data to show on a OS2.1update1 (API7) emulator. Your code had: ``` String ave_file_name = "my_media_content"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_PRIVATE); ``` DDMS showed: ``` 02-10 05:10:28.253: WARN/MediaPlayer(1992): info/warning (1, 26) 02-10 05:10:28.253: ERROR/PlayerDriver(31): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported 02-10 05:10:28.253: ERROR/MediaPlayer(1992): error (1, -4) 02-10 05:10:28.274: WARN/PlayerDriver(31): PVMFInfoErrorHandlingComplete ``` If we change **JUST** the file to MODE\_WORLD\_READABLE: ``` String ave_file_name = "my_media_content"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_WORLD_READABLE); ``` DDMS shows no improvement: ``` 02-10 05:08:28.543: WARN/MediaPlayer(1900): info/warning (1, 26) 02-10 05:08:28.553: ERROR/PlayerDriver(31): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported 02-10 05:08:28.553: ERROR/MediaPlayer(1900): error (1, -4) 02-10 05:08:28.563: WARN/PlayerDriver(31): PVMFInfoErrorHandlingComplete ``` If we change **JUST** the file extension to `ogg`: ``` String ave_file_name = "my_media_content.ogg"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_PRIVATE); ``` We get a change in DDMS output: ``` 02-10 04:59:30.153: ERROR/MediaPlayerService(31): error: -2 02-10 04:59:30.163: ERROR/MediaPlayer(1603): Unable to to create media player ``` But when we **combine the two**: ``` String ave_file_name = "my_media_content.ogg"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_WORLD_READABLE); ``` DDMS shows no errors.
It seems you are calling `prepare()` twice, first in the constructor of `AudioVideoEntry`, and second in the method `prepareMedia()`, that's why it's giving an `IllegalStateException`. If you read carefully the [documentation](http://developer.android.com/reference/android/media/MediaPlayer.html) you can understand the State Diagram and why gives such exceptions.
4,924,600
I need to get the full path to a file somewhere on the phone (any location) and play it with MediaPlayer. ive heard of using a file chooser for Android (by launching an intent). In the test code, I just copied a resource to a another file, got the path and passed it to AudioVideoEntry (as i show later, a very simple and thin wrapper around MediaPlayer) Here's the test code I've written: ``` private String ave_path; private String ave_file_name = "my_media_content"; private InputStream ave_fis; private OutputStream ave_fos; public void testAudioVideoEntry() { //get the Activity Module_JournalEntry journalentryactivity = getActivity(); //open an InputStream to a resource file (in this case strokes.mp3) ave_fis = journalentryactivity.getResources().openRawResource(module.jakway.JournalEntry.R.raw.strokes); //open an OutputStream to a new file try { ave_fos = journalentryactivity.openFileOutput(ave_file_name, Context.MODE_PRIVATE); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); assertTrue(false); } catch(Exception e) { assertTrue(false); } //copy the data from the resource into //the OutputStream int data; try { while((data = ave_fis.read()) != -1) { ave_fos.write(data); } assertTrue(true); } catch(Exception e) { assertTrue(false); } //get the full path of the file we wrote to ave_path = journalentryactivity.getFileStreamPath(ave_file_name).toString(); //and construct a new object of AudioVideoEntry with that path AudioVideoEntry ave = new AudioVideoEntry(ave_path); //register an error listener via MediaPlayer's setOnErrorListener ave.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { Log.e("MEDIAPLAYER ERRORS", "what: " + what + " extra: " + extra); assertTrue(false); // TODO Auto-generated method stub return false; } }); ave.prepareMedia(); ave.playMedia(); try { ave_fis.close(); ave_fos.close(); } catch(Exception e) { assertTrue(false); e.printStackTrace(); } ``` AudioVideoEntry is basically a thin wrapper around MediaPlayer that can hold its own path: ``` public class AudioVideoEntry { private String path_to_audio_file; private MediaPlayer mediaplayer; /** * Initialize the internal MediaPlayer * from the String parameter * @param set_path_to_audio_file */ public AudioVideoEntry(String set_path_to_audio_file) { path_to_audio_file = set_path_to_audio_file; mediaplayer = new MediaPlayer(); try { mediaplayer.setDataSource(path_to_audio_file); mediaplayer.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public AudioVideoEntry(FileDescriptor fd) { mediaplayer = new MediaPlayer(); try { mediaplayer.setDataSource(fd); mediaplayer.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * Begin playing media */ public void prepareMedia() { try { mediaplayer.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * play media * don't forget to prepare() if necessary */ public void playMedia() { mediaplayer.start(); } /** * pause the media * can be played later */ public void pauseMedia() { mediaplayer.pause(); } /** * stop media */ public void stopMedia() { mediaplayer.stop(); } public void setOnErrorListener(OnErrorListener listener) { mediaplayer.setOnErrorListener(listener); } } ``` here's the logcat output from the JUnit test (the tests were successful, the actual results - as the logat shows - were not) ``` 02-07 09:40:23.129: ERROR/MediaPlayer(1209): error (1, -2147483648) 02-07 09:40:23.139: WARN/System.err(1209): java.io.IOException: Prepare failed.: status=0x1 02-07 09:40:23.149: WARN/System.err(1209): at android.media.MediaPlayer.prepare(Native Method) 02-07 09:40:23.149: WARN/System.err(1209): at module.jakway.JournalEntry.AudioVideoEntry.<init>(AudioVideoEntry.java:39) 02-07 09:40:23.149: WARN/System.err(1209): at module.jakway.JournalEntry.test.Module_JournalEntryTest.testAudioVideoEntry(Module_JournalEntryTest.java:182) 02-07 09:40:23.149: WARN/System.err(1209): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 09:40:23.149: WARN/System.err(1209): at java.lang.reflect.Method.invoke(Method.java:507) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194) 02-07 09:40:23.159: WARN/System.err(1209): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186) 02-07 09:40:23.159: WARN/System.err(1209): at junit.framework.TestCase.runBare(TestCase.java:127) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult$1.protect(TestResult.java:106) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult.runProtected(TestResult.java:124) 02-07 09:40:23.169: WARN/System.err(1209): at junit.framework.TestResult.run(TestResult.java:109) 02-07 09:40:23.179: WARN/System.err(1209): at junit.framework.TestCase.run(TestCase.java:118) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 02-07 09:40:23.179: WARN/System.err(1209): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 02-07 09:40:23.189: WARN/System.err(1209): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 02-07 09:40:23.189: ERROR/MediaPlayer(1209): prepareAsync called in state 0 02-07 09:40:23.189: WARN/System.err(1209): java.lang.IllegalStateException 02-07 09:40:23.189: WARN/System.err(1209): at android.media.MediaPlayer.prepare(Native Method) 02-07 09:40:23.189: WARN/System.err(1209): at module.jakway.JournalEntry.AudioVideoEntry.prepareMedia(AudioVideoEntry.java:79) 02-07 09:40:23.199: WARN/System.err(1209): at module.jakway.JournalEntry.test.Module_JournalEntryTest.testAudioVideoEntry(Module_JournalEntryTest.java:197) 02-07 09:40:23.199: WARN/System.err(1209): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 09:40:23.199: WARN/System.err(1209): at java.lang.reflect.Method.invoke(Method.java:507) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:186) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestCase.runBare(TestCase.java:127) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult$1.protect(TestResult.java:106) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult.runProtected(TestResult.java:124) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestResult.run(TestResult.java:109) 02-07 09:40:23.199: WARN/System.err(1209): at junit.framework.TestCase.run(TestCase.java:118) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 02-07 09:40:23.199: WARN/System.err(1209): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 02-07 09:40:23.199: WARN/System.err(1209): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) 02-07 09:40:23.199: ERROR/MediaPlayer(1209): start called in state 0 02-07 09:40:23.199: ERROR/MediaPlayer(1209): error (-38, 0) ``` Edit: why is MediaPlayer failing? thanks! dragonwrenn
2011/02/07
[ "https://Stackoverflow.com/questions/4924600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450153/" ]
The second call to MediaPlayer.prepare() (already called once in the AudioVideoEntry ctor) in the AudioVideoEntry.prepareMedia() method was easy to spot as other people have noticed. The harder error to find was the first error. I used an Ogg file for testing. First clue was from davidsparks reply (last one) in [android-platform - Ogg on G1](http://groups.google.com/group/android-platform/browse_thread/thread/73ee9bfcf311763b) > > As long as the files have a .ogg extension, they should play with the > built-in music player. We rely on the file extensions because there is > no centralized file recognizer for the media scanner. > > > Second clue was from [[android-developers] Re: File permission about MediaPlayer](http://www.mail-archive.com/android-developers@googlegroups.com/msg12519.html) > > Due to the Android security model, MediaPlayer does not have root > access rights. It can access the sdcard, but it can't access private > app directories. > > > Your app can explicitly grant MediaPlayer temporary access to secure > files by opening the file and passing the file descriptor to > MediaPlayer using the setDataSource(FileDescriptor fd) method. > > > If you look at the absolute path of the output stream, you see it's in the `/data/data` directory under the app's package name's directory. Excuse the timestamps - I worked backwards to get data to show on a OS2.1update1 (API7) emulator. Your code had: ``` String ave_file_name = "my_media_content"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_PRIVATE); ``` DDMS showed: ``` 02-10 05:10:28.253: WARN/MediaPlayer(1992): info/warning (1, 26) 02-10 05:10:28.253: ERROR/PlayerDriver(31): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported 02-10 05:10:28.253: ERROR/MediaPlayer(1992): error (1, -4) 02-10 05:10:28.274: WARN/PlayerDriver(31): PVMFInfoErrorHandlingComplete ``` If we change **JUST** the file to MODE\_WORLD\_READABLE: ``` String ave_file_name = "my_media_content"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_WORLD_READABLE); ``` DDMS shows no improvement: ``` 02-10 05:08:28.543: WARN/MediaPlayer(1900): info/warning (1, 26) 02-10 05:08:28.553: ERROR/PlayerDriver(31): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported 02-10 05:08:28.553: ERROR/MediaPlayer(1900): error (1, -4) 02-10 05:08:28.563: WARN/PlayerDriver(31): PVMFInfoErrorHandlingComplete ``` If we change **JUST** the file extension to `ogg`: ``` String ave_file_name = "my_media_content.ogg"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_PRIVATE); ``` We get a change in DDMS output: ``` 02-10 04:59:30.153: ERROR/MediaPlayerService(31): error: -2 02-10 04:59:30.163: ERROR/MediaPlayer(1603): Unable to to create media player ``` But when we **combine the two**: ``` String ave_file_name = "my_media_content.ogg"; ave_fos = activity.openFileOutput(ave_file_name, Context.MODE_WORLD_READABLE); ``` DDMS shows no errors.
Some points: 1. Do not call `prepare()` twice (once in the constructor and the other explicitly). That could be one of the reasons that the `IllegalStateException` is thrown. 2. Also, is the file that you are trying to play inside the application? If so, why are you trying to create a stream? If the file is already within the application (and within `/res/raw`, you could try and save yourself the hassle of using `prepare()` by creating the mediaplayer object like so: mediaplayer = new MediaPlayer.create(this, R.raw.resource-name here); The create function calls `prepare()` within. 3. You can also try and use the `reset()` function if any one of the stages in the MediaPlayer fails resulting in the MediaPlayer object entering the error state. Using `reset()` would bring it back to Idle state. 4. The last time I had that error `status=0x1` message, it turned out that I had not had the correct permissions set for the files (external storage etc. in Manifest) and some files placed in incorrect folders. You may also want to take a look at that. Let me know in case that does not work, We can try something else. Sriram.
26,163,209
I'm processing a data.frame of products called "`all`" whose first variable `all$V1` is a product family. There are several rows per product family, i.e. `length(levels(all$V1))` < `length(all$V1)`. I want to traverse the data.frame and process by product family "`p`". I'm new to R, so I haven't fully grasped when I can do something vectorially, or when to loop. At the moment, I can traverse and get subsets by: ``` for (i in levels (all$V1)){ p = all[which(all[,'V1'] == i), ]; calculateStuff(p); } ``` Is this the way to do this, or is there a groovy vectorial way of doing this with `apply` or something? There are only a few thousand rows, so performance gain is probably negligeable, but I'd like to devlop good habits for larger data ses.
2014/10/02
[ "https://Stackoverflow.com/questions/26163209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3790954/" ]
Data: ``` all = data.frame(V1=c("a","b","c","d","d","c","c","b","a","a","a","d")) ``` 'all' can be split by V1: ``` > ll = split(all, all$V1) > ll $a V1 1 a 9 a 10 a 11 a $b V1 2 b 8 b $c V1 3 c 6 c 7 c $d V1 4 d 5 d 12 d ``` sapply can be used to analyze each component of list 'll'. Following finds number of rows in each component (which represents product family): ``` calculateStuff <- function(p){ nrow(p) } > sapply(ll, calculateStuff) a b c d 4 2 3 3 ```
There is unlikely to be much of a performance gain with the below, but it is at least more compact and returns the results of `calculateStuff` as a convenient list: ``` lapply(levels(all$V1), function(i) calculateStuff(all[all$V1 == i, ]) ) ``` As @SimonG points out in his comment, depending on exactly what your `calculateStuff` function is, `aggregate` may also be useful to you if you want your results in the form of dataframe.
6,507,359
[As I have seen here](https://stackoverflow.com/questions/3680429/click-through-a-div-to-underlying-elements/4839672#4839672), a filter can be used to simulate a cross browser version of ```css pointer-events: none; ``` However, this just doesn't work in IE9, nor does it in the "emulate IE8" version in IE9. A native installation of IE8 handles it fine, however. Is there any solution that makes it work for IE9?
2011/06/28
[ "https://Stackoverflow.com/questions/6507359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/775265/" ]
You're right - AlphaImageLoader filter has been removed from IE9. This was done so that it doesn't conflict with the standards compliant methods. In this case, `pointer-events: none`, which [now works in IE9](http://msdn.microsoft.com/en-us/library/ff972269%28v=vs.85%29.aspx). If you're using a conditional comments to target IE for the filter fix, change them to target only IE8 and below. Try changing `<!--[if IE]>` to `<!--[if lte IE 8]>` **Edit:** I've since come across this again and it appears that `pointer-events: none` does not work in IE9 (not for HTML elements anyway). I thought this was working, but on re-testing neither method works for click-through on IE9. Perhaps I had my IE9 in a compatibility mode. It's not ideal at all, but you could force IE9 into IE8 mode via the `<meta>` tag switch: ``` <!--[if ie 9]><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"><![endif]--> ``` Apologies for the misinformation, I'll keep looking into this. **Update Sept 24 2012:** The wonderfully useful [caniuse.com](http://caniuse.com/pointer-events) has more information on `pointer-events` for HTML. Support in IE10 is still unknown and it appears that Opera does not support this property either. I would advise against using `pointer-events` for now unless you're specifically targeting Webkit/Mozilla.
pointer-events only works in webkit, mozilla browsers in html. However pointer-events works on svg elements in internet explorer. There is a good modernizr plugin <https://github.com/ausi/Feature-detection-technique-for-pointer-events/blob/master/modernizr-pointerevents.min.js> to test the existence of pointer-events If you are using the pointer events to just add some sort of texture over the top you can replace a div with a svg element ``` if( !Modernizr.pointerevents ) { $('#texture').replaceWith('<svg id="texture"/>'); } ```
26,801,957
I am trying to create a mini accounts application that captures and stores the first name, last name, student number and grade of students through textboxes and then stores it to a comma delimited text file. The problem is that it re-writes the input every time I hit the save file. Any help would be appreciated. Here is the code I am using: ``` Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click Dim fName, lName, sNum As String Dim grade As Decimal fName = txtFName.Text lName = txtLName.Text sNum = txtSNum.Text grade = txtGrade.Text Try Dim write As StreamWriter write = New StreamWriter("hello.txt") write.WriteLine(String.Format("{0},{1},{2},{3}", fName, lName, sNum, grade)) write.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub ```
2014/11/07
[ "https://Stackoverflow.com/questions/26801957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227012/" ]
On report right click and Properties > +More under the Properties > Add this parameters; **net.sf.jasperreports.export.xls.ignore.graphics = false** and on Jasper Server : jasperreports-server-cp-5.0.0/apache-tomcat/webapps/jasperserver/WEB-INF/classes/jasperreports.properties add this parameter; **net.sf.jasperreports.export.xls.ignore.graphics = false**
1 - You can using a simply URL File Path. Create one image component. 2 - You can active "Markup" for show HTML interpreted. 3 - You can use itext API, to generate PDF using HTML code. maybe exists another options.
65,772,928
I have a meta reducer that should clear the state when logging out. ``` export function clearState(reducer: ActionReducer<any>): ActionReducer<any> { return (state, action) => { if (action.type === AuthActionTypes.UNAUTHENTICATED) { state = undefined; } return reducer(state, action); }; } export const metaReducers: MetaReducer<any>[] = [clearState]; ``` I want to unit test this piece of code. I have tested normal reducers before but for me it is hard to apply the same technique when writing a test for the meta reducer. And there are no examples in the docs.
2021/01/18
[ "https://Stackoverflow.com/questions/65772928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4956266/" ]
I figured out a way to test it after digging deep in the ngrx source code ``` const invokeActionReducer = (currentState, action: any) => { return clearState((state) => state)(currentState, action); }; it('should set state to initial value when logout action is dispatched', () => { const currentState = { /* state here */ }; expect(invokeActionReducer(currentState, userUnauthenticated)).toBeFalsy(); }); ``` [Source](https://github.com/ngrx/platform/tree/master/modules/store/spec/meta-reducers)
This might not be all of it but something like this should work: ``` let store: Store<any>; .... store = TestBed.inject(Store); // TestBed.inject is TestBed.get in older versions of Angular TestBed.configureTEstingModule({ imports: [StoreModule.forRoot(/* put your reducers here */, { metaReducers })], }); it('should re-initialize the state once unauthenticated is dispatched', async () => { store.dispatch(/* dispatch an action that will change the store */); const newPieceOfState = await this.store.select(state => ...).pipe(take(1)).toPromise(); // ensure the change took place expect(newPieceOfState).toEqual(...); store.dispatch(/* dispatch UNAUTHENTICATED */); const state = await this.store.select(state => ....).pipe(take(1)).toPromise(); expect(state).toEqual(...); // do your assertions that the meta reducer took effect and the state changed }); ```
39,487,308
I want to backup configuration of job, I am using to do this ThinBackup plugin in version 1.7.4 . And in every configuration of the job, there is something like `Promote builds when..`, how to backup this?
2016/09/14
[ "https://Stackoverflow.com/questions/39487308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5612084/" ]
I ran into same issue and found this is an [open bug](https://issues.jenkins-ci.org/browse/JENKINS-21472). Looks to have a fix but a new version of the plugin hasn't been released. A workaround which seems to work OK so far, is to separately backup the `config.xml` files under the `JENKINS_HOME/jobs/`. On Linux I ran the below from the Jenkins home directory to create this additional backup: ``` $ find jobs -name config.xml -exec tar -rzvf /tmp/config.xml-BACKUP.tgz {} \; ``` So I'm still using ThinBackup to get all the other bits but after restoring its backup: ``` tar -xzf /tmp/config.xml-BACKUP.tgz ``` I then restored the jobs `config.xml` backup and restarted Jenkins.
They are a some options with the ThinBackup plugin: [![enter image description here](https://i.stack.imgur.com/KlCz9.png)](https://i.stack.imgur.com/KlCz9.png) Did you try to enable the "Backup build archive" option?
3,604
Still with software science translations.. Now I'm coming to you with this expression that have always bothered me: "on the fly" How the hood would you translate that *elegantly* to spanish? It feels like "sobre la marcha" is way overkill, at least from a structure point of view. Also "al toque", sounds maybe too coloquial. What do you think? edit: so the english sentence could be: > > The value is returned from a new function executed on the fly. > > >
2013/04/24
[ "https://spanish.stackexchange.com/questions/3604", "https://spanish.stackexchange.com", "https://spanish.stackexchange.com/users/831/" ]
I would generally use *sobre la marcha* and I don't see it as overkill. What does this phrase have to do with Scientific translations? Maybe a few examples would help.
I'm from Latin America and "al toque" doesn't mean exactly "on the fly", the correct translation would be "sobre la marcha". "Al toque" it's more like a "immediately after".
3,604
Still with software science translations.. Now I'm coming to you with this expression that have always bothered me: "on the fly" How the hood would you translate that *elegantly* to spanish? It feels like "sobre la marcha" is way overkill, at least from a structure point of view. Also "al toque", sounds maybe too coloquial. What do you think? edit: so the english sentence could be: > > The value is returned from a new function executed on the fly. > > >
2013/04/24
[ "https://spanish.stackexchange.com/questions/3604", "https://spanish.stackexchange.com", "https://spanish.stackexchange.com/users/831/" ]
No, I don’t like very much `sobre la marcha`. I mean, not always, and in “*software science translations*” almost never. I don’t feel it translate the whole idea exactly, with sometimes is: immediately and automatically, without user’s or external elements intervention. There are many other possibilities. My favorite is the simple direct translation: “`al vuelo`”. Let’s see what the RAE said about “vuelo”: > > al ~, o a ~. > > > 1. locs. advs. Con prontitud. > > > cazarlas alguien al ~. > > > 1. loc. verb. Entender o notar con prontitud las cosas que no se dicen claramente o que se hacen ocultamente. > > > coger al ~ algo. > > > 1. loc. verb. Lograrlo de paso o casualmente. > > > cogerlas alguien al ~. > > > 1. loc. verb. coloq. cazarlas al vuelo. > > > alzar el ~. > > > 1. loc. verb. Echar a volar. > 2. loc. verb. coloq. Marcharse de repente. > > > I like this more than “`sobre la marcha`”, with the bonus that many people will automatically translate it to `on the fly` with the exact original meaning. Some of the other possibilities are: “sobre la marcha” (of course), inmediátamente, automáticamente, dinámicamente (this is probably my second favorite). *The windows layout change on the fly.* **El diseno de la pantalla cambia dinámicamente.** (a sort of this) simultáneamente Let’s see some concrete examples: [I have a class which calculates it's property on-the-fly, for example:](https://stackoverflow.com/q/15744634/1458030) Tengo una clase que calcula sus propiedades al vuelo. (dinámicamente, en tiempo real)(I’m not sure how to correctly translate `class` and `properties`) [An example enlightens the kerning-on-the-fly functionality:](https://stackoverflow.com/q/12654826/1458030) Un ejemplo aclara esta funcionalidad de posicionamiento al vuelo. (dinámico, instantaneo, sobre la marcha) [Encryption on the fly.](https://stackoverflow.com/q/16215990/1458030) Cifrado al vuelo. Cifrado simultaneo, en tiempo real, dinámico, automático… On the fly translation. Traduccion simultanuea. (al vuelo, instantanea, sobre la marcha) [More examples are here.](http://www.linguee.com/english-spanish?query=on%20the%20fly&source=english)
I would generally use *sobre la marcha* and I don't see it as overkill. What does this phrase have to do with Scientific translations? Maybe a few examples would help.
3,604
Still with software science translations.. Now I'm coming to you with this expression that have always bothered me: "on the fly" How the hood would you translate that *elegantly* to spanish? It feels like "sobre la marcha" is way overkill, at least from a structure point of view. Also "al toque", sounds maybe too coloquial. What do you think? edit: so the english sentence could be: > > The value is returned from a new function executed on the fly. > > >
2013/04/24
[ "https://spanish.stackexchange.com/questions/3604", "https://spanish.stackexchange.com", "https://spanish.stackexchange.com/users/831/" ]
"Al toque" sounds to me like Latin America spanish... in Spain, al least in Madrid, we don't use that expression. "On the fly" can be translated in several forms, but "sobre la marcha" I think is the most accurate. Other forms can be "al momento", "instantáneo" or "conforme se vea". Depends from context, but I think "sobre la marcha" is the most elegant, formal and easy. Some examples: > > We will fix the errors on the fly. - Iremos corrigiendo los errores > *sobre la marcha* / *conforme los veamos*. > > > The system enables 'on-the-fly' processing of queries. - El sistema > permite el procesamiento *instantáneo* de consultas. > > >
I'm from Latin America and "al toque" doesn't mean exactly "on the fly", the correct translation would be "sobre la marcha". "Al toque" it's more like a "immediately after".
3,604
Still with software science translations.. Now I'm coming to you with this expression that have always bothered me: "on the fly" How the hood would you translate that *elegantly* to spanish? It feels like "sobre la marcha" is way overkill, at least from a structure point of view. Also "al toque", sounds maybe too coloquial. What do you think? edit: so the english sentence could be: > > The value is returned from a new function executed on the fly. > > >
2013/04/24
[ "https://spanish.stackexchange.com/questions/3604", "https://spanish.stackexchange.com", "https://spanish.stackexchange.com/users/831/" ]
No, I don’t like very much `sobre la marcha`. I mean, not always, and in “*software science translations*” almost never. I don’t feel it translate the whole idea exactly, with sometimes is: immediately and automatically, without user’s or external elements intervention. There are many other possibilities. My favorite is the simple direct translation: “`al vuelo`”. Let’s see what the RAE said about “vuelo”: > > al ~, o a ~. > > > 1. locs. advs. Con prontitud. > > > cazarlas alguien al ~. > > > 1. loc. verb. Entender o notar con prontitud las cosas que no se dicen claramente o que se hacen ocultamente. > > > coger al ~ algo. > > > 1. loc. verb. Lograrlo de paso o casualmente. > > > cogerlas alguien al ~. > > > 1. loc. verb. coloq. cazarlas al vuelo. > > > alzar el ~. > > > 1. loc. verb. Echar a volar. > 2. loc. verb. coloq. Marcharse de repente. > > > I like this more than “`sobre la marcha`”, with the bonus that many people will automatically translate it to `on the fly` with the exact original meaning. Some of the other possibilities are: “sobre la marcha” (of course), inmediátamente, automáticamente, dinámicamente (this is probably my second favorite). *The windows layout change on the fly.* **El diseno de la pantalla cambia dinámicamente.** (a sort of this) simultáneamente Let’s see some concrete examples: [I have a class which calculates it's property on-the-fly, for example:](https://stackoverflow.com/q/15744634/1458030) Tengo una clase que calcula sus propiedades al vuelo. (dinámicamente, en tiempo real)(I’m not sure how to correctly translate `class` and `properties`) [An example enlightens the kerning-on-the-fly functionality:](https://stackoverflow.com/q/12654826/1458030) Un ejemplo aclara esta funcionalidad de posicionamiento al vuelo. (dinámico, instantaneo, sobre la marcha) [Encryption on the fly.](https://stackoverflow.com/q/16215990/1458030) Cifrado al vuelo. Cifrado simultaneo, en tiempo real, dinámico, automático… On the fly translation. Traduccion simultanuea. (al vuelo, instantanea, sobre la marcha) [More examples are here.](http://www.linguee.com/english-spanish?query=on%20the%20fly&source=english)
"Al toque" sounds to me like Latin America spanish... in Spain, al least in Madrid, we don't use that expression. "On the fly" can be translated in several forms, but "sobre la marcha" I think is the most accurate. Other forms can be "al momento", "instantáneo" or "conforme se vea". Depends from context, but I think "sobre la marcha" is the most elegant, formal and easy. Some examples: > > We will fix the errors on the fly. - Iremos corrigiendo los errores > *sobre la marcha* / *conforme los veamos*. > > > The system enables 'on-the-fly' processing of queries. - El sistema > permite el procesamiento *instantáneo* de consultas. > > >
3,604
Still with software science translations.. Now I'm coming to you with this expression that have always bothered me: "on the fly" How the hood would you translate that *elegantly* to spanish? It feels like "sobre la marcha" is way overkill, at least from a structure point of view. Also "al toque", sounds maybe too coloquial. What do you think? edit: so the english sentence could be: > > The value is returned from a new function executed on the fly. > > >
2013/04/24
[ "https://spanish.stackexchange.com/questions/3604", "https://spanish.stackexchange.com", "https://spanish.stackexchange.com/users/831/" ]
No, I don’t like very much `sobre la marcha`. I mean, not always, and in “*software science translations*” almost never. I don’t feel it translate the whole idea exactly, with sometimes is: immediately and automatically, without user’s or external elements intervention. There are many other possibilities. My favorite is the simple direct translation: “`al vuelo`”. Let’s see what the RAE said about “vuelo”: > > al ~, o a ~. > > > 1. locs. advs. Con prontitud. > > > cazarlas alguien al ~. > > > 1. loc. verb. Entender o notar con prontitud las cosas que no se dicen claramente o que se hacen ocultamente. > > > coger al ~ algo. > > > 1. loc. verb. Lograrlo de paso o casualmente. > > > cogerlas alguien al ~. > > > 1. loc. verb. coloq. cazarlas al vuelo. > > > alzar el ~. > > > 1. loc. verb. Echar a volar. > 2. loc. verb. coloq. Marcharse de repente. > > > I like this more than “`sobre la marcha`”, with the bonus that many people will automatically translate it to `on the fly` with the exact original meaning. Some of the other possibilities are: “sobre la marcha” (of course), inmediátamente, automáticamente, dinámicamente (this is probably my second favorite). *The windows layout change on the fly.* **El diseno de la pantalla cambia dinámicamente.** (a sort of this) simultáneamente Let’s see some concrete examples: [I have a class which calculates it's property on-the-fly, for example:](https://stackoverflow.com/q/15744634/1458030) Tengo una clase que calcula sus propiedades al vuelo. (dinámicamente, en tiempo real)(I’m not sure how to correctly translate `class` and `properties`) [An example enlightens the kerning-on-the-fly functionality:](https://stackoverflow.com/q/12654826/1458030) Un ejemplo aclara esta funcionalidad de posicionamiento al vuelo. (dinámico, instantaneo, sobre la marcha) [Encryption on the fly.](https://stackoverflow.com/q/16215990/1458030) Cifrado al vuelo. Cifrado simultaneo, en tiempo real, dinámico, automático… On the fly translation. Traduccion simultanuea. (al vuelo, instantanea, sobre la marcha) [More examples are here.](http://www.linguee.com/english-spanish?query=on%20the%20fly&source=english)
I'm from Latin America and "al toque" doesn't mean exactly "on the fly", the correct translation would be "sobre la marcha". "Al toque" it's more like a "immediately after".
19,673,842
I'm a Beginner in android development. I'm using Google Maps API V2 in my Application. I want to show the street name, postcode/zip-code, city automatically of the current location. Currently I'm just displaying the longitude and latitude of the current location but don't know how to get this information as well. Can Anyone please tell me the right way, that how can I get these information(street name, postcode/zipcode, city) from the maps api v2..
2013/10/30
[ "https://Stackoverflow.com/questions/19673842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2933576/" ]
As per your question **`How to fetch all DIVs that have some specific css rules (e.g. their color are red)?`** ``` $.each($('*'), function () { if ($(this).css('color') == 'rgb(255, 0, 0)') { alert($(this).text()); } }); This will get all elements with color Red ``` [**Live Demo**](http://jsfiddle.net/jpGER/3/) **Addition** As **`*`** will be selecting all the elements in Dom, we can narrow down our search by specifying the type of elements we are looking for. for example here we have `div` elements only so we can use ``` $.each($('div'), function () { if ($(this).css('color') == 'rgb(255, 0, 0)') { alert($(this).text()); } }); ```
Try this: ``` $("body").find("div:hidden") ```
19,673,842
I'm a Beginner in android development. I'm using Google Maps API V2 in my Application. I want to show the street name, postcode/zip-code, city automatically of the current location. Currently I'm just displaying the longitude and latitude of the current location but don't know how to get this information as well. Can Anyone please tell me the right way, that how can I get these information(street name, postcode/zipcode, city) from the maps api v2..
2013/10/30
[ "https://Stackoverflow.com/questions/19673842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2933576/" ]
As per your question **`How to fetch all DIVs that have some specific css rules (e.g. their color are red)?`** ``` $.each($('*'), function () { if ($(this).css('color') == 'rgb(255, 0, 0)') { alert($(this).text()); } }); This will get all elements with color Red ``` [**Live Demo**](http://jsfiddle.net/jpGER/3/) **Addition** As **`*`** will be selecting all the elements in Dom, we can narrow down our search by specifying the type of elements we are looking for. for example here we have `div` elements only so we can use ``` $.each($('div'), function () { if ($(this).css('color') == 'rgb(255, 0, 0)') { alert($(this).text()); } }); ```
Try this ``` $("div[style*=display:block]") ```
19,673,842
I'm a Beginner in android development. I'm using Google Maps API V2 in my Application. I want to show the street name, postcode/zip-code, city automatically of the current location. Currently I'm just displaying the longitude and latitude of the current location but don't know how to get this information as well. Can Anyone please tell me the right way, that how can I get these information(street name, postcode/zipcode, city) from the maps api v2..
2013/10/30
[ "https://Stackoverflow.com/questions/19673842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2933576/" ]
As per your question **`How to fetch all DIVs that have some specific css rules (e.g. their color are red)?`** ``` $.each($('*'), function () { if ($(this).css('color') == 'rgb(255, 0, 0)') { alert($(this).text()); } }); This will get all elements with color Red ``` [**Live Demo**](http://jsfiddle.net/jpGER/3/) **Addition** As **`*`** will be selecting all the elements in Dom, we can narrow down our search by specifying the type of elements we are looking for. for example here we have `div` elements only so we can use ``` $.each($('div'), function () { if ($(this).css('color') == 'rgb(255, 0, 0)') { alert($(this).text()); } }); ```
You could try using [attribute selectors](http://www.w3.org/TR/css3-selectors/#attribute-selectors). ``` document.querySelectorAll('[style="display: none"]') ``` but that would require that your `style` attributes are consistently formatted... If you are looking to get *all* elements that have a certain css property (not just in the `style=` attribute), you may have to do it manually, by looking through the [document stylesheets](https://developer.mozilla.org/en-US/docs/Web/API/document.styleSheets).