qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
510,152
Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it. Is it a good practice to run scripts (BASH, Perl etc.) from another directory? Will they usually find all the stuff they need to run properly? If so, what is the best way to run a "distant" sc...
2012/11/24
[ "https://superuser.com/questions/510152", "https://superuser.com", "https://superuser.com/users/105968/" ]
Say you want to run `./script` and the path is `/home/test/stuff/` But the path you're currently in is `/home/test/public_html/a/` Then you would need to do `../../stuff/./script` Which goes back 2 folders, then into into the folder there and run the script.
I'm not sure it works like this in linux, assuming it doesn't if no-ones suggested it. But instead of using ././ to go back directories. Can you use quotes to give it an absolute path? Maybe it doesn't give you access to the whole drive to even be able to do that actually come to think of it.
510,152
Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it. Is it a good practice to run scripts (BASH, Perl etc.) from another directory? Will they usually find all the stuff they need to run properly? If so, what is the best way to run a "distant" sc...
2012/11/24
[ "https://superuser.com/questions/510152", "https://superuser.com", "https://superuser.com/users/105968/" ]
I usually do like you say ``` sh /path/to/script ``` And to run it as root/superuser ``` sudo sh /path/to/script ``` Your current directory only matters if the scripts assumes you are in the same folder as it. I would assume most scripts don't do this and you are save to run it like above.
I usually keep my scripts in `/usr/local/bin` or `/usr/local/sbin/` (if the script needs root privileges) where, according to the Filesystem Hierarchy Standard (FHS), they belong. All you have to do is to make sure these two directories are added to your `PATH`. You can do this by editing your `$HOME/.bashrc` file and...
510,152
Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it. Is it a good practice to run scripts (BASH, Perl etc.) from another directory? Will they usually find all the stuff they need to run properly? If so, what is the best way to run a "distant" sc...
2012/11/24
[ "https://superuser.com/questions/510152", "https://superuser.com", "https://superuser.com/users/105968/" ]
sh /path/to/script will spawn a new shell and run she script independent of your current shell. The `source` (.) command will call all the commands in the script in the current shell. If the script happens to call `exit` for example, then you'll lose the current shell. Because of this it is usually safer to call script...
I usually keep my scripts in `/usr/local/bin` or `/usr/local/sbin/` (if the script needs root privileges) where, according to the Filesystem Hierarchy Standard (FHS), they belong. All you have to do is to make sure these two directories are added to your `PATH`. You can do this by editing your `$HOME/.bashrc` file and...
510,152
Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it. Is it a good practice to run scripts (BASH, Perl etc.) from another directory? Will they usually find all the stuff they need to run properly? If so, what is the best way to run a "distant" sc...
2012/11/24
[ "https://superuser.com/questions/510152", "https://superuser.com", "https://superuser.com/users/105968/" ]
I usually keep my scripts in `/usr/local/bin` or `/usr/local/sbin/` (if the script needs root privileges) where, according to the Filesystem Hierarchy Standard (FHS), they belong. All you have to do is to make sure these two directories are added to your `PATH`. You can do this by editing your `$HOME/.bashrc` file and...
I'm not sure it works like this in linux, assuming it doesn't if no-ones suggested it. But instead of using ././ to go back directories. Can you use quotes to give it an absolute path? Maybe it doesn't give you access to the whole drive to even be able to do that actually come to think of it.
510,152
Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it. Is it a good practice to run scripts (BASH, Perl etc.) from another directory? Will they usually find all the stuff they need to run properly? If so, what is the best way to run a "distant" sc...
2012/11/24
[ "https://superuser.com/questions/510152", "https://superuser.com", "https://superuser.com/users/105968/" ]
sh /path/to/script will spawn a new shell and run she script independent of your current shell. The `source` (.) command will call all the commands in the script in the current shell. If the script happens to call `exit` for example, then you'll lose the current shell. Because of this it is usually safer to call script...
I usually do like you say ``` sh /path/to/script ``` And to run it as root/superuser ``` sudo sh /path/to/script ``` Your current directory only matters if the scripts assumes you are in the same folder as it. I would assume most scripts don't do this and you are save to run it like above.
75,214
I copied 3.62 GB of data on to a re-writable DVD instead of erasing it. Now there is no data on the disc but it shows used space as 3.62 GB and 690 MB of free space. Now I am unable to erase my disc. What should I do to erase the disc and get the space back?
2009/11/25
[ "https://superuser.com/questions/75214", "https://superuser.com", "https://superuser.com/users/96938/" ]
You aren't supposed to format a DVD-RW. Use something like [CDBurnerXP](http://cdburnerxp.se/)'s erase function: ![alt text](https://i.stack.imgur.com/N3NwX.png)
As stated elsewhere, you need to erase the DVD-RW before using it again. I have a very simple low profile program I use called Active@DVD Eraser located here:<http://www.ntfs.com/dvd_eraser.htm>
75,214
I copied 3.62 GB of data on to a re-writable DVD instead of erasing it. Now there is no data on the disc but it shows used space as 3.62 GB and 690 MB of free space. Now I am unable to erase my disc. What should I do to erase the disc and get the space back?
2009/11/25
[ "https://superuser.com/questions/75214", "https://superuser.com", "https://superuser.com/users/96938/" ]
Another free alternative: [ImgBurn](http://www.imgburn.com/) ![ImgBurn](https://i.stack.imgur.com/BVxpl.png)
As stated elsewhere, you need to erase the DVD-RW before using it again. I have a very simple low profile program I use called Active@DVD Eraser located here:<http://www.ntfs.com/dvd_eraser.htm>
75,214
I copied 3.62 GB of data on to a re-writable DVD instead of erasing it. Now there is no data on the disc but it shows used space as 3.62 GB and 690 MB of free space. Now I am unable to erase my disc. What should I do to erase the disc and get the space back?
2009/11/25
[ "https://superuser.com/questions/75214", "https://superuser.com", "https://superuser.com/users/96938/" ]
if you don't want to install additional software, use **[InfraRecorder](http://infrarecorder.org/)** Portable. Go to **Actions** > **Erase/Format Disc...**
As stated elsewhere, you need to erase the DVD-RW before using it again. I have a very simple low profile program I use called Active@DVD Eraser located here:<http://www.ntfs.com/dvd_eraser.htm>
150,258
Someone moved a very important page on my website into the trash, and I do not know who did it! It was not deleted permanently so I don't need to worry, in that sense. The revisions, when I restored it, show that someone edited it 3 days prior to today, so it could have been them, but I can't be sure. Does WP keep tr...
2014/06/20
[ "https://wordpress.stackexchange.com/questions/150258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15209/" ]
By default, no, WordPress doesn't keep track of who changes post statuses (at least that I can see). you can hook into `transition_post_status` and log the user id. ``` add_action( 'transition_post_status', 'wwm_transition_post_status', 10, 3 ); function wwm_transition_post_status( $new_status, $old_status, ...
No, natively WordPress does not log any activity. While plugins for it exist, they won't work retroactively. However don't forget that any action taken in WordPress is technically a HTTP request, such as page load, form submit, or Ajax request. These are often logged pretty thoroughly in web server's access log and i...
150,258
Someone moved a very important page on my website into the trash, and I do not know who did it! It was not deleted permanently so I don't need to worry, in that sense. The revisions, when I restored it, show that someone edited it 3 days prior to today, so it could have been them, but I can't be sure. Does WP keep tr...
2014/06/20
[ "https://wordpress.stackexchange.com/questions/150258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15209/" ]
By default, no, WordPress doesn't keep track of who changes post statuses (at least that I can see). you can hook into `transition_post_status` and log the user id. ``` add_action( 'transition_post_status', 'wwm_transition_post_status', 10, 3 ); function wwm_transition_post_status( $new_status, $old_status, ...
WP can not do it, but you can go to the server logs and find the user's IP. It may take some effort and success is not guaranteed but this is the only possible way. Will's answer will help you in future mistakes. Finding a user based on their IP is not usually hard especially if the number of authors is limited.
150,258
Someone moved a very important page on my website into the trash, and I do not know who did it! It was not deleted permanently so I don't need to worry, in that sense. The revisions, when I restored it, show that someone edited it 3 days prior to today, so it could have been them, but I can't be sure. Does WP keep tr...
2014/06/20
[ "https://wordpress.stackexchange.com/questions/150258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15209/" ]
By default, no, WordPress doesn't keep track of who changes post statuses (at least that I can see). you can hook into `transition_post_status` and log the user id. ``` add_action( 'transition_post_status', 'wwm_transition_post_status', 10, 3 ); function wwm_transition_post_status( $new_status, $old_status, ...
There is a free plugin called *Stream* that will make your life much easier. Search within the WordPress plugins page. It logs all changes to posts and who is responsible for them.
150,258
Someone moved a very important page on my website into the trash, and I do not know who did it! It was not deleted permanently so I don't need to worry, in that sense. The revisions, when I restored it, show that someone edited it 3 days prior to today, so it could have been them, but I can't be sure. Does WP keep tr...
2014/06/20
[ "https://wordpress.stackexchange.com/questions/150258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15209/" ]
No, natively WordPress does not log any activity. While plugins for it exist, they won't work retroactively. However don't forget that any action taken in WordPress is technically a HTTP request, such as page load, form submit, or Ajax request. These are often logged pretty thoroughly in web server's access log and i...
There is a free plugin called *Stream* that will make your life much easier. Search within the WordPress plugins page. It logs all changes to posts and who is responsible for them.
150,258
Someone moved a very important page on my website into the trash, and I do not know who did it! It was not deleted permanently so I don't need to worry, in that sense. The revisions, when I restored it, show that someone edited it 3 days prior to today, so it could have been them, but I can't be sure. Does WP keep tr...
2014/06/20
[ "https://wordpress.stackexchange.com/questions/150258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15209/" ]
WP can not do it, but you can go to the server logs and find the user's IP. It may take some effort and success is not guaranteed but this is the only possible way. Will's answer will help you in future mistakes. Finding a user based on their IP is not usually hard especially if the number of authors is limited.
There is a free plugin called *Stream* that will make your life much easier. Search within the WordPress plugins page. It logs all changes to posts and who is responsible for them.
28,958,290
We have recently switched over to React + Flux from Angular to build a rather complex business application. Taking the approach of having one container component that passes all state as properties down the component tree isn't a practical way to develop the app for us as the app makes use of large page-like modals. E...
2015/03/10
[ "https://Stackoverflow.com/questions/28958290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525096/" ]
It feels wrong to me that you are using `getInitialState()` to change the state of your store. You should at least be doing that in [`componentWillMount`](http://facebook.github.io/react/docs/component-specs.html#mounting-componentwillmount). I would trigger an action in `componentWillMount` and have the store handler...
[`Reflux.listenTo`](https://github.com/spoike/refluxjs/#sending-initial-state-with-the-listento-function) does this when you provide a third argument and `Reflux.connect` mixin factory (that uses `Reflux.listenTo` under the hood) handles this for you automatically. Here is an example: ``` var Actions = Reflux.createAc...
28,958,290
We have recently switched over to React + Flux from Angular to build a rather complex business application. Taking the approach of having one container component that passes all state as properties down the component tree isn't a practical way to develop the app for us as the app makes use of large page-like modals. E...
2015/03/10
[ "https://Stackoverflow.com/questions/28958290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525096/" ]
It feels wrong to me that you are using `getInitialState()` to change the state of your store. You should at least be doing that in [`componentWillMount`](http://facebook.github.io/react/docs/component-specs.html#mounting-componentwillmount). I would trigger an action in `componentWillMount` and have the store handler...
Like other posters have said, the best thing to do is to trigger an action in `componentWillMount`. In ES6, this is usually done with a `constructor`. Below is an example on how to do this with ES6: (note that `AuthorActions.initAuthors()` is dependent on implementation, this is just an example. This could get initia...
28,958,290
We have recently switched over to React + Flux from Angular to build a rather complex business application. Taking the approach of having one container component that passes all state as properties down the component tree isn't a practical way to develop the app for us as the app makes use of large page-like modals. E...
2015/03/10
[ "https://Stackoverflow.com/questions/28958290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525096/" ]
[`Reflux.listenTo`](https://github.com/spoike/refluxjs/#sending-initial-state-with-the-listento-function) does this when you provide a third argument and `Reflux.connect` mixin factory (that uses `Reflux.listenTo` under the hood) handles this for you automatically. Here is an example: ``` var Actions = Reflux.createAc...
Like other posters have said, the best thing to do is to trigger an action in `componentWillMount`. In ES6, this is usually done with a `constructor`. Below is an example on how to do this with ES6: (note that `AuthorActions.initAuthors()` is dependent on implementation, this is just an example. This could get initia...
35,281,379
I have ElasticSearch 2.2 running on a linux VM. I'm running ManifoldCF 2.3 on another VM in the same netowrk. Using ManifoldCF's browser UI I added the ElasticSearch output connector and when I save it I get an error in the connector status: ``` Name: Elastic Description: Elastic search Connection type: Elas...
2016/02/08
[ "https://Stackoverflow.com/questions/35281379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/151200/" ]
You are passing an `array` of strings to jQuery's `append` method. Simply join it first: ``` jQuery('.place').append(top.join('')); ``` When you call `toString()` on an array (which is what jQuery is doing here when you try to `append` an array of strings) it casts each array element to a string and puts a comma bet...
First of all it looks there's a problem using `top` as variable name, so I changed it to top1. THEORY: According to <http://api.jquery.com/append/> you can pass an array of DOM elements, or String(s) (or other things, but they're not related to the question). You seem to pass an array of strings, that is not an array ...
25,288
We have made a installation of Sitecore Experience Platform v9.3.0 (rev. 003498) (details below): * 2 servers as Content Management role * 2 servers as Content Delivery role * 2 servers as others roles (Processing, Reporting, Identity Server, XConnect, Identity Server, Marketing, Reference Data, Cortex) * 3 servers as...
2020/05/18
[ "https://sitecore.stackexchange.com/questions/25288", "https://sitecore.stackexchange.com", "https://sitecore.stackexchange.com/users/6980/" ]
It turns out to be that the device detection rule config in sitecore 9.3 doesn't include Content Management Role by default so by patching this role solves the problem. ``` <?xml version="1.0" encoding="utf-8" ?> <!-- Purpose: This include file configures the device detection rules component. --> <configuration xml...
It looks like you have a Sitecore rule for detecting device, some thing similar to what you can see in the following screenshot: [![enter image description here](https://i.stack.imgur.com/50PtT.png)](https://i.stack.imgur.com/50PtT.png) Following what you can find when checking Sitecore documentation for device detec...
33,307,860
I have a list of years, as follows: ``` year = ['2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013'] ``` I am trying to create a series of XML tags enclosed within another pre-existing tag, like so: ``` <intro> <exposures> <exposure year = "2005"></exposure> <exposure year = "2006...
2015/10/23
[ "https://Stackoverflow.com/questions/33307860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5199451/" ]
I suspect that the issue is this line: `exposure_tag = testsoup.new_tag('exposure', year = '')`. You have one tag and you are trying to append it to the same parent multiple times. Try this instead. ``` for x in year: exposure_tag = testsoup.new_tag('exposure', year = x) exp_tag.append(exposure_tag) in...
I have not looked into BS source code, but think the behaviour is this: when you calling `exp_tag.append(smth)` you actually add pointer to `smth` object. So as you instantiate `exposure_tag` only once, you got bunch of pointers to the same object. When you modify that object in `exposure_tag['year'] = x`, it affects a...
21,239
I'm setting up a projection map for a non-profit that will have images projected onto angular and unusually shaped walls. I use modul8 on my mac in the past, but this case is different. They use PC (in fact their whole show runs off of a laptop) and they want the ability to change the images based on the theme of the s...
2017/04/20
[ "https://avp.stackexchange.com/questions/21239", "https://avp.stackexchange.com", "https://avp.stackexchange.com/users/18709/" ]
It is certainly possible to use FCPX and AfterEffects as part of the same workflow. To do this effectively, you will need to use an intermediate codec that preserves image quality across successive generations. ProRes HQ 422 is a good baseline as an intermediate codec. There are higher quality ProRes codecs (XQ 4444) a...
While Adobe and Apple each link their editing software with their own respective compositing software, saying 'AE is to Premiere as Motion is to FCPX' glosses over the strengths and differences of each package. Sure, AE is a powerful compositing app, and it's dynamic link to Premiere is convenient, but Adobe is still ...
74,240,319
I am trying to set my machines javac version to 11 from 18.0.2 and I'm doing the following steps 1. open ~/.zshenv 2. export JAVA\_HOME=$(/usr/libexec/java\_home -v11) 3. source ~/.zshenv When I check the version, I still get it as 18.0.2. Not sure what I am doing wrong here. Could someone please help me with this? B...
2022/10/28
[ "https://Stackoverflow.com/questions/74240319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6466023/" ]
What works like a charme for me is using jenv: <https://www.jenv.be/> With jenv you can also switch between different Java versions. Before using jenv, I relied on the Maven toolchains plugin: <https://maven.apache.org/plugins/maven-toolchains-plugin/> Thus, I actually never really worried about `JAVA_HOME` on MacOS...
``` export JAVA_HOME=`/usr/libexec/java_home -v 11` ```
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
The easiest way is to avoid `length`: ``` myButLast (x : _ : []) = x -- base case myButLast (_ : xs) = myButLast xs ``` The definitive reference on patterns in Haskell is the language report: <https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-580003.17> GHC implements a few extensions describ...
Exploiting `zip`: ``` \l -> fst . last $ zip l (tail l) ``` Also available in a pointless, obfuscated style: ``` fst . last . (zip <*> tail) ``` or even without parentheses (thanks to @melpomene): ``` fst . last . ap zip tail ``` Other variants: ``` last . ap (zipWith const) tail ```
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
what about ``` myButLast [] = error "oho" myButLast [x,_] = x myButLast (_:xs) = myButLast xs ```
Another solution: ``` myButLast [] = error "List is empty" myButLast [x] = error "List is a singleton" myButLast xs = last $ init xs ```
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
what about ``` myButLast [] = error "oho" myButLast [x,_] = x myButLast (_:xs) = myButLast xs ```
Another zip-based solution, without exlicitly zipping. Throw in some safety for good measure. ``` import Data.Maybe g :: Int -> [a] -> Maybe a g i = (head <$>) . listToMaybe . reverse -- quick'n'dirty safe-last . getZipList . traverse ZipList . sequence [id, drop i] g 1 [...
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
The easiest way is to avoid `length`: ``` myButLast (x : _ : []) = x -- base case myButLast (_ : xs) = myButLast xs ``` The definitive reference on patterns in Haskell is the language report: <https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-580003.17> GHC implements a few extensions describ...
Here is my solution using the tail function from prelude ``` myButLast :: [Int] -> Maybe Int myButLast (x:xs) | ((null xs) || null (tail xs)) = Just x | otherwise = myButLast(xs) myButLast [] = Nothing ```
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
The easiest way is to avoid `length`: ``` myButLast (x : _ : []) = x -- base case myButLast (_ : xs) = myButLast xs ``` The definitive reference on patterns in Haskell is the language report: <https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-580003.17> GHC implements a few extensions describ...
Another zip-based solution, without exlicitly zipping. Throw in some safety for good measure. ``` import Data.Maybe g :: Int -> [a] -> Maybe a g i = (head <$>) . listToMaybe . reverse -- quick'n'dirty safe-last . getZipList . traverse ZipList . sequence [id, drop i] g 1 [...
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
Another solution: ``` myButLast [] = error "List is empty" myButLast [x] = error "List is a singleton" myButLast xs = last $ init xs ```
Here is my solution using the tail function from prelude ``` myButLast :: [Int] -> Maybe Int myButLast (x:xs) | ((null xs) || null (tail xs)) = Just x | otherwise = myButLast(xs) myButLast [] = Nothing ```
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
The easiest way is to avoid `length`: ``` myButLast (x : _ : []) = x -- base case myButLast (_ : xs) = myButLast xs ``` The definitive reference on patterns in Haskell is the language report: <https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-580003.17> GHC implements a few extensions describ...
Another solution: ``` myButLast [] = error "List is empty" myButLast [x] = error "List is a singleton" myButLast xs = last $ init xs ```
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
Another solution: ``` myButLast [] = error "List is empty" myButLast [x] = error "List is a singleton" myButLast xs = last $ init xs ```
Another zip-based solution, without exlicitly zipping. Throw in some safety for good measure. ``` import Data.Maybe g :: Int -> [a] -> Maybe a g i = (head <$>) . listToMaybe . reverse -- quick'n'dirty safe-last . getZipList . traverse ZipList . sequence [id, drop i] g 1 [...
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
Exploiting `zip`: ``` \l -> fst . last $ zip l (tail l) ``` Also available in a pointless, obfuscated style: ``` fst . last . (zip <*> tail) ``` or even without parentheses (thanks to @melpomene): ``` fst . last . ap zip tail ``` Other variants: ``` last . ap (zipWith const) tail ```
Another zip-based solution, without exlicitly zipping. Throw in some safety for good measure. ``` import Data.Maybe g :: Int -> [a] -> Maybe a g i = (head <$>) . listToMaybe . reverse -- quick'n'dirty safe-last . getZipList . traverse ZipList . sequence [id, drop i] g 1 [...
33,068,428
Consider the following function for finding the second-to-last element of a list: ``` myButLast (x:xs) = if length xs > 1 then myButLast xs else x ``` This is an O(n^2) algorithm, because `length xs` is O(n) and is called O(n) times. What is the most elegant way to write this in Haskell such that `length` stops once...
2015/10/11
[ "https://Stackoverflow.com/questions/33068428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154996/" ]
Exploiting `zip`: ``` \l -> fst . last $ zip l (tail l) ``` Also available in a pointless, obfuscated style: ``` fst . last . (zip <*> tail) ``` or even without parentheses (thanks to @melpomene): ``` fst . last . ap zip tail ``` Other variants: ``` last . ap (zipWith const) tail ```
Another solution: ``` myButLast [] = error "List is empty" myButLast [x] = error "List is a singleton" myButLast xs = last $ init xs ```
7,756,437
Is that possible to get notification when Home button is pressed or Home Screen is launched? In [Android Overriding home key](https://stackoverflow.com/questions/5039500/android-overriding-home-key) thread i read that "it will be notified when the home screen is about to be launched". So is that possible, if yes how? ...
2011/10/13
[ "https://Stackoverflow.com/questions/7756437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/992888/" ]
> > Is that possible to get notification when Home button is pressed or Home Screen is launched? > > > Only by being a home screen.
You can simply add this on your activity: ``` @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_HOME) { // Do something } return super.onKeyDown(keyCode, event); } ```
7,756,437
Is that possible to get notification when Home button is pressed or Home Screen is launched? In [Android Overriding home key](https://stackoverflow.com/questions/5039500/android-overriding-home-key) thread i read that "it will be notified when the home screen is about to be launched". So is that possible, if yes how? ...
2011/10/13
[ "https://Stackoverflow.com/questions/7756437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/992888/" ]
> > Is that possible to get notification when Home button is pressed or Home Screen is launched? > > > Only by being a home screen.
You can `Detect Home Screen is running or not`. You can see [this page](http://andytsui.wordpress.com/2012/08/02/detect-home-screen-is-running-or-not-android/) for more details,Or you can see [this answer](https://stackoverflow.com/a/6562223/1043882).It propose use `isScreenOn ()` from `PowerManager`(Returns whether...
2,347,497
> > Let $R$ be a ring. If $I\_1,\ldots, I\_k$ are ideals of $R$ and for all $i$: > > > $$I\_i + \bigcap\_{j\neq i} I\_j = R$$ > > > then for all $a\_1,\ldots,a\_k \in R$, there exists some $a \in R$ such that for all $i$, $a \equiv a\_i \pmod{I\_i}$ > > > I could prove this for $k=2$: for $a\_1,a\_2 \in R$, $a...
2017/07/05
[ "https://math.stackexchange.com/questions/2347497", "https://math.stackexchange.com", "https://math.stackexchange.com/users/360858/" ]
**Hint for the inductive step:** Suppose $I\_1,\dots, I\_k,I\_{k+1}$ are ideals in $R$ such that for any $1\le i \le k+1$, $$I\_i+\bigcap\_{\substack{1\le j \le k+1\\j\ne i}}I\_j=R. $$ Then, *a fortiori*, we have for any $1\le i \le k$, $$I\_i+\bigcap\_{\substack{1\le j \le k\\j\ne i}}I\_j=R. $$ So, given $a\_1, \d...
**Hint** $ $ It is easy if we view the solutions as "vectors" in the product ring $\, (R/I\_1,\ldots, R/I\_k).\,$ Then every such congruence is solvable iff the natural image of $R$ in the product ring is onto iff the image contains all unit vectors $e\_j$ with $1$ in the $j$'th component and $0$ in all others, since t...
6,637,219
Let's say I accidentally evaluate an enormous variable--a list with a ba-jillion elements, or whatever. As they scroll down my screen and my computer crawls to a halt, is there a good way to interrupt this *without* killing my `*Python*` buffer? I'm using IPython via `python-mode.el` and `ipython.el` in emacs24 on Mac ...
2011/07/09
[ "https://Stackoverflow.com/questions/6637219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37772/" ]
Could you not just use the [DisplayAttribute](http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute.aspx "DisplayAttribute")?
Why don't you just use @Html.Label("Business name")?
6,637,219
Let's say I accidentally evaluate an enormous variable--a list with a ba-jillion elements, or whatever. As they scroll down my screen and my computer crawls to a halt, is there a good way to interrupt this *without* killing my `*Python*` buffer? I'm using IPython via `python-mode.el` and `ipython.el` in emacs24 on Mac ...
2011/07/09
[ "https://Stackoverflow.com/questions/6637219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37772/" ]
Could you not just use the [DisplayAttribute](http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute.aspx "DisplayAttribute")?
You need a new metadataprovider which can inherit from the default one like this: ``` using System; using System.Web.Mvc; using System.Collections.Generic; public class MyMetadataProvider : DataAnnotationsModelMetadataProvider { protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Ty...
6,637,219
Let's say I accidentally evaluate an enormous variable--a list with a ba-jillion elements, or whatever. As they scroll down my screen and my computer crawls to a halt, is there a good way to interrupt this *without* killing my `*Python*` buffer? I'm using IPython via `python-mode.el` and `ipython.el` in emacs24 on Mac ...
2011/07/09
[ "https://Stackoverflow.com/questions/6637219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37772/" ]
You need a new metadataprovider which can inherit from the default one like this: ``` using System; using System.Web.Mvc; using System.Collections.Generic; public class MyMetadataProvider : DataAnnotationsModelMetadataProvider { protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Ty...
Why don't you just use @Html.Label("Business name")?
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
Tested with latest **Firebase iOS SDK i.e. 4.0.0** and **Xcode 8.3** Firstly , remove this key `FirebaseAppDelegateProxyEnabled` from info.plist. This is not needed. Now in **AppDelegate.swift** add following functions ``` import Firebase import UserNotifications @UIApplicationMain class AppDelegate: UIResponder, ...
Double check that the app bundle ID in Xcode matches the bundle ID in Firebase **exactly**. And by **exactly**, make sure their case matches - Xcode likes to use mixed case by default for the app name part of the bundle ID. If you end up changing the bundle ID in Xcode, make sure to manually delete the provisioning pr...
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
Tested with latest **Firebase iOS SDK i.e. 4.0.0** and **Xcode 8.3** Firstly , remove this key `FirebaseAppDelegateProxyEnabled` from info.plist. This is not needed. Now in **AppDelegate.swift** add following functions ``` import Firebase import UserNotifications @UIApplicationMain class AppDelegate: UIResponder, ...
In my case it was the apns token type that was wrong: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.prod) ``` should have been: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.sandbox) ```
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
Tested with latest **Firebase iOS SDK i.e. 4.0.0** and **Xcode 8.3** Firstly , remove this key `FirebaseAppDelegateProxyEnabled` from info.plist. This is not needed. Now in **AppDelegate.swift** add following functions ``` import Firebase import UserNotifications @UIApplicationMain class AppDelegate: UIResponder, ...
Well, in my case I have sending wrong `self.verificationID` to `FIRAuthCredential`. If you are having this error, then please print your `verificationID` and check, is that the same one you are sending to `FIRAuthCredential`. Here is my code in `objC` : ``` [[FIRPhoneAuthProvider provider] verifyPhoneNumber:self.phon...
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
Tested with latest **Firebase iOS SDK i.e. 4.0.0** and **Xcode 8.3** Firstly , remove this key `FirebaseAppDelegateProxyEnabled` from info.plist. This is not needed. Now in **AppDelegate.swift** add following functions ``` import Firebase import UserNotifications @UIApplicationMain class AppDelegate: UIResponder, ...
i am solve it easy make type .sandbox ``` func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { // Pass device token to auth. let firebaseAuth = Auth.auth() //At development time we use .sandbox firebaseAuth.setAPNSToken(deviceToken, type: ...
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
In my case it was the apns token type that was wrong: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.prod) ``` should have been: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.sandbox) ```
Double check that the app bundle ID in Xcode matches the bundle ID in Firebase **exactly**. And by **exactly**, make sure their case matches - Xcode likes to use mixed case by default for the app name part of the bundle ID. If you end up changing the bundle ID in Xcode, make sure to manually delete the provisioning pr...
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
Double check that the app bundle ID in Xcode matches the bundle ID in Firebase **exactly**. And by **exactly**, make sure their case matches - Xcode likes to use mixed case by default for the app name part of the bundle ID. If you end up changing the bundle ID in Xcode, make sure to manually delete the provisioning pr...
Well, in my case I have sending wrong `self.verificationID` to `FIRAuthCredential`. If you are having this error, then please print your `verificationID` and check, is that the same one you are sending to `FIRAuthCredential`. Here is my code in `objC` : ``` [[FIRPhoneAuthProvider provider] verifyPhoneNumber:self.phon...
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
Double check that the app bundle ID in Xcode matches the bundle ID in Firebase **exactly**. And by **exactly**, make sure their case matches - Xcode likes to use mixed case by default for the app name part of the bundle ID. If you end up changing the bundle ID in Xcode, make sure to manually delete the provisioning pr...
i am solve it easy make type .sandbox ``` func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { // Pass device token to auth. let firebaseAuth = Auth.auth() //At development time we use .sandbox firebaseAuth.setAPNSToken(deviceToken, type: ...
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
In my case it was the apns token type that was wrong: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.prod) ``` should have been: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.sandbox) ```
Well, in my case I have sending wrong `self.verificationID` to `FIRAuthCredential`. If you are having this error, then please print your `verificationID` and check, is that the same one you are sending to `FIRAuthCredential`. Here is my code in `objC` : ``` [[FIRPhoneAuthProvider provider] verifyPhoneNumber:self.phon...
44,091,666
I set up my app to be able to send Apple Notifications using firebase and I verified that it works using the console. Now I want to do phone authentication which is built on top of APN. So I wrote this: ``` PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber) { verificationID, error in if error != nil { ...
2017/05/20
[ "https://Stackoverflow.com/questions/44091666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/666818/" ]
In my case it was the apns token type that was wrong: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.prod) ``` should have been: ``` Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.sandbox) ```
i am solve it easy make type .sandbox ``` func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { // Pass device token to auth. let firebaseAuth = Auth.auth() //At development time we use .sandbox firebaseAuth.setAPNSToken(deviceToken, type: ...
50,488,521
I am looking for a solution to convert my string to `camelcaps` by the `dot` it contains. here is my string: `'sender.state'` I am expecting the result as : `'senderState'`; I tried this: `'sender.state'.replace(/\./g, '');` it removes the `.` but how to handle the `camel caps` stuff?
2018/05/23
[ "https://Stackoverflow.com/questions/50488521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218349/" ]
You can pass a function to `.replace()`: ``` 'sender.state'.replace(/\.([a-z])/g, (match, letter) => letter.toUpperCase()); ```
Without `regex` - this might help : ``` var str = "bad.unicron"; var temp = str.split("."); return temp[0]+temp[1].charAt(0).toUpperCase() + temp[1].slice(1); ``` I'll try to come up with `regex`
51,094,339
I need to measure the execution time of a Python program having the following structure: ``` import numpy import pandas def func1(): code def func2(): code if __name__ == '__main__': func1() func2() ``` If I want to use "time.time()", where should I put them in the code? I want to get the executi...
2018/06/29
[ "https://Stackoverflow.com/questions/51094339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9668218/" ]
In linux: you could run this file test.py using the time command > > time python3 test.py > > > After your program runs it will give you the following output: real 0m0.074s user 0m0.004s sys 0m0.000s [this link](https://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-tim...
The whole program: ``` import time t1 = time.time() import numpy import pandas def func1(): code def func2(): code if __name__ == '__main__': func1() func2() t2 = time.time() print("The execution time is", t2 - t1) ```
38,659,379
I've been experiencing an irritating issue that I cant get around. I am trying to `vagrant up` a centos7 system in this environment: * Windows 10 * Hyper-V (not anniversary update version) * Docker image "serveit/centos-7" or "bluefedora/hyperv-alpha-centos7" * OpenSSH installed, private key configured The contents ...
2016/07/29
[ "https://Stackoverflow.com/questions/38659379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2951942/" ]
Turns out, there is a known bug in Vagrant 1.8.5 (Will be fixed in 1.8.6): Details [here](https://github.com/mitchellh/vagrant/issues/7610) If you are using 1.8.5, you can download the updated version from PR [#7611](https://github.com/mitchellh/vagrant/pull/7611) using PowerShell: `[IO.File]::WriteAllLines("C:\Hash...
SSH into the vagrant machine and give this privilege. vagrant@localhost:chmod 600 ~/.ssh/authorized\_keys. exit out comeback to the host and hit "vagrant reload" It works!!!
38,659,379
I've been experiencing an irritating issue that I cant get around. I am trying to `vagrant up` a centos7 system in this environment: * Windows 10 * Hyper-V (not anniversary update version) * Docker image "serveit/centos-7" or "bluefedora/hyperv-alpha-centos7" * OpenSSH installed, private key configured The contents ...
2016/07/29
[ "https://Stackoverflow.com/questions/38659379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2951942/" ]
Turns out, there is a known bug in Vagrant 1.8.5 (Will be fixed in 1.8.6): Details [here](https://github.com/mitchellh/vagrant/issues/7610) If you are using 1.8.5, you can download the updated version from PR [#7611](https://github.com/mitchellh/vagrant/pull/7611) using PowerShell: `[IO.File]::WriteAllLines("C:\Hash...
Inside `public_key.rb` file find those at line 56 and append `chmod 0600 ~/.ssh/authorized_keys` like so: ``` if test -f ~/.ssh/authorized_keys; then grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys ...
38,659,379
I've been experiencing an irritating issue that I cant get around. I am trying to `vagrant up` a centos7 system in this environment: * Windows 10 * Hyper-V (not anniversary update version) * Docker image "serveit/centos-7" or "bluefedora/hyperv-alpha-centos7" * OpenSSH installed, private key configured The contents ...
2016/07/29
[ "https://Stackoverflow.com/questions/38659379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2951942/" ]
Turns out, there is a known bug in Vagrant 1.8.5 (Will be fixed in 1.8.6): Details [here](https://github.com/mitchellh/vagrant/issues/7610) If you are using 1.8.5, you can download the updated version from PR [#7611](https://github.com/mitchellh/vagrant/pull/7611) using PowerShell: `[IO.File]::WriteAllLines("C:\Hash...
check permissions inside vagrant instance: ``` chmod 600 /vagrant/.ssh/authorized_keys chmod 700 /vagrant/.ssh chmod 700 /vagrant # important too! (for me that was a reason of same error) ``` ssh keys will be used only with right permissions. Also, as *workaround*, you can add to the Vagrantfile: ``` conf...
38,659,379
I've been experiencing an irritating issue that I cant get around. I am trying to `vagrant up` a centos7 system in this environment: * Windows 10 * Hyper-V (not anniversary update version) * Docker image "serveit/centos-7" or "bluefedora/hyperv-alpha-centos7" * OpenSSH installed, private key configured The contents ...
2016/07/29
[ "https://Stackoverflow.com/questions/38659379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2951942/" ]
Inside `public_key.rb` file find those at line 56 and append `chmod 0600 ~/.ssh/authorized_keys` like so: ``` if test -f ~/.ssh/authorized_keys; then grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys ...
SSH into the vagrant machine and give this privilege. vagrant@localhost:chmod 600 ~/.ssh/authorized\_keys. exit out comeback to the host and hit "vagrant reload" It works!!!
38,659,379
I've been experiencing an irritating issue that I cant get around. I am trying to `vagrant up` a centos7 system in this environment: * Windows 10 * Hyper-V (not anniversary update version) * Docker image "serveit/centos-7" or "bluefedora/hyperv-alpha-centos7" * OpenSSH installed, private key configured The contents ...
2016/07/29
[ "https://Stackoverflow.com/questions/38659379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2951942/" ]
check permissions inside vagrant instance: ``` chmod 600 /vagrant/.ssh/authorized_keys chmod 700 /vagrant/.ssh chmod 700 /vagrant # important too! (for me that was a reason of same error) ``` ssh keys will be used only with right permissions. Also, as *workaround*, you can add to the Vagrantfile: ``` conf...
SSH into the vagrant machine and give this privilege. vagrant@localhost:chmod 600 ~/.ssh/authorized\_keys. exit out comeback to the host and hit "vagrant reload" It works!!!
4,778,743
I created a wordpress blog (http://raptor.hk), but i am unable to set the right sidebar into correct position. i think i have missed something in CSS. the DIV is named "rightbar". I would like the DIV to be positioned right next to the content, within the white wrapper. Also, support of fluid layout (not moving on brow...
2011/01/24
[ "https://Stackoverflow.com/questions/4778743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/188331/" ]
You can use the [Users API](http://code.google.com/appengine/docs/python/users/) to authenticate users - either using Google accounts, or OpenID. If you want sessions without user login, there are a number of libraries, such as [gaesessions](https://github.com/dound/gae-sessions).
Yes, this is for me the easiest way using Python 2.7. ``` import Cookie value_session = "userid (encrypted);time of login" name_cookie = "sessioncookie" expires = 2629743 # 1 month in seconds D = Cookie.SimpleCookie() D["name_cookie"] = value_session D["name_cookie"]["path"] = "/" D["name_cookie"]["expires"] = expire...
36,967,907
i have a string array that contains 20 words. I made a function that take 1 random word from the array. But i want to know how can i return that word from array. Right now i am using void function, i had used char type but it wont work. Little help here ? Need to make word guessing game. CODE: ``` #include <iostrea...
2016/05/01
[ "https://Stackoverflow.com/questions/36967907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058648/" ]
Make `random` return `string`. You also only need to seed the number generator once. Since you only want to get 1 random word from the array, you don't need a `for` loop. ``` string random(string names[]){ int randNum = 0; randNum = rand() % 20 + 1; return names[randNum]; } ``` Then, in the `main` functi...
I'm not super familiar with strings, but you should be able to just declare random() as a string function. Ex: string random (string names[]);
36,967,907
i have a string array that contains 20 words. I made a function that take 1 random word from the array. But i want to know how can i return that word from array. Right now i am using void function, i had used char type but it wont work. Little help here ? Need to make word guessing game. CODE: ``` #include <iostrea...
2016/05/01
[ "https://Stackoverflow.com/questions/36967907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058648/" ]
Additionally srand(time(NULL)) should be called only one time, on the beginning of main() function.
I'm not super familiar with strings, but you should be able to just declare random() as a string function. Ex: string random (string names[]);
36,967,907
i have a string array that contains 20 words. I made a function that take 1 random word from the array. But i want to know how can i return that word from array. Right now i am using void function, i had used char type but it wont work. Little help here ? Need to make word guessing game. CODE: ``` #include <iostrea...
2016/05/01
[ "https://Stackoverflow.com/questions/36967907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058648/" ]
In your question as well as in the previous answer, you are running out of bounds accessing the names array: ``` int randNum = rand() % 20 + 1; return names[randNum]; ``` You are never accessing names[0] but instead reach behind the array when addressing names[20].
I'm not super familiar with strings, but you should be able to just declare random() as a string function. Ex: string random (string names[]);
36,967,907
i have a string array that contains 20 words. I made a function that take 1 random word from the array. But i want to know how can i return that word from array. Right now i am using void function, i had used char type but it wont work. Little help here ? Need to make word guessing game. CODE: ``` #include <iostrea...
2016/05/01
[ "https://Stackoverflow.com/questions/36967907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058648/" ]
Make `random` return `string`. You also only need to seed the number generator once. Since you only want to get 1 random word from the array, you don't need a `for` loop. ``` string random(string names[]){ int randNum = 0; randNum = rand() % 20 + 1; return names[randNum]; } ``` Then, in the `main` functi...
Additionally srand(time(NULL)) should be called only one time, on the beginning of main() function.
36,967,907
i have a string array that contains 20 words. I made a function that take 1 random word from the array. But i want to know how can i return that word from array. Right now i am using void function, i had used char type but it wont work. Little help here ? Need to make word guessing game. CODE: ``` #include <iostrea...
2016/05/01
[ "https://Stackoverflow.com/questions/36967907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058648/" ]
Make `random` return `string`. You also only need to seed the number generator once. Since you only want to get 1 random word from the array, you don't need a `for` loop. ``` string random(string names[]){ int randNum = 0; randNum = rand() % 20 + 1; return names[randNum]; } ``` Then, in the `main` functi...
In your question as well as in the previous answer, you are running out of bounds accessing the names array: ``` int randNum = rand() % 20 + 1; return names[randNum]; ``` You are never accessing names[0] but instead reach behind the array when addressing names[20].
36,967,907
i have a string array that contains 20 words. I made a function that take 1 random word from the array. But i want to know how can i return that word from array. Right now i am using void function, i had used char type but it wont work. Little help here ? Need to make word guessing game. CODE: ``` #include <iostrea...
2016/05/01
[ "https://Stackoverflow.com/questions/36967907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058648/" ]
In your question as well as in the previous answer, you are running out of bounds accessing the names array: ``` int randNum = rand() % 20 + 1; return names[randNum]; ``` You are never accessing names[0] but instead reach behind the array when addressing names[20].
Additionally srand(time(NULL)) should be called only one time, on the beginning of main() function.
24,587,704
So am trying to do some end to end testing in specflow using entity framework 6. I have code migrations enabled and my seed method written. I have a context factory to generate my context with a connection string that in influenced by a step definition. What I want to be able to do is in a Feature I want to create a ...
2014/07/05
[ "https://Stackoverflow.com/questions/24587704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109347/" ]
I personally see your bonus question as part of a potential overall approach. I dont see why `SEED` and `Migration` need to be so tightly coupled. A basic pattern that works with Multiple DBs. a) By default Use Context against a DB with No initializer ``` Database.SetInitializer(new ContextInitializerNone<MYDbCont...
An approach that I have used for this is to declare a `[BeforeScenario]` method and create the database and run the migrations in here, and then in an `[AfterScenario]` method I delete the database. Its often better to put these in a seperate class specifically for setup. As long as its marked as a `[Binding]` class th...
9,272,270
Hi I've an input button like ``` <input id="btnDelete" type="button" value="Delete" name="btnDelete" runat="server" onclick="return confirm('Are you sure you wish to delete these records?');" /> and my serverside code is Private Sub btnDelete_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ...
2012/02/14
[ "https://Stackoverflow.com/questions/9272270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225264/" ]
USE [OnClientClick](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.onclientclick.aspx#Y570) for your client side javascript validation ``` <asp:BUTTON id="btnDelete" name="btnDelete" value="Delete" onclick="btnDelete_ServerClick" OnClientClick="return confirm('Are...
Maybe because its not a type=submit button? ``` <form name="frmPerson" action="/dome.asp"> some form fields here . . <input id="btnDelete" type="submit" name="btnDelete" value="Delete" /> </form> ```
53,834,396
Assuming that I have a QPushButton named `button`, I successfully do the following to allow **click** event: ``` class UI(object): def setupUi(self, Dialog): # ... self.button.clicked.connect(self.do_something) def do_something(self): # Something here ``` My question is: how can I ca...
2018/12/18
[ "https://Stackoverflow.com/questions/53834396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9923495/" ]
To get what you want there are many methods but before pointing it by observing your code I see that you have generated it with Qt Designer so that code should not be modified but create another class that uses that code so I will place the base code: ``` from PyQt5 import QtCore, QtWidgets class UI(object): def ...
I assume you put your widget in QDialog widget, so if you want to implement your own key press event, you should override the **keyPressEvent** of your Dialog widget, then it can behave as you like. Here's an example, ``` from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog class UI(QDialog): def __i...
62,910,520
I tried to run `flutter pub get` and I got this error: ``` Error on line 1, column 1 of pubspec.lock: Unexpected character ╷ 1 │ │ ^ ╵ pub upgrade failed (65; ╵) ```
2020/07/15
[ "https://Stackoverflow.com/questions/62910520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13753831/" ]
The file pubspec.lock is a generated file, so you can delete it and then regenerate it. Delete **pubspec.lock**. Run the following command: ``` flutter pub get ``` or ``` flutter pub upgrade ``` Notes on [pub upgrade](https://dart.dev/tools/pub/cmd/pub-upgrade) (you could probably skip the delete step).
Delete the file at flutter/packages/flutter\_tools/pubspec.lock then try flutter pub upgrade again. You may have interrupted the upgrade process before it finished hence the file became invalid.
62,910,520
I tried to run `flutter pub get` and I got this error: ``` Error on line 1, column 1 of pubspec.lock: Unexpected character ╷ 1 │ │ ^ ╵ pub upgrade failed (65; ╵) ```
2020/07/15
[ "https://Stackoverflow.com/questions/62910520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13753831/" ]
The file pubspec.lock is a generated file, so you can delete it and then regenerate it. Delete **pubspec.lock**. Run the following command: ``` flutter pub get ``` or ``` flutter pub upgrade ``` Notes on [pub upgrade](https://dart.dev/tools/pub/cmd/pub-upgrade) (you could probably skip the delete step).
I took the same error, but this error was coming from my main folder. in this path "C:\Users"yourusername"\AppData\Local\Pub\Cache\global\_packages\devtools" I deleted the file and I started app. file has been by itself created and problem solved.
62,910,520
I tried to run `flutter pub get` and I got this error: ``` Error on line 1, column 1 of pubspec.lock: Unexpected character ╷ 1 │ │ ^ ╵ pub upgrade failed (65; ╵) ```
2020/07/15
[ "https://Stackoverflow.com/questions/62910520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13753831/" ]
The file pubspec.lock is a generated file, so you can delete it and then regenerate it. Delete **pubspec.lock**. Run the following command: ``` flutter pub get ``` or ``` flutter pub upgrade ``` Notes on [pub upgrade](https://dart.dev/tools/pub/cmd/pub-upgrade) (you could probably skip the delete step).
I got the same error while working. I deleted **pubspec.lock** file. then I ran command `flutter pub get` It created new **pubspec.lock** file. Now application runs without any errors.
62,910,520
I tried to run `flutter pub get` and I got this error: ``` Error on line 1, column 1 of pubspec.lock: Unexpected character ╷ 1 │ │ ^ ╵ pub upgrade failed (65; ╵) ```
2020/07/15
[ "https://Stackoverflow.com/questions/62910520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13753831/" ]
Delete the file at flutter/packages/flutter\_tools/pubspec.lock then try flutter pub upgrade again. You may have interrupted the upgrade process before it finished hence the file became invalid.
I took the same error, but this error was coming from my main folder. in this path "C:\Users"yourusername"\AppData\Local\Pub\Cache\global\_packages\devtools" I deleted the file and I started app. file has been by itself created and problem solved.
62,910,520
I tried to run `flutter pub get` and I got this error: ``` Error on line 1, column 1 of pubspec.lock: Unexpected character ╷ 1 │ │ ^ ╵ pub upgrade failed (65; ╵) ```
2020/07/15
[ "https://Stackoverflow.com/questions/62910520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13753831/" ]
Delete the file at flutter/packages/flutter\_tools/pubspec.lock then try flutter pub upgrade again. You may have interrupted the upgrade process before it finished hence the file became invalid.
I got the same error while working. I deleted **pubspec.lock** file. then I ran command `flutter pub get` It created new **pubspec.lock** file. Now application runs without any errors.
877,690
How does a 3D model handled unit wise ? When i have a random model that i want to fit in my view port i dunno if it is too big or not, if i need to translate it to be in the middle... I think a 3d object might have it's own origine.
2009/05/18
[ "https://Stackoverflow.com/questions/877690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2566/" ]
You need to find a bounding volume, a shape that encloses all the object's vertices, for your object that is easier to work with than the object itself. Spheres are often used for this. Either the artist can define the sphere as part of the model information or you can work it out at run time. Calculating the optimal s...
Sorry, your question is very unclear. I suppose you want to center a 3D model to a viewport. You can achieve this by calculating the model's bounding box. To do this, traverse all polygons and get the minimum/maximum X/Y/Z coordinates. The bounding box given by the points `(min_x,min_y,min_z)` and `(max_x,max_y,max_z)`...
877,690
How does a 3D model handled unit wise ? When i have a random model that i want to fit in my view port i dunno if it is too big or not, if i need to translate it to be in the middle... I think a 3d object might have it's own origine.
2009/05/18
[ "https://Stackoverflow.com/questions/877690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2566/" ]
You need to find a bounding volume, a shape that encloses all the object's vertices, for your object that is easier to work with than the object itself. Spheres are often used for this. Either the artist can define the sphere as part of the model information or you can work it out at run time. Calculating the optimal s...
"so i tried to scale it down" The best thing to do in this situation is not to transform your model at all! Leave it be. What you want to change is your camera. First calculate the bounding box of your model somewhere in 3D space. Next calculate the radius of it by taking the max( aabb.max.x-aabb.min.x, aabb.max.y-a...
32,747,720
I have a table called Product. I need to select all product records that have the MAX ManufatureDate. Here is a sample of the table data: ``` Id ProductName ManufactureDate 1 Car 01-01-2015 2 Truck 05-01-2015 3 Computer 05-01-2015 4 Phone 02-01-2015 5 Chair ...
2015/09/23
[ "https://Stackoverflow.com/questions/32747720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150565/" ]
``` select * from product where manufactureDate = (select max(manufactureDate) from product) ``` The inner select-statements selects the maximum date, the outer all products which have the date.
You can use a subQuery ``` SELECT * FROM Product WHERE ManufactureDate = ( SELECT ManufactureDate FROM Product ORDER BY ManufactureDate LIMIT 1 );` ``` You may need to use `ASC` or `DESC` to collect the right order
32,747,720
I have a table called Product. I need to select all product records that have the MAX ManufatureDate. Here is a sample of the table data: ``` Id ProductName ManufactureDate 1 Car 01-01-2015 2 Truck 05-01-2015 3 Computer 05-01-2015 4 Phone 02-01-2015 5 Chair ...
2015/09/23
[ "https://Stackoverflow.com/questions/32747720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5150565/" ]
``` select * from product where manufactureDate = (select max(manufactureDate) from product) ``` The inner select-statements selects the maximum date, the outer all products which have the date.
Try this pattern: ``` SELECT Id, ProductName, ManufactureDate FROM ( SELECT Id, ProductName, ManufactureDate, MAX(ManufactureDate)OVER() AS MaxManufactureDate FROM Product P ) P WHERE P.MaxManufactureDate = P.ManufactureDate ``` Essentially, use a window function to get the data you're looking for in the...
68,118,208
``` CREATE TABLE mydataset.newtable (transaction_id INT64, transaction_date DATE) PARTITION BY transaction_date AS SELECT transaction_id, transaction_date FROM mydataset.mytable ``` The docs don't specify whether the PARTITION BY clause supports "required".
2021/06/24
[ "https://Stackoverflow.com/questions/68118208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3381013/" ]
Solved it finally by displaying more logs on the error message. The key action is to update Gradle in my project level build.gradle file, I changed: ``` classpath 'com.android.tools.build:gradle:4.0.2' ``` To: ``` classpath 'com.android.tools.build:gradle:4.2.1' ```
I had a similar problem (yet not related to the NDK so I gave your solution a shot). I just want to preface that your answer helped me realize something that was horribly wrong with my installation of Android Studio in terms of configuration. Uninstalling and Reinstalling the IDE helped me find the true culprit as to ...
68,118,208
``` CREATE TABLE mydataset.newtable (transaction_id INT64, transaction_date DATE) PARTITION BY transaction_date AS SELECT transaction_id, transaction_date FROM mydataset.mytable ``` The docs don't specify whether the PARTITION BY clause supports "required".
2021/06/24
[ "https://Stackoverflow.com/questions/68118208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3381013/" ]
Solved it finally by displaying more logs on the error message. The key action is to update Gradle in my project level build.gradle file, I changed: ``` classpath 'com.android.tools.build:gradle:4.0.2' ``` To: ``` classpath 'com.android.tools.build:gradle:4.2.1' ```
**first** go to your pc dir wich android sdk is installed ``` in my pc dir is -> C:\Users\lotka-pc\AppData\Local\Android\Sdk\cmake ``` and delete the older version **second** in your gradle file **module** you should change the version of cmake ``` externalNativeBuild { cmake { path file('src/main...
68,118,208
``` CREATE TABLE mydataset.newtable (transaction_id INT64, transaction_date DATE) PARTITION BY transaction_date AS SELECT transaction_id, transaction_date FROM mydataset.mytable ``` The docs don't specify whether the PARTITION BY clause supports "required".
2021/06/24
[ "https://Stackoverflow.com/questions/68118208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3381013/" ]
**first** go to your pc dir wich android sdk is installed ``` in my pc dir is -> C:\Users\lotka-pc\AppData\Local\Android\Sdk\cmake ``` and delete the older version **second** in your gradle file **module** you should change the version of cmake ``` externalNativeBuild { cmake { path file('src/main...
I had a similar problem (yet not related to the NDK so I gave your solution a shot). I just want to preface that your answer helped me realize something that was horribly wrong with my installation of Android Studio in terms of configuration. Uninstalling and Reinstalling the IDE helped me find the true culprit as to ...
29,808,109
So, I am trying to read in a text file using VB.NET and add the values of each line into a SQL Server database table. The code I have this far reads in the first line but keeps trying to read in the same line and fails. It adds the first, but like I stated it fails after the first one. I am quite sure the problem is in...
2015/04/22
[ "https://Stackoverflow.com/questions/29808109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3889163/" ]
Do the selection of the friend ID in a subquery, then join that with `users`. ``` SELECT u.firstname, u.lastname FROM users as u JOIN (SELECT DISTINCT IF(friends.sender = 75, friends.recipient, friends.sender) AS friend FROM friends WHERE 75 in (sender, recipient)) AS f ON f.friend = u.id ```
If I understood your question, you want to list all users first and lastname that received from user 75, if it's the case, this will work for you : ``` SELECT u.id,u.firstname,u.lastname FROM users u JOIN friends f ON u.id = f.sender OR u.id = f.recipient WHERE f.sender=75 AND u.id<>75 ``` And the `AND u.id...
2,937,395
I have a JavaScript class that has a method: ``` function someClass() { this.someMethod = someClass_someMethod; } function someClass_someMethod() { // make an AJAX request } ``` The problem is that `someClass_someMethod()` needs to return the value of the AJAX request. I'm using jQuery's `$.getJSON()` meth...
2010/05/30
[ "https://Stackoverflow.com/questions/2937395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/193619/" ]
Make your special view its own UIWindow. Set the UIWindow's windowLevel to UIWindowLevelStatusBar. If it still isn't on top, you can use bringSubviewToFront: on the UIWindow (remember, a UIWindow is a UIView) to bring it to the top of that level.
Answer here: [Add UIView Above All Other Views, Including StatusBar](https://stackoverflow.com/questions/2666792/add-uiview-above-all-other-views-including-statusbar) Have to create a UIWindow and set it's windowLevel property to statusBarLevel.
276,080
Given all variables are in $\mathbb{R}$, and $\{ a, d\} \neq 0$, solve for $\theta$: $$a \sin^2 \theta + b \sin \theta + c + d \cos^2 \theta + e \cos \theta + f = 0$$ as posed in [this question](https://math.stackexchange.com/questions/4577312/solving-quadratic-function-of-sine-and-cosine#4577312). The straightforwa...
2022/11/15
[ "https://mathematica.stackexchange.com/questions/276080", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/9735/" ]
Mathematica has no trouble solving ``` eqn = a Sin[θ]^2 + b Sin[θ] + c + d Cos[θ]^2 + e Cos[θ] + f == 0; subs = {Sin[θ] -> sin, Cos[θ] -> cos}; solution = Solve[(eqn /. subs) && sin^2 + cos^2 == 1, {sin, cos}]; ``` though the solution is rather large, and may not be useful to you.
I think Weirstaß-substitution isn't "awkward" and gives a clear direct solution: Transforming the equation using Weirstaß-substitution `\[Theta] -> 2 ArcTan[u\[Theta]]` gives ``` eqW = a Sin[\[Theta]]^2 + b Sin[\[Theta]] + c + d Cos[\[Theta]]^2 + e Cos[\[Theta]] + f /. \[Theta] -> 2 ArcTan[u\[Theta]] // TrigExpand /...
49,124,177
I have a class where written is a function creating my button: LoginButton.swift ``` func createButton() { let myButton: UIButton = { let button = UIButton() button.addTarget(self, action: #selector(Foo().buttonPressed(_:)), for: .touchUpInside) }() } ``` Now in my second class, Foo.swift, ...
2018/03/06
[ "https://Stackoverflow.com/questions/49124177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9449419/" ]
The action method is called in the target object. Thus, you have either to move `buttonPressed` to the class which contains `createButton` or to pass an instance of `Foo` as a target object. But note that a button is not the owner of its targets. So, if you just write: ``` button.addTarget(Foo(), action: #selector(bu...
Just pass `Selector` as function argument. ``` func createButtonWith(selector: Selector) { let myButton: UIButton = { let button = UIButton() button.addTarget(self, action: selector), for: .touchUpInside) }() } ``` And call this function like below... ``` createButtonWith(selector: #selec...
49,124,177
I have a class where written is a function creating my button: LoginButton.swift ``` func createButton() { let myButton: UIButton = { let button = UIButton() button.addTarget(self, action: #selector(Foo().buttonPressed(_:)), for: .touchUpInside) }() } ``` Now in my second class, Foo.swift, ...
2018/03/06
[ "https://Stackoverflow.com/questions/49124177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9449419/" ]
You are missing with target. So make instant of target globally and make use of it as target for button action handler. ``` class ViewController: UIViewController { let foo = Foo() override func viewDidLoad() { super.viewDidLoad() createButton() } func createButton() { let myButton: UIButton = { ...
Just pass `Selector` as function argument. ``` func createButtonWith(selector: Selector) { let myButton: UIButton = { let button = UIButton() button.addTarget(self, action: selector), for: .touchUpInside) }() } ``` And call this function like below... ``` createButtonWith(selector: #selec...
32,173,907
I am new to Apache. I have 2 jboss (Jboss as 7.1.1) and apache httpd server. I am using mod\_cluster for load balancing. I wish to hide the jboss url from user and wish to show the user clean urls. for e.g. www.mydomain.com will be having my static website. subdomain.mydomain.com should go to mydomain.com:8080/my...
2015/08/24
[ "https://Stackoverflow.com/questions/32173907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2392795/" ]
You could roll your own without too much coding using `do.call`: ``` partial <- function(f, ...) { l <- list(...) function(...) { do.call(f, c(l, list(...))) } } ``` Basically `partial` returns a function that stores `f` as well as the originally provided arguments (stored in list `l`). When this function ...
You have also `Curry` from package `functional`: ``` library(functional) f <- function(a, b, c, d) a+b+c+d ff = Curry(f, a=2, c=10) ff(1,5) #[1] 18 ff(b=1,d=5) #[1] 18 ```
32,173,907
I am new to Apache. I have 2 jboss (Jboss as 7.1.1) and apache httpd server. I am using mod\_cluster for load balancing. I wish to hide the jboss url from user and wish to show the user clean urls. for e.g. www.mydomain.com will be having my static website. subdomain.mydomain.com should go to mydomain.com:8080/my...
2015/08/24
[ "https://Stackoverflow.com/questions/32173907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2392795/" ]
There are functions in the `pryr` package that can handle this, namely `partial()` ``` f <- function(a, b, c, d) a + b + c + d pryr::partial(f, a = 1, c = 2) # function (...) # f(a = 1, c = 2, ...) ``` So you can use it like this - ``` new_fun <- pryr::partial(f, a = 1, c = 2) new_fun(b = 2, d = 5) # [1] 10 ## ...
You have also `Curry` from package `functional`: ``` library(functional) f <- function(a, b, c, d) a+b+c+d ff = Curry(f, a=2, c=10) ff(1,5) #[1] 18 ff(b=1,d=5) #[1] 18 ```
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
Does the button need to be absolutely positioned? If so, you could specify a width and then a negative left margin: ``` .btn-bot{ position: absolute; left: 50%; width: 100px; margin-left: -50px; bottom:0px; } ``` [fiddle](http://jsfiddle.net/3QguR/8/)
I know this has been answered a long time ago, but I couldn't use display:table on the parent container so I had to find another way around. It turned out that this worked just fine: ``` .container{ position:absolute; } .button{ position:absolute; bottom: 5px; left: 0%; right: 0%; text-align: ...
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
Does the button need to be absolutely positioned? If so, you could specify a width and then a negative left margin: ``` .btn-bot{ position: absolute; left: 50%; width: 100px; margin-left: -50px; bottom:0px; } ``` [fiddle](http://jsfiddle.net/3QguR/8/)
You can use [`align-items: flex-end`](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) like so: ```css html, body { height: 100%; } .flex-container { height: 100%; display: flex; align-items: center; justify-content: center; } .center { width: 200px; height: 200px; backgroun...
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
Give the parent element… ``` display: table; text-align: center; ``` …and its child element… ``` display: table-cell; vertical-align: bottom; ``` This way you do not need to know the width of the child element in case it changes, thus requiring no negative margins or workarounds.
One way of doing this would be to give it an absolute width and then a margin half of that: ``` width: 250px; margin-left: -125px; ``` Another way would be to give the `div` the following line-height and remove all styles from the `button`: ``` line-height: 398px; ```
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
Give the parent element… ``` display: table; text-align: center; ``` …and its child element… ``` display: table-cell; vertical-align: bottom; ``` This way you do not need to know the width of the child element in case it changes, thus requiring no negative margins or workarounds.
For example write like this if you have position absolute: ``` .btn-bot{ position:absolute; margin-left:-50px; left:50%; width:100px; bottom:0px; } ``` Note: give margin-left half of the width of the button. [JSFiddle demo](http://jsfiddle.net/3QguR/12/)
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
For example write like this if you have position absolute: ``` .btn-bot{ position:absolute; margin-left:-50px; left:50%; width:100px; bottom:0px; } ``` Note: give margin-left half of the width of the button. [JSFiddle demo](http://jsfiddle.net/3QguR/12/)
This is what worked for me and I think is what several people were trying to get at. Just use a full width wrapper div with the button centered inside it. ``` <div class="outer"> <div class="inner-button-container"> <a href="#">The Button</a> </div> </div> .outer{ position:relative;...
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
One way of doing this would be to give it an absolute width and then a margin half of that: ``` width: 250px; margin-left: -125px; ``` Another way would be to give the `div` the following line-height and remove all styles from the `button`: ``` line-height: 398px; ```
You can use [`align-items: flex-end`](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) like so: ```css html, body { height: 100%; } .flex-container { height: 100%; display: flex; align-items: center; justify-content: center; } .center { width: 200px; height: 200px; backgroun...
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
For example write like this if you have position absolute: ``` .btn-bot{ position:absolute; margin-left:-50px; left:50%; width:100px; bottom:0px; } ``` Note: give margin-left half of the width of the button. [JSFiddle demo](http://jsfiddle.net/3QguR/12/)
I used `table-row` to combine text and button in one container: ``` #out{ display:table; position:absolute; } #out div#textContainer{ display:table-row; } #out div#text{ display:table-cell; vertical-align:top; } #out div#buttonContainer{ display:table-row; text-align:center; } #out div#b...
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
For example write like this if you have position absolute: ``` .btn-bot{ position:absolute; margin-left:-50px; left:50%; width:100px; bottom:0px; } ``` Note: give margin-left half of the width of the button. [JSFiddle demo](http://jsfiddle.net/3QguR/12/)
I know this has been answered a long time ago, but I couldn't use display:table on the parent container so I had to find another way around. It turned out that this worked just fine: ``` .container{ position:absolute; } .button{ position:absolute; bottom: 5px; left: 0%; right: 0%; text-align: ...
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
For example write like this if you have position absolute: ``` .btn-bot{ position:absolute; margin-left:-50px; left:50%; width:100px; bottom:0px; } ``` Note: give margin-left half of the width of the button. [JSFiddle demo](http://jsfiddle.net/3QguR/12/)
Does the button need to be absolutely positioned? If so, you could specify a width and then a negative left margin: ``` .btn-bot{ position: absolute; left: 50%; width: 100px; margin-left: -50px; bottom:0px; } ``` [fiddle](http://jsfiddle.net/3QguR/8/)
22,162,560
How to make a button be at the bottom of div and at the center of it at the same time? ```css .Center { width: 200px; height: 200px; background: #0088cc; margin: auto; padding: 2%; position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .btn-bot { position: absolute; bottom: ...
2014/03/04
[ "https://Stackoverflow.com/questions/22162560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2789810/" ]
One way of doing this would be to give it an absolute width and then a margin half of that: ``` width: 250px; margin-left: -125px; ``` Another way would be to give the `div` the following line-height and remove all styles from the `button`: ``` line-height: 398px; ```
I know this has been answered a long time ago, but I couldn't use display:table on the parent container so I had to find another way around. It turned out that this worked just fine: ``` .container{ position:absolute; } .button{ position:absolute; bottom: 5px; left: 0%; right: 0%; text-align: ...
60,878,489
When I generate the production version of my PWA built with VueJS I got this error in Google Chrome after deploying it to my server: * `Uncaught SyntaxError: Unexpected token '<'` in app.21fde857.js:1 * `Uncaught SyntaxError: Unexpected token '<'` in chunk-vendors.d1f8f63f.js:1 I take a look in the Network tab of the...
2020/03/27
[ "https://Stackoverflow.com/questions/60878489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12542704/" ]
Here is a solution that doesn't require hand-editing your dist assets. Simply add the following property to the exports of your vue.config.js: `publicPath: './'`
1. Add <%= BASE\_URL %> on all links in index.html (Example: `<link href="<%= BASE_URL %>favicon/apple-icon-144x144.png">`) 2. And add the **base** tag (Example: `<base href="https://mywebsite.com" />`) in the **head** tag, and now this works perfectly. **Old answer** I found a solution. I have to add a manually a `....
22,094,668
I have a database, I mapped it via Ado.net entity model, now I want to expose a single class from my model via WCF service. How can it be achieved?
2014/02/28
[ "https://Stackoverflow.com/questions/22094668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2606389/" ]
Just use specifc CSS rules as: ``` .yellow:hover ~ #slider { background: yellow !important; } ``` [SEE jsFiddle](http://jsfiddle.net/GJQA5/1/)
My approach: **Working:** <http://jsfiddle.net/skozz/YW24L/1/> **Pro tip:** You can refactor this code using array + each/for loop. ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("le...
22,094,668
I have a database, I mapped it via Ado.net entity model, now I want to expose a single class from my model via WCF service. How can it be achieved?
2014/02/28
[ "https://Stackoverflow.com/questions/22094668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2606389/" ]
Just use specifc CSS rules as: ``` .yellow:hover ~ #slider { background: yellow !important; } ``` [SEE jsFiddle](http://jsfiddle.net/GJQA5/1/)
Here is something much more simple: [Fiddle](http://jsfiddle.net/tomanow/GJQA5/7/) ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("left", $(".current_page a").position().left) .dat...
22,094,668
I have a database, I mapped it via Ado.net entity model, now I want to expose a single class from my model via WCF service. How can it be achieved?
2014/02/28
[ "https://Stackoverflow.com/questions/22094668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2606389/" ]
Just use specifc CSS rules as: ``` .yellow:hover ~ #slider { background: yellow !important; } ``` [SEE jsFiddle](http://jsfiddle.net/GJQA5/1/)
Here is the update code: **new CSS** ``` #slider.blue { background-color: blue; } #slider.orange { background-color: orange; } #slider.yellow { background-color: yellow; } #slider.lime { background-color: lime; } ``` **JS COde** ``` $(function() { $("#example-one").append("<div id='slider'></div>");...
22,094,668
I have a database, I mapped it via Ado.net entity model, now I want to expose a single class from my model via WCF service. How can it be achieved?
2014/02/28
[ "https://Stackoverflow.com/questions/22094668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2606389/" ]
Just use specifc CSS rules as: ``` .yellow:hover ~ #slider { background: yellow !important; } ``` [SEE jsFiddle](http://jsfiddle.net/GJQA5/1/)
I like the CSS solution of A.Wolff best, but here's an alternative. The changes are only made in your jQuery code. ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("left", $(".current_page ...
22,094,668
I have a database, I mapped it via Ado.net entity model, now I want to expose a single class from my model via WCF service. How can it be achieved?
2014/02/28
[ "https://Stackoverflow.com/questions/22094668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2606389/" ]
Here is something much more simple: [Fiddle](http://jsfiddle.net/tomanow/GJQA5/7/) ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("left", $(".current_page a").position().left) .dat...
My approach: **Working:** <http://jsfiddle.net/skozz/YW24L/1/> **Pro tip:** You can refactor this code using array + each/for loop. ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("le...
22,094,668
I have a database, I mapped it via Ado.net entity model, now I want to expose a single class from my model via WCF service. How can it be achieved?
2014/02/28
[ "https://Stackoverflow.com/questions/22094668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2606389/" ]
Here is the update code: **new CSS** ``` #slider.blue { background-color: blue; } #slider.orange { background-color: orange; } #slider.yellow { background-color: yellow; } #slider.lime { background-color: lime; } ``` **JS COde** ``` $(function() { $("#example-one").append("<div id='slider'></div>");...
My approach: **Working:** <http://jsfiddle.net/skozz/YW24L/1/> **Pro tip:** You can refactor this code using array + each/for loop. ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("le...
22,094,668
I have a database, I mapped it via Ado.net entity model, now I want to expose a single class from my model via WCF service. How can it be achieved?
2014/02/28
[ "https://Stackoverflow.com/questions/22094668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2606389/" ]
I like the CSS solution of A.Wolff best, but here's an alternative. The changes are only made in your jQuery code. ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("left", $(".current_page ...
My approach: **Working:** <http://jsfiddle.net/skozz/YW24L/1/> **Pro tip:** You can refactor this code using array + each/for loop. ``` $(function() { $("#example-one").append("<div id='slider'></div>"); var $slider = $("#slider"); $slider .width($(".current_page").width()) .css("le...