qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
25,261,647
Is it possible to encrypt/decrypt data with AES without installing extra modules? I need to send/receive data from `C#`, which is encrypted with the `System.Security.Cryptography` reference. **UPDATE** I have tried to use PyAES, but that is too old. I updated some things to make that work, but it didn't. I've also can't install because it latest version is `3.3` while my version is `3.4`.
2014/08/12
[ "https://Stackoverflow.com/questions/25261647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3902480/" ]
The available Cryptographic Services available in the Standard Library are [those](https://docs.python.org/3.4/library/crypto.html). As you can see `AES` is not listed, but is suggest to use [`pycrypto`](https://pypi.python.org/pypi/pycrypto) which is an *extra module*. You just have to install it using *pip*, or *easy\_install* and then as showed in *pycrypto*'s page: ``` from Crypto.Cipher import AES obj = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') message = "The answer is no" print obj.encrypt(message) ``` The only other way without using an extra module would be to code the function yourself, but what's the difference of downloading an extra module and use that instead? If you want a pure Python implementation of AES that you can download and import check [pyaes](https://pypi.python.org/pypi/pyaes).
To add to @enrico.bacis' answer: AES is not implemented in the standard library. It is implemented in the PyCrypto library, which is stable and well tested. If you need AES, add PyCrypto as a dependency of your code. While the AES primitives are, in theory, simple enough that you could write an implementation of them in pure Python, it is **strongly** recommended that you not do so. This is the first rule of crypto: don't implement it yourself. In particular, if you're just rolling your own crypto library, you'll almost certainly leave yourself open to some kind of side-channel attack.
25,261,647
Is it possible to encrypt/decrypt data with AES without installing extra modules? I need to send/receive data from `C#`, which is encrypted with the `System.Security.Cryptography` reference. **UPDATE** I have tried to use PyAES, but that is too old. I updated some things to make that work, but it didn't. I've also can't install because it latest version is `3.3` while my version is `3.4`.
2014/08/12
[ "https://Stackoverflow.com/questions/25261647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3902480/" ]
I'm using [Cryptography](https://cryptography.io/en/latest/#) library. > > Cryptography is an actively developed library that provides > cryptographic recipes and primitives. It supports Python 2.6-2.7, > Python 3.3+ and PyPy. > > > [Here is an example](https://cryptography.io/en/latest/hazmat/primitives/symmetric-encryption/?highlight=aes) of how to use that library: ``` >>> import os >>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes >>> from cryptography.hazmat.backends import default_backend >>> backend = default_backend() >>> key = os.urandom(32) >>> iv = os.urandom(16) >>> cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend) >>> encryptor = cipher.encryptor() >>> ct = encryptor.update(b"a secret message") + encryptor.finalize() >>> decryptor = cipher.decryptor() >>> decryptor.update(ct) + decryptor.finalize() 'a secret message' ```
The available Cryptographic Services available in the Standard Library are [those](https://docs.python.org/3.4/library/crypto.html). As you can see `AES` is not listed, but is suggest to use [`pycrypto`](https://pypi.python.org/pypi/pycrypto) which is an *extra module*. You just have to install it using *pip*, or *easy\_install* and then as showed in *pycrypto*'s page: ``` from Crypto.Cipher import AES obj = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') message = "The answer is no" print obj.encrypt(message) ``` The only other way without using an extra module would be to code the function yourself, but what's the difference of downloading an extra module and use that instead? If you want a pure Python implementation of AES that you can download and import check [pyaes](https://pypi.python.org/pypi/pyaes).
25,261,647
Is it possible to encrypt/decrypt data with AES without installing extra modules? I need to send/receive data from `C#`, which is encrypted with the `System.Security.Cryptography` reference. **UPDATE** I have tried to use PyAES, but that is too old. I updated some things to make that work, but it didn't. I've also can't install because it latest version is `3.3` while my version is `3.4`.
2014/08/12
[ "https://Stackoverflow.com/questions/25261647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3902480/" ]
PYAES should work with any version of Python3.x. No need to modify the library. Here is a complete working example for pyaes CTR mode for Python3.x (<https://github.com/ricmoo/pyaes>) ``` import pyaes # A 256 bit (32 byte) key key = "This_key_for_demo_purposes_only!" plaintext = "Text may be any length you wish, no padding is required" # key must be bytes, so we convert it key = key.encode('utf-8') aes = pyaes.AESModeOfOperationCTR(key) ciphertext = aes.encrypt(plaintext) # show the encrypted data print (ciphertext) # DECRYPTION # CRT mode decryption requires a new instance be created aes = pyaes.AESModeOfOperationCTR(key) # decrypted data is always binary, need to decode to plaintext decrypted = aes.decrypt(ciphertext).decode('utf-8') # True print (decrypted == plaintext) ``` Let me know if you get any errors
Python 3.6 with cryptography module ``` from cryptography.fernet import Fernet key = Fernet.generate_key() f = Fernet(key) token = f.encrypt(b"my deep dark secret") print(token) f.decrypt(token) ```
25,261,647
Is it possible to encrypt/decrypt data with AES without installing extra modules? I need to send/receive data from `C#`, which is encrypted with the `System.Security.Cryptography` reference. **UPDATE** I have tried to use PyAES, but that is too old. I updated some things to make that work, but it didn't. I've also can't install because it latest version is `3.3` while my version is `3.4`.
2014/08/12
[ "https://Stackoverflow.com/questions/25261647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3902480/" ]
PYAES should work with any version of Python3.x. No need to modify the library. Here is a complete working example for pyaes CTR mode for Python3.x (<https://github.com/ricmoo/pyaes>) ``` import pyaes # A 256 bit (32 byte) key key = "This_key_for_demo_purposes_only!" plaintext = "Text may be any length you wish, no padding is required" # key must be bytes, so we convert it key = key.encode('utf-8') aes = pyaes.AESModeOfOperationCTR(key) ciphertext = aes.encrypt(plaintext) # show the encrypted data print (ciphertext) # DECRYPTION # CRT mode decryption requires a new instance be created aes = pyaes.AESModeOfOperationCTR(key) # decrypted data is always binary, need to decode to plaintext decrypted = aes.decrypt(ciphertext).decode('utf-8') # True print (decrypted == plaintext) ``` Let me know if you get any errors
[Here is a self-contained implementation of AES compatible with Python 3](http://uthcode.googlecode.com/svn-history/r678/trunk/python/py3AES.py). Example usage: ``` aesmodal = AESModeOfOperation() key = [143,194,34,208,145,203,230,143,177,246,97,206,145,92,255,84] iv = [103,35,148,239,76,213,47,118,255,222,123,176,106,134,98,92] size = aesmodal.aes.keySize["SIZE_128"] mode,orig_len,ciphertext = aesmodal.encrypt("Hello, world!", aesmodal.modeOfOperation["OFB"], key, size, iv) print(ciphertext) plaintext = aesmodal.decrypt(ciphertext, orig_len, mode, key, size, iv) print(plaintext) ```
25,261,647
Is it possible to encrypt/decrypt data with AES without installing extra modules? I need to send/receive data from `C#`, which is encrypted with the `System.Security.Cryptography` reference. **UPDATE** I have tried to use PyAES, but that is too old. I updated some things to make that work, but it didn't. I've also can't install because it latest version is `3.3` while my version is `3.4`.
2014/08/12
[ "https://Stackoverflow.com/questions/25261647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3902480/" ]
I'm using [Cryptography](https://cryptography.io/en/latest/#) library. > > Cryptography is an actively developed library that provides > cryptographic recipes and primitives. It supports Python 2.6-2.7, > Python 3.3+ and PyPy. > > > [Here is an example](https://cryptography.io/en/latest/hazmat/primitives/symmetric-encryption/?highlight=aes) of how to use that library: ``` >>> import os >>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes >>> from cryptography.hazmat.backends import default_backend >>> backend = default_backend() >>> key = os.urandom(32) >>> iv = os.urandom(16) >>> cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend) >>> encryptor = cipher.encryptor() >>> ct = encryptor.update(b"a secret message") + encryptor.finalize() >>> decryptor = cipher.decryptor() >>> decryptor.update(ct) + decryptor.finalize() 'a secret message' ```
To add to @enrico.bacis' answer: AES is not implemented in the standard library. It is implemented in the PyCrypto library, which is stable and well tested. If you need AES, add PyCrypto as a dependency of your code. While the AES primitives are, in theory, simple enough that you could write an implementation of them in pure Python, it is **strongly** recommended that you not do so. This is the first rule of crypto: don't implement it yourself. In particular, if you're just rolling your own crypto library, you'll almost certainly leave yourself open to some kind of side-channel attack.
17,572,519
I am working on STM32l151rct6a by stm, I have stumbled upon these MACRO definitions ``` __CC_ARM, __ICCARM__, __GNUC__, __TASKING__ ``` Does anyone know what they mean?
2013/07/10
[ "https://Stackoverflow.com/questions/17572519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1314467/" ]
These are different compilers for ARM processors, probably these macros are used to hide compiler-dependent stuff in code that's compilable by several compilers. * `ICCARM` --> [IAR](https://wwwfiles.iar.com/arm/webic/doc/ewarm_developmentguide.enu.pdf) (there will also be a macro `__IAR_SYSTEMS_ICC__` that is set to the compiler platform version * `__IMAGECRAFT__` --> [Imagecraft C](https://www.imagecraft.com/) (also see Clifford's comments below - there's also a macro `__ICC_VERSION__`, see the [pdf documentation](https://www.imagecraft.com/help/iccv8cortex/ICCCORTEX.pdf)) * `TASKING` --> [Tasking](https://www.tasking.com/products/arm/) * `__CC_ARM` --> [ARM's (RealView) compiler](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0282b/Babbacdb.html) (link broken) * `__GNUC__` --> [gcc](https://gcc.gnu.org/)
These are compiler specific MACROS and defined in compiler code.For example \_\_ICC is for IAR and \_\_GNU is for GNU compilers.There are some code given in BSP part for STM platform which have dependency on compilers.
17,572,519
I am working on STM32l151rct6a by stm, I have stumbled upon these MACRO definitions ``` __CC_ARM, __ICCARM__, __GNUC__, __TASKING__ ``` Does anyone know what they mean?
2013/07/10
[ "https://Stackoverflow.com/questions/17572519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1314467/" ]
These are different compilers for ARM processors, probably these macros are used to hide compiler-dependent stuff in code that's compilable by several compilers. * `ICCARM` --> [IAR](https://wwwfiles.iar.com/arm/webic/doc/ewarm_developmentguide.enu.pdf) (there will also be a macro `__IAR_SYSTEMS_ICC__` that is set to the compiler platform version * `__IMAGECRAFT__` --> [Imagecraft C](https://www.imagecraft.com/) (also see Clifford's comments below - there's also a macro `__ICC_VERSION__`, see the [pdf documentation](https://www.imagecraft.com/help/iccv8cortex/ICCCORTEX.pdf)) * `TASKING` --> [Tasking](https://www.tasking.com/products/arm/) * `__CC_ARM` --> [ARM's (RealView) compiler](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0282b/Babbacdb.html) (link broken) * `__GNUC__` --> [gcc](https://gcc.gnu.org/)
They are macros for identifying the compiler being used to build the code. A list of such macros, and others for identifying architecture and OS etc. can be found at <http://sourceforge.net/p/predef/wiki/Home/>. It does not however comprehensively cover many compilers from smaller embedded systems vendors (Tasking and Imagecraft for example).
17,572,519
I am working on STM32l151rct6a by stm, I have stumbled upon these MACRO definitions ``` __CC_ARM, __ICCARM__, __GNUC__, __TASKING__ ``` Does anyone know what they mean?
2013/07/10
[ "https://Stackoverflow.com/questions/17572519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1314467/" ]
They are macros for identifying the compiler being used to build the code. A list of such macros, and others for identifying architecture and OS etc. can be found at <http://sourceforge.net/p/predef/wiki/Home/>. It does not however comprehensively cover many compilers from smaller embedded systems vendors (Tasking and Imagecraft for example).
These are compiler specific MACROS and defined in compiler code.For example \_\_ICC is for IAR and \_\_GNU is for GNU compilers.There are some code given in BSP part for STM platform which have dependency on compilers.
58,760,689
I'm trying to upgrade AngularJS version from 1.3 to 1.7 in my project. As a part of the upgradation I have upgraded the existing libraries to the respective compatible versions for AngularJS 1.7. However, I'm getting the below error in the console from the angular.js file. Any idea where I might be going wrong? > > angular.js:26037 Uncaught Error: [$injector:unpr] <http://errors.angularjs.org/1.7.8/$injector/unpr?p0=%24modalProvider%20%3C-%20%24modal%20%3C-%20ifesModal%20%3C-%20platform.systemInformationWarningsService> > > > > ``` > at angular.js:26037 > at angular.js:26037 > at Object.d [as get] (angular.js:26037) > at angular.js:26037 > at d (angular.js:26037) > at e (angular.js:26037) > at Object.invoke (angular.js:26037) > at Object.$get (angular.js:26037) > at Object.invoke (angular.js:26037) > at angular.js:26037 > > ``` > > `platform.systemInformationWarningsService` is a file in my application which is defined as: ``` (function () { 'use strict'; angular .module('platform') .service('platform.systemInformationWarningsService', systemInformationWarningsService); systemInformationWarningsService.$inject = ['$rootScope', '$interval', 'ifesModal', 'api', 'platform.ifesSecurity']; function systemInformationWarningsService($rootScope, $interval, ifesModal, api, ifesSecurity) { var warningsService = getWarningsService(); var translations = Ifes.Assets.WebUI.Areas.Platform.Views.SystemInformation.SystemInformation(); var service = { init: init, subscribe: undefined, unsubscribe: undefined }; function init() { ifesSecurity.hasFunctionPermission('Core.SystemInformation.View').then(startScheduler); function startScheduler() { $interval(checkWarnings, 300000); } } function checkWarnings() { warningsService.getWarnings().$promise.then(success); function success(result) { if (result === undefined) { return; } var text = ""; var previousWarnings = JSON.parse(localStorage.getItem("previousWarnings")); angular.forEach(result, function (warning) { var found = (previousWarnings !== null && previousWarnings.some(function(id) { return id === warning.Id; })); if (!found) { if (previousWarnings === null) { previousWarnings = []; } previousWarnings.push(warning.Id); if (text !== "") { text += "\r\n\r\n"; } text += warning.Title + ":\r\n" + warning.Text; } }); if (text !== "") { showWarning(text); } localStorage.setItem("previousWarnings", JSON.stringify(previousWarnings)); } } function showWarning(text) { var modalOptions = { scope: $rootScope }; $rootScope.alertHeader = translations.SystemInformationLabel; $rootScope.alertMessage = text; $rootScope.alertType = "warning"; ifesModal.alert.open(modalOptions); } function getWarningsService() { return api('User/SystemInformation/:id', { id: '@Id' }, { getWarnings: { method: 'GET', url: 'User/SystemInformation/Warnings/Current', isArray: true } }); } return service; } })(); ``` I read here <https://code.angularjs.org/1.7.8/docs/error/$injector/unpr?p0=$modalProvider%20%3C-%20$modal%20%3C-%20ifesModal%20%3C-%20platform.systemInformationWarningsService%20at%20angular.js:26037> that the dependency might not be properly defined but I don't think that this is the issue here.
2019/11/08
[ "https://Stackoverflow.com/questions/58760689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10204642/" ]
If you are using the latest version of AngularUI bootstrap, the code needs to inject `$uibModal` instead of `$modal`, as all bootstrap directives and services names are now prepended with the `$uib` prefix. Same thing will happen with the `$modalInstance` dependency, which needs to be changed to `$uibModalInstance`. For more information, see * [Angular Error - ReferenceError: $modal is not defined](https://stackoverflow.com/questions/36071978/angular-error-referenceerror-modal-is-not-defined/36071996#36071996)
Maybe here you have problem ``` systemInformationWarningsService.$inject = ['$rootScope', '$interval', 'ifesModal', 'api', 'platform.ifesSecurity']; function systemInformationWarningsService($rootScope, $interval, ifesModal, api, ifesSecurity) { ``` You have add `platform.ifesSecurity` in `$inject` and `ifesSecurity` in controller
26,111,982
is theres a workaround or any other ways to make this work on Sass 3.4 + ```css @mixin icon ($name, $code) { .#{$name}::before { content: str-slice("\x",1,1) + $code;} } @include icon('test', 4556); ``` Code should output > > .test::before { content: "\4556"; } > > > But on 3.4+ the `\` slash is getting removed and outputted as > > .test::before { content: "x4556"; } > > > Thanks
2014/09/30
[ "https://Stackoverflow.com/questions/26111982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3507442/" ]
You stumbled across a [currently-debated issue with escape characters in Sass](https://github.com/sass/sass/issues/659). It seems that, currently, Sass will either add too many characters, or winds up putting the unicode character into the output css. ### UPDATE: ``` @mixin icon ($name, $code) { $withslash: "\"\\#{$code}\""; .#{$name}:before { content: unquote($withslash); } } @include icon('test', '4556'); ``` outputs ``` .test:before { content: "\4556"; } ``` <http://sassmeister.com/gist/04f5be11c5a6b26b8ff9> Obviously the drawback to this approach is that it relies on doing weird things with an escape character and tricking Sass into unquoting a possibly malformed string.
Alternatively, you can use a helper function to delete whitespace from a string: ``` @function nospaces($str) { @while (str-index($str, ' ') != null) { $index: str-index($str, ' '); $str: "#{str-slice($str, 0, $index - 1)}#{str-slice($str, $index + 1)}"; } @return $str; } ``` Then the function would look like this: ``` @mixin icon ($name, $code) { .#{$name}:before { content: nospaces("\ #{$code}"); } } @include icon('test', '4556'); ``` Or without quotes: ``` @mixin icon ($name, $code) { .#{$name}:before { content: nospaces(\ #{$code}); } } @include icon('test', '4556'); ```
11,315,504
I'm using Sphinx for code documentation and use several languages within the code, I would like to setup highlighting for all of that code. Sphinx briefly mentions a few of the languages it supports ([on this page](http://sphinx.pocoo.org/markup/code.html)), and then mentions that it uses [Pygments](http://pygments.org/) for lexical analysis and highlighting. Sifting through the documentation for both Sphinx and Pygments yielded me no clue on how to do something like highlight objective-c code. Pygments does mention the list of languages it supports, [here](http://pygments.org/languages/), however that doesn't tell me the exact syntax that I must use within Sphinx (.rst files) to tell the code block to highlight for a specific language. For example, to highlight c++ code you simply use this before your code block: `.. highlight:: c++` However after trying these I cannot seem to highlight Objective-C code: ``` .. highlight:: Objective-C .. highlight:: objective-c .. highlight:: Obj-C .. highlight:: obj-c ``` Can anyone supply me with the list of languages (as you would refer to them within documentation)?
2012/07/03
[ "https://Stackoverflow.com/questions/11315504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/967504/" ]
As far as I can tell, the list is in the file `pygments/lexers/_mapping.py`, in the (autogenerated) dictionary `LEXERS`. In my copy, I see a line ``` 'ObjectiveCLexer': ('pygments.lexers.compiled', 'Objective-C', ('objective-c', 'objectivec', 'obj-c', 'objc'), ('*.m',), ('text/x-objective-c',)), ``` I think this should mean that any of the tags `objective-c`, `objectivec`, `obj-c`, or `objc` should work, as long as your version of Pygments is up-to-date. They work for me.
If you install pygments module. You can use this script to get a list of supported highlighters: ``` from pygments.lexers import get_all_lexers lexers = get_all_lexers() for lexer in lexers: print "-\t" + lexer[0] + "\n" print "\t-\t" + "\n\t-\t".join(lexer[1]) + "\n" ``` First indent level of output will be general name and second level will be short names of highlighters that you can use. **Example Output** * Debian Sourcelist + sourceslist + sources.list * Delphi + delphi + pas + pascal + objectpascal [Source](http://haisum.github.io/2014/11/07/jekyll-pygments-supported-highlighters/)
11,315,504
I'm using Sphinx for code documentation and use several languages within the code, I would like to setup highlighting for all of that code. Sphinx briefly mentions a few of the languages it supports ([on this page](http://sphinx.pocoo.org/markup/code.html)), and then mentions that it uses [Pygments](http://pygments.org/) for lexical analysis and highlighting. Sifting through the documentation for both Sphinx and Pygments yielded me no clue on how to do something like highlight objective-c code. Pygments does mention the list of languages it supports, [here](http://pygments.org/languages/), however that doesn't tell me the exact syntax that I must use within Sphinx (.rst files) to tell the code block to highlight for a specific language. For example, to highlight c++ code you simply use this before your code block: `.. highlight:: c++` However after trying these I cannot seem to highlight Objective-C code: ``` .. highlight:: Objective-C .. highlight:: objective-c .. highlight:: Obj-C .. highlight:: obj-c ``` Can anyone supply me with the list of languages (as you would refer to them within documentation)?
2012/07/03
[ "https://Stackoverflow.com/questions/11315504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/967504/" ]
`pygmentize -L lexers` lists all supported lexers. * <http://pygments.org/languages/> * <http://pygments.org/docs/lexers/> * <http://pygments.org/docs/cmdline/#getting-help>
If you install pygments module. You can use this script to get a list of supported highlighters: ``` from pygments.lexers import get_all_lexers lexers = get_all_lexers() for lexer in lexers: print "-\t" + lexer[0] + "\n" print "\t-\t" + "\n\t-\t".join(lexer[1]) + "\n" ``` First indent level of output will be general name and second level will be short names of highlighters that you can use. **Example Output** * Debian Sourcelist + sourceslist + sources.list * Delphi + delphi + pas + pascal + objectpascal [Source](http://haisum.github.io/2014/11/07/jekyll-pygments-supported-highlighters/)
40,496,643
I would like to know if there is any way to embed native java libraries in maven as dependency or something like that but from the internet not from local. Like java.util or all that jdk provides. Example of "pom.xml": ``` <dependency> <groupId>jdk</groupId> <artifactId>java.util.arraylist</artifactId> <version>1.1.3</version> </dependency> ```
2016/11/08
[ "https://Stackoverflow.com/questions/40496643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7133814/" ]
All of the standard, built-in Java classes are available to your build already - you don't need to add them as dependencies. If you have a jar (possibly home-built) that you need to use in your maven build as a dependency, you can add it to your local maven repository as an artefact and have your pom.xml depend upon it as normal. ``` mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \ -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging> ``` For more details, see this [SO answer](https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-in-maven-project), or this [Maven reference](https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html) for details on how to perform this.
Think of Maven as an infrastructure that handles dependencies. ``` mvn install ``` Write to local Maven directory on your machine. ``` mvn deploy ``` Write to an external repository server, e.g. Nexus, so it can be shared with others. (Your local Maven must be configured to recognize this Nexus.) See <https://maven.apache.org/run.html>
1,511,716
I have the following linq query: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where d.GetFiles().Count() > 10 where d.GetFiles().Count() < 100 select d ); ``` However, as you can see above, I am calling d.GetFiles().Count() twice, is this where the concept of the => operator comes in handy. Using the syntax from jdehaan, why can't I do it directly like this: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where(x => x.GetFiles().Count() > 10) && (x.GetFiles().Count() < 100)) select d ); ``` I know the above is stupid because I could just do my original query with d.GetFiles().Count(), but I am curious on the difference between using Where as opposed to the keyword where.
2009/10/02
[ "https://Stackoverflow.com/questions/1511716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
Use `let` to assign within the query, like this ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() let f = d.GetFiles().Count() where f > 10 where f < 100 select d ); ``` As Reed Copsey points out you can merge the two `where` clauses using `&&`. Also, since `GetFiles` returns an array you can use the `Length` property instead of the `Count` method. ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() let f = d.GetFiles().Length where f > 10 && f < 100 select d ); ```
Lambda expressions will not help here, but the let keyword may... ``` var files = from d in new DirectoryInfo(@"c:\program files").GetDirectories() let c = d.GetFiles().Count() where c > 10 && c < 100 select d; ```
1,511,716
I have the following linq query: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where d.GetFiles().Count() > 10 where d.GetFiles().Count() < 100 select d ); ``` However, as you can see above, I am calling d.GetFiles().Count() twice, is this where the concept of the => operator comes in handy. Using the syntax from jdehaan, why can't I do it directly like this: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where(x => x.GetFiles().Count() > 10) && (x.GetFiles().Count() < 100)) select d ); ``` I know the above is stupid because I could just do my original query with d.GetFiles().Count(), but I am curious on the difference between using Where as opposed to the keyword where.
2009/10/02
[ "https://Stackoverflow.com/questions/1511716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
Use `let` to assign within the query, like this ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() let f = d.GetFiles().Count() where f > 10 where f < 100 select d ); ``` As Reed Copsey points out you can merge the two `where` clauses using `&&`. Also, since `GetFiles` returns an array you can use the `Length` property instead of the `Count` method. ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() let f = d.GetFiles().Length where f > 10 && f < 100 select d ); ```
With lambda expressions it would look like this: ``` var files = new DirectoryInfo(@"c:\program files").GetDirectories(). Where(x => (x.GetFiles().Count() > 10) && (x.GetFiles().Count() < 100)); ``` You also call the `GetFiles()` twice. The lambda expressions don't help solving it. EDIT: Beside being ugly, it is really inefficient, prefer the **`let`** solution presented in the other answers, this answer was meant to show what it looks like written using lambda expressions. **Have a look at "Paul Williams"'s answer, he showed how to reach the same thing with lambda expressions in a better and nicer way that is semantically equivalent to the `let` solution.**
1,511,716
I have the following linq query: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where d.GetFiles().Count() > 10 where d.GetFiles().Count() < 100 select d ); ``` However, as you can see above, I am calling d.GetFiles().Count() twice, is this where the concept of the => operator comes in handy. Using the syntax from jdehaan, why can't I do it directly like this: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where(x => x.GetFiles().Count() > 10) && (x.GetFiles().Count() < 100)) select d ); ``` I know the above is stupid because I could just do my original query with d.GetFiles().Count(), but I am curious on the difference between using Where as opposed to the keyword where.
2009/10/02
[ "https://Stackoverflow.com/questions/1511716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
Use `let` to assign within the query, like this ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() let f = d.GetFiles().Count() where f > 10 where f < 100 select d ); ``` As Reed Copsey points out you can merge the two `where` clauses using `&&`. Also, since `GetFiles` returns an array you can use the `Length` property instead of the `Count` method. ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() let f = d.GetFiles().Length where f > 10 && f < 100 select d ); ```
The answer involving the "let" keyword is probably what you will want to use. I am providing this alternate answer to show you how "=>" could be used to accomplish the same thing. First, make sure you are `using System.Linq;` ``` var files = new DirectoryInfo(@"c:\program files").GetDirectories().Where(d => { int c = d.GetFiles().Count(); return c > 10 && c < 100; }); ``` As you can see, lambda expressions aren't a "better" solution in this case, just different.
1,511,716
I have the following linq query: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where d.GetFiles().Count() > 10 where d.GetFiles().Count() < 100 select d ); ``` However, as you can see above, I am calling d.GetFiles().Count() twice, is this where the concept of the => operator comes in handy. Using the syntax from jdehaan, why can't I do it directly like this: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where(x => x.GetFiles().Count() > 10) && (x.GetFiles().Count() < 100)) select d ); ``` I know the above is stupid because I could just do my original query with d.GetFiles().Count(), but I am curious on the difference between using Where as opposed to the keyword where.
2009/10/02
[ "https://Stackoverflow.com/questions/1511716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
Lambda expressions will not help here, but the let keyword may... ``` var files = from d in new DirectoryInfo(@"c:\program files").GetDirectories() let c = d.GetFiles().Count() where c > 10 && c < 100 select d; ```
With lambda expressions it would look like this: ``` var files = new DirectoryInfo(@"c:\program files").GetDirectories(). Where(x => (x.GetFiles().Count() > 10) && (x.GetFiles().Count() < 100)); ``` You also call the `GetFiles()` twice. The lambda expressions don't help solving it. EDIT: Beside being ugly, it is really inefficient, prefer the **`let`** solution presented in the other answers, this answer was meant to show what it looks like written using lambda expressions. **Have a look at "Paul Williams"'s answer, he showed how to reach the same thing with lambda expressions in a better and nicer way that is semantically equivalent to the `let` solution.**
1,511,716
I have the following linq query: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where d.GetFiles().Count() > 10 where d.GetFiles().Count() < 100 select d ); ``` However, as you can see above, I am calling d.GetFiles().Count() twice, is this where the concept of the => operator comes in handy. Using the syntax from jdehaan, why can't I do it directly like this: ``` var files = (from d in new DirectoryInfo(@"c:\program files").GetDirectories() where(x => x.GetFiles().Count() > 10) && (x.GetFiles().Count() < 100)) select d ); ``` I know the above is stupid because I could just do my original query with d.GetFiles().Count(), but I am curious on the difference between using Where as opposed to the keyword where.
2009/10/02
[ "https://Stackoverflow.com/questions/1511716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
Lambda expressions will not help here, but the let keyword may... ``` var files = from d in new DirectoryInfo(@"c:\program files").GetDirectories() let c = d.GetFiles().Count() where c > 10 && c < 100 select d; ```
The answer involving the "let" keyword is probably what you will want to use. I am providing this alternate answer to show you how "=>" could be used to accomplish the same thing. First, make sure you are `using System.Linq;` ``` var files = new DirectoryInfo(@"c:\program files").GetDirectories().Where(d => { int c = d.GetFiles().Count(); return c > 10 && c < 100; }); ``` As you can see, lambda expressions aren't a "better" solution in this case, just different.
41,624,554
Heroku and my production environment are not loading the jQuery JavaScript Library leading to the following "Failed to load resource: the server responded with a status of 404 (Not Found)". All the research I have done point to a asset pipeline issues, but i have confirmed the assets are being precompiled localy and delivered to Heroku. I have performed / tested the following and still having issues. ---------------------------------------------------------------- 1. arranged my asset order in application.js 2. changed production.rb: config.assets.compile = true , from default config.serve\_static\_files = ENV['RAILS\_SERVE\_STATIC\_FILES'].present? 3. ran the command: rake assets:precompile then git push heroku master 4. ran the command: RAILS\_ENV=production bundle exec rake assets:precompile 5. ran the command: heroku run rake assets:precompile --app appName 6. added the gem 'rails\_serve\_static\_assets' as mentioned in heroku documentation 7. precompiled production assets and pushhed and compiled on Heroku. RAILS\_ENV=production bundle exec rake assets:precompile 8. Debugged in Heroku: confirmed precompiled assets loaded to public/assets $ heroku run bash $ ls public/assets 9. Still getting the 404 error in my console "Failed to load resource: the server responded with a status of 404 (Not Found)" specifically naming the Jquery javascript library. Hit a road block on what I am doing wrong. Any help is appreciated. My problem seems similar to this issue with no answer although i am getting a 404 error. ---------------------------------------------------------------------------------------- [Jquery not working in Production & Heroku but works perfectly well in development](https://stackoverflow.com/questions/36887988/jquery-not-working-in-production-heroku-but-works-perfectly-well-in-developmen) code ==== application.js ``` //= require jquery //= require jquery_ujs //= require turbolinks //= require map_theme/vendor/modernizr.custom //= require map_theme/vendor/matchMedia //= require map_theme/vendor/bootstrap //= require map_theme/vendor/jquery.storageapi //= require map_theme/vendor/jquery.easing //= require map_theme/vendor/animo //= require map_theme/vendor/jquery.slimscroll.min //= require map_theme/vendor/screenfull //= require map_theme/vendor/jquery.localize //= require map_theme/demo/demo-rtl //= require map_theme/vendor/index //= require map_theme/vendor/jquery.classyloader.min //= require map_theme/vendor/moment-with-locales.min //= require map_theme/app ``` production.rb ``` config.cache_classes = true config.eager_load = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.serve_static_files = true config.assets.js_compressor = :uglifier config.assets.compile = false config.assets.digest = true config.log_level = :debug config.i18n.fallbacks = true config.active_support.deprecation = :notify config.log_formatter = ::Logger::Formatter.new config.active_record.dump_schema_after_migration = false config.middleware.use('PartyFoul::Middleware') config.secret_key_base = ENV["SECRET_KEY_BASE"] ``` gemfile ``` gem 'rails', '4.2.5.1' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc gem "figaro" gem 'geocoder' gem 'seed_dump' gem 'gmaps4rails' gem 'devise' gem 'puma' gem 'activeadmin', github: 'activeadmin' gem 'filterrific' gem 'sprockets-rails', '2.3.3' gem 'by_star', git: "git://github.com/radar/by_star" gem 'colorize' gem 'carrierwave' gem 'mandrill-api' gem 'active_model_serializers', '~> 0.10.0' gem 'moving_average' gem 'party_foul' gem 'rails_serve_static_assets' group :production do gem 'pg' gem 'rails_12factor' end group :development, :test do gem 'byebug' gem 'sqlite3' end ``` view ``` <script> var map; var infoWindow; // Map Display options function initMap() { map = new google.maps.Map(document.getElementById('map'), { zoom: 9, center: {lat: 42.05, lng: -70.25}, mapTypeId: google.maps.MapTypeId.SATELLITE, scrollwheel: false, scaleControl: false, }); var polygons = []; $.ajax({ url: '/species_filter', type: "get", //send it through get method data:{target_species:$('#species_select').val()}, success: function(response) { console.log(response); for (var i = 0; i < response.length ; i++) { polygons.push(new google.maps.Polygon({ paths: response[i].cfile, strokeColor: '#F7F8FF', strokeOpacity: 0.8, strokeWeight: .35, fillColor: response[i].color, fillOpacity: 0.45, editable: false, map: map, loc: response[i].location, rep: response[i].reports, mavg: response[i].movingavg })); polygons[polygons.length-1].setMap(map); var p = polygons[i]; google.maps.event.addListener(p, 'click', function (event) { console.log(this); // console.log(location_reports); var contentString = '<table><thead><tr><th>Date</th><th>Target Species</th><th>Vessel Name</th><th>Primary Method</th><th>Catch Total</th><th>Trip Summary</th></tr></thead><tbody><b>' + this.loc.short_name +'</b> <br>' + this.loc.long_name +'<br> <br>'; for(var j=0;j<this.rep.length; j++){ contentString += '<tr><td>' +this.rep[j].rep.date + '</td> <td>' +this.rep[j].rep.target_species + '</td><td>' +this.rep[j].vessel_name + '</td><td>' +this.rep[j].rep.primary_method + '</td><td>' +this.rep[j].rep.catch_total + '</td><td>' +this.rep[j].rep.trip_summary + '</td></tr>'; }; contentString +='</tbody></table>'; // Replace the info window's content and position. infoWindow = new google.maps.InfoWindow; infoWindow.setContent(contentString); infoWindow.setPosition(event.latLng); google.maps.event.addListener(infoWindow, 'domready', function() { var iwOuter = $('.gm-style-iw'); var iwBackground = iwOuter.prev(); // Remove the background shadow DIV iwBackground.children(':nth-child(2)').css({'display' : 'none'}); // Remove the white background DIV iwBackground.children(':nth-child(4)').css({'display' : 'none'}); iwOuter.parent().parent().css({left: '115px'}); iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 76px !important;'}); iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 155px !important;'}); iwBackground.children(':nth-child(3)').find('div').children().css({'box-shadow': 'rgba(72, 181, 233, 0.6) 0px 1px 6px', 'z-index' : '1'}); var iwCloseBtn = iwOuter.next(); // Apply the desired effect to the close button iwCloseBtn.css({ opacity: '1', // by default the close button has an opacity of 0.7 right: '44px', top: '8px', // button repositioning // border: '7px solid #48b5e9', // increasing button border and new color 'border-radius': '13px', // circular effect 'box-shadow': '0 0 5px #3990B9' // 3D effect to highlight the button }); iwCloseBtn.mouseout(function(){ $(this).css({opacity: '1'}); }); }); infoWindow.open(map); }); google.maps.event.addListener(p, 'mouseover',function (event){ $("#locdetails").css("display", "block"); $( "#locdetails" ).append( "<div class='hoverrow'> <div class='hoverclass'>Location</div> <div class='hoverclass'>Average Catch Per Trip</div> <div class='hoverclass'>Reports posted past 7 days</div> </div> <div class='hoverrow'><div class='hoverclass'>"+ this.loc.short_name +"</div>" +"<div class='hoverclass'>" + this.mavg + "</div>"+"<div class='hoverclass'>" + this.rep.length + "</div></div>" ); map.data.revertStyle(); this.setOptions({ strokeColor: '#F7F8FF', strokeWeight: 3 , fillOpacity: 0.75 }); }); google.maps.event.addListener(p, 'mouseout',function (event){ $("#locdetails").css("display", "none"); $( "#locdetails" ).empty(); map.data.revertStyle(); this.setOptions({ strokeColor: '#F7F8FF', strokeOpacity: 0.8, strokeWeight: .35, fillOpacity: 0.5, }); }); }; }, error: function(xhr) { } }); } $('#species_select').change(function(){ initMap(); infoWindow.close(); }); </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=""&callback=initMap"> </script> ``` logs ``` 2017-01-13T15:34:39.920225+00:00 app[web.1]: Report Load (1.3ms) SELECT DISTINCT(tide) FROM "reports" WHERE "reports"."user_id" = $1 [["user_id", 3]] 2017-01-13T15:34:39.944172+00:00 app[web.1]: Location Load (1.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 15]] 2017-01-13T15:34:39.945545+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]] 2017-01-13T15:34:39.946432+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 15]] 2017-01-13T15:34:39.938746+00:00 app[web.1]: Location Load (2.7ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]] 2017-01-13T15:34:39.949118+00:00 app[web.1]: Location Load (0.8ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 7]] 2017-01-13T15:34:39.947292+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]] 2017-01-13T15:34:39.954280+00:00 app[web.1]: Rendered layouts/_navbar.html.erb (2.0ms) 2017-01-13T15:34:39.950113+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 7]] 2017-01-13T15:34:39.950936+00:00 app[web.1]: Rendered reports/index.html.erb within layouts/application (72.2ms) 2017-01-13T15:34:39.954731+00:00 app[web.1]: Completed 200 OK in 98ms (Views: 63.7ms | ActiveRecord: 20.2ms) 2017-01-13T15:34:40.100226+00:00 heroku[router]: at=info method=GET path="/assets/lighthouse2-ad6fdcbcefd4cb9d7254996e97d636d1010a916771ce0142bd8d2c0769f2b70b.jpg" host=currents.herokuapp.com request_id=887c16fd-2968-4772-8a3f-8ab815a033df fwd="199.253.243.3" dyno=web.1 connect=0ms service=1ms status=304 bytes=48 2017-01-13T15:34:41.085541+00:00 heroku[router]: at=info method=GET path="/maps" host=currents.herokuapp.com request_id=9b3b88a2-dd64-4fe0-b14b-c9393f4a1db3 fwd="199.253.243.3" dyno=web.1 connect=1ms service=25ms status=200 bytes=13348 2017-01-13T15:34:41.031038+00:00 app[web.1]: Started GET "/maps" for 199.253.243.3 at 2017-01-13 15:34:41 +0000 2017-01-13T15:34:41.034594+00:00 app[web.1]: Processing by MapsController#index as HTML 2017-01-13T15:34:41.036794+00:00 app[web.1]: User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]] 2017-01-13T15:34:41.048084+00:00 app[web.1]: Report Load (1.0ms) SELECT "reports".* FROM "reports" 2017-01-13T15:34:41.049807+00:00 app[web.1]: Rendered maps/index.html.erb within layouts/application (4.9ms) 2017-01-13T15:34:41.051861+00:00 app[web.1]: Rendered layouts/_navbar.html.erb (1.1ms) 2017-01-13T15:34:41.052294+00:00 app[web.1]: Completed 200 OK in 18ms (Views: 12.8ms | ActiveRecord: 1.8ms) 2017-01-13T15:34:41.220850+00:00 app[web.1]: Started GET "/species_filter?target_species=Any" for 199.253.243.3 at 2017-01-13 15:34:41 +0000 2017-01-13T15:34:41.224007+00:00 app[web.1]: Processing by MapsController#filter_by_species as */* 2017-01-13T15:34:41.224055+00:00 app[web.1]: Parameters: {"target_species"=>"Any"} 2017-01-13T15:34:41.239336+00:00 app[web.1]: User Load (13.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]] 2017-01-13T15:34:41.244027+00:00 app[web.1]: Location Load (1.2ms) SELECT "locations".* FROM "locations" 2017-01-13T15:34:41.255948+00:00 app[web.1]: (1.0ms) SELECT AVG("reports"."catch_keepers") AS average_catch_keepers, date AS date FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-06') AND (date < '2017-01-13') GROUP BY "reports"."date" ORDER BY "reports"."date" DESC [["location_id", 1]] 2017-01-13T15:34:41.258770+00:00 app[web.1]: (0.8ms) SELECT AVG("reports"."catch_keepers") AS average_catch_keepers, date AS date FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-05') AND (date < '2017-01-12') GROUP BY "reports"."date" [["location_id", 1]] 2017-01-13T15:34:41.258905+00:00 app[web.1]: ----moving average 2017-01-13T15:34:41.258927+00:00 app[web.1]: 0.0 2017-01-13T15:34:41.258951+00:00 app[web.1]: 0.0 2017-01-13T15:34:41.258931+00:00 app[web.1]: ----previous moving average 2017-01-13T15:34:41.258969+00:00 app[web.1]: ---movingavg 2017-01-13T15:34:41.258999+00:00 app[web.1]: {:movingavg=>0.0, :color=>"#4562A8"} 2017-01-13T15:34:41.261129+00:00 app[web.1]: Report Load (0.8ms) SELECT "reports".* FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-06') AND (date < '2017-01-13') ORDER BY "reports"."date" DESC [["location_id", 1]] 2017-01-13T15:34:41.266026+00:00 app[web.1]: Completed 500 Internal Server Error in 42ms (ActiveRecord: 17.9ms) 2017-01-13T15:34:41.670858+00:00 heroku[router]: at=info method=GET path="/species_filter?target_species=Any" host=currents.herokuapp.com request_id=51400dbb-d5cb-4eef-a0fd-162e96339a1b fwd="199.253.243.3" dyno=web.1 connect=0ms service=424ms status=500 bytes=1669 2017-01-13T15:34:41.639677+00:00 app[web.1]: 2017-01-13T15:34:41.639685+00:00 app[web.1]: NoMethodError (undefined method `each' for #<ActionDispatch::Request::Session:0x007f05c5a61ae0>): 2017-01-13T15:34:41.639686+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/http/parameter_filter.rb:51:in `call' 2017-01-13T15:34:41.639686+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/http/parameter_filter.rb:11:in `filter' 2017-01-13T15:34:41.639687+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/rails.rb:15:in `session' 2017-01-13T15:34:41.639687+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/rack.rb:8:in `comment_options' 2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:31:in `run' 2017-01-13T15:34:41.639688+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/base.rb:46:in `comment' 2017-01-13T15:34:41.639688+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:67:in `update_issue' 2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/processors/sync.rb:9:in `handle' 2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:10:in `handle' 2017-01-13T15:34:41.639690+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/middleware.rb:11:in `rescue in call' 2017-01-13T15:34:41.639691+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/middleware.rb:8:in `call' 2017-01-13T15:34:41.639691+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:35:in `block in call' 2017-01-13T15:34:41.639692+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `catch' 2017-01-13T15:34:41.639692+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `call' 2017-01-13T15:34:41.639693+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call' 2017-01-13T15:34:41.639693+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in `call' 2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call' 2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call' 2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/flash.rb:260:in `call' 2017-01-13T15:34:41.639695+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context' 2017-01-13T15:34:41.639695+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call' 2017-01-13T15:34:41.639696+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/cookies.rb:560:in `call' 2017-01-13T15:34:41.639696+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/query_cache.rb:36:in `call' 2017-01-13T15:34:41.639697+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call' 2017-01-13T15:34:41.639697+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' 2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:81:in `run_callbacks' 2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__' 2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks' 2017-01-13T15:34:41.639699+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 2017-01-13T15:34:41.639699+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call' 2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' 2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:38:in `call_app' 2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:20:in `block in call' 2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `block in tagged' 2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:26:in `tagged' 2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `tagged' 2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:20:in `call' 2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call' 2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/engine.rb:518:in `call' 2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/request_id.rb:21:in `call' 2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call' 2017-01-13T15:34:41.639708+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call' 2017-01-13T15:34:41.639708+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/static.rb:116:in `call' 2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/application.rb:165:in `call' 2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call' 2017-01-13T15:34:41.639710+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/configuration.rb:224:in `call' 2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:271:in `block in run' 2017-01-13T15:34:41.639710+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:569:in `handle_request' 2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:406:in `process_client' 2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `call' 2017-01-13T15:34:41.639712+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `block in spawn_thread' 2017-01-13T15:34:41.639712+00:00 app[web.1]: 2017-01-13T15:34:41.639712+00:00 app[web.1]: 2017-01-13T16:09:59.608738+00:00 heroku[web.1]: Idling 2017-01-13T16:09:59.609122+00:00 heroku[web.1]: State changed from up to down 2017-01-13T16:10:00.308786+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2017-01-13T16:10:00.324473+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish 2017-01-13T16:10:00.325921+00:00 app[web.1]: === puma shutdown: 2017-01-13 16:10:00 +0000 === 2017-01-13T16:10:00.325951+00:00 app[web.1]: - Goodbye! 2017-01-13T16:10:00.325992+00:00 app[web.1]: Exiting 2017-01-13T16:10:00.573756+00:00 heroku[web.1]: Process exited with status 0 ```
2017/01/12
[ "https://Stackoverflow.com/questions/41624554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6317543/" ]
It's <http://www.embeddedjs.com/> thanks to [jade template tag bracket percentage definition](https://stackoverflow.com/questions/28256371/jade-template-tag-bracket-percentage-definition) I originally missed this thread as stackoverflow doesn't recognize <% as a search term. Located the thread via searx.
Might be Twig, it's a templating engine for PHP. It supports the <% %> syntax and has the number\_format() function <http://twig.sensiolabs.org/>
41,624,554
Heroku and my production environment are not loading the jQuery JavaScript Library leading to the following "Failed to load resource: the server responded with a status of 404 (Not Found)". All the research I have done point to a asset pipeline issues, but i have confirmed the assets are being precompiled localy and delivered to Heroku. I have performed / tested the following and still having issues. ---------------------------------------------------------------- 1. arranged my asset order in application.js 2. changed production.rb: config.assets.compile = true , from default config.serve\_static\_files = ENV['RAILS\_SERVE\_STATIC\_FILES'].present? 3. ran the command: rake assets:precompile then git push heroku master 4. ran the command: RAILS\_ENV=production bundle exec rake assets:precompile 5. ran the command: heroku run rake assets:precompile --app appName 6. added the gem 'rails\_serve\_static\_assets' as mentioned in heroku documentation 7. precompiled production assets and pushhed and compiled on Heroku. RAILS\_ENV=production bundle exec rake assets:precompile 8. Debugged in Heroku: confirmed precompiled assets loaded to public/assets $ heroku run bash $ ls public/assets 9. Still getting the 404 error in my console "Failed to load resource: the server responded with a status of 404 (Not Found)" specifically naming the Jquery javascript library. Hit a road block on what I am doing wrong. Any help is appreciated. My problem seems similar to this issue with no answer although i am getting a 404 error. ---------------------------------------------------------------------------------------- [Jquery not working in Production & Heroku but works perfectly well in development](https://stackoverflow.com/questions/36887988/jquery-not-working-in-production-heroku-but-works-perfectly-well-in-developmen) code ==== application.js ``` //= require jquery //= require jquery_ujs //= require turbolinks //= require map_theme/vendor/modernizr.custom //= require map_theme/vendor/matchMedia //= require map_theme/vendor/bootstrap //= require map_theme/vendor/jquery.storageapi //= require map_theme/vendor/jquery.easing //= require map_theme/vendor/animo //= require map_theme/vendor/jquery.slimscroll.min //= require map_theme/vendor/screenfull //= require map_theme/vendor/jquery.localize //= require map_theme/demo/demo-rtl //= require map_theme/vendor/index //= require map_theme/vendor/jquery.classyloader.min //= require map_theme/vendor/moment-with-locales.min //= require map_theme/app ``` production.rb ``` config.cache_classes = true config.eager_load = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.serve_static_files = true config.assets.js_compressor = :uglifier config.assets.compile = false config.assets.digest = true config.log_level = :debug config.i18n.fallbacks = true config.active_support.deprecation = :notify config.log_formatter = ::Logger::Formatter.new config.active_record.dump_schema_after_migration = false config.middleware.use('PartyFoul::Middleware') config.secret_key_base = ENV["SECRET_KEY_BASE"] ``` gemfile ``` gem 'rails', '4.2.5.1' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc gem "figaro" gem 'geocoder' gem 'seed_dump' gem 'gmaps4rails' gem 'devise' gem 'puma' gem 'activeadmin', github: 'activeadmin' gem 'filterrific' gem 'sprockets-rails', '2.3.3' gem 'by_star', git: "git://github.com/radar/by_star" gem 'colorize' gem 'carrierwave' gem 'mandrill-api' gem 'active_model_serializers', '~> 0.10.0' gem 'moving_average' gem 'party_foul' gem 'rails_serve_static_assets' group :production do gem 'pg' gem 'rails_12factor' end group :development, :test do gem 'byebug' gem 'sqlite3' end ``` view ``` <script> var map; var infoWindow; // Map Display options function initMap() { map = new google.maps.Map(document.getElementById('map'), { zoom: 9, center: {lat: 42.05, lng: -70.25}, mapTypeId: google.maps.MapTypeId.SATELLITE, scrollwheel: false, scaleControl: false, }); var polygons = []; $.ajax({ url: '/species_filter', type: "get", //send it through get method data:{target_species:$('#species_select').val()}, success: function(response) { console.log(response); for (var i = 0; i < response.length ; i++) { polygons.push(new google.maps.Polygon({ paths: response[i].cfile, strokeColor: '#F7F8FF', strokeOpacity: 0.8, strokeWeight: .35, fillColor: response[i].color, fillOpacity: 0.45, editable: false, map: map, loc: response[i].location, rep: response[i].reports, mavg: response[i].movingavg })); polygons[polygons.length-1].setMap(map); var p = polygons[i]; google.maps.event.addListener(p, 'click', function (event) { console.log(this); // console.log(location_reports); var contentString = '<table><thead><tr><th>Date</th><th>Target Species</th><th>Vessel Name</th><th>Primary Method</th><th>Catch Total</th><th>Trip Summary</th></tr></thead><tbody><b>' + this.loc.short_name +'</b> <br>' + this.loc.long_name +'<br> <br>'; for(var j=0;j<this.rep.length; j++){ contentString += '<tr><td>' +this.rep[j].rep.date + '</td> <td>' +this.rep[j].rep.target_species + '</td><td>' +this.rep[j].vessel_name + '</td><td>' +this.rep[j].rep.primary_method + '</td><td>' +this.rep[j].rep.catch_total + '</td><td>' +this.rep[j].rep.trip_summary + '</td></tr>'; }; contentString +='</tbody></table>'; // Replace the info window's content and position. infoWindow = new google.maps.InfoWindow; infoWindow.setContent(contentString); infoWindow.setPosition(event.latLng); google.maps.event.addListener(infoWindow, 'domready', function() { var iwOuter = $('.gm-style-iw'); var iwBackground = iwOuter.prev(); // Remove the background shadow DIV iwBackground.children(':nth-child(2)').css({'display' : 'none'}); // Remove the white background DIV iwBackground.children(':nth-child(4)').css({'display' : 'none'}); iwOuter.parent().parent().css({left: '115px'}); iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 76px !important;'}); iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 155px !important;'}); iwBackground.children(':nth-child(3)').find('div').children().css({'box-shadow': 'rgba(72, 181, 233, 0.6) 0px 1px 6px', 'z-index' : '1'}); var iwCloseBtn = iwOuter.next(); // Apply the desired effect to the close button iwCloseBtn.css({ opacity: '1', // by default the close button has an opacity of 0.7 right: '44px', top: '8px', // button repositioning // border: '7px solid #48b5e9', // increasing button border and new color 'border-radius': '13px', // circular effect 'box-shadow': '0 0 5px #3990B9' // 3D effect to highlight the button }); iwCloseBtn.mouseout(function(){ $(this).css({opacity: '1'}); }); }); infoWindow.open(map); }); google.maps.event.addListener(p, 'mouseover',function (event){ $("#locdetails").css("display", "block"); $( "#locdetails" ).append( "<div class='hoverrow'> <div class='hoverclass'>Location</div> <div class='hoverclass'>Average Catch Per Trip</div> <div class='hoverclass'>Reports posted past 7 days</div> </div> <div class='hoverrow'><div class='hoverclass'>"+ this.loc.short_name +"</div>" +"<div class='hoverclass'>" + this.mavg + "</div>"+"<div class='hoverclass'>" + this.rep.length + "</div></div>" ); map.data.revertStyle(); this.setOptions({ strokeColor: '#F7F8FF', strokeWeight: 3 , fillOpacity: 0.75 }); }); google.maps.event.addListener(p, 'mouseout',function (event){ $("#locdetails").css("display", "none"); $( "#locdetails" ).empty(); map.data.revertStyle(); this.setOptions({ strokeColor: '#F7F8FF', strokeOpacity: 0.8, strokeWeight: .35, fillOpacity: 0.5, }); }); }; }, error: function(xhr) { } }); } $('#species_select').change(function(){ initMap(); infoWindow.close(); }); </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=""&callback=initMap"> </script> ``` logs ``` 2017-01-13T15:34:39.920225+00:00 app[web.1]: Report Load (1.3ms) SELECT DISTINCT(tide) FROM "reports" WHERE "reports"."user_id" = $1 [["user_id", 3]] 2017-01-13T15:34:39.944172+00:00 app[web.1]: Location Load (1.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 15]] 2017-01-13T15:34:39.945545+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]] 2017-01-13T15:34:39.946432+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 15]] 2017-01-13T15:34:39.938746+00:00 app[web.1]: Location Load (2.7ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]] 2017-01-13T15:34:39.949118+00:00 app[web.1]: Location Load (0.8ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 7]] 2017-01-13T15:34:39.947292+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]] 2017-01-13T15:34:39.954280+00:00 app[web.1]: Rendered layouts/_navbar.html.erb (2.0ms) 2017-01-13T15:34:39.950113+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 7]] 2017-01-13T15:34:39.950936+00:00 app[web.1]: Rendered reports/index.html.erb within layouts/application (72.2ms) 2017-01-13T15:34:39.954731+00:00 app[web.1]: Completed 200 OK in 98ms (Views: 63.7ms | ActiveRecord: 20.2ms) 2017-01-13T15:34:40.100226+00:00 heroku[router]: at=info method=GET path="/assets/lighthouse2-ad6fdcbcefd4cb9d7254996e97d636d1010a916771ce0142bd8d2c0769f2b70b.jpg" host=currents.herokuapp.com request_id=887c16fd-2968-4772-8a3f-8ab815a033df fwd="199.253.243.3" dyno=web.1 connect=0ms service=1ms status=304 bytes=48 2017-01-13T15:34:41.085541+00:00 heroku[router]: at=info method=GET path="/maps" host=currents.herokuapp.com request_id=9b3b88a2-dd64-4fe0-b14b-c9393f4a1db3 fwd="199.253.243.3" dyno=web.1 connect=1ms service=25ms status=200 bytes=13348 2017-01-13T15:34:41.031038+00:00 app[web.1]: Started GET "/maps" for 199.253.243.3 at 2017-01-13 15:34:41 +0000 2017-01-13T15:34:41.034594+00:00 app[web.1]: Processing by MapsController#index as HTML 2017-01-13T15:34:41.036794+00:00 app[web.1]: User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]] 2017-01-13T15:34:41.048084+00:00 app[web.1]: Report Load (1.0ms) SELECT "reports".* FROM "reports" 2017-01-13T15:34:41.049807+00:00 app[web.1]: Rendered maps/index.html.erb within layouts/application (4.9ms) 2017-01-13T15:34:41.051861+00:00 app[web.1]: Rendered layouts/_navbar.html.erb (1.1ms) 2017-01-13T15:34:41.052294+00:00 app[web.1]: Completed 200 OK in 18ms (Views: 12.8ms | ActiveRecord: 1.8ms) 2017-01-13T15:34:41.220850+00:00 app[web.1]: Started GET "/species_filter?target_species=Any" for 199.253.243.3 at 2017-01-13 15:34:41 +0000 2017-01-13T15:34:41.224007+00:00 app[web.1]: Processing by MapsController#filter_by_species as */* 2017-01-13T15:34:41.224055+00:00 app[web.1]: Parameters: {"target_species"=>"Any"} 2017-01-13T15:34:41.239336+00:00 app[web.1]: User Load (13.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]] 2017-01-13T15:34:41.244027+00:00 app[web.1]: Location Load (1.2ms) SELECT "locations".* FROM "locations" 2017-01-13T15:34:41.255948+00:00 app[web.1]: (1.0ms) SELECT AVG("reports"."catch_keepers") AS average_catch_keepers, date AS date FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-06') AND (date < '2017-01-13') GROUP BY "reports"."date" ORDER BY "reports"."date" DESC [["location_id", 1]] 2017-01-13T15:34:41.258770+00:00 app[web.1]: (0.8ms) SELECT AVG("reports"."catch_keepers") AS average_catch_keepers, date AS date FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-05') AND (date < '2017-01-12') GROUP BY "reports"."date" [["location_id", 1]] 2017-01-13T15:34:41.258905+00:00 app[web.1]: ----moving average 2017-01-13T15:34:41.258927+00:00 app[web.1]: 0.0 2017-01-13T15:34:41.258951+00:00 app[web.1]: 0.0 2017-01-13T15:34:41.258931+00:00 app[web.1]: ----previous moving average 2017-01-13T15:34:41.258969+00:00 app[web.1]: ---movingavg 2017-01-13T15:34:41.258999+00:00 app[web.1]: {:movingavg=>0.0, :color=>"#4562A8"} 2017-01-13T15:34:41.261129+00:00 app[web.1]: Report Load (0.8ms) SELECT "reports".* FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-06') AND (date < '2017-01-13') ORDER BY "reports"."date" DESC [["location_id", 1]] 2017-01-13T15:34:41.266026+00:00 app[web.1]: Completed 500 Internal Server Error in 42ms (ActiveRecord: 17.9ms) 2017-01-13T15:34:41.670858+00:00 heroku[router]: at=info method=GET path="/species_filter?target_species=Any" host=currents.herokuapp.com request_id=51400dbb-d5cb-4eef-a0fd-162e96339a1b fwd="199.253.243.3" dyno=web.1 connect=0ms service=424ms status=500 bytes=1669 2017-01-13T15:34:41.639677+00:00 app[web.1]: 2017-01-13T15:34:41.639685+00:00 app[web.1]: NoMethodError (undefined method `each' for #<ActionDispatch::Request::Session:0x007f05c5a61ae0>): 2017-01-13T15:34:41.639686+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/http/parameter_filter.rb:51:in `call' 2017-01-13T15:34:41.639686+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/http/parameter_filter.rb:11:in `filter' 2017-01-13T15:34:41.639687+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/rails.rb:15:in `session' 2017-01-13T15:34:41.639687+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/rack.rb:8:in `comment_options' 2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:31:in `run' 2017-01-13T15:34:41.639688+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/base.rb:46:in `comment' 2017-01-13T15:34:41.639688+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:67:in `update_issue' 2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/processors/sync.rb:9:in `handle' 2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:10:in `handle' 2017-01-13T15:34:41.639690+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/middleware.rb:11:in `rescue in call' 2017-01-13T15:34:41.639691+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/middleware.rb:8:in `call' 2017-01-13T15:34:41.639691+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:35:in `block in call' 2017-01-13T15:34:41.639692+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `catch' 2017-01-13T15:34:41.639692+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `call' 2017-01-13T15:34:41.639693+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call' 2017-01-13T15:34:41.639693+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in `call' 2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call' 2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call' 2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/flash.rb:260:in `call' 2017-01-13T15:34:41.639695+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context' 2017-01-13T15:34:41.639695+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call' 2017-01-13T15:34:41.639696+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/cookies.rb:560:in `call' 2017-01-13T15:34:41.639696+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/query_cache.rb:36:in `call' 2017-01-13T15:34:41.639697+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call' 2017-01-13T15:34:41.639697+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' 2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:81:in `run_callbacks' 2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__' 2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks' 2017-01-13T15:34:41.639699+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 2017-01-13T15:34:41.639699+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call' 2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' 2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:38:in `call_app' 2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:20:in `block in call' 2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `block in tagged' 2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:26:in `tagged' 2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `tagged' 2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:20:in `call' 2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call' 2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/engine.rb:518:in `call' 2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/request_id.rb:21:in `call' 2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call' 2017-01-13T15:34:41.639708+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call' 2017-01-13T15:34:41.639708+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/static.rb:116:in `call' 2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/application.rb:165:in `call' 2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call' 2017-01-13T15:34:41.639710+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/configuration.rb:224:in `call' 2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:271:in `block in run' 2017-01-13T15:34:41.639710+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:569:in `handle_request' 2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:406:in `process_client' 2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `call' 2017-01-13T15:34:41.639712+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `block in spawn_thread' 2017-01-13T15:34:41.639712+00:00 app[web.1]: 2017-01-13T15:34:41.639712+00:00 app[web.1]: 2017-01-13T16:09:59.608738+00:00 heroku[web.1]: Idling 2017-01-13T16:09:59.609122+00:00 heroku[web.1]: State changed from up to down 2017-01-13T16:10:00.308786+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2017-01-13T16:10:00.324473+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish 2017-01-13T16:10:00.325921+00:00 app[web.1]: === puma shutdown: 2017-01-13 16:10:00 +0000 === 2017-01-13T16:10:00.325951+00:00 app[web.1]: - Goodbye! 2017-01-13T16:10:00.325992+00:00 app[web.1]: Exiting 2017-01-13T16:10:00.573756+00:00 heroku[web.1]: Process exited with status 0 ```
2017/01/12
[ "https://Stackoverflow.com/questions/41624554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6317543/" ]
It's <http://www.embeddedjs.com/> thanks to [jade template tag bracket percentage definition](https://stackoverflow.com/questions/28256371/jade-template-tag-bracket-percentage-definition) I originally missed this thread as stackoverflow doesn't recognize <% as a search term. Located the thread via searx.
Could be twig as mentioned above, is the common .erb syntax in ruby.
13,590,447
Can someone suggest what do I have to do with this message? > > CA1060 Move P/Invokes to NativeMethods class Because it is a P/Invoke > method, 'UControl.InternetGetConnectedState(out int, int)' should be > defined in a class named NativeMethods, SafeNativeMethods, or > UnsafeNativeMethods. Mega. UControl.xaml.cs 33 > > > **Code:** ``` namespace Mega { /// <summary> /// Interaction logic for UserControl1.xaml /// </summary> public partial class UControl { [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState(out int description, int reservedValue); ``` THANK YOU!
2012/11/27
[ "https://Stackoverflow.com/questions/13590447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196919/" ]
To get rid of the warning, just add your `P/Invoke` methods to one of the classes below (usually `NativeMethods`). If you are creating a reusable library, you should put these in either `UnsafeNativeMethods` or `SafeNativeMethods`. --- The [msdn page](https://msdn.microsoft.com/library/ms182161.aspx) says > > To fix a violation of this rule, move the method to the appropriate **NativeMethods** class. For most applications, moving P/Invokes to a new class that is named **NativeMethods** is enough. > > > There are 3 `NativeMethods` classes they recommend using: > > **NativeMethods** - This class does not suppress stack walks for unmanaged code permission. (System.Security.SuppressUnmanagedCodeSecurityAttribute must not be applied to this class.) This class is for methods that can be used anywhere because a stack walk will be performed. > > > **SafeNativeMethods** - This class suppresses stack walks for unmanaged code permission. (System.Security.SuppressUnmanagedCodeSecurityAttribute is applied to this class.) This class is for methods that are safe for anyone to call. Callers of these methods are not required to perform a full security review to make sure that the usage is secure because the methods are harmless for any caller. > > > **UnsafeNativeMethods** - This class suppresses stack walks for unmanaged code permission. (System.Security.SuppressUnmanagedCodeSecurityAttribute is applied to this class.) This class is for methods that are potentially dangerous. Any caller of these methods must perform a full security review to make sure that the usage is secure because no stack walk will be performed. > > > But most of the time it is okay to just use the `NativeMethods` class (this will at least get rid of the warning you are seeing): ``` internal static class NativeMethods { [DllImport("kernel32.dll")] internal static extern bool RemoveDirectory(string name); } ``` There is some discussion about this [here](https://stackoverflow.com/questions/4511418/how-to-know-if-native-method-is-safe-unsafe), and the article linked above gives some suggestions on when to use each of the 3 classes: **NativeMethods** > > Because the **NativeMethods** class should not be marked by using **SuppressUnmanagedCodeSecurityAttribute**, P/Invokes that are put in it will require **UnmanagedCode** permission. Because most applications run from the local computer and run together with full trust, this is usually not a problem. However, if you are developing reusable libraries, you should consider defining a **SafeNativeMethods** or **UnsafeNativeMethods** class. > > > **SafeNativeMethods** > > P/Invoke methods that can be safely exposed to any application and that do not have any side effects should be put in a class that is named **SafeNativeMethods**. You do not have to demand permissions and you do not have to pay much attention to where they are called from. > > > **UnsafeNativeMethods** > > P/Invoke methods that cannot be safely called and that could cause side effects should be put in a class that is named **UnsafeNativeMethods**. These methods should be rigorously checked to make sure that they are not exposed to the user unintentionally. The rule [CA2118: Review SuppressUnmanagedCodeSecurityAttribute usage](https://msdn.microsoft.com/en-us/library/ms182311.aspx) can help with this. Alternatively, the methods should have another permission that is demanded instead of **UnmanagedCode** when they use them. > > >
Oh! I found an answer <https://msdn.microsoft.com/library/ms182161.aspx> ``` using System; using System.Runtime.InteropServices; namespace DesignLibrary { // Violates rule: MovePInvokesToNativeMethodsClass. internal class UnmanagedApi { [DllImport("kernel32.dll")] internal static extern bool RemoveDirectory(string name); } } ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
To set up on Centos (do all installation as root) Install pip Download <https://bootstrap.pypa.io/get-pip.py> ``` python get-pip.py ``` Installing selenium If you have pip on your system, you can simply install or upgrade the Python bindings: pip install -U selenium Alternately, you can download the source distribution from PyPI (e.g. selenium-2.53.1.tar.gz), unarchive it, and run: ``` python setup.py install ``` install the program: pyvirtualdisplay ``` pip install pyvirtualdisplay yum install Xvfb libXfont Xorg ``` Then modify your script to add the bold lines within \*\* and \*\* ``` **from pyvirtualdisplay import Display** from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException import unittest, time, re class SeleniumDemo(unittest.TestCase): def setUp(self): **self.display = Display(visible=0, size=(800, 600)) self.display.start()** self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "http://www.soastastore.com/" self.verificationErrors = [] self.accept_next_alert = True def tearDown(self):`enter code here` self.driver.quit() ***self.display.stop()*** self.assertEqual([], self.verificationErrors) ```
requirements: ``` sudo apt-get install xvfb pip install selenium pip install PyVirtualDisplay ``` download chrome driver binary from below link and paste into drivers directory: <https://sites.google.com/a/chromium.org/chromedriver/downloads> code: ``` from selenium import webdriver from pyvirtualdisplay import Display with Display(visible=False, size=(800, 600)): browser = webdriver.Chrome('drivers/chromedriver') browser.get('https://www.example.com') print(browser.page_source) browser.quit() ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
To set up on Centos (do all installation as root) Install pip Download <https://bootstrap.pypa.io/get-pip.py> ``` python get-pip.py ``` Installing selenium If you have pip on your system, you can simply install or upgrade the Python bindings: pip install -U selenium Alternately, you can download the source distribution from PyPI (e.g. selenium-2.53.1.tar.gz), unarchive it, and run: ``` python setup.py install ``` install the program: pyvirtualdisplay ``` pip install pyvirtualdisplay yum install Xvfb libXfont Xorg ``` Then modify your script to add the bold lines within \*\* and \*\* ``` **from pyvirtualdisplay import Display** from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException import unittest, time, re class SeleniumDemo(unittest.TestCase): def setUp(self): **self.display = Display(visible=0, size=(800, 600)) self.display.start()** self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "http://www.soastastore.com/" self.verificationErrors = [] self.accept_next_alert = True def tearDown(self):`enter code here` self.driver.quit() ***self.display.stop()*** self.assertEqual([], self.verificationErrors) ```
You can import `Options` if you don't want to open a web browser. ``` from selenium import webdriver # for webdriver from selenium.webdriver.support.ui import WebDriverWait # for implicit and explict waits from selenium.webdriver.chrome.options import Options # for suppressing the browser ``` Then in the code: ``` option = webdriver.ChromeOptions() option.add_argument('headless') driver = webdriver.Chrome(options=option) ``` And continue with the rest of the program.
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
Since PhantomJS has been deprecated, using headless versions of Firefox would be a viable option. ``` from selenium import webdriver from selenium.webdriver.firefox.options import Options options = Options() options.add_argument("--headless") driver = webdriver.Firefox(options=options) driver.get('https://www.google.com/') ```
requirements: ``` sudo apt-get install xvfb pip install selenium pip install PyVirtualDisplay ``` download chrome driver binary from below link and paste into drivers directory: <https://sites.google.com/a/chromium.org/chromedriver/downloads> code: ``` from selenium import webdriver from pyvirtualdisplay import Display with Display(visible=False, size=(800, 600)): browser = webdriver.Chrome('drivers/chromedriver') browser.get('https://www.example.com') print(browser.page_source) browser.quit() ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
You can run Selenium headless, take a look at this question/answer: [Is it possible to hide the browser in Selenium RC?](https://stackoverflow.com/questions/1418082/selenium-can-i-hide-the-browser) Especially for performance load tests, you should have a look at [Apache JMeter](http://jakarta.apache.org/jmeter).
requirements: ``` sudo apt-get install xvfb pip install selenium pip install PyVirtualDisplay ``` download chrome driver binary from below link and paste into drivers directory: <https://sites.google.com/a/chromium.org/chromedriver/downloads> code: ``` from selenium import webdriver from pyvirtualdisplay import Display with Display(visible=False, size=(800, 600)): browser = webdriver.Chrome('drivers/chromedriver') browser.get('https://www.example.com') print(browser.page_source) browser.quit() ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
To set up on Centos (do all installation as root) Install pip Download <https://bootstrap.pypa.io/get-pip.py> ``` python get-pip.py ``` Installing selenium If you have pip on your system, you can simply install or upgrade the Python bindings: pip install -U selenium Alternately, you can download the source distribution from PyPI (e.g. selenium-2.53.1.tar.gz), unarchive it, and run: ``` python setup.py install ``` install the program: pyvirtualdisplay ``` pip install pyvirtualdisplay yum install Xvfb libXfont Xorg ``` Then modify your script to add the bold lines within \*\* and \*\* ``` **from pyvirtualdisplay import Display** from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException import unittest, time, re class SeleniumDemo(unittest.TestCase): def setUp(self): **self.display = Display(visible=0, size=(800, 600)) self.display.start()** self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "http://www.soastastore.com/" self.verificationErrors = [] self.accept_next_alert = True def tearDown(self):`enter code here` self.driver.quit() ***self.display.stop()*** self.assertEqual([], self.verificationErrors) ```
Since PhantomJS has been deprecated, using headless versions of Firefox would be a viable option. ``` from selenium import webdriver from selenium.webdriver.firefox.options import Options options = Options() options.add_argument("--headless") driver = webdriver.Firefox(options=options) driver.get('https://www.google.com/') ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
You can import `Options` if you don't want to open a web browser. ``` from selenium import webdriver # for webdriver from selenium.webdriver.support.ui import WebDriverWait # for implicit and explict waits from selenium.webdriver.chrome.options import Options # for suppressing the browser ``` Then in the code: ``` option = webdriver.ChromeOptions() option.add_argument('headless') driver = webdriver.Chrome(options=option) ``` And continue with the rest of the program.
requirements: ``` sudo apt-get install xvfb pip install selenium pip install PyVirtualDisplay ``` download chrome driver binary from below link and paste into drivers directory: <https://sites.google.com/a/chromium.org/chromedriver/downloads> code: ``` from selenium import webdriver from pyvirtualdisplay import Display with Display(visible=False, size=(800, 600)): browser = webdriver.Chrome('drivers/chromedriver') browser.get('https://www.example.com') print(browser.page_source) browser.quit() ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
You can run Selenium headless, take a look at this question/answer: [Is it possible to hide the browser in Selenium RC?](https://stackoverflow.com/questions/1418082/selenium-can-i-hide-the-browser) Especially for performance load tests, you should have a look at [Apache JMeter](http://jakarta.apache.org/jmeter).
You can import `Options` if you don't want to open a web browser. ``` from selenium import webdriver # for webdriver from selenium.webdriver.support.ui import WebDriverWait # for implicit and explict waits from selenium.webdriver.chrome.options import Options # for suppressing the browser ``` Then in the code: ``` option = webdriver.ChromeOptions() option.add_argument('headless') driver = webdriver.Chrome(options=option) ``` And continue with the rest of the program.
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
Try this code: ``` op = webdriver.ChromeOptions() op.add_argument('headless') driver = webdriver.Chrome(options=op) ```
Always follow the Documentation. Here is what [selenium doc](http://selenium-python.readthedocs.io/getting-started.html#using-selenium-with-remote-webdriver) says. It provide a [standalone jar](http://selenium-release.storage.googleapis.com/3.7/selenium-server-stand%20alone-3.7.1.jar). * Download the standalone jar. And run it with command ``` java -jar selenium-server-standalone.jar ``` * Now you will see a stanalone server started. * Now set up your webdriver like below and rest part will be as it is. ``` driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities={'browserName': 'htmlunit', 'version': '2', 'javascriptEnabled': True}) ``` * Summary code will be like. ``` from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.keys import Keys driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities={'browserName': 'htmlunit', 'version': '2', 'javascriptEnabled': True}) driver.get("http://www.python.org") assert "Python" in driver.title elem = driver.find_element_by_name("q") elem.clear() elem.send_keys("pycon") elem.send_keys(Keys.RETURN) assert "No results found." not in driver.page_source driver.close() ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
It is possible, but not with the standard firefox driver / chrome / etc. You would need to install PhantomJS. Just assign your WebDriver to an instance of phantomJS driver: ``` driver = webdriver.PhantomJS() ``` If you run your code now, no browser window will be opened.
requirements: ``` sudo apt-get install xvfb pip install selenium pip install PyVirtualDisplay ``` download chrome driver binary from below link and paste into drivers directory: <https://sites.google.com/a/chromium.org/chromedriver/downloads> code: ``` from selenium import webdriver from pyvirtualdisplay import Display with Display(visible=False, size=(800, 600)): browser = webdriver.Chrome('drivers/chromedriver') browser.get('https://www.example.com') print(browser.page_source) browser.quit() ```
7,593,615
// HANDLER ``` private static final String SCRIPT_CREATE_DATABASE = "create table " + MYDATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_CONTENT1 + " text not null);"; private static final String SCRIPT_CREATE_DATABASE2 = "create table " + MYDATABASE_TABLE2 + " (" + KEY_ID2 + " integer foreign key autoincrement, " + KEY_CONTENT2 + " text not null, " + KEY_CONTENT3 + " text not null);"; ``` Any ideas what I might be doing wrong? // ERROR LOG > > > ``` > > 09-29 11:54:40.052: INFO/Database(484): sqlite returned: error > > ``` > > code = > > > > > > > 1, msg = near "foreign": syntax error 09-29 11:54:40.052: > > ERROR/Database(484): Failure 1 (near "foreign": syntax error) on > > 0x217ba8 when preparing 'create table MY\_TABLE2 (\_id2 integer > > foreign > > key autoincrement, Content2 text not null, Content3 text not > > null);'. > > 09-29 11:54:40.062: DEBUG/AndroidRuntime(484): Shutting down VM > > 09-29 > > 11:54:40.062: WARN/dalvikvm(484): threadid=1: thread exiting > > with > > uncaught exception (group=0x4001d800) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): FATAL EXCEPTION: main 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): java.lang.RuntimeException: Unable to > > start > > activity ComponentInfo{sep.com/sep.com.SepActivity}: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.access$2300(ActivityThread.java:125) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Handler.dispatchMessage(Handler.java:99) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > android.os.Looper.loop(Looper.java:123) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.app.ActivityThread.main(ActivityThread.java:4627) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invokeNative(Native Method) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > java.lang.reflect.Method.invoke(Method.java:521) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > > 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > dalvik.system.NativeStart.main(Native Method) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): Caused by: > > android.database.sqlite.SQLiteException: near "foreign": syntax > > error: > > create table MY\_TABLE2 (\_id2 integer foreign key autoincrement, > > Content2 text not null, Content3 text not null); 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > android.database.sqlite.SQLiteDatabase.native\_execSQL(Native > > Method) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle$SQLiteHelper.onCreate(handle.java:104) 09-29 > > 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > sep.com.handle.openToWrite(handle.java:44) 09-29 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > sep.com.SepActivity.onCreate(SepActivity.java:38) 09-29 > > 11:54:40.082: > > ERROR/AndroidRuntime(484): at > > > > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): at > > > > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) > > 09-29 11:54:40.082: ERROR/AndroidRuntime(484): ... 11 more > > > > > > > > >
2011/09/29
[ "https://Stackoverflow.com/questions/7593615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970474/" ]
Chrome now has a headless mode: ``` op = webdriver.ChromeOptions() op.add_argument('headless') driver = webdriver.Chrome(options=op) ```
To set up on Centos (do all installation as root) Install pip Download <https://bootstrap.pypa.io/get-pip.py> ``` python get-pip.py ``` Installing selenium If you have pip on your system, you can simply install or upgrade the Python bindings: pip install -U selenium Alternately, you can download the source distribution from PyPI (e.g. selenium-2.53.1.tar.gz), unarchive it, and run: ``` python setup.py install ``` install the program: pyvirtualdisplay ``` pip install pyvirtualdisplay yum install Xvfb libXfont Xorg ``` Then modify your script to add the bold lines within \*\* and \*\* ``` **from pyvirtualdisplay import Display** from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException import unittest, time, re class SeleniumDemo(unittest.TestCase): def setUp(self): **self.display = Display(visible=0, size=(800, 600)) self.display.start()** self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "http://www.soastastore.com/" self.verificationErrors = [] self.accept_next_alert = True def tearDown(self):`enter code here` self.driver.quit() ***self.display.stop()*** self.assertEqual([], self.verificationErrors) ```
35,916,511
I'm currently working on a project for college but i'm having issues with it. I have two pages with a form on each which includes three text fields (des,act,date) I'm trying to make it so that it will add to the text document the information from the forms but at the minute all it is doing is overwriting it. Anyone know how to solve this? Page 1 ``` if (isset($_GET['logout'])){ session_destroy(); } if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) { header("Location: index.php"); } //Send Data $content = 'OBSERVATION'."\r\n".'Breif Description: '.$_POST['des1']."\r\n".'Agreed Action: '.$_POST['act1']."\r\n".'Close Date: '.$_POST['date1']."\r\n"; if (isset($_POST['submit'])){ $myFile=fopen("Observation.txt","w") or exit("Can’t open file!"); fwrite($myFile, $content); fclose($myFile); header( 'Location: http://www.murphy.sulmaxmarketing.com/GoodPractices.php' ) ; } ?> ``` Page 2 ``` if (isset($_GET['logout'])){ session_destroy(); } if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) { header("Location: index.php"); } //Send Data $content = "\r\n\r\n".'GOOD PRACTICES'."\r\n".'Breif Description: '.$_POST['des2']."\r\n".'Agreed Action: '.$_POST['act2']."\r\n".'Close Date: '.$_POST['date2']."\r\n"; if (isset($_POST['submit'])){ $myFile=fopen("Observation.txt","w") or exit("Can’t open file!"); fwrite($myFile, $content); fclose($myFile); } ?> ```
2016/03/10
[ "https://Stackoverflow.com/questions/35916511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044749/" ]
[fopen()](http://php.net/manual/en/function.fopen.php) with a mode of `'w'` > > Open for writing only; **place the file pointer at the beginning of the file and truncate the file to zero length**. If the file does not exist, attempt to create it. > > > fopen() with a mode of `'a'` > > Open for writing only; place the file pointer at the **end** of the file. If the file does not exist, attempt to create it. In this mode, fseek() has no effect, **writes are always appended**. > > >
Use `file_put_contents` function with `FILE_APPEND` flag. > > This function is identical to calling fopen(), fwrite() and fclose() > successively to write data to a file. > > > **FILE\_APPEND** : If file filename already exists, append the data to the file instead of overwriting it. > > > ``` ... if (isset($_POST['submit'])) { file_put_contents("Observation.txt", $content, FILE_APPEND); header( 'Location: http://www.murphy.sulmaxmarketing.com/GoodPractices.php' ) ; exit; } ... ``` <http://php.net/manual/en/function.file-put-contents.php>
35,916,511
I'm currently working on a project for college but i'm having issues with it. I have two pages with a form on each which includes three text fields (des,act,date) I'm trying to make it so that it will add to the text document the information from the forms but at the minute all it is doing is overwriting it. Anyone know how to solve this? Page 1 ``` if (isset($_GET['logout'])){ session_destroy(); } if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) { header("Location: index.php"); } //Send Data $content = 'OBSERVATION'."\r\n".'Breif Description: '.$_POST['des1']."\r\n".'Agreed Action: '.$_POST['act1']."\r\n".'Close Date: '.$_POST['date1']."\r\n"; if (isset($_POST['submit'])){ $myFile=fopen("Observation.txt","w") or exit("Can’t open file!"); fwrite($myFile, $content); fclose($myFile); header( 'Location: http://www.murphy.sulmaxmarketing.com/GoodPractices.php' ) ; } ?> ``` Page 2 ``` if (isset($_GET['logout'])){ session_destroy(); } if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) { header("Location: index.php"); } //Send Data $content = "\r\n\r\n".'GOOD PRACTICES'."\r\n".'Breif Description: '.$_POST['des2']."\r\n".'Agreed Action: '.$_POST['act2']."\r\n".'Close Date: '.$_POST['date2']."\r\n"; if (isset($_POST['submit'])){ $myFile=fopen("Observation.txt","w") or exit("Can’t open file!"); fwrite($myFile, $content); fclose($myFile); } ?> ```
2016/03/10
[ "https://Stackoverflow.com/questions/35916511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044749/" ]
[fopen()](http://php.net/manual/en/function.fopen.php) with a mode of `'w'` > > Open for writing only; **place the file pointer at the beginning of the file and truncate the file to zero length**. If the file does not exist, attempt to create it. > > > fopen() with a mode of `'a'` > > Open for writing only; place the file pointer at the **end** of the file. If the file does not exist, attempt to create it. In this mode, fseek() has no effect, **writes are always appended**. > > >
Use file\_put\_content ``` if (isset($_POST['submit'])) { file_put_contents("Observation.txt", $content, FILE_APPEND); ... your code here } ``` Here third parameter in file\_put\_content "FILE\_APPEND" will append your file every time with new content in your previous code it was overwrite one content with another because of same name so if you want to do it on that way than you want to set different name of both file. Here file\_put\_content function url : <http://php.net/manual/en/function.file-put-contents.php>
35,916,511
I'm currently working on a project for college but i'm having issues with it. I have two pages with a form on each which includes three text fields (des,act,date) I'm trying to make it so that it will add to the text document the information from the forms but at the minute all it is doing is overwriting it. Anyone know how to solve this? Page 1 ``` if (isset($_GET['logout'])){ session_destroy(); } if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) { header("Location: index.php"); } //Send Data $content = 'OBSERVATION'."\r\n".'Breif Description: '.$_POST['des1']."\r\n".'Agreed Action: '.$_POST['act1']."\r\n".'Close Date: '.$_POST['date1']."\r\n"; if (isset($_POST['submit'])){ $myFile=fopen("Observation.txt","w") or exit("Can’t open file!"); fwrite($myFile, $content); fclose($myFile); header( 'Location: http://www.murphy.sulmaxmarketing.com/GoodPractices.php' ) ; } ?> ``` Page 2 ``` if (isset($_GET['logout'])){ session_destroy(); } if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) { header("Location: index.php"); } //Send Data $content = "\r\n\r\n".'GOOD PRACTICES'."\r\n".'Breif Description: '.$_POST['des2']."\r\n".'Agreed Action: '.$_POST['act2']."\r\n".'Close Date: '.$_POST['date2']."\r\n"; if (isset($_POST['submit'])){ $myFile=fopen("Observation.txt","w") or exit("Can’t open file!"); fwrite($myFile, $content); fclose($myFile); } ?> ```
2016/03/10
[ "https://Stackoverflow.com/questions/35916511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044749/" ]
Use `file_put_contents` function with `FILE_APPEND` flag. > > This function is identical to calling fopen(), fwrite() and fclose() > successively to write data to a file. > > > **FILE\_APPEND** : If file filename already exists, append the data to the file instead of overwriting it. > > > ``` ... if (isset($_POST['submit'])) { file_put_contents("Observation.txt", $content, FILE_APPEND); header( 'Location: http://www.murphy.sulmaxmarketing.com/GoodPractices.php' ) ; exit; } ... ``` <http://php.net/manual/en/function.file-put-contents.php>
Use file\_put\_content ``` if (isset($_POST['submit'])) { file_put_contents("Observation.txt", $content, FILE_APPEND); ... your code here } ``` Here third parameter in file\_put\_content "FILE\_APPEND" will append your file every time with new content in your previous code it was overwrite one content with another because of same name so if you want to do it on that way than you want to set different name of both file. Here file\_put\_content function url : <http://php.net/manual/en/function.file-put-contents.php>
28,036,820
In legacy ASP.Net and .Net in general, sending mail was accomplished via `System.Net.Mail` classes which resided in `System.dll`. Now with KRE, vNext doesn't seem to have `System.Net.Mail` as a separate package. Referencing the `"net453"` framework in `project.json` ``` "frameworks": { "aspnet50": { }, "aspnetcore50": { }, "net453": {} // <<< throws compilation errors }, ``` causes all hell to break loose with errors like: > > .NET Framework 4.5.3 error CS0234: The type or namespace name 'AspNet' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) > > > It virtually complains about all vNext dependencies that are part of kpm packages. So, has anyone figured out a way to send mails using ASP.Net vNext yet? **Note** Even though `System` appears under References and even though Intellisense shows `System.Net.Mail` is available for use, the code doesn't compile. E.g., a simple statement like this, although appears valid, ``` using System.Net.Mail; var m = new MailMessage(); ``` will throw compilation error such as: > > ASP.NET Core 5.0 error CS0234: The type or namespace name 'Net' does not exist in the namespace 'System' (are you missing an assembly reference?) > > > ASP.NET Core 5.0 error CS0246: The type or namespace name 'MailMessage' could not be found (are you missing a using directive or an assembly reference?) > > > **Update** With latest Visual Studio 2015 CTP 5, they seemed to have fixed the intellisense glitch. Now `System.Net` doesn't have `Mail` namespace anymore. On a side note, the vNext project I created with VS 2015 preview is no longer working - I get an 403.3 error on the home page! Ah, the joy of working with beta software!
2015/01/20
[ "https://Stackoverflow.com/questions/28036820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/244353/" ]
To use `System.Net.Mail` your app can target only `aspnet50`. The `aspnetcore50` target has no such support (at least, not right now, as far as I know). You shouldn't ever have your app target `net453` (which, as Luca mentioned in a comment, has since been renamed anyway) because ASP.NET 5 apps don't run on that platform. An app that targets `aspnet50` can generally reference any .NET 4.0+ NuGet package or GAC reference. So, in your case, remove the `net453` and `aspnetcore50` targets, and *within* the `aspnet50` target add a framework reference to `System.Net.Mail`. A complete alternative would be to find some other existing NuGet package that has support for sending email in both `aspnet50` and `aspnetcore50`, but I doubt such a package exists at this time (though it no doubt will at some point in the future).
To follow up... .NET team has stated that porting System.Net.Mail will be less than straightforward and will likely take a while. That's a bummer since a production website usually does more than a little email sending. In the meantime, someone just released a Core-Clr compatible email API called MailKit. You can read about it here <https://github.com/jstedfast/MailKit/issues/212>
60,386,944
I just start learning about adding items in set (Python), but then I don't understand why this happens ``` thisset = {"apple", "banana", "cherry"} thisset.update("durian", "mango", "orange") print(thisset) ``` and I get the output like this: ``` {'i', 'o', 'r', 'm', 'cherry', 'n', 'u', 'a', 'apple', 'banana', 'd', 'e', 'g'} ``` What I want is put the other 3 items into the set, what else I need to add/change?
2020/02/25
[ "https://Stackoverflow.com/questions/60386944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12213279/" ]
According to the reference, `set.update(*others)` will update the set, adding elements from all others, what it does is `set |= other | ...`. So in your case, what `thisset.update("durian", "mango", "orange")` does is `thisset |= set("marian") | set("mango") | set("orange")`. To accomplish what you want, you need to pass a list or a set, say `thisset.update(["durian", "mango", "orange"])` or `thisset.update({"durian", "mango", "orange"})`.
You need to put curly braces inside `update`: ``` >>> thisset = {"apple", "banana", "cherry"} >>> thisset.update({"durian", "mango", "orange"}) >>> thisset {'orange', 'banana', 'mango', 'apple', 'cherry', 'durian'} >>> ```
31,189,098
I am trying to access the custom annotation values from jointCut. But I couldn't find a way. My sample code : ``` @ComponentValidation(input1="input1", typeOfRule="validation", logger=Log.EXCEPTION) public boolean validator(Map<String,String> mapStr) { //blah blah } ``` Trying to access `@Aspect` class. But, i didnt see any scope to access values. Way i am trying to access is below code ``` CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); String[] names = codeSignature.getParameterNames(); MethodSignature methodSignature = (MethodSignature) joinPoint.getStaticPart().getSignature(); Annotation[][] annotations = methodSignature.getMethod().getParameterAnnotations(); Object[] values = joinPoint.getArgs(); ``` i didnt see any value returns input = input1. how to achieve this.
2015/07/02
[ "https://Stackoverflow.com/questions/31189098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/399426/" ]
While the answer by *Jama Asatillayev* is correct from a plain Java perspective, it involves reflection. But the question was specifically about Spring AOP or AspectJ, and there is a much simpler and more canonical way to bind matched annotations to aspect advice parameters with AspectJ syntax - without any reflection, BTW. ```java import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import my.package.ComponentValidation; @Aspect public class MyAspect { @Before("@annotation(validation)") public void myAdvice(JoinPoint thisJoinPoint, ComponentValidation validation) { System.out.println(thisJoinPoint + " -> " + validation); } } ```
For getting values, use below: ``` ComponentValidation validation = methodSignature.getMethod().getAnnotation(ComponentValidation.class); ``` you can call `validation.getInput1()`, assuming you have this method in `ComponentValidation` custom annotation.
31,189,098
I am trying to access the custom annotation values from jointCut. But I couldn't find a way. My sample code : ``` @ComponentValidation(input1="input1", typeOfRule="validation", logger=Log.EXCEPTION) public boolean validator(Map<String,String> mapStr) { //blah blah } ``` Trying to access `@Aspect` class. But, i didnt see any scope to access values. Way i am trying to access is below code ``` CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); String[] names = codeSignature.getParameterNames(); MethodSignature methodSignature = (MethodSignature) joinPoint.getStaticPart().getSignature(); Annotation[][] annotations = methodSignature.getMethod().getParameterAnnotations(); Object[] values = joinPoint.getArgs(); ``` i didnt see any value returns input = input1. how to achieve this.
2015/07/02
[ "https://Stackoverflow.com/questions/31189098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/399426/" ]
While the answer by *Jama Asatillayev* is correct from a plain Java perspective, it involves reflection. But the question was specifically about Spring AOP or AspectJ, and there is a much simpler and more canonical way to bind matched annotations to aspect advice parameters with AspectJ syntax - without any reflection, BTW. ```java import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import my.package.ComponentValidation; @Aspect public class MyAspect { @Before("@annotation(validation)") public void myAdvice(JoinPoint thisJoinPoint, ComponentValidation validation) { System.out.println(thisJoinPoint + " -> " + validation); } } ```
For example if you have defined a method in Annotation interface like below : ``` @Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) public @interface AspectParameter { String passArgument() default ""; } ``` then you can access the class and the method values in the aspect like below : ``` @Slf4j @Aspect @Component public class ParameterAspect { @Before("@annotation(AspectParameter)") public void validateInternalService(JoinPoint joinPoint, AspectParameter aspectParameter) throws Throwable { String customParameter = aspectParameter.passArgument(); } } ```
33,218,509
I have strings that I need to remove the trailing characters from. There are several types, here are some examples: "82.882ft" "101in" "15.993ft³" "10.221mm" Etc. I need to remove the length delimiters so I will be left with strings: "82.882" "101" "15.993" "10.221" Ideas?
2015/10/19
[ "https://Stackoverflow.com/questions/33218509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3482896/" ]
Try using a replaceAll on the string, specifying all characters that are not a decimal point or number: ``` myString = myString.replaceAll("[^0-9\\.]",""); ``` "^0-9\." means all characters that are not a number 0 through 9, or a decimal. The reason why we put two slashes are to escape the period, as it has a different connotation in a Java regex than the literal character '.'.
Just use regex: ``` String result = input.replaceAll("[^0-9.]", ""); ```
33,218,509
I have strings that I need to remove the trailing characters from. There are several types, here are some examples: "82.882ft" "101in" "15.993ft³" "10.221mm" Etc. I need to remove the length delimiters so I will be left with strings: "82.882" "101" "15.993" "10.221" Ideas?
2015/10/19
[ "https://Stackoverflow.com/questions/33218509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3482896/" ]
Just use regex: ``` String result = input.replaceAll("[^0-9.]", ""); ```
Regular Expressions probably works best for this. ``` Pattern lp = Pattern.compile("([\\d.]+)(.*)"); // Optional cleanup using Apache Commons StringUtils currentInput = StringUtils.upperCase( StringUtils.deleteWhitespace(currentInput)); Matcher lpm = lp.matcher(currentInput); if( lpm.matches() ) { // Values String value = lpm.group(1); // And the trailing chars for further processing String measure = lpm.group(2); } ```
33,218,509
I have strings that I need to remove the trailing characters from. There are several types, here are some examples: "82.882ft" "101in" "15.993ft³" "10.221mm" Etc. I need to remove the length delimiters so I will be left with strings: "82.882" "101" "15.993" "10.221" Ideas?
2015/10/19
[ "https://Stackoverflow.com/questions/33218509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3482896/" ]
Try using a replaceAll on the string, specifying all characters that are not a decimal point or number: ``` myString = myString.replaceAll("[^0-9\\.]",""); ``` "^0-9\." means all characters that are not a number 0 through 9, or a decimal. The reason why we put two slashes are to escape the period, as it has a different connotation in a Java regex than the literal character '.'.
Regular Expressions probably works best for this. ``` Pattern lp = Pattern.compile("([\\d.]+)(.*)"); // Optional cleanup using Apache Commons StringUtils currentInput = StringUtils.upperCase( StringUtils.deleteWhitespace(currentInput)); Matcher lpm = lp.matcher(currentInput); if( lpm.matches() ) { // Values String value = lpm.group(1); // And the trailing chars for further processing String measure = lpm.group(2); } ```
36,380,157
I have two seperated machines 1. Ubuntu Server 12.04 maven Instaled (Apache Maven 3.0.4) 2. Windows Server 2008 R2 nexus installed (Nexus Repository Manager OSS 2.12.0-01) I create a simple java project with maven and i'm unable to deploy it on remote nexus repository. MY pom.xml : ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>tn.esprit.simpleapp</groupId> <artifactId>my-simpleapp</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>my-simpleapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <distributionManagement> <!-- Publish the versioned releases here --> <repository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/releases/</url> </repository> <!-- Publish the versioned releases here --> <snapshotRepository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> <!-- download artifacts from this repo --> <repositories> <repository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/repo1.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <!-- download plugins from this repo --> <pluginRepositories> <pluginRepository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/repo1.maven.org/maven2/snopshots</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project> ``` mvn deploy X result : ``` [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project (/home/esprit/Maven/someProject/pom.xml) has 1 error [ERROR] Non-parseable POM /home/esprit/Maven/someProject/pom.xml: Unrecognised tag: 'distributionManagement' (position: START_TAG seen ...</dependency>\n <distributionManagement>... @15:27) @ line 15, column 27 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException esprit@ubuntu:~/Maven/someProject$ nano pom.xml esprit@ubuntu:~/Maven/someProject$ mvn clean package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building someProject 2.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.3 is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.253s [INFO] Finished at: Sat Apr 02 16:56:41 PDT 2016 [INFO] Final Memory: 4M/15M [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.3: Failure to find org.apache.maven.plugins:maven-clean-plugin:pom:2.3 in http://192.168.2.195:8081/nexus/content/repositories/central/ was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException ``` My ~/.2/settings.xml ``` <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.home}/conf/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true <interactiveMode>true</interactiveMode> --> <!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: false <offline>false</offline> --> <!-- pluginGroups | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list. |--> <pluginGroups> <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> --> </pluginGroups> <!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--> <proxies> <!-- proxy | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies> <!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection to a remote server. |--> <servers> <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | <server> <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password> </server> --> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --> <server> <id>central</id> <username>deployment</username> <password>deployment123</password> </server> </servers> <!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository. |--> <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>central</id> <mirrorOf>central</mirrorOf> <name>Nexus central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/central/</url> </mirror> </mirrors> <!-- profiles | This is a list of profiles which can be activated in a variety of ways, and which can modify | the build process. Profiles provided in the settings.xml are intended to provide local machine- | specific paths and repository locations which allow the build to work in the local environment. | | For example, if you have an integration testing plugin - like cactus - that needs to know where | your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during the build process to configure the cactus plugin. | | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles | section of this document (settings.xml) - will be discussed later. Another way essentially | relies on the detection of a system property, either matching a particular value for the property, | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally, the list of active profiles can be specified directly from the command line. | | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact | repositories, plugin repositories, and free-form properties to be used as configuration | variables for plugins in the POM. | |--> <profiles> <!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>jdk14</id> <name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository> </repositories> </profile> --> <!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId> | | <configuration> | <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the <value/> inside the activation-property. | <profile> <id>env-dev</id> <activation> <property> <name>target-env</name> <value>dev</value> </property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties> </profile> --> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.jdbc.url>jdbc:mysql://192.168.2.197:3306/sonar?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url> <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver> <sonar.jdbc.username>sonar</sonar.jdbc.username> <sonar.jdbc.password>sonar</sonar.jdbc.password> <!-- La ligne ci-dessous n'est utile que si le port par défaut (9000) est modifié dans le fichier de configuration. --> <sonar.host.url>http://192.168.2.197:9000/sonar</sonar.host.url> </properties> </profile> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> </settings> ```
2016/04/03
[ "https://Stackoverflow.com/questions/36380157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1358417/" ]
The brackets are documentation notation indicating that those parameters are optional, and can be omitted from any given invocation. They are not indicative of syntax you should be using in your program. Both of these styles should work, given that documentation. The callback being optional. ``` makeOffer({ ... }); makeOffer({ ... }, function (...) { ... }); ``` *Dots indicate more code - in this case an object definition, function parameters, and the function body.* Some other examples of this type of documentation notation: MDN Array: [`concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat), [`slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice), [`reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
~~`makeOffer(accessToken[, itemsFromThem])` is not JavaScript syntax. It's just common notation that's used to indicate that the function can take any number of arguments, like so:~~ ``` makeOffer(accessToken, something, somethingElse); makeOffer(accessToken, something, secondThing, thirdThing); makeOffer(accessToken); ``` Check the documentation for more details on how that library behaves.
36,380,157
I have two seperated machines 1. Ubuntu Server 12.04 maven Instaled (Apache Maven 3.0.4) 2. Windows Server 2008 R2 nexus installed (Nexus Repository Manager OSS 2.12.0-01) I create a simple java project with maven and i'm unable to deploy it on remote nexus repository. MY pom.xml : ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>tn.esprit.simpleapp</groupId> <artifactId>my-simpleapp</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>my-simpleapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <distributionManagement> <!-- Publish the versioned releases here --> <repository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/releases/</url> </repository> <!-- Publish the versioned releases here --> <snapshotRepository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> <!-- download artifacts from this repo --> <repositories> <repository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/repo1.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <!-- download plugins from this repo --> <pluginRepositories> <pluginRepository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/repo1.maven.org/maven2/snopshots</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project> ``` mvn deploy X result : ``` [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project (/home/esprit/Maven/someProject/pom.xml) has 1 error [ERROR] Non-parseable POM /home/esprit/Maven/someProject/pom.xml: Unrecognised tag: 'distributionManagement' (position: START_TAG seen ...</dependency>\n <distributionManagement>... @15:27) @ line 15, column 27 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException esprit@ubuntu:~/Maven/someProject$ nano pom.xml esprit@ubuntu:~/Maven/someProject$ mvn clean package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building someProject 2.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.3 is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.253s [INFO] Finished at: Sat Apr 02 16:56:41 PDT 2016 [INFO] Final Memory: 4M/15M [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.3: Failure to find org.apache.maven.plugins:maven-clean-plugin:pom:2.3 in http://192.168.2.195:8081/nexus/content/repositories/central/ was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException ``` My ~/.2/settings.xml ``` <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.home}/conf/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true <interactiveMode>true</interactiveMode> --> <!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: false <offline>false</offline> --> <!-- pluginGroups | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list. |--> <pluginGroups> <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> --> </pluginGroups> <!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--> <proxies> <!-- proxy | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies> <!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection to a remote server. |--> <servers> <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | <server> <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password> </server> --> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --> <server> <id>central</id> <username>deployment</username> <password>deployment123</password> </server> </servers> <!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository. |--> <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>central</id> <mirrorOf>central</mirrorOf> <name>Nexus central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/central/</url> </mirror> </mirrors> <!-- profiles | This is a list of profiles which can be activated in a variety of ways, and which can modify | the build process. Profiles provided in the settings.xml are intended to provide local machine- | specific paths and repository locations which allow the build to work in the local environment. | | For example, if you have an integration testing plugin - like cactus - that needs to know where | your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during the build process to configure the cactus plugin. | | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles | section of this document (settings.xml) - will be discussed later. Another way essentially | relies on the detection of a system property, either matching a particular value for the property, | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally, the list of active profiles can be specified directly from the command line. | | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact | repositories, plugin repositories, and free-form properties to be used as configuration | variables for plugins in the POM. | |--> <profiles> <!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>jdk14</id> <name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository> </repositories> </profile> --> <!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId> | | <configuration> | <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the <value/> inside the activation-property. | <profile> <id>env-dev</id> <activation> <property> <name>target-env</name> <value>dev</value> </property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties> </profile> --> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.jdbc.url>jdbc:mysql://192.168.2.197:3306/sonar?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url> <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver> <sonar.jdbc.username>sonar</sonar.jdbc.username> <sonar.jdbc.password>sonar</sonar.jdbc.password> <!-- La ligne ci-dessous n'est utile que si le port par défaut (9000) est modifié dans le fichier de configuration. --> <sonar.host.url>http://192.168.2.197:9000/sonar</sonar.host.url> </properties> </profile> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> </settings> ```
2016/04/03
[ "https://Stackoverflow.com/questions/36380157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1358417/" ]
The brackets are documentation notation indicating that those parameters are optional, and can be omitted from any given invocation. They are not indicative of syntax you should be using in your program. Both of these styles should work, given that documentation. The callback being optional. ``` makeOffer({ ... }); makeOffer({ ... }, function (...) { ... }); ``` *Dots indicate more code - in this case an object definition, function parameters, and the function body.* Some other examples of this type of documentation notation: MDN Array: [`concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat), [`slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice), [`reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
I don't have full code of what You've done. But I'll give necessary part of it. Look here: ``` var SteamTradeOffers = require('steam-tradeoffers'); var offers = new SteamTradeOffers(); // look at api, it needs 2 arguments // 1. offer object, that consist of params like this: var offer = { partnerAccountId: 'steam id goes here', accessToken: 'access token goes here', itemsFromThem: [{ appid: 440, contextid: 2, amount: 1, assetid: "1627590398" }], itemsFromMe: [{ appid: 440, contextid: 2, amount: 1, assetid: "1627590399" }], message: "Hello! Checkout what I'm offering You ;)" }; offers.makeOffer(offer, function(err, result){ // 2. callback function that will handle result of makeOffer console.log(result); }); ```
36,380,157
I have two seperated machines 1. Ubuntu Server 12.04 maven Instaled (Apache Maven 3.0.4) 2. Windows Server 2008 R2 nexus installed (Nexus Repository Manager OSS 2.12.0-01) I create a simple java project with maven and i'm unable to deploy it on remote nexus repository. MY pom.xml : ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>tn.esprit.simpleapp</groupId> <artifactId>my-simpleapp</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>my-simpleapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <distributionManagement> <!-- Publish the versioned releases here --> <repository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/releases/</url> </repository> <!-- Publish the versioned releases here --> <snapshotRepository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> <!-- download artifacts from this repo --> <repositories> <repository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/repo1.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <!-- download plugins from this repo --> <pluginRepositories> <pluginRepository> <id>central</id> <name>central</name> <url>http://192.168.2.195:8081/repo1.maven.org/maven2/snopshots</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project> ``` mvn deploy X result : ``` [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project (/home/esprit/Maven/someProject/pom.xml) has 1 error [ERROR] Non-parseable POM /home/esprit/Maven/someProject/pom.xml: Unrecognised tag: 'distributionManagement' (position: START_TAG seen ...</dependency>\n <distributionManagement>... @15:27) @ line 15, column 27 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException esprit@ubuntu:~/Maven/someProject$ nano pom.xml esprit@ubuntu:~/Maven/someProject$ mvn clean package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building someProject 2.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.3 is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.253s [INFO] Finished at: Sat Apr 02 16:56:41 PDT 2016 [INFO] Final Memory: 4M/15M [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.3: Failure to find org.apache.maven.plugins:maven-clean-plugin:pom:2.3 in http://192.168.2.195:8081/nexus/content/repositories/central/ was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException ``` My ~/.2/settings.xml ``` <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.home}/conf/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true <interactiveMode>true</interactiveMode> --> <!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: false <offline>false</offline> --> <!-- pluginGroups | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list. |--> <pluginGroups> <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> --> </pluginGroups> <!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--> <proxies> <!-- proxy | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies> <!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection to a remote server. |--> <servers> <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | <server> <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password> </server> --> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --> <server> <id>central</id> <username>deployment</username> <password>deployment123</password> </server> </servers> <!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository. |--> <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>central</id> <mirrorOf>central</mirrorOf> <name>Nexus central</name> <url>http://192.168.2.195:8081/nexus/content/repositories/central/</url> </mirror> </mirrors> <!-- profiles | This is a list of profiles which can be activated in a variety of ways, and which can modify | the build process. Profiles provided in the settings.xml are intended to provide local machine- | specific paths and repository locations which allow the build to work in the local environment. | | For example, if you have an integration testing plugin - like cactus - that needs to know where | your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during the build process to configure the cactus plugin. | | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles | section of this document (settings.xml) - will be discussed later. Another way essentially | relies on the detection of a system property, either matching a particular value for the property, | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally, the list of active profiles can be specified directly from the command line. | | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact | repositories, plugin repositories, and free-form properties to be used as configuration | variables for plugins in the POM. | |--> <profiles> <!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>jdk14</id> <name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository> </repositories> </profile> --> <!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId> | | <configuration> | <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the <value/> inside the activation-property. | <profile> <id>env-dev</id> <activation> <property> <name>target-env</name> <value>dev</value> </property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties> </profile> --> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.jdbc.url>jdbc:mysql://192.168.2.197:3306/sonar?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url> <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver> <sonar.jdbc.username>sonar</sonar.jdbc.username> <sonar.jdbc.password>sonar</sonar.jdbc.password> <!-- La ligne ci-dessous n'est utile que si le port par défaut (9000) est modifié dans le fichier de configuration. --> <sonar.host.url>http://192.168.2.197:9000/sonar</sonar.host.url> </properties> </profile> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> </settings> ```
2016/04/03
[ "https://Stackoverflow.com/questions/36380157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1358417/" ]
~~`makeOffer(accessToken[, itemsFromThem])` is not JavaScript syntax. It's just common notation that's used to indicate that the function can take any number of arguments, like so:~~ ``` makeOffer(accessToken, something, somethingElse); makeOffer(accessToken, something, secondThing, thirdThing); makeOffer(accessToken); ``` Check the documentation for more details on how that library behaves.
I don't have full code of what You've done. But I'll give necessary part of it. Look here: ``` var SteamTradeOffers = require('steam-tradeoffers'); var offers = new SteamTradeOffers(); // look at api, it needs 2 arguments // 1. offer object, that consist of params like this: var offer = { partnerAccountId: 'steam id goes here', accessToken: 'access token goes here', itemsFromThem: [{ appid: 440, contextid: 2, amount: 1, assetid: "1627590398" }], itemsFromMe: [{ appid: 440, contextid: 2, amount: 1, assetid: "1627590399" }], message: "Hello! Checkout what I'm offering You ;)" }; offers.makeOffer(offer, function(err, result){ // 2. callback function that will handle result of makeOffer console.log(result); }); ```
3,293,134
I hear that Visual Studio 2010 has "Multi-Monitor Support". Yet now that I am using it, I see no difference from VS2008. I still have to resize all my windows when switching from one monitor to two and back again. Is there somekind of Profile or setting I am missing? For example, Delphi lets you save desktop profiles that record where you like specific windows. Switching from single to dual monitors is as simple as selecting a different desktop profile. Is there something similar in VS2010 that I am missing?
2010/07/20
[ "https://Stackoverflow.com/questions/3293134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16241/" ]
Multi-monitor support refers to the ability for you to undock a code window and drag it to another monitor. Try dragging on the tab of a code window into your other monitor. ScottGu has an excellent blog post on this subject * <http://weblogs.asp.net/scottgu/archive/2009/08/31/multi-monitor-support-vs-2010-and-net-4-series.aspx>
Just drag the editor tabs out and onto your other monitor and witness the glory.
3,293,134
I hear that Visual Studio 2010 has "Multi-Monitor Support". Yet now that I am using it, I see no difference from VS2008. I still have to resize all my windows when switching from one monitor to two and back again. Is there somekind of Profile or setting I am missing? For example, Delphi lets you save desktop profiles that record where you like specific windows. Switching from single to dual monitors is as simple as selecting a different desktop profile. Is there something similar in VS2010 that I am missing?
2010/07/20
[ "https://Stackoverflow.com/questions/3293134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16241/" ]
Just drag the editor tabs out and onto your other monitor and witness the glory.
In VS2008 you could detach things like the solution explorer and put them onto a different monitor, but source code pages were forced to stay on one monitor.
3,293,134
I hear that Visual Studio 2010 has "Multi-Monitor Support". Yet now that I am using it, I see no difference from VS2008. I still have to resize all my windows when switching from one monitor to two and back again. Is there somekind of Profile or setting I am missing? For example, Delphi lets you save desktop profiles that record where you like specific windows. Switching from single to dual monitors is as simple as selecting a different desktop profile. Is there something similar in VS2010 that I am missing?
2010/07/20
[ "https://Stackoverflow.com/questions/3293134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16241/" ]
Multi-monitor support refers to the ability for you to undock a code window and drag it to another monitor. Try dragging on the tab of a code window into your other monitor. ScottGu has an excellent blog post on this subject * <http://weblogs.asp.net/scottgu/archive/2009/08/31/multi-monitor-support-vs-2010-and-net-4-series.aspx>
In VS2008 you could detach things like the solution explorer and put them onto a different monitor, but source code pages were forced to stay on one monitor.
36,635,298
My problem is this, in the app when a user clicks somewhere not important an alertView is raised that's ok, I can find the call to that view, but then is showing again and again empty and I have placed breakpoint everywhere I see a call to any alert. But the ghost alert is not breaking anywhere I have no idea who is throwing it is just a sentient view. Can you give some tips on how to pin point where is the view being called? [![Phantom alertView](https://i.stack.imgur.com/197cG.png)](https://i.stack.imgur.com/197cG.png) [![Breakpoint never hitting that alert](https://i.stack.imgur.com/xK2rg.png)](https://i.stack.imgur.com/xK2rg.png) EDIT: Code for the viewController: ``` #import <CoreLocation/CoreLocation.h> #import "FormViewController.h" #import "FormPageViewController.h" #import "FormElement+UtilityMethods.h" #import "UserBO.h" #import "RecordBO.h" #import "RecordAnswer.h" #import "UserDefaultsUtilities.h" #import "TimeTrackingUtilities.h" #import "DxColors.h" #import "EDQueueUtilities.h" #import "GroupAnswerMetadata.h" #import "RecordAnswer+UtilityMethods.h" #import "Record+UtilityMethods.h" #import "FormPageIndexViewController.h" #import "ManagedObjectUtilities.h" #import "EDQueue.h" #import "EDQueueUtilities.h" #import "DxAnswerObject.h" #import "ImageAnswerMetadata.h" #import "DateUtilities.h" #import <ifaddrs.h> #import "CarbonKit.h" #define INITIAL_CONTROLLER_INDEX 0 #define FORM_RECORDS_TEMP_NAME @"<~TMP>" #define TAG_RETURN_BUTTON 0 #define TAG_SAVE_BUTTON 1 #define TAG_SEND_BUTTON 2 typedef NS_ENUM(NSUInteger, AlertViewPurpose) { ALERT_VIEW_FORM_NONE = 0, ALERT_VIEW_FORM_SEND_SUCCESS = 1, ALERT_VIEW_FORM_SEND_FAILURE = 2, ALERT_VIEW_FORM_SAVE_PROMPT = 3, ALERT_VIEW_FORM_FILE_NAME_PROMPT = 4, ALERT_VIEW_FORM_ASYNC_SEND_SUCCESS = 5, ALERT_VIEW_FORM_COULDNT_SEND = 6, ALERT_VIEW_FORM_WANT_TO_SEND = 7, ALERT_VIEW_FORM_SAVE_IN_CONTEXT_PROMPT = 8, ALERT_VIEW_FORM_FILE_NAME_IN_CTXT_SAVE_PROMPT = 9, ALERT_VIEW_FORM_REQUIRED_INTERNET_CONECTION = 10, // Enumeration counter. ALERT_VIEW_PURPOSE_COUNT }; // Based on: // Ref.: http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/ @interface FormViewController () <RecordBOProtocol, FieldElementProtocol, CLLocationManagerDelegate, FormPageIndexProtocol,CarbonTabSwipeNavigationDelegate> { AlertViewPurpose _currentAlertViewPurpose; CarbonTabSwipeNavigation *_carbonTabSwipeNavigation; BOOL _unedited; BOOL _formRecordNilAtStartUp; BOOL _timestampTaken; CLLocationManager *_locationManager; CLLocation *_location; NSDate *_timeSpentBaseTimestamp; NSArray *_sortedPages; NSUInteger _currentPageIndex; NSString *formID; NSArray *_pagesNames; } @property (weak, nonatomic) IBOutlet UILabel *lblFormTitle; @property (weak, nonatomic) IBOutlet UIButton *btnSmallReturn; @property (weak, nonatomic) IBOutlet UIButton *btnSmallSave; @property (weak, nonatomic) IBOutlet UIButton *btnSmallSend; @property (weak, nonatomic) IBOutlet UIButton *btnBigSend; @property (weak, nonatomic) IBOutlet UIBarButtonItem *btnReturn; @property (strong, nonatomic) IBOutlet UIButton *lblBack; @property (strong, nonatomic) IBOutlet UIButton *lblSave; @end @implementation FormViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization _currentAlertViewPurpose = ALERT_VIEW_FORM_NONE; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self localizedButtons]; // Starting up location manager if form requires it. // Ref.: // https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestAlwaysAuthorization if ([self.form.geolocationEnabled boolValue]) { _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; if ([CLLocationManager locationServicesEnabled]) { CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; if (status == kCLAuthorizationStatusNotDetermined) { // Requesting authorization. if ([CLLocationManager instancesRespondToSelector:@selector(requestWhenInUseAuthorization)]) { #ifdef DEBUG_MODE NSAssert( [[[NSBundle mainBundle] infoDictionary] valueForKey:@"NSLocationWhenInUseUsageDescription"], @"For iOS 8 and above, your app must have a value for NSLocationWhenInUseUsageDescription in its Info.plist"); #endif // DEBUG_MODE [_locationManager requestWhenInUseAuthorization]; } } else if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse) { _locationManager.distanceFilter = kCLDistanceFilterNone; _locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; [_locationManager startUpdatingLocation]; } } } self.lblFormTitle.text = self.form.name ; // Saving whether self.formRecord was nil at beginning. // Important for time spent tap calculations. _formRecordNilAtStartUp = self.formRecord == nil; [self setup]; //Take the time for counting _timeSpentBaseTimestamp = [NSDate date]; _unedited = YES; } -(void)localizedButtons { [self.lblBack setTitle:NSLocalizedString(@"Back", @"Regresar") forState:UIControlStateNormal]; [self.lblSave setTitle:NSLocalizedString(@"Save", @"Guardar") forState:UIControlStateNormal]; [self.btnBigSend setTitle:NSLocalizedString(@"Send", @"Enviar") forState:UIControlStateNormal]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } // Overriding from DxBaseViewController. -(void)refresh { } -(void)setup { // Obtaining sorted pages array. _sortedPages = [[self.form.pages allObjects] sortedArrayUsingComparator:^NSComparisonResult(Page *obj1, Page * obj2) { return [obj1.pageNumber compare: obj2.pageNumber]; }]; //Adding toolBar NSMutableArray *namesPages = [[NSMutableArray alloc]init]; for (Page *page in _sortedPages) { NSString *namePage = page.name; [namesPages addObject:namePage]; } _pagesNames = [namesPages copy] ; // Creating by default a record in case there's none. if (self.formRecord == nil) { self.formRecord = [Record createInContext:self.managedObjectContext]; // Filling in basic record information. self.formRecord.name = FORM_RECORDS_TEMP_NAME; self.formRecord.editable = self.form.editableRecords; self.formRecord.dateLastSaved = self.formRecord.dateCreated = [NSDate date]; self.formRecord.syncStatusId = [NSNumber numberWithInt:SYNC_STATUS_NOT_SYNCED]; self.formRecord.user = [UserBO loggedInUser]; self.formRecord.form = self.form; self.formRecord.formId = self.form.pkey; self.formRecord.temporary = [NSNumber numberWithBool:YES]; self.formRecord.isBeingEdited = [NSNumber numberWithBool:YES]; // Committing record information as is. It will be removed if user doesn't // want to save changes. if (![Record commitChangesFromContext:self.managedObjectContext]) { DebugLog(@"Temp form record couldn't be saved! Check!"); } // Initializing page view controller. _carbonTabSwipeNavigation =[[CarbonTabSwipeNavigation alloc] initWithItems:_pagesNames delegate:self]; _carbonTabSwipeNavigation.toolbar.barTintColor = [DxColors colorWithHexRGB:NEW_FORMS_GREEN]; [_carbonTabSwipeNavigation setNormalColor:[UIColor whiteColor]]; [_carbonTabSwipeNavigation setIndicatorColor:[UIColor whiteColor]]; [_carbonTabSwipeNavigation setSelectedColor:[UIColor whiteColor]]; } else { [self prepareControllerForEdition]; } [_carbonTabSwipeNavigation insertIntoRootViewController:self]; self.pageViewController = _carbonTabSwipeNavigation.pageViewController; } - (UIViewController *)carbonTabSwipeNavigation:(CarbonTabSwipeNavigation *)carbontTabSwipeNavigation viewControllerAtIndex:(NSUInteger)index { _currentPageIndex = index; // Create a new view controller and pass suitable data. FormPageViewController *formPageViewController = [[FormPageViewController alloc] init]; formPageViewController.pageIndex = index; formPageViewController.formPage = _sortedPages[index]; formPageViewController.managedObjectContext = self.managedObjectContext; formPageViewController.formRecord = self.formRecord; formPageViewController.observer = self; formPageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); return formPageViewController; } #pragma mark - Button Actions (IBActions) -(IBAction)send:(id)sender { _timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(isAlertViewShowing:) userInfo:nil repeats:YES]; [self setButtonWithTag:self.btnBigSend.tag toHighlight:NO]; // Disabling button to avoid double submissions. self.btnBigSend.enabled = NO; // Show alert. [self showAreYouReadyToSubmitFormMsg]; } ``` ... can't paste it all
2016/04/14
[ "https://Stackoverflow.com/questions/36635298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1423656/" ]
For testing only: Subclass `UIAlertView` i.e. `@interface MyAlertView : UIAlertView` Then replace all instances of `UIAlertView` from `MyAlertView` i.e. `MyAlertView *someAlert = [[MyAlertView alloc] init.......];` Then override ``` -(void)show { [super show]; //Your breakpoint here OR NSLog([NSThread callStackSymbols]); } ```
Check your viewcontroller that has an uialertviewdelegate. 1. Log your alertview.delegate 2. Check your super class of a viewcontroller that it doesn't call uialertviewdelegate function. 3. If it is an UIAlertController, check viewwillappear, viewdidappear, viewwilldisappear (super class too) and find out they don't call [alertview show]
36,635,298
My problem is this, in the app when a user clicks somewhere not important an alertView is raised that's ok, I can find the call to that view, but then is showing again and again empty and I have placed breakpoint everywhere I see a call to any alert. But the ghost alert is not breaking anywhere I have no idea who is throwing it is just a sentient view. Can you give some tips on how to pin point where is the view being called? [![Phantom alertView](https://i.stack.imgur.com/197cG.png)](https://i.stack.imgur.com/197cG.png) [![Breakpoint never hitting that alert](https://i.stack.imgur.com/xK2rg.png)](https://i.stack.imgur.com/xK2rg.png) EDIT: Code for the viewController: ``` #import <CoreLocation/CoreLocation.h> #import "FormViewController.h" #import "FormPageViewController.h" #import "FormElement+UtilityMethods.h" #import "UserBO.h" #import "RecordBO.h" #import "RecordAnswer.h" #import "UserDefaultsUtilities.h" #import "TimeTrackingUtilities.h" #import "DxColors.h" #import "EDQueueUtilities.h" #import "GroupAnswerMetadata.h" #import "RecordAnswer+UtilityMethods.h" #import "Record+UtilityMethods.h" #import "FormPageIndexViewController.h" #import "ManagedObjectUtilities.h" #import "EDQueue.h" #import "EDQueueUtilities.h" #import "DxAnswerObject.h" #import "ImageAnswerMetadata.h" #import "DateUtilities.h" #import <ifaddrs.h> #import "CarbonKit.h" #define INITIAL_CONTROLLER_INDEX 0 #define FORM_RECORDS_TEMP_NAME @"<~TMP>" #define TAG_RETURN_BUTTON 0 #define TAG_SAVE_BUTTON 1 #define TAG_SEND_BUTTON 2 typedef NS_ENUM(NSUInteger, AlertViewPurpose) { ALERT_VIEW_FORM_NONE = 0, ALERT_VIEW_FORM_SEND_SUCCESS = 1, ALERT_VIEW_FORM_SEND_FAILURE = 2, ALERT_VIEW_FORM_SAVE_PROMPT = 3, ALERT_VIEW_FORM_FILE_NAME_PROMPT = 4, ALERT_VIEW_FORM_ASYNC_SEND_SUCCESS = 5, ALERT_VIEW_FORM_COULDNT_SEND = 6, ALERT_VIEW_FORM_WANT_TO_SEND = 7, ALERT_VIEW_FORM_SAVE_IN_CONTEXT_PROMPT = 8, ALERT_VIEW_FORM_FILE_NAME_IN_CTXT_SAVE_PROMPT = 9, ALERT_VIEW_FORM_REQUIRED_INTERNET_CONECTION = 10, // Enumeration counter. ALERT_VIEW_PURPOSE_COUNT }; // Based on: // Ref.: http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/ @interface FormViewController () <RecordBOProtocol, FieldElementProtocol, CLLocationManagerDelegate, FormPageIndexProtocol,CarbonTabSwipeNavigationDelegate> { AlertViewPurpose _currentAlertViewPurpose; CarbonTabSwipeNavigation *_carbonTabSwipeNavigation; BOOL _unedited; BOOL _formRecordNilAtStartUp; BOOL _timestampTaken; CLLocationManager *_locationManager; CLLocation *_location; NSDate *_timeSpentBaseTimestamp; NSArray *_sortedPages; NSUInteger _currentPageIndex; NSString *formID; NSArray *_pagesNames; } @property (weak, nonatomic) IBOutlet UILabel *lblFormTitle; @property (weak, nonatomic) IBOutlet UIButton *btnSmallReturn; @property (weak, nonatomic) IBOutlet UIButton *btnSmallSave; @property (weak, nonatomic) IBOutlet UIButton *btnSmallSend; @property (weak, nonatomic) IBOutlet UIButton *btnBigSend; @property (weak, nonatomic) IBOutlet UIBarButtonItem *btnReturn; @property (strong, nonatomic) IBOutlet UIButton *lblBack; @property (strong, nonatomic) IBOutlet UIButton *lblSave; @end @implementation FormViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization _currentAlertViewPurpose = ALERT_VIEW_FORM_NONE; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self localizedButtons]; // Starting up location manager if form requires it. // Ref.: // https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestAlwaysAuthorization if ([self.form.geolocationEnabled boolValue]) { _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; if ([CLLocationManager locationServicesEnabled]) { CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; if (status == kCLAuthorizationStatusNotDetermined) { // Requesting authorization. if ([CLLocationManager instancesRespondToSelector:@selector(requestWhenInUseAuthorization)]) { #ifdef DEBUG_MODE NSAssert( [[[NSBundle mainBundle] infoDictionary] valueForKey:@"NSLocationWhenInUseUsageDescription"], @"For iOS 8 and above, your app must have a value for NSLocationWhenInUseUsageDescription in its Info.plist"); #endif // DEBUG_MODE [_locationManager requestWhenInUseAuthorization]; } } else if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse) { _locationManager.distanceFilter = kCLDistanceFilterNone; _locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; [_locationManager startUpdatingLocation]; } } } self.lblFormTitle.text = self.form.name ; // Saving whether self.formRecord was nil at beginning. // Important for time spent tap calculations. _formRecordNilAtStartUp = self.formRecord == nil; [self setup]; //Take the time for counting _timeSpentBaseTimestamp = [NSDate date]; _unedited = YES; } -(void)localizedButtons { [self.lblBack setTitle:NSLocalizedString(@"Back", @"Regresar") forState:UIControlStateNormal]; [self.lblSave setTitle:NSLocalizedString(@"Save", @"Guardar") forState:UIControlStateNormal]; [self.btnBigSend setTitle:NSLocalizedString(@"Send", @"Enviar") forState:UIControlStateNormal]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } // Overriding from DxBaseViewController. -(void)refresh { } -(void)setup { // Obtaining sorted pages array. _sortedPages = [[self.form.pages allObjects] sortedArrayUsingComparator:^NSComparisonResult(Page *obj1, Page * obj2) { return [obj1.pageNumber compare: obj2.pageNumber]; }]; //Adding toolBar NSMutableArray *namesPages = [[NSMutableArray alloc]init]; for (Page *page in _sortedPages) { NSString *namePage = page.name; [namesPages addObject:namePage]; } _pagesNames = [namesPages copy] ; // Creating by default a record in case there's none. if (self.formRecord == nil) { self.formRecord = [Record createInContext:self.managedObjectContext]; // Filling in basic record information. self.formRecord.name = FORM_RECORDS_TEMP_NAME; self.formRecord.editable = self.form.editableRecords; self.formRecord.dateLastSaved = self.formRecord.dateCreated = [NSDate date]; self.formRecord.syncStatusId = [NSNumber numberWithInt:SYNC_STATUS_NOT_SYNCED]; self.formRecord.user = [UserBO loggedInUser]; self.formRecord.form = self.form; self.formRecord.formId = self.form.pkey; self.formRecord.temporary = [NSNumber numberWithBool:YES]; self.formRecord.isBeingEdited = [NSNumber numberWithBool:YES]; // Committing record information as is. It will be removed if user doesn't // want to save changes. if (![Record commitChangesFromContext:self.managedObjectContext]) { DebugLog(@"Temp form record couldn't be saved! Check!"); } // Initializing page view controller. _carbonTabSwipeNavigation =[[CarbonTabSwipeNavigation alloc] initWithItems:_pagesNames delegate:self]; _carbonTabSwipeNavigation.toolbar.barTintColor = [DxColors colorWithHexRGB:NEW_FORMS_GREEN]; [_carbonTabSwipeNavigation setNormalColor:[UIColor whiteColor]]; [_carbonTabSwipeNavigation setIndicatorColor:[UIColor whiteColor]]; [_carbonTabSwipeNavigation setSelectedColor:[UIColor whiteColor]]; } else { [self prepareControllerForEdition]; } [_carbonTabSwipeNavigation insertIntoRootViewController:self]; self.pageViewController = _carbonTabSwipeNavigation.pageViewController; } - (UIViewController *)carbonTabSwipeNavigation:(CarbonTabSwipeNavigation *)carbontTabSwipeNavigation viewControllerAtIndex:(NSUInteger)index { _currentPageIndex = index; // Create a new view controller and pass suitable data. FormPageViewController *formPageViewController = [[FormPageViewController alloc] init]; formPageViewController.pageIndex = index; formPageViewController.formPage = _sortedPages[index]; formPageViewController.managedObjectContext = self.managedObjectContext; formPageViewController.formRecord = self.formRecord; formPageViewController.observer = self; formPageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); return formPageViewController; } #pragma mark - Button Actions (IBActions) -(IBAction)send:(id)sender { _timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(isAlertViewShowing:) userInfo:nil repeats:YES]; [self setButtonWithTag:self.btnBigSend.tag toHighlight:NO]; // Disabling button to avoid double submissions. self.btnBigSend.enabled = NO; // Show alert. [self showAreYouReadyToSubmitFormMsg]; } ``` ... can't paste it all
2016/04/14
[ "https://Stackoverflow.com/questions/36635298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1423656/" ]
For testing only: Subclass `UIAlertView` i.e. `@interface MyAlertView : UIAlertView` Then replace all instances of `UIAlertView` from `MyAlertView` i.e. `MyAlertView *someAlert = [[MyAlertView alloc] init.......];` Then override ``` -(void)show { [super show]; //Your breakpoint here OR NSLog([NSThread callStackSymbols]); } ```
You can catch the content of your AlertView, if it has no content at all, don't present it! To do this check the message you are passing to the method that presents the alertView. However, I can't seem to find your method `showAreYouReadyToSubmitFormMsg`.
36,635,298
My problem is this, in the app when a user clicks somewhere not important an alertView is raised that's ok, I can find the call to that view, but then is showing again and again empty and I have placed breakpoint everywhere I see a call to any alert. But the ghost alert is not breaking anywhere I have no idea who is throwing it is just a sentient view. Can you give some tips on how to pin point where is the view being called? [![Phantom alertView](https://i.stack.imgur.com/197cG.png)](https://i.stack.imgur.com/197cG.png) [![Breakpoint never hitting that alert](https://i.stack.imgur.com/xK2rg.png)](https://i.stack.imgur.com/xK2rg.png) EDIT: Code for the viewController: ``` #import <CoreLocation/CoreLocation.h> #import "FormViewController.h" #import "FormPageViewController.h" #import "FormElement+UtilityMethods.h" #import "UserBO.h" #import "RecordBO.h" #import "RecordAnswer.h" #import "UserDefaultsUtilities.h" #import "TimeTrackingUtilities.h" #import "DxColors.h" #import "EDQueueUtilities.h" #import "GroupAnswerMetadata.h" #import "RecordAnswer+UtilityMethods.h" #import "Record+UtilityMethods.h" #import "FormPageIndexViewController.h" #import "ManagedObjectUtilities.h" #import "EDQueue.h" #import "EDQueueUtilities.h" #import "DxAnswerObject.h" #import "ImageAnswerMetadata.h" #import "DateUtilities.h" #import <ifaddrs.h> #import "CarbonKit.h" #define INITIAL_CONTROLLER_INDEX 0 #define FORM_RECORDS_TEMP_NAME @"<~TMP>" #define TAG_RETURN_BUTTON 0 #define TAG_SAVE_BUTTON 1 #define TAG_SEND_BUTTON 2 typedef NS_ENUM(NSUInteger, AlertViewPurpose) { ALERT_VIEW_FORM_NONE = 0, ALERT_VIEW_FORM_SEND_SUCCESS = 1, ALERT_VIEW_FORM_SEND_FAILURE = 2, ALERT_VIEW_FORM_SAVE_PROMPT = 3, ALERT_VIEW_FORM_FILE_NAME_PROMPT = 4, ALERT_VIEW_FORM_ASYNC_SEND_SUCCESS = 5, ALERT_VIEW_FORM_COULDNT_SEND = 6, ALERT_VIEW_FORM_WANT_TO_SEND = 7, ALERT_VIEW_FORM_SAVE_IN_CONTEXT_PROMPT = 8, ALERT_VIEW_FORM_FILE_NAME_IN_CTXT_SAVE_PROMPT = 9, ALERT_VIEW_FORM_REQUIRED_INTERNET_CONECTION = 10, // Enumeration counter. ALERT_VIEW_PURPOSE_COUNT }; // Based on: // Ref.: http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/ @interface FormViewController () <RecordBOProtocol, FieldElementProtocol, CLLocationManagerDelegate, FormPageIndexProtocol,CarbonTabSwipeNavigationDelegate> { AlertViewPurpose _currentAlertViewPurpose; CarbonTabSwipeNavigation *_carbonTabSwipeNavigation; BOOL _unedited; BOOL _formRecordNilAtStartUp; BOOL _timestampTaken; CLLocationManager *_locationManager; CLLocation *_location; NSDate *_timeSpentBaseTimestamp; NSArray *_sortedPages; NSUInteger _currentPageIndex; NSString *formID; NSArray *_pagesNames; } @property (weak, nonatomic) IBOutlet UILabel *lblFormTitle; @property (weak, nonatomic) IBOutlet UIButton *btnSmallReturn; @property (weak, nonatomic) IBOutlet UIButton *btnSmallSave; @property (weak, nonatomic) IBOutlet UIButton *btnSmallSend; @property (weak, nonatomic) IBOutlet UIButton *btnBigSend; @property (weak, nonatomic) IBOutlet UIBarButtonItem *btnReturn; @property (strong, nonatomic) IBOutlet UIButton *lblBack; @property (strong, nonatomic) IBOutlet UIButton *lblSave; @end @implementation FormViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization _currentAlertViewPurpose = ALERT_VIEW_FORM_NONE; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self localizedButtons]; // Starting up location manager if form requires it. // Ref.: // https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestAlwaysAuthorization if ([self.form.geolocationEnabled boolValue]) { _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; if ([CLLocationManager locationServicesEnabled]) { CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; if (status == kCLAuthorizationStatusNotDetermined) { // Requesting authorization. if ([CLLocationManager instancesRespondToSelector:@selector(requestWhenInUseAuthorization)]) { #ifdef DEBUG_MODE NSAssert( [[[NSBundle mainBundle] infoDictionary] valueForKey:@"NSLocationWhenInUseUsageDescription"], @"For iOS 8 and above, your app must have a value for NSLocationWhenInUseUsageDescription in its Info.plist"); #endif // DEBUG_MODE [_locationManager requestWhenInUseAuthorization]; } } else if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse) { _locationManager.distanceFilter = kCLDistanceFilterNone; _locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; [_locationManager startUpdatingLocation]; } } } self.lblFormTitle.text = self.form.name ; // Saving whether self.formRecord was nil at beginning. // Important for time spent tap calculations. _formRecordNilAtStartUp = self.formRecord == nil; [self setup]; //Take the time for counting _timeSpentBaseTimestamp = [NSDate date]; _unedited = YES; } -(void)localizedButtons { [self.lblBack setTitle:NSLocalizedString(@"Back", @"Regresar") forState:UIControlStateNormal]; [self.lblSave setTitle:NSLocalizedString(@"Save", @"Guardar") forState:UIControlStateNormal]; [self.btnBigSend setTitle:NSLocalizedString(@"Send", @"Enviar") forState:UIControlStateNormal]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } // Overriding from DxBaseViewController. -(void)refresh { } -(void)setup { // Obtaining sorted pages array. _sortedPages = [[self.form.pages allObjects] sortedArrayUsingComparator:^NSComparisonResult(Page *obj1, Page * obj2) { return [obj1.pageNumber compare: obj2.pageNumber]; }]; //Adding toolBar NSMutableArray *namesPages = [[NSMutableArray alloc]init]; for (Page *page in _sortedPages) { NSString *namePage = page.name; [namesPages addObject:namePage]; } _pagesNames = [namesPages copy] ; // Creating by default a record in case there's none. if (self.formRecord == nil) { self.formRecord = [Record createInContext:self.managedObjectContext]; // Filling in basic record information. self.formRecord.name = FORM_RECORDS_TEMP_NAME; self.formRecord.editable = self.form.editableRecords; self.formRecord.dateLastSaved = self.formRecord.dateCreated = [NSDate date]; self.formRecord.syncStatusId = [NSNumber numberWithInt:SYNC_STATUS_NOT_SYNCED]; self.formRecord.user = [UserBO loggedInUser]; self.formRecord.form = self.form; self.formRecord.formId = self.form.pkey; self.formRecord.temporary = [NSNumber numberWithBool:YES]; self.formRecord.isBeingEdited = [NSNumber numberWithBool:YES]; // Committing record information as is. It will be removed if user doesn't // want to save changes. if (![Record commitChangesFromContext:self.managedObjectContext]) { DebugLog(@"Temp form record couldn't be saved! Check!"); } // Initializing page view controller. _carbonTabSwipeNavigation =[[CarbonTabSwipeNavigation alloc] initWithItems:_pagesNames delegate:self]; _carbonTabSwipeNavigation.toolbar.barTintColor = [DxColors colorWithHexRGB:NEW_FORMS_GREEN]; [_carbonTabSwipeNavigation setNormalColor:[UIColor whiteColor]]; [_carbonTabSwipeNavigation setIndicatorColor:[UIColor whiteColor]]; [_carbonTabSwipeNavigation setSelectedColor:[UIColor whiteColor]]; } else { [self prepareControllerForEdition]; } [_carbonTabSwipeNavigation insertIntoRootViewController:self]; self.pageViewController = _carbonTabSwipeNavigation.pageViewController; } - (UIViewController *)carbonTabSwipeNavigation:(CarbonTabSwipeNavigation *)carbontTabSwipeNavigation viewControllerAtIndex:(NSUInteger)index { _currentPageIndex = index; // Create a new view controller and pass suitable data. FormPageViewController *formPageViewController = [[FormPageViewController alloc] init]; formPageViewController.pageIndex = index; formPageViewController.formPage = _sortedPages[index]; formPageViewController.managedObjectContext = self.managedObjectContext; formPageViewController.formRecord = self.formRecord; formPageViewController.observer = self; formPageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); return formPageViewController; } #pragma mark - Button Actions (IBActions) -(IBAction)send:(id)sender { _timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(isAlertViewShowing:) userInfo:nil repeats:YES]; [self setButtonWithTag:self.btnBigSend.tag toHighlight:NO]; // Disabling button to avoid double submissions. self.btnBigSend.enabled = NO; // Show alert. [self showAreYouReadyToSubmitFormMsg]; } ``` ... can't paste it all
2016/04/14
[ "https://Stackoverflow.com/questions/36635298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1423656/" ]
For testing only: Subclass `UIAlertView` i.e. `@interface MyAlertView : UIAlertView` Then replace all instances of `UIAlertView` from `MyAlertView` i.e. `MyAlertView *someAlert = [[MyAlertView alloc] init.......];` Then override ``` -(void)show { [super show]; //Your breakpoint here OR NSLog([NSThread callStackSymbols]); } ```
Why you take enum for alertview ? just make instance of `UIAlertView` where it require's to show. you can make one method in which you can pass two string parameters alertview massage and title and method shows alertview with this title and massage.
14,573,466
I am trying to write a balancer tool for Hbase which could balance regions across regionServers for a table by region count and/or region size (sum of storeFile sizes). I could not find any Hbase API class which returns the regions size or related info. I have already checked a few of the classes which could be used to get other table/region info, e.g. org.apache.hadoop.hbase.client.HTable and HBaseAdmin. I am thinking, another way this could be implemented is by using one of the Hadoop classes which returns the size of the directories in the fileSystem, for e.g. org.apache.hadoop.fs.FileSystem lists the files under a particular HDFS path. Any suggestions ?
2013/01/28
[ "https://Stackoverflow.com/questions/14573466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1231731/" ]
I use this to do managed splits of regions, but, you could leverage it to load-balance on your own. I also load-balance myself to spread the regions ( of a given table ) evenly across our nodes so that MR jobs are evenly distributed. Perhaps the code-snippet below is useful? ``` final HBaseAdmin admin = new HBaseAdmin(conf); final ClusterStatus clusterStatus = admin.getClusterStatus(); for (ServerName serverName : clusterStatus.getServers()) { final HServerLoad serverLoad = clusterStatus.getLoad(serverName); for (Map.Entry<byte[], HServerLoad.RegionLoad> entry : serverLoad.getRegionsLoad().entrySet()) { final String region = Bytes.toString(entry.getKey()); final HServerLoad.RegionLoad regionLoad = entry.getValue(); long storeFileSize = regionLoad.getStorefileSizeMB(); // other useful thing in regionLoad if you like } } ```
What's wrong with the default [Load Balancer](http://hbase.apache.org/book/master.html#master.processes.loadbalancer)? From the Wiki: *The balancer is a periodic operation which is run on the master to redistribute regions on the cluster. It is configured via `hbase.balancer.period` and defaults to 300000 (5 minutes).* If you really want to do it yourself you could indeed use the [Hadoop API](http://hadoop.apache.org/docs/stable/api/index.html) and more specifally, the `FileStatus` class. This class acts as an interface to represent the client side information for a file.
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
> > Why is that? > > > If you want to use `position: absolute` relatively to the entire window, you need to make sure that your `#lol` has no parent elements also positioned `absolute`, `fixed`, or `relative`. Otherwise, any positioning you specify will take place relative to them.
That's just how positioning works. If you have any parent elements with any position specified the absolute positioning will happen relative to them. If you want it to the window but can't do away with any of the other elements' positioning you'll need to remove the item from regular page flow either manually or with a bit of JS.
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
As pointed out in the other answers, at least one of the parent element of `#lol` has a `position` set, that causes your element to be positioned within the parent. A solution with jQuery would be to attach the element directly to body. ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0 }).appendTo('body'); ``` This will make it to appear top left of the window.
> > Why is that? > > > If you want to use `position: absolute` relatively to the entire window, you need to make sure that your `#lol` has no parent elements also positioned `absolute`, `fixed`, or `relative`. Otherwise, any positioning you specify will take place relative to them.
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
> > Why is that? > > > If you want to use `position: absolute` relatively to the entire window, you need to make sure that your `#lol` has no parent elements also positioned `absolute`, `fixed`, or `relative`. Otherwise, any positioning you specify will take place relative to them.
If you want to use **absolute:position** on an element relative to the entire window screen than any parent of that element should not given any position values like absolute,fixed or relative,because the element will take the position relative to its parent if any position attribute is given to it. Hope it answer you well...:)
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
Elements that have `position: relative` or `position: absolute` will be positioned relative to the closest parent that has `position: relative` or `position: absolute`. So, if you want your element to be positioned relative to the entire window, keep it outside of any parent wrappers with relative or absolute positions.
That's just how positioning works. If you have any parent elements with any position specified the absolute positioning will happen relative to them. If you want it to the window but can't do away with any of the other elements' positioning you'll need to remove the item from regular page flow either manually or with a bit of JS.
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
As pointed out in the other answers, at least one of the parent element of `#lol` has a `position` set, that causes your element to be positioned within the parent. A solution with jQuery would be to attach the element directly to body. ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0 }).appendTo('body'); ``` This will make it to appear top left of the window.
Elements that have `position: relative` or `position: absolute` will be positioned relative to the closest parent that has `position: relative` or `position: absolute`. So, if you want your element to be positioned relative to the entire window, keep it outside of any parent wrappers with relative or absolute positions.
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
Elements that have `position: relative` or `position: absolute` will be positioned relative to the closest parent that has `position: relative` or `position: absolute`. So, if you want your element to be positioned relative to the entire window, keep it outside of any parent wrappers with relative or absolute positions.
If you want to use **absolute:position** on an element relative to the entire window screen than any parent of that element should not given any position values like absolute,fixed or relative,because the element will take the position relative to its parent if any position attribute is given to it. Hope it answer you well...:)
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
As pointed out in the other answers, at least one of the parent element of `#lol` has a `position` set, that causes your element to be positioned within the parent. A solution with jQuery would be to attach the element directly to body. ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0 }).appendTo('body'); ``` This will make it to appear top left of the window.
That's just how positioning works. If you have any parent elements with any position specified the absolute positioning will happen relative to them. If you want it to the window but can't do away with any of the other elements' positioning you'll need to remove the item from regular page flow either manually or with a bit of JS.
6,505,067
I have a code like that: ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0}); ``` The problem is that my div is positioned relatively, so it is point 0 of a div rather than the entire window. Why is that?
2011/06/28
[ "https://Stackoverflow.com/questions/6505067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/295815/" ]
As pointed out in the other answers, at least one of the parent element of `#lol` has a `position` set, that causes your element to be positioned within the parent. A solution with jQuery would be to attach the element directly to body. ``` $('#lol').css({ position: "absolute", marginLeft: 0, marginTop: 0, top: 0, left: 0 }).appendTo('body'); ``` This will make it to appear top left of the window.
If you want to use **absolute:position** on an element relative to the entire window screen than any parent of that element should not given any position values like absolute,fixed or relative,because the element will take the position relative to its parent if any position attribute is given to it. Hope it answer you well...:)
299,349
i want to buy a portable 1TB HDD, which should be supportable in Ubuntu as well as Microsoft windows (xp and above). Can any one suggest me a good HDD?
2013/05/24
[ "https://askubuntu.com/questions/299349", "https://askubuntu.com", "https://askubuntu.com/users/150344/" ]
Ubuntu will support any HDD you buy and almost all HDD's available in market mentions compatibility with Windows.
Go with ***Transcend*** *Storejet* (R). It has real value for money plus the compatibilities you're looking for and added features. Source : My experience :) :)
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
The certificate was not exportable, so I was unable to use Roberts suggestion. Ultimately, I had to rekey the certificate at the Go Daddy account management page, and install it on both servers again. Some of the options during the wizard for the install on IIS6 were grayed out for me, and my initial attempt on that server failed. I ended up installing the certificate on the new server (IIS7), and then exporting that certificate in a .pfx format, and then importing that version into the IIS6 installation. At which point everything started working.
As far as I can tell from having these issues today, if you have a certificate with multiple SANs (or I guess a wildcard) and run multiple servers, you need to rekey in Godaddy every time you install on a different machine. This is easy enough - generate a CSR (2048 bit encryption), paste it on the Rekey page in Godaddy and you can then download a new cert. There isn't a wait for approval.
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
try importing into Intermediate Certificate Stores. If you view the certificate there, you will find that "you have a private key that corresponds to this certificate". Simply export to .pfx, then import into IIS. Worked for me :)
I had the same problem today, and fixed it by repairing the key store and providing the serial number of the public certificate. See my answer [here](https://serverfault.com/a/785649/335855) or go directly to [this link](http://www.entrust.net/knowledge-base/technote.cfm?tn=7905) which explains how to repair the key store
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
try importing into Intermediate Certificate Stores. If you view the certificate there, you will find that "you have a private key that corresponds to this certificate". Simply export to .pfx, then import into IIS. Worked for me :)
I've found the problem can be reproduced when the leaf certificate has been installed under Intermediate Certification Authorities. Removing it (and leaving any real intermediate, if applicable) then completing the wizard corrects the problem.
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
Try exporting the certificate from the IIS6 server using these instructions: <http://www.sslshopper.com/move-or-copy-an-ssl-certificate-from-a-windows-server-to-another-windows-server.html> That will ensure that the certificate has a private key.
I had the same problem today, and fixed it by repairing the key store and providing the serial number of the public certificate. See my answer [here](https://serverfault.com/a/785649/335855) or go directly to [this link](http://www.entrust.net/knowledge-base/technote.cfm?tn=7905) which explains how to repair the key store
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
The certificate was not exportable, so I was unable to use Roberts suggestion. Ultimately, I had to rekey the certificate at the Go Daddy account management page, and install it on both servers again. Some of the options during the wizard for the install on IIS6 were grayed out for me, and my initial attempt on that server failed. I ended up installing the certificate on the new server (IIS7), and then exporting that certificate in a .pfx format, and then importing that version into the IIS6 installation. At which point everything started working.
I had the same problem today, and fixed it by repairing the key store and providing the serial number of the public certificate. See my answer [here](https://serverfault.com/a/785649/335855) or go directly to [this link](http://www.entrust.net/knowledge-base/technote.cfm?tn=7905) which explains how to repair the key store
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
The certificate was not exportable, so I was unable to use Roberts suggestion. Ultimately, I had to rekey the certificate at the Go Daddy account management page, and install it on both servers again. Some of the options during the wizard for the install on IIS6 were grayed out for me, and my initial attempt on that server failed. I ended up installing the certificate on the new server (IIS7), and then exporting that certificate in a .pfx format, and then importing that version into the IIS6 installation. At which point everything started working.
I've found the problem can be reproduced when the leaf certificate has been installed under Intermediate Certification Authorities. Removing it (and leaving any real intermediate, if applicable) then completing the wizard corrects the problem.
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
The certificate was not exportable, so I was unable to use Roberts suggestion. Ultimately, I had to rekey the certificate at the Go Daddy account management page, and install it on both servers again. Some of the options during the wizard for the install on IIS6 were grayed out for me, and my initial attempt on that server failed. I ended up installing the certificate on the new server (IIS7), and then exporting that certificate in a .pfx format, and then importing that version into the IIS6 installation. At which point everything started working.
I ran into this issue as well. Rekeying the cert resolved the issue, but the *reason* was that I was using a UCC cert, and the SARs had been changed *AFTER* the cert had last been re-keyed. Re-keying the cert again resolved the issue. I spent 2 hours on the phone with a tech there before I found that out <:(
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
The certificate was not exportable, so I was unable to use Roberts suggestion. Ultimately, I had to rekey the certificate at the Go Daddy account management page, and install it on both servers again. Some of the options during the wizard for the install on IIS6 were grayed out for me, and my initial attempt on that server failed. I ended up installing the certificate on the new server (IIS7), and then exporting that certificate in a .pfx format, and then importing that version into the IIS6 installation. At which point everything started working.
Try exporting the certificate from the IIS6 server using these instructions: <http://www.sslshopper.com/move-or-copy-an-ssl-certificate-from-a-windows-server-to-another-windows-server.html> That will ensure that the certificate has a private key.
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
Try exporting the certificate from the IIS6 server using these instructions: <http://www.sslshopper.com/move-or-copy-an-ssl-certificate-from-a-windows-server-to-another-windows-server.html> That will ensure that the certificate has a private key.
I ran into this issue as well. Rekeying the cert resolved the issue, but the *reason* was that I was using a UCC cert, and the SARs had been changed *AFTER* the cert had last been re-keyed. Re-keying the cert again resolved the issue. I spent 2 hours on the phone with a tech there before I found that out <:(
132,738
Windows Server 2008 R2, IIS7. We have an SSL cert from Go Daddy. It's a wildcard cert, so it will work across subdomains (e.g. \*.domain.com). I followed the instructions located at <http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7> for installing the certificate. I get to the IIS step, where I: * Click on "Security Certificates" feature when the server is selected in the left pane * Click on "Complete Certificate Request" * Navigate to the .crt file on the file system * Give it a "friendly" name, click finish The cert gets listed on the main pane now of this "Server Certificates" panel. But, if I refresh the page, or navigate away and come back, it's gone. And the cert is *not* listed as a viable binding when trying to bind a site to https. This seems like a pretty straight forward process, but clearly I'm missing something here. Any ideas? EDIT: I found [this](http://blogs.msdn.com/vijaysk/archive/2009/05/22/disappearing-ssl-certificates-from-iis-7-0-manager.aspx) post, which seems to imply this behavior happens when you try to use the intermediate certificate. When I downloaded the files from GoDaddy, there were 2 in a zip file. 1 was the gd\_iis\_intermediates, the other was named for the domain. I installed the domain one (extension .crt). There didn't seem to be any other option - installing the other from IIS gives an error "Cannot find the certificate request that is associated with this certificate file. A certificate request must be completed on the computer where the request was created". That being said, there doesn't appear to be any other download I can use. There was also mention, in the comments (and elsewhere after googling) of "exporting" the cert as a pfx, and installing that. But I can't figure out how to export it - even through certmgr.msc. I should also mention this cert is installed on another computer running IIS6 (this IIS7 installation is meant to be a failover, plus the primary while we upgrade the IIS6 to IIS7). But I can't figure out how to export it from that computer either.
2010/04/15
[ "https://serverfault.com/questions/132738", "https://serverfault.com", "https://serverfault.com/users/18496/" ]
try importing into Intermediate Certificate Stores. If you view the certificate there, you will find that "you have a private key that corresponds to this certificate". Simply export to .pfx, then import into IIS. Worked for me :)
As far as I can tell from having these issues today, if you have a certificate with multiple SANs (or I guess a wildcard) and run multiple servers, you need to rekey in Godaddy every time you install on a different machine. This is easy enough - generate a CSR (2048 bit encryption), paste it on the Rekey page in Godaddy and you can then download a new cert. There isn't a wait for approval.
633,391
Given a finite set $S = \{A\_1,A\_2,A\_3...\}$ containing an arbitrary number of finite sets such that for any $A\_i{}\in{}S$ and $A\_j{}\in{}S$, $| A\_i{} | = | A\_j{} |$, and given that for every $A\_i{}\in{}S$, and for every $x\in{}A\_i$, $x$ is a finite real number, could it ever be the case that for any $i$ and $j$, the mean values of $A\_i$ and of $A\_j$ coincide? In other words, given two finite distinct sets of the same cardinality of real numbers, is it the case that the mean of the elements of these sets could ever be the same?
2014/01/10
[ "https://math.stackexchange.com/questions/633391", "https://math.stackexchange.com", "https://math.stackexchange.com/users/110798/" ]
Let $a\_i=\{i,-i\}$, for each $i=1,2,\ldots$. Then each $a\_i$ has mean $0$, and cardinality $2$. And $S=\{a\_1, a\_2,\ldots\}=\{\{1,-1\},\{2,-2\},\{3,-3\},\ldots\}$.
A simple example would be the sets $A\_1 = \{1,4\}$ and $A\_2 = \{2,3\}$. This covers the case of the counting numbers, and can be generalized to sets of any size comprised of real numbers.
10,103,672
I need to create a folder for some images, I'm doing it right now using "New Group", inside the Project Navigator of my Xcode Project. The problem comes when I see the contents of the `.app` package, and inside it the images are with all the other files (not inside my folder) How can I create a folder that will be inside of the `.app`?
2012/04/11
[ "https://Stackoverflow.com/questions/10103672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/550034/" ]
**1.** Create a folder with the images. **2.** While adding into the Xcode you drag and drop the folder and choose the option "Create folder references for any added folders". The folder will be in **blue** color, not yellow.
Create a folder in you project folder, add image to that folder and then add them to Xcode.
97,870
This puzzle relates to [Prime to Prime: Get all first 25 Prime Numbers using up to 4 Primes](https://puzzling.stackexchange.com/questions/91841/prime-to-prime-get-all-first-25-prime-numbers-using-up-to-4-primes) and its sequel [Prime to Prime Sequel](https://puzzling.stackexchange.com/questions/91891/prime-to-prime-sequel) > > Using any **three of the first 4** prime numbers (2,3,5 and 7) and the > folllowing math operations get the first 23 numbers (from 1 to 23). > > > x / + - ^ ! !! Square root > > > Other Rules Once you select the three primes all the three primes must appear (once only) in every equation. Use of only 1 or 2 primes not permitted. All three primes must appear once only. ( e.g. 4=7-3 not allowed. it could be 4=2+7-5) Same three primes must appear in every equation. Any prime that appears anywhere in the equation is counted. If you used 3^2 then you have used up 2 and 3 Multiple roots not allowed ( Sq root of sq root) Concatenation is forbidden. Parentheses are permitted. Please no partial answers.
2020/05/04
[ "https://puzzling.stackexchange.com/questions/97870", "https://puzzling.stackexchange.com", "https://puzzling.stackexchange.com/users/34419/" ]
It might be more fun to fill the whole table. I've started with a few examples: $$\require{begingroup}\begingroup \def\\*{\times } \begin{array}{|c|c|c|c|c|} \hline n& 2,3,5 & 2,3,7 & 2,5,7 & 3,5,7 \\ \hline 1& 2\\*3-5 & 7-2\\*3 & \frac{2+5}{7} & 3+5-7 \\ 2& (3!-5)\\*2 & 7-3-2 & \sqrt{(7-5)\\*2} & \frac{3+7}5 \\ 3& (5-2)!-3 & \frac{7+2}{3} & 2\\*5-7 & \sqrt{3^{7-5}} \\ 4& 2-3+5 & 2^{\sqrt{7-3}} & 2-5+7 & \frac{7+5}{3} \\ 5& (3-2)\\*5 & \frac{7+3}{2} &\frac{7!!}{5!!}-2& 3-5+7 \\ 6& -2+3+5 & 2-3+7 & \frac{7+5}{2} & (7-5)\\*3 \\ 7& 2\\*5-3 & (3-2)\\*7 & \sqrt{(2+5)\\*7} & \sqrt{7^{5-3}} \\ 8& (\frac{3+5}{2})!! & -2+3+7 & 5+\sqrt{2+7} & 3\\*5-7 \\ 9& (5-2)!+3 & (7-2)!!-3! & 2\\*7-5 & -3+5+7 \\ 10& 2+3+5 & 7+\frac{3!}{2} & -2+5+7 & 5\\*\sqrt{7-3} \\ 11& 2\\*3+5 & 2\\*7-3 & \frac{5!!+7}{2} & 5!!+3-7 \\ 12& (5-2)!+3! & 2+3+7 & \sqrt{(5+7)^2} & (7-5)\\*3! \\ 13& 2\\*5+3 & 2\\*3+7 & (5-2)!+7 & {7!!\over5!!}+3!\\ 14& 3^2+5 & 2\\*\frac{7!}{(3!)!} & 2+5+7 & (5-3)\\*7 \\ 15& (3-2)\\*5!! & (7-2)\\*3 & 5\\*\sqrt{2+7} & 3+5+7 \\ 16& (5+3)\\*2 & 2^{(7-3)} & (5!!-7)\\*2 & 3\\*7-5 \\ 17& 3\\*5+2 & 2\\*7+3 & 2\\*5+7 & 5!!+\sqrt{7-3} \\ 18& (5-2)!\\*3 & (7-2)!!+3 & 5^2-7 & 3+5!-7!! \\ 19& 5!!+3!-2 & 3\\*7-2 & 2\\*7+5 & 5!!+7-3 \\ 20& 5!!+3+2 & 2\\*(3+7) & 5!!+7-2 & (7-3)\\*5 \\ 21& (5+2)\\*3 & (7-2)!!+3! & 7\\*(5-2) & 3\*{7!!\over5!!} \\ 22& 5^2-3 & (7-3)!-2 & & 3\\*5+7 \\ 23& 5!!+3!+2 & 3\\*7+2 & 5!!\\*2-7 & 5!!+(7-3)!! \\ \hline \end{array} \endgroup$$
I tried writing a generator. I can get everything from 1 to 24 inclusive, for all 4 combinations. I can get 0 to 33 for one combination. The first ungeneratable counting number is 68. $$\begin{array}{|c|c|c|c|c|} \hline n& 2,3,5 & 2,3,7 & 2,5,7 & 3,5,7 \\ \hline 0 & (5-(2+3)) & (3-\sqrt{(2+7)}) & (7-(2+5)) & - \\ 1 & (\frac{5}{(2+3)}) & (7-(2\times3)) & (\frac{7}{(2+5)}) & ((3+5)-7) \\ 2 & \sqrt{(5+(2-3))} & (7-(2+3)) & \sqrt{(7+(2-5))} & (\frac{(3+7)}{5}) \\ 3 & ({2}^{3}-5) & (\frac{(2+7)}{3}) & ((2\times5)-7) & \sqrt{(7-(3-5))} \\ 4 & (5+(2-3)) & \sqrt{(7+{3}^{2})} & (7+(2-5)) & (\frac{(5+7)}{3}) \\ 5 & (5\times(3-2)) & (\frac{(3+7)}{2}) & \sqrt{({2}^{5}-7)} & (7+(3-5)) \\ 6 & (5-(2-3)) & (7+(2-3)) & (\frac{(5+7)}{2}) & (3\times(7-5)) \\ 7 & ((2\times5)-3) & (7\times(3-2)) & \sqrt{(7\times(2+5))} & (\frac{{7}!!}{(3\times5)}) \\ 8 & (\frac{{5}!}{{(2+3)}!!}) & (7-(2-3)) & {(7+(2-5))}!! & ((3\times5)-7) \\ 9 & (3\times(5-2)) & (3\times\sqrt{(2+7)}) & ((2\times7)-5) & (7-(3-5)) \\ 10 & (5+(2+3)) & \sqrt{({7}!!-(2+3))} & (7-(2-5)) & (5\times\sqrt{(7-3)}) \\ 11 & (5+(2\times3)) & ((2\times7)-3) & (\frac{({5}!!+7)}{2}) & ({5}!!+(3-7)) \\ 12 & \sqrt{(\frac{{(2\times3)}!}{5})} & (7+(2+3)) & ({5}!!-\sqrt{(2+7)}) & (\frac{{5}!}{(3+7)}) \\ 13 & (5+{2}^{3}) & (7+(2\times3)) & (7+{(5-2)}!) & (5+{(7-3)}!!) \\ 14 & (5+{3}^{2}) & (7\times\sqrt{({3}!-2)}) & (7+(2+5)) & (7\times(5-3)) \\ 15 & \sqrt{({5}!!\times{(2+3)}!!)} & (7+{2}^{3}) & (\frac{{(2+5)}!!}{7}) & (7+(3+5)) \\ 16 & (2\times(3+5)) & (7+{3}^{2}) & (2\times({5}!!-7)) & ((3\times7)-5) \\ 17 & (2+(3\times5)) & (3+(2\times7)) & (7+(2\times5)) & ({5}!!+\sqrt{(7-3)}) \\ 18 & ({5}!!+\sqrt{{3}^{2}}) & ({3}!\times\sqrt{(2+7)}) & ({5}^{2}-7) & ({3}!+(5+7)) \\ 19 & ({5}^{2}-{3}!) & ((3\times7)-2) & (5+(2\times7)) & ({5}!!-(3-7)) \\ 20 & (5+{(2+3)}!!) & (2\times(3+7)) & ({5}!!-(2-7)) & (5\times(7-3)) \\ 21 & (3\times(2+5)) & (\frac{{7}!!}{(2+3)}) & (7\times(5-2)) & (\frac{(3\times{7}!!)}{{5}!!}) \\ 22 & ({5}^{2}-3) & (7+{(2+3)}!!) & ({5}!!+\sqrt{{7}^{2}}) & (7+(3\times5)) \\ 23 & ({5}!!+{2}^{3}) & (2+(3\times7)) & (2+(\frac{{7}!!}{5})) & ({5}!!+{(7-3)}!!) \\ 24 & (\frac{{(2+3)}!}{5}) & {(7-\sqrt{{3}^{2}})}! & (2\times(5+7)) & {(\frac{(5+7)}{3})}! \\ 25 & (5\times(2+3)) & - & ({2}^{5}-7) & ({5}!!+(3+7)) \\ 26 & ({2}^{5}-{3}!) & (2+{(7-3)}!) & - & (5+(3\times7)) \\ 27 & {3}^{(5-2)} & (3\times(2+7)) & - & ({3}!+(\frac{{7}!!}{5})) \\ 28 & (3+{5}^{2}) & (7\times({3}!-2)) & - & ({3}!+({5}!!+7)) \\ 29 & ({2}^{5}-3) & ({{3}!}^{2}-7) & ({5}!!+(2\times7)) & ((5\times7)-{3}!) \\ 30 & (5\times(2\times3)) & ({3}!\times(7-2)) & ({5}!!+{(7-2)}!!) & (\frac{{5}!}{(7-3)}) \\ 31 & ({3}!+{5}^{2}) & (7+{({3}!-2)}!) & - & - \\ 32 & {2}^{(\frac{{5}!!}{3})} & \sqrt{{2}^{(3+7)}} & (7+{5}^{2}) & ((5\times7)-3) \\ 33 & ({(2\times3)}!!-{5}!!) & ((\frac{{7}!!}{3})-2) & ((5\times7)-2) & ((\frac{{5}!}{3})-7) \\ 34 & - & ({({3}!)}!!-(2\times7)) & ({7}^{2}-{5}!!) & - \\ 35 & (3+{2}^{5}) & (7\times(2+3)) & (\frac{{7}!!}{(5-2)}) & (\frac{{5}!!}{(\frac{3}{7})}) \\ 36 & ({3}!\times{(5-2)}!) & - & - & (3\times(5+7)) \\ 37 & - & (2+(\frac{{7}!!}{3})) & (2+(5\times7)) & (7+({3}!\times5)) \\ 38 & ({3}!+{2}^{5}) & - & - & (3+(5\times7)) \\ 39 & (3\times({5}!!-2)) & ({({3}!)}!!-(2+7)) & (7+{2}^{5}) & ({5}!!+{(7-3)}!) \\ 40 & (5\times{2}^{3}) & (\frac{{(7-2)}!}{3}) & (\frac{{5}!}{\sqrt{(2+7)}}) & (5\times{(7-3)}!!) \\ 41 & ({({3}!)}!!-(2+5)) & ({(2\times3)}!!-7) & - & ({3}!+(5\times7)) \\ 42 & ({3}!\times(2+5)) & (7\times(2\times3)) & ({7}!!\times(\frac{2}{5})) & (\frac{{7}!}{{(\frac{{5}!!}{3})}!}) \\ 43 & ({(2\times3)}!!-5) & ({7}^{2}-{3}!) & - & - \\ 44 & - & (2+({3}!\times7)) & ({7}^{2}-5) & - \\ 45 & (5\times{3}^{2}) & (3\times{(7-2)}!!) & (5\times(2+7)) & (3+(\frac{{7}!}{{5}!})) \\ 46 & - & ({7}^{2}-3) & - & ({({3}!)}!!+(5-7)) \\ 47 & (2+(3\times{5}!!)) & - & - & (7+(\frac{{5}!}{3})) \\ 48 & {(5-(2-3))}!! & {(7+(2-3))}!! & (\frac{{7}!}{{(2+5)}!!}) & {((3\times7)-{5}!!)}!! \\ 49 & ({2}^{{3}!}-{5}!!) & \sqrt{{7}^{({3}!-2)}} & (7\times(2+5)) & {7}^{(5-3)} \\ 50 & - & - & (\frac{({7}!!-5)}{2}) & (5\times(3+7)) \\ 51 & (3\times(2+{5}!!)) & (\frac{({7}!!-3)}{2}) & - & - \\ 52 & - & (3+{7}^{2}) & - & (7+(3\times{5}!!)) \\ 53 & (5+{(2\times3)}!!) & ({({3}!)}!!-(2-7)) & ((\frac{{5}!}{2})-7) & - \\ 54 & ((\frac{{5}!}{2})-{3}!) & ({3}!\times(2+7)) & (5+{7}^{2}) & - \\ 55 & ({({3}!)}!!+(2+5)) & (7+{(2\times3)}!!) & (\frac{(5+{7}!!)}{2}) & ({({3}!)}!!+(\frac{{7}!!}{{5}!!})) \\ 56 & ({5}!-{2}^{{3}!}) & (7\times{2}^{3}) & - & (7\times(3+5)) \\ 57 & ((\frac{{5}!}{2})-3) & ({7}!!-{(2\times3)}!!) & - & ({5}!!+({3}!\times7)) \\ 58 & ({({3}!)}!!+(2\times5)) & - & - & ({({3}!)}!!+\sqrt{({7}!!-5)}) \\ 59 & ({2}^{{3}!}-5) & ((2+{7}!!)-{({3}!)}!!) & - & - \\ 60 & \sqrt{(5\times{(2\times3)}!)} & \sqrt{({({3}!)}!\times(7-2))} & (\frac{({5}!!+{7}!!)}{2}) & (\frac{{5}!}{\sqrt{(7-3)}}) \\ 61 & ({({3}!)}!!-(2-{5}!!)) & - & - & - \\ 62 & - & ({({3}!)}!!+(2\times7)) & - & ((5+{7}!!)-{({3}!)}!!) \\ 63 & ({5}!!+{(2\times3)}!!) & (7\times{3}^{2}) & (\frac{{(2+7)}!!}{{5}!!}) & ({7}!!\times(\frac{3}{5})) \\ 64 & {(3+5)}^{2} & {{(7-3)}!!}^{2} & \sqrt{{2}^{(5+7)}} & {(5-7)}^{{3}!} \\ 65 & ({({3}!)}!!+(2+{5}!!)) & - & - & ({7}!!-(\frac{{5}!}{3})) \\ 66 & ({3}!+(\frac{{5}!}{2})) & - & - & (3\times({5}!!+7)) \\ 67 & - & - & (7+(\frac{{5}!}{2})) & - \\ 68 & - & - & - & - \\ 69 & (5+{2}^{{3}!}) & ({7}!!-{{3}!}^{2}) & - & ({({3}!)}!!+(\frac{{7}!!}{5})) \\ \hline \end{array}$$ Edit: Line Break issue (that someone else also noticed). Corrected ${{3}!}!!$ to ${{(3}!)}!!$ and ${{3}!}!$ to ${{(3}!)}!$. (The mathjax source is OK, but it doesn't combine right.)
67,620,475
I am getting error while renaming a column, is there anyway i can rename it, as there are space in column name `df=df.withColumnRenamed("std deviation","stdDeviation")` `Error:AnalysisException: Attribute name "std deviation" contains invalid character(s) among " ,;{}()\n\t=". Please use alias to rename it.` I tried another way by using alias, but no success. `df=df.select(col("std deviation").alias("stdDeviation"))` is there a way I can rename columns that contain space? `Error:AnalysisException: Attribute name "std deviation" contains invalid character(s) among " ,;{}()\n\t=". Please use alias to rename it.`
2021/05/20
[ "https://Stackoverflow.com/questions/67620475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15513020/" ]
What your script does is: 1. Try to get element with id "100" (btw. starting ids with a number is bad practice although it might work in some browsers — see [What are valid values for the id attribute in HTML?](https://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html#answer-79022)). It might fail to detect the element, because of bad naming. 2. Expecting the element would have been found, you don’t assign the new `innerHTML` (which would work with a `=`), but make a comparison with a `==`. 3. Then you try to find an element by `[lower]`. First, `getElementById` expects a string and second `lower` is `undefined` at this moment. It hasn’t been set yet. It will be set in the next line, where you execute `start()`. Also notice that only `<p>` does not have a `value`. In this case better go with `innerText`. If you just want the paragraph to show the value of `lower`, just assign lower like: `document.getElementById("100").innerText = lower;` 4. `toString()` is not needed if the argument is always a string. Then it would just be ```js var dictionary = "HouSe"; document.getElementById("a100").innerText = dictionary.toLowerCase(); ``` A working example could be: ```js function toLowerCaseString(value) { return value.toString().toLowerCase(); } var dictionary = "HouSe"; document.getElementById("a100").innerText=toLowerCaseString(dictionary); ``` ```html <html> <body> <p id="a100"></p> </body> </html> ```
remarks are in the comment in code snippet. ```html <html> <body> <p id="A100"> </p> <script> var dictionary,lower; function start(){dictionary="house"; lower=dictionary.toString().toLowerCase(); //you need to return something for the function output to be consumed somewhere else return lower; } //you use start output to render innerhtml // you dont do another document.get because lower is not a dom element its is Js object and we have used start return to make is consumable // == is comparative = is used as setter we are setting not comparing as code would suggest document.getElementById("A100").innerHTML=start(); </script> </body> </html> ``` Local scope example as suggested by Mathi; ```html <html> <body> <p id="A100"> </p> <script> function start(){ let dictionary, lower; dictionary="house"; lower=dictionary.toString().toLowerCase(); return lower; } document.getElementById("A100").innerHTML=start(); </script> </body> </html> ```
18,277,192
I want to use certain operations (like clearing the screen etc.) in C programs in Linux platform and I am informed that it can be done including **curses.h** header-file. But this doesn't seem to be available along with **gcc** package. Please, tell me how can I install it?
2013/08/16
[ "https://Stackoverflow.com/questions/18277192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2689842/" ]
Try this: ``` sudo apt-get install libncurses5-dev ```
On RHEL / Fedora / CentOS Linux, type the following yum command at a shell prompt as root user: ``` yum install ncurses-devel ncurses ```
18,277,192
I want to use certain operations (like clearing the screen etc.) in C programs in Linux platform and I am informed that it can be done including **curses.h** header-file. But this doesn't seem to be available along with **gcc** package. Please, tell me how can I install it?
2013/08/16
[ "https://Stackoverflow.com/questions/18277192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2689842/" ]
Try this: ``` sudo apt-get install libncurses5-dev ```
On Debian/Ubuntu/Deepin,use the following command: `sudo apt install libncurses5-dev` man document: `sudo apt install ncurses-doc` then: `man ncurses`
48,412,108
I've got a procedure within a SPARK module that calls the standard `Ada-Text_IO.Put_Line`. During proving I get the following warning `warning: no Global contract available for "Put_Line"`. I do already know how to add the respective data dependency contract to procedures and functions written by myself but how do I add them to a procedures / functions written by others where I can't edit the source files? I looked through sections 5.2 and 7.4 of the Adacore SPARK 2014 user's guide but didn't found an example with a solution to my problem.
2018/01/23
[ "https://Stackoverflow.com/questions/48412108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7962239/" ]
This means that the analyzer cannot "see" whether global variables might be affected when this function is called. It therefore assumes this call is not modifying anything (otherwise all other proofs could be refuted immediately). This is likely a valid assumption for your specific example, but it might not be valid on an embedded system, where a custom implementation of Put\_Line might do anything. There are two ways to convey the missing information: 1. verifier can examine the source code of the function. Then it can try to generate global contracts itself. 2. global contracts are specified explicitly, see RM 6.1.4 (<http://docs.adacore.com/spark2014-docs/html/lrm/subprograms.html#global-aspects>) In this case, the procedure you are calling is part of the run-time system (RTS), and therefore the source is not visible, and you probably cannot/should not change it. **What to do in practice?** Suppressing warnings is almost never a good idea, especially not when you are working on something safety-critical. Usually the code has to be changed until the warning goes away, or some justification process has to start. If you are serious about the analysis results, I recommend to not use such subprograms. If you really need output there, either write your own procedure that replaces the RTS subprogram, or ensure that the subprogram really has no side effects. This is further backed up by what Frédéric has linked: Even if the callee has no side effects, you don't know whether it raises an exception for specific inputs (e.g., very long strings). If you are not so serious about the results, then you can consider this specific one as a warning that you could live with.
I think you just can't add Spark contracts on code you don't own, especially code from the Ada standard. About *Text\_Io*, I found [something](http://docs.adacore.com/spark2014-docs/html/lrm/the-standard-library.html#the-package-text-io-a-10-1) that may be valuable to you in the reference manual. **EDIT** Another solution compared to what Martin said, according to ["Building high integrity applications with Spark" book](https://www.cambridge.org/core/books/building-high-integrity-applications-with-spark/F213D9867D2E271F5FF3EDA765D48E95), is to create a wrapper package. As Spark requires you to deal with Spark packages but allows you to depend on a Spark spec with an Ada body, the solution is to build a Spark package wrapping your Ada.Text\_io calls. It might be tedious as you will have to wrap possible exceptions, possibly define specific types and so on but this way, you'll be able to discharge VCs on your full Spark package.
48,412,108
I've got a procedure within a SPARK module that calls the standard `Ada-Text_IO.Put_Line`. During proving I get the following warning `warning: no Global contract available for "Put_Line"`. I do already know how to add the respective data dependency contract to procedures and functions written by myself but how do I add them to a procedures / functions written by others where I can't edit the source files? I looked through sections 5.2 and 7.4 of the Adacore SPARK 2014 user's guide but didn't found an example with a solution to my problem.
2018/01/23
[ "https://Stackoverflow.com/questions/48412108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7962239/" ]
Wrapper packages for use in development of SPARK applications may be found here: <https://github.com/joakim-strandberg/aida_2012>
I think you just can't add Spark contracts on code you don't own, especially code from the Ada standard. About *Text\_Io*, I found [something](http://docs.adacore.com/spark2014-docs/html/lrm/the-standard-library.html#the-package-text-io-a-10-1) that may be valuable to you in the reference manual. **EDIT** Another solution compared to what Martin said, according to ["Building high integrity applications with Spark" book](https://www.cambridge.org/core/books/building-high-integrity-applications-with-spark/F213D9867D2E271F5FF3EDA765D48E95), is to create a wrapper package. As Spark requires you to deal with Spark packages but allows you to depend on a Spark spec with an Ada body, the solution is to build a Spark package wrapping your Ada.Text\_io calls. It might be tedious as you will have to wrap possible exceptions, possibly define specific types and so on but this way, you'll be able to discharge VCs on your full Spark package.
48,412,108
I've got a procedure within a SPARK module that calls the standard `Ada-Text_IO.Put_Line`. During proving I get the following warning `warning: no Global contract available for "Put_Line"`. I do already know how to add the respective data dependency contract to procedures and functions written by myself but how do I add them to a procedures / functions written by others where I can't edit the source files? I looked through sections 5.2 and 7.4 of the Adacore SPARK 2014 user's guide but didn't found an example with a solution to my problem.
2018/01/23
[ "https://Stackoverflow.com/questions/48412108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7962239/" ]
This means that the analyzer cannot "see" whether global variables might be affected when this function is called. It therefore assumes this call is not modifying anything (otherwise all other proofs could be refuted immediately). This is likely a valid assumption for your specific example, but it might not be valid on an embedded system, where a custom implementation of Put\_Line might do anything. There are two ways to convey the missing information: 1. verifier can examine the source code of the function. Then it can try to generate global contracts itself. 2. global contracts are specified explicitly, see RM 6.1.4 (<http://docs.adacore.com/spark2014-docs/html/lrm/subprograms.html#global-aspects>) In this case, the procedure you are calling is part of the run-time system (RTS), and therefore the source is not visible, and you probably cannot/should not change it. **What to do in practice?** Suppressing warnings is almost never a good idea, especially not when you are working on something safety-critical. Usually the code has to be changed until the warning goes away, or some justification process has to start. If you are serious about the analysis results, I recommend to not use such subprograms. If you really need output there, either write your own procedure that replaces the RTS subprogram, or ensure that the subprogram really has no side effects. This is further backed up by what Frédéric has linked: Even if the callee has no side effects, you don't know whether it raises an exception for specific inputs (e.g., very long strings). If you are not so serious about the results, then you can consider this specific one as a warning that you could live with.
Wrapper packages for use in development of SPARK applications may be found here: <https://github.com/joakim-strandberg/aida_2012>
32,325
I want to get some spare inner tubes for my new road bike, but I'm unsure what size to get. On my tire it says the size is 700 x 25c and I know that 25 is the max width of the inner tube. So should I get 700x20-25c or 700x25-32c? I'm guessing 700x20-25c would be the safer option, correct?
2015/07/29
[ "https://bicycles.stackexchange.com/questions/32325", "https://bicycles.stackexchange.com", "https://bicycles.stackexchange.com/users/20788/" ]
As long as it is in the range you are good. You can even cheat outside the stated range a bit. Too big and you can fold. Too small and you stretch. If it is spare you are going to carry on the bike then the smaller.
Either of those inner tubes are fine for that tyre. I'd recommend the smaller size since it's easier to get in the tyre without folds or twists.
28,134,755
I am creating a web API to extract data from SAP service. My Team lead has asked me to make a odata enabled web API. I read few articles but there is no strong reason which can tell that odata has great advantage if we are consuming an asmx service into web API which in turn will be used by Sharepoint client.
2015/01/25
[ "https://Stackoverflow.com/questions/28134755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3387733/" ]
There are a couple of reasons why I'd recommend to choosing OData over general WebApi: 1. OData provide a level of discoverability that is not present out of the box with a generic WebApi solution. For example, if you have an entity "Widget", one can query the Odata root and it will be listed, along with all the other entities you've exposed. I can tell you from experience, going back to a WebApi project and trying to remember what everything is called is a pain, and this really helps. 2. OData provide a level of basic queryability without having to with a bunch of plumbing code. If you want to filter you widget's by color, you don't need to write a bunch of code to pass this down to your data layer, just add something to the querystring, e.g. "$fitler=color eq 'red'". Works with paging, etc., as well. Along with this, it is relatively easy to place limits (e.g. max number of results), to prevent a host of issues.
The BI service API permits the extraction and direct access to data from SAP systems in standardized form. This can be SAP application systems or SAP NetWeaver BI systems. The data request is controlled from the SAP NetWeaver BI system. More about you'll find there: <http://help.sap.com/saphelp_erp60_sp/helpdata/en/46/b861bb1ba01825e10000000a1553f6/content.htm>
35,473,352
How to read the below xml using php? ``` <?xml version="1.0" encoding="UTF-8"?> <video> <youtube> youtube video url </youtube> </video> ``` I tried the code below but seems not working: ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $results = $dom->documentElement; foreach( $results as $result) { foreach( $result->getElementsByTagName('youtube') as $youtube ) { echo ' video url ' . $youtube->nodeValue; } } ```
2016/02/18
[ "https://Stackoverflow.com/questions/35473352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4935959/" ]
try this : ``` if (file_exists('result.xml')) { $xml = simplexml_load_file('result.xml'); echo $xml->youtube; } else { exit('Failed to open result.xml.'); } ```
No need for anything fancy, just use `->getElementsByTagName()` method after you've loaded it up: ``` $dom->load('new_result.xml'); // load the file // use ->getElementsByTagName() right away $youtube = $dom->getElementsByTagName('youtube'); if($youtube->length > 0) { // if there are youtube nodes indeed foreach($youtube as $y) { // for each youtube node echo $y->nodeValue; } } ```
35,473,352
How to read the below xml using php? ``` <?xml version="1.0" encoding="UTF-8"?> <video> <youtube> youtube video url </youtube> </video> ``` I tried the code below but seems not working: ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $results = $dom->documentElement; foreach( $results as $result) { foreach( $result->getElementsByTagName('youtube') as $youtube ) { echo ' video url ' . $youtube->nodeValue; } } ```
2016/02/18
[ "https://Stackoverflow.com/questions/35473352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4935959/" ]
try this : ``` if (file_exists('result.xml')) { $xml = simplexml_load_file('result.xml'); echo $xml->youtube; } else { exit('Failed to open result.xml.'); } ```
The `DOMDocument::documentElement` is the root element node. In your XML, this would be the `video` element node. It is not a node list, but the actual node, so `foreach` will not work. Just remove the outer `foreach` ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $video = $dom->documentElement; foreach($video->getElementsByTagName('youtube') as $youtube) { echo ' video url ' . $youtube->nodeValue; } ``` If you XML gets more complex you can use Xpath expressions: ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $xpath = new DOMXpath($dom); foreach($xpath->evaluate('/video/youtube') as $youtube) { echo ' video url ' . $youtube->nodeValue; } ``` Most Xpath expression will return node lists, but they can return scalar values. With that you can eliminate the second loop, too: ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $xpath = new DOMXpath($dom); echo ' video url ' . $xpath->evaluate('string(/video/youtube[1])'); ```
35,473,352
How to read the below xml using php? ``` <?xml version="1.0" encoding="UTF-8"?> <video> <youtube> youtube video url </youtube> </video> ``` I tried the code below but seems not working: ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $results = $dom->documentElement; foreach( $results as $result) { foreach( $result->getElementsByTagName('youtube') as $youtube ) { echo ' video url ' . $youtube->nodeValue; } } ```
2016/02/18
[ "https://Stackoverflow.com/questions/35473352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4935959/" ]
No need for anything fancy, just use `->getElementsByTagName()` method after you've loaded it up: ``` $dom->load('new_result.xml'); // load the file // use ->getElementsByTagName() right away $youtube = $dom->getElementsByTagName('youtube'); if($youtube->length > 0) { // if there are youtube nodes indeed foreach($youtube as $y) { // for each youtube node echo $y->nodeValue; } } ```
The `DOMDocument::documentElement` is the root element node. In your XML, this would be the `video` element node. It is not a node list, but the actual node, so `foreach` will not work. Just remove the outer `foreach` ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $video = $dom->documentElement; foreach($video->getElementsByTagName('youtube') as $youtube) { echo ' video url ' . $youtube->nodeValue; } ``` If you XML gets more complex you can use Xpath expressions: ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $xpath = new DOMXpath($dom); foreach($xpath->evaluate('/video/youtube') as $youtube) { echo ' video url ' . $youtube->nodeValue; } ``` Most Xpath expression will return node lists, but they can return scalar values. With that you can eliminate the second loop, too: ``` $dom = new DOMDocument(); $dom->load('new_result.xml'); $xpath = new DOMXpath($dom); echo ' video url ' . $xpath->evaluate('string(/video/youtube[1])'); ```
35,786,199
I have a multi-project SBT build. There is a root which does not have anything, it just aggregates all sub projects. ``` lazy val aaRoot = (project in file(".")).settings(commonSettings: _*).settings( libraryDependencies ++= appDependencies ).enablePlugins(PlayJava).aggregate(foo, bar) lazy val foo: Project = (project in file("modules/foo")).settings(commonSettings: _*).settings( libraryDependencies ++= appDependencies ).enablePlugins(PlayJava).dependsOn(bar) lazy val bar = (project in file("modules/bar")).settings(commonSettings: _*).settings( libraryDependencies ++= appDependencies ).enablePlugins(PlayJava).dependsOn(foo) ``` It is clearly a cyclic dependency here (`foo` depends on `bar` and `bar` depends on `foo`). What are the possible approaches to avoid these kinds of dependencies or is there an `SBT` way of handling this.
2016/03/04
[ "https://Stackoverflow.com/questions/35786199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1300669/" ]
None of the build tools I know allow for cyclic dependencies... and in my experience that is a symptom of a issue with the design of the application or modules, rather than a 'missing' feature from the tools. It's even seen as something bad when this happens at the package level in the same module/jar. Can you merge those 2 modules? or reshufle the classes so the cyclic dependency disappears?
As @Augusto suggested, I have re-organized my classes into three different sub-modules and using my Dependency Injection little more wisely. This solved my problem and gave much more abstraction than what I initially had. Three sub-projects: * api (Just interfaces) * foo (depends on api) * bar (depends on api) * aaRoot (which aggregates all of the above) In `FooModule` (in my case `Guice` module), I am binding `FooInterface` from api module to `FooImplementation` (foo module). While calling the bar module, I just use `BarInterface` (from api) by passing `FooInterface`. Same as the case with `bar` module. At runtime they all will be available and it can easily resolve.
57,509,957
I'm new to fairly new to Javascript and I need some help solving the 804. Unique Morse Code Words - Leetcode problem. I figured how to search return the morse code by using the index of each letter from a word and using it to concatenate the codes at those specific index in the morse code array. The problem is I can't store the results into an Set array excluding the duplicates and returning the length of the Set array. ```js var letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; var morseCode = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."]; var words = ["gin", "zen", "gig", "msg"] var uniqueMorseRepresentations = function(words) { for (i = 0; i < words.length; i++) { let word = words[i]; var result = ""; for (j = 0; j < word.length; j++) { let letter = word.charAt(j); let index = letters.indexOf(letter); result += morseCode[index]; }; console.log(result); }; }; uniqueMorseRepresentations(words); ``` The console.log method return the results in 4 separate strings but I don't know how to store them into an array while verifying if there are duplicate. I'm sorry if the question is sloppy. It's my first one. Thanks in advance!
2019/08/15
[ "https://Stackoverflow.com/questions/57509957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11849190/" ]
Inside your function, create a Set: ``` const resultSet = new Set(); ``` Then when each `result` is built up (when you log it), add the resulting morse code to that Set: ``` resultSet.add(result); ``` Then you can finally `return` that Set, or its `.size`.
I think this should solve your problem. Take an obj, and store the result in that and check if the result is repeating then don't push that result into that array. And the time complexity in this operation would be O(1), so you don't have to worry about it if you want to scale your algorithm. ``` var letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; var morseCode = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."]; var words = ["gin", "zen", "gig", "msg","gig"] var array = []; var uniqueMorseRepresentations = function(words) { let obj = {}; for (i = 0; i < words.length; i++) { let word = words[i]; var result = ""; for (j = 0; j < word.length; j++) { let letter = word.charAt(j); let index = letters.indexOf(letter); result += morseCode[index]; }; if(!obj[result]){ obj[result] = result; array.push(result); } console.log(result); }; console.log(array) }; uniqueMorseRepresentations(words); ```
62,595
I have to describe what it means, when a function is discontinuous in a. I also have to use quantification notation. I have tried following: $$\exists \varepsilon > 0, \exists \delta > 0 : |x-a| < \delta \Rightarrow |f(x)-f(a)| \geq \varepsilon$$ But when I went to the classes they used a different notation. But is this wrong?
2011/09/07
[ "https://math.stackexchange.com/questions/62595", "https://math.stackexchange.com", "https://math.stackexchange.com/users/15552/" ]
Consider what a pure strategy for X will actually look like. It must have two components: it must specify X’s Round 1 move, and it must specify what X is to do in Round 3 for every possible response by Y in Round 2. The Round 1 component can obviously be chosen in $4$ ways. Suppose that it’s been chosen. Then Y’s $3$ possible responses are known, and a countermove must be specified for each of them. There are $2$ choices for each countermove, so the entire set of countermoves can be chosen in $2^3 = 8$ ways. In other words, for each choice of Round 1 move, X has $8$ possible strategies for Round 3, each covering every possible response by Y in Round 2. Since there are $4$ possible round 1 moves, X has altogether $4 \cdot 8 = 32$ pure strategies. Here’s another way to see it. Number the cells of the board $1$ through $4$. A strategy for X can be specified as follows. First give the number of the cell in which X plays in Round 1. Then list remaining cells in numerical order. Finally, replace each of the three numbers in that list by $0$ or $1$; replacing number $c$ by $0$ means that if Y plays $c$ in Round 2, X will play in the lower-number of the remaining cells in Round 3, while replacing it by $1$ means that X will instead play in the higher-numbered of the two remaining cells. The strategy $3010$, for instance, means that X will play in cell $3$ in Round 1. If Y then plays in cell $1$, leaving cells $2$ and $4$ open, X will play in cell $2$, the lower-numbered one. If Y plays in cell $2$ in Round 2, leaving $1$ and $4$ open, X will play in $4$. And if Y plays in cell $4$ in Round 2, X will answer with cell $1$. Clearly every strategy for X can be uniquely specified in this way, and clearly there are $4 \cdot 2^3$ such specifications.
I'm a beginner myself, but I think the difference boils down to the fact that the generalized statement mentioned (and information sets concept) apply to imperfect information games, while the example given is one with perfect information because the players know the complete history of the game. This means that the number of information sets at each move is a singleton. And thus, the number of pure strategies is the product of the number of moves at various points of the game, which for X is $4 \times 8 = 32$ (which is actually $4(1) \times 8(1) = 32$)(OP, the fault in your argument is that the $12$ in the exponent of $2^{12}$ comes from $4\times3$ in round 1 and 2, but here you're recounting the $4$). For Y, the number of singleton information sets is 4(each corresponding to round 1 of X) and for each set, has 3 moves of his own and thus the total number of strategies he can choose from is $3^4$(Think of each strategy as 4 consequent digits, the $i^{th}$ digit representing the move Y makes should X mark the cell $i$. Now see that there are 3 choices for each digit). This link will describe the information sets better: <http://lcm.csa.iisc.ernet.in/gametheory/ln/web-ncp2-efg.pdf>
62,595
I have to describe what it means, when a function is discontinuous in a. I also have to use quantification notation. I have tried following: $$\exists \varepsilon > 0, \exists \delta > 0 : |x-a| < \delta \Rightarrow |f(x)-f(a)| \geq \varepsilon$$ But when I went to the classes they used a different notation. But is this wrong?
2011/09/07
[ "https://math.stackexchange.com/questions/62595", "https://math.stackexchange.com", "https://math.stackexchange.com/users/15552/" ]
Consider what a pure strategy for X will actually look like. It must have two components: it must specify X’s Round 1 move, and it must specify what X is to do in Round 3 for every possible response by Y in Round 2. The Round 1 component can obviously be chosen in $4$ ways. Suppose that it’s been chosen. Then Y’s $3$ possible responses are known, and a countermove must be specified for each of them. There are $2$ choices for each countermove, so the entire set of countermoves can be chosen in $2^3 = 8$ ways. In other words, for each choice of Round 1 move, X has $8$ possible strategies for Round 3, each covering every possible response by Y in Round 2. Since there are $4$ possible round 1 moves, X has altogether $4 \cdot 8 = 32$ pure strategies. Here’s another way to see it. Number the cells of the board $1$ through $4$. A strategy for X can be specified as follows. First give the number of the cell in which X plays in Round 1. Then list remaining cells in numerical order. Finally, replace each of the three numbers in that list by $0$ or $1$; replacing number $c$ by $0$ means that if Y plays $c$ in Round 2, X will play in the lower-number of the remaining cells in Round 3, while replacing it by $1$ means that X will instead play in the higher-numbered of the two remaining cells. The strategy $3010$, for instance, means that X will play in cell $3$ in Round 1. If Y then plays in cell $1$, leaving cells $2$ and $4$ open, X will play in cell $2$, the lower-numbered one. If Y plays in cell $2$ in Round 2, leaving $1$ and $4$ open, X will play in $4$. And if Y plays in cell $4$ in Round 2, X will answer with cell $1$. Clearly every strategy for X can be uniquely specified in this way, and clearly there are $4 \cdot 2^3$ such specifications.
OP is correct. First, we define an information set: an informations set is a node or possibly collection of nodes at which a player makes a decision, and for which the player cannot distinguish between multiple nodes in the informations set. Hence the player has the same available actions at each node in an information set. An information set establishes all possible moves that could have taken place in the game until the point of the player's decision, given what the player has observed. In the game of tic tac toe, every player knows exactly what moves have been played at every step in the game (perfect information) so every information set is a singleton. Now we define a strategy: a strategy for a player is a map from *all* of the player's information sets to actions. This includes information sets that the player would never even encounter by virtue of following their own strategy in the course of the game! Player 1 had 4 actions to choose from at the first information set and after player 2 moves, there are 12 possible information sets player 1 could possibly be at before making a decision, and at each of these information sets, player 1 has 2 possible actions. Hence, the total number of strategies for player 1 is given by 4\*2^12. The key point is strategies include off-path actions. That is, even though once player 1 makes a move, he/she is effectively avoiding all subsequent information sets that would be encountered by playing any of the other three actions, a strategy *must* include a contingent plan for every information set the player has in the game. More casually, you can think about it as a plan for everything in case somebody (including the player making the strategy) screws up somewhere along the way.
7,576
I would like to have help in producing examples of mathematicians that, in some sense I'll explain below,turned their career into failure. I am mainly interested in examples from XIX and XXth century. I'd like to hear of mathematicians that: * started their career in a very promising manner and then turned to pseudosciences, or devoted all their energies to "lost causes". * lost years and years in trying to prove statements that turned out to be wrong and/or for which there were not suitablly developed techniques. * lost their life in trying to support theories that turned out to be of little use/ of limited interest/ not well granted. * developed complete theories that rapidly went "out of fashion" and did never become fashionable again. * missed by little big opportunities of great results. * were very famous during their lifetime and are completely forgotten nowadays. I am of course thinking of reasonably well-known mathematicians, not of an obscure Molvanian guy that got lost in his studies. I list just one example which falls into some of this categories: Luigi Fantappié that became quite famous in the 30ies for his theory of analytic functionals. This theory was somewhat halted, since it needed a more abstract approach that was possible only after sheaf theory was developed in the 50ies. He then developed an alternative "final relativity theory" that was completely ignored by physicist (missing the opportunity to anticipate of some years the theory of Lie algebra deformations). He also devoted enormous amount of time to the so-called theory of sintropy which turned out being a bizarre mixture of pseudoscience, theological considerations, doubtful philosophical statements. No living mathematicians please.
2018/08/04
[ "https://hsm.stackexchange.com/questions/7576", "https://hsm.stackexchange.com", "https://hsm.stackexchange.com/users/1689/" ]
One possibility is Ted Kaczynski, the [Unabomber](https://en.wikipedia.org/wiki/Ted_Kaczynski). He has been described as a mathematical prodigy and [Allen Shields](https://en.wikipedia.org/wiki/Allen_Shields), his doctoral adviser, once told that Kaczynski was the best doctoral student he ever directed.
Two examples come to my mind but they are not to be taken too *seriously*. Our set theory professor in his lectures introduced [Bertrand Russell](https://www.youtube.com/watch?v=1bZv3pSaLtY) jokingly by saying that he had started off as a mathematician, then became a philosopher, then became a peace activist. The implication was that this was clearly a downhill career. My other example is [Oded Schramm](https://en.wikipedia.org/wiki/Oded_Schramm). He was a probability theorist, the inventor of Schramm–Loewner evolutions (SLE). His `failure' was that he died too early in a mountaineering accident (at the age of 46). I mean, he could have avoided it by not going into the mountains. I hope I didn't offend anybody's sensitivities. (But then one could list [Évariste Galois](https://en.wikipedia.org/wiki/%C3%89variste_Galois) as well, and possibly others.)
7,576
I would like to have help in producing examples of mathematicians that, in some sense I'll explain below,turned their career into failure. I am mainly interested in examples from XIX and XXth century. I'd like to hear of mathematicians that: * started their career in a very promising manner and then turned to pseudosciences, or devoted all their energies to "lost causes". * lost years and years in trying to prove statements that turned out to be wrong and/or for which there were not suitablly developed techniques. * lost their life in trying to support theories that turned out to be of little use/ of limited interest/ not well granted. * developed complete theories that rapidly went "out of fashion" and did never become fashionable again. * missed by little big opportunities of great results. * were very famous during their lifetime and are completely forgotten nowadays. I am of course thinking of reasonably well-known mathematicians, not of an obscure Molvanian guy that got lost in his studies. I list just one example which falls into some of this categories: Luigi Fantappié that became quite famous in the 30ies for his theory of analytic functionals. This theory was somewhat halted, since it needed a more abstract approach that was possible only after sheaf theory was developed in the 50ies. He then developed an alternative "final relativity theory" that was completely ignored by physicist (missing the opportunity to anticipate of some years the theory of Lie algebra deformations). He also devoted enormous amount of time to the so-called theory of sintropy which turned out being a bizarre mixture of pseudoscience, theological considerations, doubtful philosophical statements. No living mathematicians please.
2018/08/04
[ "https://hsm.stackexchange.com/questions/7576", "https://hsm.stackexchange.com", "https://hsm.stackexchange.com/users/1689/" ]
One possibility is Ted Kaczynski, the [Unabomber](https://en.wikipedia.org/wiki/Ted_Kaczynski). He has been described as a mathematical prodigy and [Allen Shields](https://en.wikipedia.org/wiki/Allen_Shields), his doctoral adviser, once told that Kaczynski was the best doctoral student he ever directed.
[Isaac Newton](https://en.wikipedia.org/wiki/Religious_views_of_Isaac_Newton) devoted much of his later life to religious speculations that even most religious people regard as having dubious value. In particular, he spent a lot of time on what are now generally termed [occult studies](https://en.wikipedia.org/wiki/Isaac_Newton%27s_occult_studies) such as alchemy and mystical interpretations of the Bible. Martin Gardner wrote an entertaining *Skeptical Inquirer* article on this topic, entitled "Isaac Newton: Alchemist and Fundamentalist." The article is reprinted in the anthology *Did Adam and Eve Have Navels?* --- **EDIT:** Here are a few quotes from Martin Gardner's article, to give some sense of how much effort Newton devoted to these studies. > > For a large part of his life Newton's time and energy were devoted to fruitless alchemy experiments and efforts to interpret Biblical prophecy. His handwritten manuscripts on those topics far exceed his writings about physics. They constitute several million words now scattered in rare book rooms of libraries and in private collections. … [Newton] read all the old books on alchemy he could find, accumulating more than 150 for his library. He built furnaces for endless experiments and left about a million words on the topic. … > > > Newton's passion for alchemy was exceeded only by his passion for Biblical prophecy. Incredible amounts of intellectual energy were spent trying to interpret the prophecies of Daniel in the Old Testament and the Book of Revelation in the New. He left more than a million words on these subjects, seeing himself as one who for the first time was correctly judging both books. … > > > Newton's writings on Biblical prophecy are so huge an embarrassment to his admirers that to this day they are downplayed or ignored. … [John Maynard] Keynes spoke of having gone through some million of Newton's words on alchemy and found them "wholly devoid of scientific value." > > >
7,576
I would like to have help in producing examples of mathematicians that, in some sense I'll explain below,turned their career into failure. I am mainly interested in examples from XIX and XXth century. I'd like to hear of mathematicians that: * started their career in a very promising manner and then turned to pseudosciences, or devoted all their energies to "lost causes". * lost years and years in trying to prove statements that turned out to be wrong and/or for which there were not suitablly developed techniques. * lost their life in trying to support theories that turned out to be of little use/ of limited interest/ not well granted. * developed complete theories that rapidly went "out of fashion" and did never become fashionable again. * missed by little big opportunities of great results. * were very famous during their lifetime and are completely forgotten nowadays. I am of course thinking of reasonably well-known mathematicians, not of an obscure Molvanian guy that got lost in his studies. I list just one example which falls into some of this categories: Luigi Fantappié that became quite famous in the 30ies for his theory of analytic functionals. This theory was somewhat halted, since it needed a more abstract approach that was possible only after sheaf theory was developed in the 50ies. He then developed an alternative "final relativity theory" that was completely ignored by physicist (missing the opportunity to anticipate of some years the theory of Lie algebra deformations). He also devoted enormous amount of time to the so-called theory of sintropy which turned out being a bizarre mixture of pseudoscience, theological considerations, doubtful philosophical statements. No living mathematicians please.
2018/08/04
[ "https://hsm.stackexchange.com/questions/7576", "https://hsm.stackexchange.com", "https://hsm.stackexchange.com/users/1689/" ]
[Alexander Abian](https://en.wikipedia.org/wiki/Alexander_Abian) may fit the bill here. His most notable contribution to mathematics was proving consistency and independence of four of the Zermelo-Fraenkel axioms. [source: Wolfram Mathworld](http://mathworld.wolfram.com/Zermelo-FraenkelAxioms.html). They are : *Extensionality*, *Replacement*, *Power set*, and *"Sum-set"* (i.e., *Union*). See, for example, Abian and LaMacchia's [Original Paper](https://pdfs.semanticscholar.org/9dce/c1b889ba513c42ea08dc564b9bdb3665c6b3.pdf). So far, so good. However, Abian spent the last 10 years of his life promoting his "Moonless Earth" theory. From the wikipedia article: > > Abian gained a degree of international notoriety for his claim that blowing up the Moon would solve virtually every problem of human existence. He made this claim in 1991 in a campus newspaper. Stating that a Moonless Earth wouldn't wobble, eliminating both the seasons and its associated events like heat waves, snowstorms and hurricanes. Refutations were given toward that idea by NASA saying that part of the exploded Moon would come back as a meteorite impacting the Earth and causing sufficient damage to extinguish all life, while restoring the seasons in the process. > > > Abian said that "Those critics who say 'Dismiss Abian's ideas' are very close to those who dismissed Galileo." This claim and others, made in thousands of Usenet posts during the last portion of his life, gained Abian mention (not entirely favorable) and even interviews in such diverse publications as Omni, People, Weekly World News, and The Wall Street Journal. > > >
Two examples come to my mind but they are not to be taken too *seriously*. Our set theory professor in his lectures introduced [Bertrand Russell](https://www.youtube.com/watch?v=1bZv3pSaLtY) jokingly by saying that he had started off as a mathematician, then became a philosopher, then became a peace activist. The implication was that this was clearly a downhill career. My other example is [Oded Schramm](https://en.wikipedia.org/wiki/Oded_Schramm). He was a probability theorist, the inventor of Schramm–Loewner evolutions (SLE). His `failure' was that he died too early in a mountaineering accident (at the age of 46). I mean, he could have avoided it by not going into the mountains. I hope I didn't offend anybody's sensitivities. (But then one could list [Évariste Galois](https://en.wikipedia.org/wiki/%C3%89variste_Galois) as well, and possibly others.)
7,576
I would like to have help in producing examples of mathematicians that, in some sense I'll explain below,turned their career into failure. I am mainly interested in examples from XIX and XXth century. I'd like to hear of mathematicians that: * started their career in a very promising manner and then turned to pseudosciences, or devoted all their energies to "lost causes". * lost years and years in trying to prove statements that turned out to be wrong and/or for which there were not suitablly developed techniques. * lost their life in trying to support theories that turned out to be of little use/ of limited interest/ not well granted. * developed complete theories that rapidly went "out of fashion" and did never become fashionable again. * missed by little big opportunities of great results. * were very famous during their lifetime and are completely forgotten nowadays. I am of course thinking of reasonably well-known mathematicians, not of an obscure Molvanian guy that got lost in his studies. I list just one example which falls into some of this categories: Luigi Fantappié that became quite famous in the 30ies for his theory of analytic functionals. This theory was somewhat halted, since it needed a more abstract approach that was possible only after sheaf theory was developed in the 50ies. He then developed an alternative "final relativity theory" that was completely ignored by physicist (missing the opportunity to anticipate of some years the theory of Lie algebra deformations). He also devoted enormous amount of time to the so-called theory of sintropy which turned out being a bizarre mixture of pseudoscience, theological considerations, doubtful philosophical statements. No living mathematicians please.
2018/08/04
[ "https://hsm.stackexchange.com/questions/7576", "https://hsm.stackexchange.com", "https://hsm.stackexchange.com/users/1689/" ]
Lucjan Emil Böttcher (1872–1937) might fit the bill. He got his PhD in Leipzig in 1898 under Sophus Lie and lectured at Lwow Polytechnics from 1901 until his retrement in 1935. His publications, starting with his PhD thesis, are full of ideas anticipating holomorphic dynamics (developed about 20 years later by Pierre Fatou and Gaston Julia), and his theorem on local behavior of a holomorphic function around its superattracting fixed point is well known (and referred to as Böttcher's theorem). It is amazing how much he accomplished without the notion of a normal family, introduced by Paul Montel, which gave solid foundations to holomorphic dynamics in one variable and accelerated its development. However, Böttcher's goal was to put iteration of holomorphic maps into the framework of Lie groups, which was a hopeless task. Besides, his writings were lacking in rigor, which is probably why his applications to extend his lecturing licence from Lwow Polytechnics to Lwow University met with failure (he tried 4 times). There were mathematicians at Lwow University familiar with complex variables and special functions (mainly Jozef Puzyna, a student of Weierstrass and an author of the first monograph in Polish on analytic functions, incorporating also elements of set theory and group theory), but they did not appreciate Böottcher's work. Böttcher continued teaching and popularizing activities (e.g., making Russell's paradox familiar to Lwow scholarly community), but did not publish any mathematical research after 1914. Around that time he became actively involved with spiritism and later published 2 brochures, on turning tables and on afterlife (this interest might have been influenced by his attending Wilhelm Wundt's lectures in Leipzig, possibly also by his earlier contact with Julian Ochorowicz, an inventor, publicist and spiritist, and Wundt's student). Judging from Lwow's newspapers, at the moment of his death he was more recognized as a “spiritual” activist than as a mathematician.
Two examples come to my mind but they are not to be taken too *seriously*. Our set theory professor in his lectures introduced [Bertrand Russell](https://www.youtube.com/watch?v=1bZv3pSaLtY) jokingly by saying that he had started off as a mathematician, then became a philosopher, then became a peace activist. The implication was that this was clearly a downhill career. My other example is [Oded Schramm](https://en.wikipedia.org/wiki/Oded_Schramm). He was a probability theorist, the inventor of Schramm–Loewner evolutions (SLE). His `failure' was that he died too early in a mountaineering accident (at the age of 46). I mean, he could have avoided it by not going into the mountains. I hope I didn't offend anybody's sensitivities. (But then one could list [Évariste Galois](https://en.wikipedia.org/wiki/%C3%89variste_Galois) as well, and possibly others.)
7,576
I would like to have help in producing examples of mathematicians that, in some sense I'll explain below,turned their career into failure. I am mainly interested in examples from XIX and XXth century. I'd like to hear of mathematicians that: * started their career in a very promising manner and then turned to pseudosciences, or devoted all their energies to "lost causes". * lost years and years in trying to prove statements that turned out to be wrong and/or for which there were not suitablly developed techniques. * lost their life in trying to support theories that turned out to be of little use/ of limited interest/ not well granted. * developed complete theories that rapidly went "out of fashion" and did never become fashionable again. * missed by little big opportunities of great results. * were very famous during their lifetime and are completely forgotten nowadays. I am of course thinking of reasonably well-known mathematicians, not of an obscure Molvanian guy that got lost in his studies. I list just one example which falls into some of this categories: Luigi Fantappié that became quite famous in the 30ies for his theory of analytic functionals. This theory was somewhat halted, since it needed a more abstract approach that was possible only after sheaf theory was developed in the 50ies. He then developed an alternative "final relativity theory" that was completely ignored by physicist (missing the opportunity to anticipate of some years the theory of Lie algebra deformations). He also devoted enormous amount of time to the so-called theory of sintropy which turned out being a bizarre mixture of pseudoscience, theological considerations, doubtful philosophical statements. No living mathematicians please.
2018/08/04
[ "https://hsm.stackexchange.com/questions/7576", "https://hsm.stackexchange.com", "https://hsm.stackexchange.com/users/1689/" ]
[Isaac Newton](https://en.wikipedia.org/wiki/Religious_views_of_Isaac_Newton) devoted much of his later life to religious speculations that even most religious people regard as having dubious value. In particular, he spent a lot of time on what are now generally termed [occult studies](https://en.wikipedia.org/wiki/Isaac_Newton%27s_occult_studies) such as alchemy and mystical interpretations of the Bible. Martin Gardner wrote an entertaining *Skeptical Inquirer* article on this topic, entitled "Isaac Newton: Alchemist and Fundamentalist." The article is reprinted in the anthology *Did Adam and Eve Have Navels?* --- **EDIT:** Here are a few quotes from Martin Gardner's article, to give some sense of how much effort Newton devoted to these studies. > > For a large part of his life Newton's time and energy were devoted to fruitless alchemy experiments and efforts to interpret Biblical prophecy. His handwritten manuscripts on those topics far exceed his writings about physics. They constitute several million words now scattered in rare book rooms of libraries and in private collections. … [Newton] read all the old books on alchemy he could find, accumulating more than 150 for his library. He built furnaces for endless experiments and left about a million words on the topic. … > > > Newton's passion for alchemy was exceeded only by his passion for Biblical prophecy. Incredible amounts of intellectual energy were spent trying to interpret the prophecies of Daniel in the Old Testament and the Book of Revelation in the New. He left more than a million words on these subjects, seeing himself as one who for the first time was correctly judging both books. … > > > Newton's writings on Biblical prophecy are so huge an embarrassment to his admirers that to this day they are downplayed or ignored. … [John Maynard] Keynes spoke of having gone through some million of Newton's words on alchemy and found them "wholly devoid of scientific value." > > >
Two examples come to my mind but they are not to be taken too *seriously*. Our set theory professor in his lectures introduced [Bertrand Russell](https://www.youtube.com/watch?v=1bZv3pSaLtY) jokingly by saying that he had started off as a mathematician, then became a philosopher, then became a peace activist. The implication was that this was clearly a downhill career. My other example is [Oded Schramm](https://en.wikipedia.org/wiki/Oded_Schramm). He was a probability theorist, the inventor of Schramm–Loewner evolutions (SLE). His `failure' was that he died too early in a mountaineering accident (at the age of 46). I mean, he could have avoided it by not going into the mountains. I hope I didn't offend anybody's sensitivities. (But then one could list [Évariste Galois](https://en.wikipedia.org/wiki/%C3%89variste_Galois) as well, and possibly others.)
7,576
I would like to have help in producing examples of mathematicians that, in some sense I'll explain below,turned their career into failure. I am mainly interested in examples from XIX and XXth century. I'd like to hear of mathematicians that: * started their career in a very promising manner and then turned to pseudosciences, or devoted all their energies to "lost causes". * lost years and years in trying to prove statements that turned out to be wrong and/or for which there were not suitablly developed techniques. * lost their life in trying to support theories that turned out to be of little use/ of limited interest/ not well granted. * developed complete theories that rapidly went "out of fashion" and did never become fashionable again. * missed by little big opportunities of great results. * were very famous during their lifetime and are completely forgotten nowadays. I am of course thinking of reasonably well-known mathematicians, not of an obscure Molvanian guy that got lost in his studies. I list just one example which falls into some of this categories: Luigi Fantappié that became quite famous in the 30ies for his theory of analytic functionals. This theory was somewhat halted, since it needed a more abstract approach that was possible only after sheaf theory was developed in the 50ies. He then developed an alternative "final relativity theory" that was completely ignored by physicist (missing the opportunity to anticipate of some years the theory of Lie algebra deformations). He also devoted enormous amount of time to the so-called theory of sintropy which turned out being a bizarre mixture of pseudoscience, theological considerations, doubtful philosophical statements. No living mathematicians please.
2018/08/04
[ "https://hsm.stackexchange.com/questions/7576", "https://hsm.stackexchange.com", "https://hsm.stackexchange.com/users/1689/" ]
[Alexander Abian](https://en.wikipedia.org/wiki/Alexander_Abian) may fit the bill here. His most notable contribution to mathematics was proving consistency and independence of four of the Zermelo-Fraenkel axioms. [source: Wolfram Mathworld](http://mathworld.wolfram.com/Zermelo-FraenkelAxioms.html). They are : *Extensionality*, *Replacement*, *Power set*, and *"Sum-set"* (i.e., *Union*). See, for example, Abian and LaMacchia's [Original Paper](https://pdfs.semanticscholar.org/9dce/c1b889ba513c42ea08dc564b9bdb3665c6b3.pdf). So far, so good. However, Abian spent the last 10 years of his life promoting his "Moonless Earth" theory. From the wikipedia article: > > Abian gained a degree of international notoriety for his claim that blowing up the Moon would solve virtually every problem of human existence. He made this claim in 1991 in a campus newspaper. Stating that a Moonless Earth wouldn't wobble, eliminating both the seasons and its associated events like heat waves, snowstorms and hurricanes. Refutations were given toward that idea by NASA saying that part of the exploded Moon would come back as a meteorite impacting the Earth and causing sufficient damage to extinguish all life, while restoring the seasons in the process. > > > Abian said that "Those critics who say 'Dismiss Abian's ideas' are very close to those who dismissed Galileo." This claim and others, made in thousands of Usenet posts during the last portion of his life, gained Abian mention (not entirely favorable) and even interviews in such diverse publications as Omni, People, Weekly World News, and The Wall Street Journal. > > >
[Isaac Newton](https://en.wikipedia.org/wiki/Religious_views_of_Isaac_Newton) devoted much of his later life to religious speculations that even most religious people regard as having dubious value. In particular, he spent a lot of time on what are now generally termed [occult studies](https://en.wikipedia.org/wiki/Isaac_Newton%27s_occult_studies) such as alchemy and mystical interpretations of the Bible. Martin Gardner wrote an entertaining *Skeptical Inquirer* article on this topic, entitled "Isaac Newton: Alchemist and Fundamentalist." The article is reprinted in the anthology *Did Adam and Eve Have Navels?* --- **EDIT:** Here are a few quotes from Martin Gardner's article, to give some sense of how much effort Newton devoted to these studies. > > For a large part of his life Newton's time and energy were devoted to fruitless alchemy experiments and efforts to interpret Biblical prophecy. His handwritten manuscripts on those topics far exceed his writings about physics. They constitute several million words now scattered in rare book rooms of libraries and in private collections. … [Newton] read all the old books on alchemy he could find, accumulating more than 150 for his library. He built furnaces for endless experiments and left about a million words on the topic. … > > > Newton's passion for alchemy was exceeded only by his passion for Biblical prophecy. Incredible amounts of intellectual energy were spent trying to interpret the prophecies of Daniel in the Old Testament and the Book of Revelation in the New. He left more than a million words on these subjects, seeing himself as one who for the first time was correctly judging both books. … > > > Newton's writings on Biblical prophecy are so huge an embarrassment to his admirers that to this day they are downplayed or ignored. … [John Maynard] Keynes spoke of having gone through some million of Newton's words on alchemy and found them "wholly devoid of scientific value." > > >
7,576
I would like to have help in producing examples of mathematicians that, in some sense I'll explain below,turned their career into failure. I am mainly interested in examples from XIX and XXth century. I'd like to hear of mathematicians that: * started their career in a very promising manner and then turned to pseudosciences, or devoted all their energies to "lost causes". * lost years and years in trying to prove statements that turned out to be wrong and/or for which there were not suitablly developed techniques. * lost their life in trying to support theories that turned out to be of little use/ of limited interest/ not well granted. * developed complete theories that rapidly went "out of fashion" and did never become fashionable again. * missed by little big opportunities of great results. * were very famous during their lifetime and are completely forgotten nowadays. I am of course thinking of reasonably well-known mathematicians, not of an obscure Molvanian guy that got lost in his studies. I list just one example which falls into some of this categories: Luigi Fantappié that became quite famous in the 30ies for his theory of analytic functionals. This theory was somewhat halted, since it needed a more abstract approach that was possible only after sheaf theory was developed in the 50ies. He then developed an alternative "final relativity theory" that was completely ignored by physicist (missing the opportunity to anticipate of some years the theory of Lie algebra deformations). He also devoted enormous amount of time to the so-called theory of sintropy which turned out being a bizarre mixture of pseudoscience, theological considerations, doubtful philosophical statements. No living mathematicians please.
2018/08/04
[ "https://hsm.stackexchange.com/questions/7576", "https://hsm.stackexchange.com", "https://hsm.stackexchange.com/users/1689/" ]
Lucjan Emil Böttcher (1872–1937) might fit the bill. He got his PhD in Leipzig in 1898 under Sophus Lie and lectured at Lwow Polytechnics from 1901 until his retrement in 1935. His publications, starting with his PhD thesis, are full of ideas anticipating holomorphic dynamics (developed about 20 years later by Pierre Fatou and Gaston Julia), and his theorem on local behavior of a holomorphic function around its superattracting fixed point is well known (and referred to as Böttcher's theorem). It is amazing how much he accomplished without the notion of a normal family, introduced by Paul Montel, which gave solid foundations to holomorphic dynamics in one variable and accelerated its development. However, Böttcher's goal was to put iteration of holomorphic maps into the framework of Lie groups, which was a hopeless task. Besides, his writings were lacking in rigor, which is probably why his applications to extend his lecturing licence from Lwow Polytechnics to Lwow University met with failure (he tried 4 times). There were mathematicians at Lwow University familiar with complex variables and special functions (mainly Jozef Puzyna, a student of Weierstrass and an author of the first monograph in Polish on analytic functions, incorporating also elements of set theory and group theory), but they did not appreciate Böottcher's work. Böttcher continued teaching and popularizing activities (e.g., making Russell's paradox familiar to Lwow scholarly community), but did not publish any mathematical research after 1914. Around that time he became actively involved with spiritism and later published 2 brochures, on turning tables and on afterlife (this interest might have been influenced by his attending Wilhelm Wundt's lectures in Leipzig, possibly also by his earlier contact with Julian Ochorowicz, an inventor, publicist and spiritist, and Wundt's student). Judging from Lwow's newspapers, at the moment of his death he was more recognized as a “spiritual” activist than as a mathematician.
[Isaac Newton](https://en.wikipedia.org/wiki/Religious_views_of_Isaac_Newton) devoted much of his later life to religious speculations that even most religious people regard as having dubious value. In particular, he spent a lot of time on what are now generally termed [occult studies](https://en.wikipedia.org/wiki/Isaac_Newton%27s_occult_studies) such as alchemy and mystical interpretations of the Bible. Martin Gardner wrote an entertaining *Skeptical Inquirer* article on this topic, entitled "Isaac Newton: Alchemist and Fundamentalist." The article is reprinted in the anthology *Did Adam and Eve Have Navels?* --- **EDIT:** Here are a few quotes from Martin Gardner's article, to give some sense of how much effort Newton devoted to these studies. > > For a large part of his life Newton's time and energy were devoted to fruitless alchemy experiments and efforts to interpret Biblical prophecy. His handwritten manuscripts on those topics far exceed his writings about physics. They constitute several million words now scattered in rare book rooms of libraries and in private collections. … [Newton] read all the old books on alchemy he could find, accumulating more than 150 for his library. He built furnaces for endless experiments and left about a million words on the topic. … > > > Newton's passion for alchemy was exceeded only by his passion for Biblical prophecy. Incredible amounts of intellectual energy were spent trying to interpret the prophecies of Daniel in the Old Testament and the Book of Revelation in the New. He left more than a million words on these subjects, seeing himself as one who for the first time was correctly judging both books. … > > > Newton's writings on Biblical prophecy are so huge an embarrassment to his admirers that to this day they are downplayed or ignored. … [John Maynard] Keynes spoke of having gone through some million of Newton's words on alchemy and found them "wholly devoid of scientific value." > > >
29,436,804
I have a string which is very long. I would like to split this string into substrings 16 characters long, skipping one character every time (e.g. substring1=first 16 elements of the string, substring2 from element 18 to element 34 and so on) and list them. I wrote the following code: ``` string="abcd..." list=[] for j in range(0,int(len(string)/17)-1): list.append(string[int(j*17):int(j*17+16)]) ``` But it returns: ``` list=[] ``` I can't figure out what is wrong with this code.
2015/04/03
[ "https://Stackoverflow.com/questions/29436804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4743279/" ]
It seems to me that you have to customise the admin-view for your models. It is a task that you have to do for your models if they are not displayed correctly "out of the box". In most of the cases you don't have to fully rewrite the views. In most of the cases it will be enough to customise built-in views. I don't have any experience developing for flask, but you will basically have to subclass `ModelView`. and register the subclass to the admin ```python #Customized admin views class ExerciseQuestionView(ModelView): # # add customisation code here # class MultipleAnswerMCQExerciseQuestionView(ModelView): # # add customisation code here # class UniqueAnswerMCQExerciseQuestionView(ModelView): # # add customisation code here # if __name__ == '__main__': # Create admin admin = admin.Admin(app, 'Example: MongoEngine') # Add admin views admin.add_view(ExerciseQuestionView(ExerciseQuestion)) admin.add_view(MultipleAnswerMCQExerciseQuestionView(MultipleAnswerMCQExerciseQuestion)) admin.add_view(UniqueAnswerMCQExerciseQuestionView(UniqueAnswerMCQExerciseQuestion)) #... ``` Anyway i think you should go through the documentation... or you may end up waiting too long here... <http://flask-admin.readthedocs.io/en/latest/api/mod_contrib_mongoengine/>
``` import time sentence = "ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY" s = sentence.split() another = [0] time.sleep(0.5) print(sentence) for count, i in enumerate(s): if s.count(i) < 2: another.append(max(another) + 1) else: another.append(s.index(i) +1) another.remove(0) time.sleep(0.5) print(another) file = open("N:\(Filedirectory)","w") file.write(another) file.write(s) ```
69,209,618
I am trying to make a `GET` request to the [International Space station REST API](https://api.wheretheiss.at/v1/satellites/25544) as a test from PLSQL, but it is giving me a `ORA-29273: HTTP request failed` error. My code is this: ``` declare l_url varchar2(32767) := 'https://api.wheretheiss.at/v1/satellites/25544'; l_http_request utl_http.req; l_http_response utl_http.resp; l_text varchar2(32767); begin -- Make a HTTP request and get the response. l_http_request := utl_http.begin_request(l_url); -- Use basic authentication if required. --IF p_username IS NOT NULL and p_password IS NOT NULL THEN -- UTL_HTTP.set_authentication(l_http_request, p_username, p_password); --END IF; l_http_response := utl_http.get_response(l_http_request); -- Loop through the response. begin loop utl_http.read_text(l_http_response, l_text, 32766); dbms_output.put_line(l_text); end loop; exception when utl_http.end_of_body then utl_http.end_response(l_http_response); end; exception when others then utl_http.end_response(l_http_response); raise; end; ``` And the error is this: ``` ORA-29273: HTTP request failed ORA-06512: at line 27 ORA-29259: end-of-input reached ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at line 8 ``` Anybody know what the problem is or how to correctly make a `GET` request to a REST API endpoint url?
2021/09/16
[ "https://Stackoverflow.com/questions/69209618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/941397/" ]
Depending on how the webpack based code does manage the tab handling of resources one possible solution was to wrap own code around `window.open` or even entirely replace it with an own implementation. As for the wrapping, based on the intercepted data, one could decide of whether one does suppress the url-handling entirely or, instead of opening a new tab/window, does a forwarding to `location.href` or even proceed with invoking the original `window.open`. ```js // untouchable 3rd party code // function alienLocationHandler({ currentTarget }) { let { url, target } = currentTarget.dataset; url = (url ?? '').trim(); if (url) { target = (target ?? '').trim(); if (target) { // due to SO's permission handling ... // // ... Blocked opening 'https://stackoverflow.com/' in a // new window because the request was made in a sandboxed // frame whose 'allow-popups' permission is not set. // window.open(url, target); } else { window.location.href = url; } } } document .querySelectorAll('[data-url]') .forEach(elmNode => elmNode.addEventListener('click', alienLocationHandler) ); // one possible approach :: wrap around `window.open` // window.open = (function createAroundHandler(proceed, thisArg) { return function aroundWindowOpen(url, target, ...rest) { console.log('aroundWindowOpen ...', { url, target, rest, }); // - of cause all the code is just for demonstration purpose. // // - the OP has to come up with own handler logic which does // fit the OP's needs best. if (url !== 'https://stackoverflow.com') { // invocation of the original `window.open` // will be blocked by SO's permission handling. proceed.call(thisArg, url, target, ...rest); } else { // delayed fowarding to `location.href`. setTimeout(() => { window.location.href = url }, 5000); } }; }(window.open, window)); ``` ```css body { margin: 0; } .as-console-wrapper { min-height: 87%; top: auto; } ``` ```html <button data-url="https://stackoverflow.com"> no interception </button> <button data-url="https://google.com" data-target='google' > intercepted &amp; open attempt </button> <button id="_653cde4c-1620-11ec-85b5-5ae26c154b46" data-url="https://stackoverflow.com" data-target='_blank' > intercepted and forwarded with 5sec delay </button> ``` Another approach was to make use of [event delegation](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#event_delegation) by listening to and handling `click` events at e.g. `document.body` level. ```js // untouchable 3rd party code // function alienLocationHandler({ currentTarget }) { let { url, target } = currentTarget.dataset; url = (url ?? '').trim(); if (url) { target = (target ?? '').trim(); if (target) { // due to SO's permission handling ... // // ... Blocked opening 'https://stackoverflow.com/' in a // new window because the request was made in a sandboxed // frame whose 'allow-popups' permission is not set. // window.open(url, target); } else { window.location.href = url; } } } document .querySelectorAll('[data-url]') .forEach(elmNode => elmNode.addEventListener('click', alienLocationHandler) ); // another possible approach :: event delegation // // - [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#event_delegation] // - [https://davidwalsh.name/event-delegate] // // - [https://javascript.info/event-delegation] // - [https://learn.jquery.com/events/event-delegation/] // function isButtonEvent(activeElement, targetNode) { return (activeElement.tagName.toLowerCase() === 'button') && ( activeElement.isSameNode(targetNode) || activeElement.contains(targetNode) ); } function preventSpecificButtonClickBehavior(evt) { const elmButton = document.activeElement; if (isButtonEvent(elmButton, evt.target)) { const url = (elmButton.dataset.url ?? '').trim(); const isUrlBasedPrevented = (url !== 'https://stackoverflow.com'); const isIdBasedPrevented = ((elmButton.id ?? '').trim() !== ''); if (isUrlBasedPrevented || isIdBasedPrevented) { evt.stopImmediatePropagation(); evt.stopPropagation(); if (isUrlBasedPrevented) { console.log('prevented button click behavior ... URL based') } if (isIdBasedPrevented) { console.log('prevented button click behavior ... ID based') } } } } document .body .addEventListener( 'click', preventSpecificButtonClickBehavior, // - [https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters] // - The boolean `useCapture` parameter/flag does the trick if set as `true` value. true ); ``` ```css body { margin: 0; } .as-console-wrapper { min-height: 87%; top: auto; } ``` ```html <button data-url="https://stackoverflow.com"> click behavior not prevented </button> <button id="_653cde4c-1620-11ec-85b5-5ae26c154b46" data-url="https://stackoverflow.com" > prevented behavior (id based) </button> <button data-url="https://google.com" data-target='google' > <span> <span> prevented behavior (url based) </span> </span> </button> ```
Probably the logic in the `onClick()` does something like `window.open(url, [params])`. You can change this to setting `window.location.href = url;` and the url will be loaded in the same window.
21,251,875
I'm unit testing my application and I get a `NotFoundHttpException` when trying to call controller actions with `TestCase::callSecure()` and the `route()` helper. For those tests (only a few) I have also enabled filters with `Route::enableFilters`. My filters.php: ``` App::before( function ($request) { // force ssl if (!$request->isSecure()) { return Redirect::secure($request->getRequestUri()); } } ); // some authentication Route::filter('auth.api', 'Authentication'); ``` My routes.php: ``` Route::post('login', array('as' => 'login', 'uses' => 'AuthenticationController@login')); Route::post('register', array('as' => 'register', 'uses' => 'AuthenticationController@register')); ``` Example Test where i get the exception: ``` $credentials = [ // ... ]; $response = $this->callSecure('POST', route('login'), $credentials); ``` When i call those actions by their path, it works fine. ``` $credentials = [ // ... ]; $response = $this->callSecure('POST', '/login', $credentials); ``` Is this intended or a bug?
2014/01/21
[ "https://Stackoverflow.com/questions/21251875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/985521/" ]
The [route()](http://laravel.com/docs/helpers#urls) helper will generate a [URL](http://en.wikipedia.org/wiki/Uniform_resource_locator) (including the relevant protocol, i.e. http/s) for the given named route. In your case, it'll return something like: > > <https://example.com/login> > > > Which isn't what you want. This is useful when you want to perform a redirect, for example: ``` Redirect::route('login'); ``` So what you're doing in your last example, is the correct way to be doing what you want; as you don't want to pass the full URL as a parameter to your callSecure() function. ``` $response = $this->callSecure('POST', '/login', $credentials); ``` And as dave has mentioned, you can generate a relative URL by using URL::route and pass an `$absolute` parameter which defaults to `true`. For example, when using named routes you can use the following: ``` $route = URL::route('profile', array(), false); ``` Which will generate a relative URL like `/profile`
The `route()` helper does not create relative URLs, which is what you really want. To generate a relative URL, you can use `URL::route` as it allows you to pass a `$absolute` parameter which defaults to true. So to get your relative url using a named route, you could do ``` $credentials = [ // ... ]; $route = URL::route('login', array(), false); $response = $this->callSecure('POST', $route, $credentials); ``` While the `'/login'` method is correct, it defeats the purpose of using named routes if you still have to hunt down all the places where you have that URL if/when you decide to change it.
54,902,157
I am trying to make an audio-only player using python for a small project. The script I am using is as follows: ``` #!/usr/bin/env python import re import sys import pafy import vlc url = "https://www.youtube.com/watch?v=G0OqIkgZqlA" video = pafy.new(url) best = video.getbestaudio() playurl = best.url player = vlc.MediaPlayer(playurl) player.play() while True: pass ``` Now, this script works great on my work machine running manjaro and the following python version: ``` Python 3.7.2 (default, Jan 10 2019, 23:51:51) ``` The machine I plan to run this script is a raspberry pi zero W running raspbian stretch and I set it to run this python version: ``` Python 3.5.3 (default, Sep 27 2018, 17:25:39) ``` When I run this script on the raspberry pi I get nothing and when I stop it I get the following messages: ``` Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/youtube_dl/extractor/__init__.py", line 4, in <module> from .lazy_extractors import * ImportError: No module named 'youtube_dl.extractor.lazy_extractors' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "box.py", line 4, in <module> import pafy File "/usr/local/lib/python3.5/dist-packages/pafy/__init__.py", line 7, in <module> from .pafy import new File "/usr/local/lib/python3.5/dist-packages/pafy/pafy.py", line 48, in <module> import youtube_dl File "/usr/local/lib/python3.5/dist-packages/youtube_dl/__init__.py", line 43, in <module> from .extractor import gen_extractors, list_extractors File "/usr/local/lib/python3.5/dist-packages/youtube_dl/extractor/__init__.py", line 9, in <module> from .extractors import * File "/usr/local/lib/python3.5/dist-packages/youtube_dl/extractor/extractors.py", line 732, in <module> from .newgrounds import ( File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 896, in _find_spec File "<frozen importlib._bootstrap_external>", line 1147, in find_spec File "<frozen importlib._bootstrap_external>", line 1121, in _get_spec File "<frozen importlib._bootstrap_external>", line 1229, in find_spec File "<frozen importlib._bootstrap_external>", line 82, in _path_stat KeyboardInterrupt ``` Running the commands one by one, I think I found the problem with the `vlc module`. When the script reaches the following command: ``` player=vlc.MediaPlayer(playurl) ``` I get: ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'vlc' has no attribute 'MediaPlayer' ``` For reference I used pip3 to install python-vlc, pafy and youtube\_dl modules. This is my first ever experience with Python. I got this far by reading from several posts on here and other sites. This completely confuses me and I have no idea what to do to make it work. It is entirely possible that there is a problem with the python installation on raspbian (I am using a completely fresh install, only last night I reinstalled it again!). The only thing I added to the fresh raspbian install was to update the system, install git and a few other programs. Can someone please help me out?
2019/02/27
[ "https://Stackoverflow.com/questions/54902157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4873946/" ]
The problem seems to be related to two versions of vlc package (32 bit vs 64bit). There are two ways to install it as well: python-vlc vs vlc. Please check which system version you have and install the correct package version for it. You may still experience the same problem I had where I was missing some DLLs. I hope the following links will help: [Python vlc install problems](https://stackoverflow.com/questions/42045887/python-vlc-install-problems) [Error when importingPython-vlc](https://stackoverflow.com/questions/42105208/error-when-importingpython-vlc) [Import Vlc module in python](https://stackoverflow.com/questions/38265773/import-vlc-module-in-python) 1. `pip install vlc` does not have the MediaPlayer class 2. `pip install python-vlc` has the MediaPlayer class but gives a DLL lib error
For simplicity, place the `vlc.py` program in the same directory as your program. Then this is the simplest form of getting `vlc` to play something ``` url = "file:///home/rolf/GWPE.mp4" import vlc playing = set([1,2,3,4]) instance=vlc.Instance() player=instance.media_player_new() player.set_mrl(url) player.play() while True: state = player.get_state() if state not in playing: break ``` Not sure what the `pafy` part is about but the above will play a local file and I suspect whatever pafy passes to it.
46,257,489
I'm very much a beginning programmer, trying to grasp the details of event handling. And I'm breaking my head over a problem. See below: ``` public class Knop_ClickEventArgs : System.EventArgs { //Here comes code that still needs to be written. } static void Knop_Click(object sender, Knop_ClickEventArgs e) { Canvas canvas = new Canvas(); Application.Run(canvas); } public PromptScherm() { //Deleted some code here that is most likely uninteresting Button Knop = new Button(); // Deleted uninteresting code here as well this.Controls.Add(Knop); Knop.Click += Knop_Click; } ``` This (shortened) piece of code gives the `CS0123` error, describing that my `Knop_Click` method does not match the delegate `EventHandler`. I've pinpointed that the problem is with the `Knop_ClickEventArgs`, because if I replace that with `System.EventArgs` it works fine. However, since I specify in the definition of `Knop_ClickEventArgs` that it is a specific instance of `System.EventArgs`, it puzzles me why that would cause a problem?
2017/09/16
[ "https://Stackoverflow.com/questions/46257489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8620027/" ]
When you add a handler to the `Click` event of a control, (in this case, a `Button` that you call `Knop`,) the `Button` will be invoking your handler passing it `object sender, System.EventArgs e`. This means that: * it is impossible to define your handler as accepting your own event class instead of `System.EventArgs`, * If the compiler allowed you to do so, you would be in real trouble, because `Button` would still be passing a `System.EventArgs` to your handler, completely ignoring your wishes to receive something else instead. Your plan to add code to your event class tells me that perhaps there is something you have not understood about events and event-passing. Events are supposed to carry data, they are not supposed to contain code.
You are getting it all wrong. you just need a appropriate event handler attached to Click event. ``` static void Knop_Click(object sender, EventArgs e) { } // ... Knop.Click += Knop_Click; ``` Now this method will be called when Button fires Click event. you can not change signature because that's how button fires this event. something like this. ``` Click.Invoke(this, EventArgs.Empty); // "this" refers to button it self. ``` Now in `Knop_Click` you receive arguments that Button has just passed to. ``` static void Knop_Click(object sender, EventArgs e) { var btn = (Button)sender; // do some logic. } ``` Now what do you expect to happen if you change signature? what you want cant be achieved because EventArgs is base class, and Button is passing EventArgs, it cant be converted to your derived class. You must clarify what your goal is. clarify what code needs to be written, so we can suggest right place for it