qid
int64
10
74.7M
question
stringlengths
15
26.2k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
27
28.1k
response_k
stringlengths
23
26.8k
38,770,403
I am doing my project and ran into a weird error of git. I clone a private project of a company named X by setting the user.name by following these commands : ``` git config --global --unset-all user.name ``` and then :- ``` git config --global --add user.name <whatever> ``` was able to clone the project. After this when I tried to push to my git profile I was unable to do that. It gave me the below error :- ``` Vikass-MacBook-Air% git push remote: Permission to vikkyconer/coursera-test.git denied to X. fatal: unable to access 'https://github.com/vikkyconer/coursera-test.git/': The requested URL returned error: 403 ``` After normal googling I found and understood that I have to reset again my user.name. I ran the above two commands again but I was unsuccessful to push to my branch. I am obviously able to clone the project and also able to take the pull of the project but not able to run git push. I reset my global, local and system's git user. After unset all users below command confirms me that no present user is there. ``` git config -l ``` I am still not able to do git push. Please help me if someone out there also faced the above error.
2016/08/04
[ "https://Stackoverflow.com/questions/38770403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3338909/" ]
Seeder usually just adds some data. It's just a simple class which does something like this: ``` // Insert one row of random data into the 'users' table DB::table('users')->insert([ 'name' => str_random(10), 'email' => str_random(10).'@gmail.com', 'password' => bcrypt('secret'), ]); ``` So no, it will not overwrite anything if you'll not tell it to do that.
To create migration of seeding use the following laravel package <https://github.com/slampenny/SmartSeeder> It creates versioned seeding and will only seed new files that are not migrated just like the default table migrations
11,544
I recently posted this question about character optimization: [What class has the most damage output per round at level 6?](https://rpg.stackexchange.com/questions/185443/what-class-has-the-most-damage-output-per-round-at-level-6) I made several revisions to it, and it received the required 5 votes to be re-opened, so clearly some part of the community felt that it was a perfectly valid question. Only a few hours after it was re-opened, it was closed again, and now has gained some reopen votes (I fully expect that it will be re-opened again in the next day or two). **How do we handle controversial questions such as this one, where a significant portion of the community believes it should be opened and another portion thinks it should remain closed?** Obviously, a cycle of open-close-open-close is undesirable. Note that this is *not* a question asking about the viability of my post in particular. That already has a meta post on it here: [My question was closed for being opinion based. Now it's been reopened and closed again. Why?](https://rpg.meta.stackexchange.com/questions/11535/my-question-was-closed-for-being-opinion-based-now-its-been-reopened-and-close) Rather, this is a question regarding questions that have been closed and opened multiple times in general.
2021/05/25
[ "https://rpg.meta.stackexchange.com/questions/11544", "https://rpg.meta.stackexchange.com", "https://rpg.meta.stackexchange.com/users/71240/" ]
Repeated close and reopen rounds occur in a narrow range of circumstances. One of the most common situations is that a question is simply contentious: several people think it ought to be closed for some reason or another, several other people think it ought to be open. The situation your question is in, however, is different: your question's had several iterations. Each iteration has had problems, so people have voted to close it. Then it gets edited, and the next iteration resolves some of those problems, and some voters have decided it's ready to reopen. Others think it still has problems, or has new problems, and still needs to be closed, so people have voted to close it. Close/reopen wars get won by exhaustion of votes. Eventually, the close/reopen tug-of-war settles on one side or another. You can only vote to close a question once, and the same goes for reopening, so each person has their say over subsequent rounds of closing/reopening and then everyone who can vote has done so and the question remains either closed or open. In the case of a contentious question, we might host a meta to come to agreement on whether to keep the question closed or not, and that usually resolves things all on its own. In your situation, it's trickier—the question has gone through several different iterations. We *haven't* really voted to close and reopen the same question multiple times; we've voted to close or reopen *different* questions each time, but all contained in the same post. [It probably should've been asked as a different question somewhere along the way](https://rpg.meta.stackexchange.com/questions/6519/when-a-question-changes-completely-should-it-be-a-new-question), but the changes were so incremental each time it's hard to say when that should have been done. Sometimes this just happens, and it's not ideal. Assuming your question is stabilised, we basically go back to that first paragraph I wrote: either your question has problems and gets closed, or doesn't and stays open, or it's contentious and we have to talk about it. There's already been two closures and two reopens, so that's ten votes used up—the community will weigh in with more if it's called for. --- That said, your question does have a bounty posted. Active bounties mean we *can't* vote to close it. If the community decides it needs to be closed before the bounty runs out, a diamond moderator (provided they agree) would step in to refund the bounty. Really, at this point, your question is now going to be measured by its activity and whether we see serious trouble brewing in the answers coming in.
### Whose vote is most valuable? No one user’s vote is most valuable. Every user with access to close votes gets one vote, and no vote is more valuable than any other. In a comment, you wrote: > > It's much better for questions to simply follow the close-edit-reopen cycle once, and at that point (once members have indicated the question is satisfactory to them) to simply let it play out as it will. > > > This idea is inconsistent with the principle that every vote is of equal value. If 100 people think a question should be closed, and 5 think it should be reopened, why should it be that those 5 reopen votes have the final say, and the remaining 95 voters who think the question should be closed should abstain from voting? ### Community moderation is working as intended. Everyone who has earned the privilege to vote can vote, and a cycle of close-open-close-open is indicative of a healthy and active system of community moderation. There are several other stacks that I read where question flags age out sitting in the review queue because nobody is doing moderation activities.
47,839,438
I have two arrays of numbers that have the same size. How can I tell if there is any element in the second array that is greater than the first array at a given index? With this example: ``` a = [2, 8, 10] b = [3, 7, 5] ``` `3` is greater than `2` at position `0`. But in the following: ``` a = [1, 10] b = [0, 8] ``` there is no such element. At index `0`, `0` is not greater than `1`, and at index `1`, `8` is not greater than `10`.
2017/12/15
[ "https://Stackoverflow.com/questions/47839438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
No need for indices. Just pair them and check each pair. ``` b.zip(a).any? { |x, y| x > y } => true or false ``` And a tricky one: Check whether at every position, `a` is the maximum: ``` a.zip(b).map(&:max) != a => true or false ``` And a very efficient one (both time and space): ``` b.zip(a) { |x, y| break true if x > y } => true or nil ``` (If you need `true`/`false` (often you don't, for example in `if`-conditions), you could prepend `!!` or append `|| false`)
If there's a number in `b` greater than the number in `a` at the given index, this will return the number in `b`. If no numbers in `b` are greater, `nil` will be returned. ``` b.detect.with_index { |n, index| n > a[index] } ``` For example, if you have the following arrays. ``` a = [3, 4, 5] b = [6, 7, 8] ``` You'll get a return value of `6`.
60,567,949
I have static website hosted in S3 which is served by Cloudfront.I invoke lambda functions through API gateway Rest API from my website.The API calls return 200 ok response and everything works ok,but sometimes the call fails with the message in X Amazon Header read as Authorizer Configuration Exception. I have configured the lambda invoke policy in my Lambda Authorizer through API gateway and have also enabled API GATEWAY invocation by editing the Trust relationship of my Authorizer Role. Still I keep getting this error infrequently.An API call which was successfully completed earlier would then throw this error upon successive invocations.What would be causing this error? What am I missing here?
2020/03/06
[ "https://Stackoverflow.com/questions/60567949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11011113/" ]
One `dplyr` possibility could be: ``` df %>% rowwise() %>% mutate(ID = +(sd(c(A, B, C)) == 0 & D == 11)) A B C D ID <int> <int> <int> <int> <int> 1 12 12 13 4 0 2 12 13 12 11 0 3 12 12 12 11 1 ```
An option with `pmap` ``` library(dplyr) library(purrr) df1 %>% mutate(ID = pmap(., ~ +(sd(head(c(...), 3)) == 0 & ..4 == 11))) # A B C D ID #1 12 12 13 4 0 #2 12 13 12 11 0 #3 12 12 12 11 1 ``` ### data ``` df1 <- structure(list(A = c(12L, 12L, 12L), B = c(12L, 13L, 12L), C = c(13L, 12L, 12L), D = c(4L, 11L, 11L)), class = "data.frame", row.names = c(NA, -3L)) ```
8,158,153
I've used rvm to install rails..no problems. Created a new app successfully Running bundle install without issues. Although, trying to run any command further (rails s, rails g controller.., etc) I'm getting this error ``` /home/USER/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.9/lib/execjs /runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) ``` I'm assuming there's an issue with a gem but I'm really clueless on what happened and can't seem to find anything that addresses this issue
2011/11/16
[ "https://Stackoverflow.com/questions/8158153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/967070/" ]
This happens when your ubuntu installation does not have a javascript runtime installed. Try: ``` sudo apt-get install nodejs ```
I had the same issue. Gemfile -> ``` gem 'execjs' gem 'rubytheracer' ``` bundle install
35,811,939
``` #include <stdio.h> #include <math.h> int binary(int); void main() { int num; printf("Enter the number:\n"); scanf_s("%d", &num); binary(num); } int binary(int num) { int rem; rem = num % 2; num = num / 2; if(num == 0) { printf("\nThe binary equivalent is %d", rem); return rem; } else binary(num); printf("%d", rem); } ``` I am not able to understand the working of return statement here. To what does it return the value to? I want to know how the final output is coming. Say if we take '8' as input, it outputs 1000, which is the binary equivalent of '8'. But I am unable to get the working.
2016/03/05
[ "https://Stackoverflow.com/questions/35811939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5930398/" ]
The variable in the global namespace will have much poorer performance, but not precisely for the reasons that @Freddie mentions. A variable in the global namespace could potentially be changed by something external, forcing the interpreter to reload the value each time through the loop. Using a local variable, the JIT engine can optimize the loop down to a few machine cycles per iteration, which is what seems to be happening here.
Have a look at this under Technique 1 - <http://www.webreference.com/programming/javascript/jkm3/index.html> > > Global variables have slow performance because they live in a highly-populated namespace. Not only are they stored along with many other user-defined quantities and JavaScript variables, the browser must also distinguish between global variables and properties of objects that are in the current context. Many objects in the current context can be referred to by a variable name rather than as an object property, such as alert() being synonymous with window.alert(). The down side is this convenience slows down code that uses global variables. > > >
22,879
Some sites allow you to register and only provide a single password box, which is protected with stars. Traditionally a "confirm password" box is used when registering which allows you to confirm that the password entered is indeed the password the user wishes to use. I know that an interface is only complete when there is nothing left to remove from it, however I got caught out this week by registering at a webservice that only asks for 1 password entry. I accidentally hit the wrong key when signing up, and ended up having to go through a password reset process in order to access the service later. **Would it not be advisable to allow password entry without the stars when going with the "single password box upon registration" model?**
2012/06/26
[ "https://ux.stackexchange.com/questions/22879", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/11862/" ]
The idea behind masking is that **someone may be watching you**r screen (from behind you). (Couldn't find an existing answer with this, even though I am sure I saw it here once, the is the closet I found is [Ben Brocka's answer here](https://ux.stackexchange.com/a/20958/687).) You could let the users **elect** to unmask or use the same trick used in mobile phones (temporarily unmasking the last character). (See [Jonathan Dickinson's answer](https://ux.stackexchange.com/questions/484/is-a-repeat-password-field-necessary-in-a-signup-page/508#508) and [Monica Cellio's answer](https://ux.stackexchange.com/a/20962/687).) * Both these methods are risky if you are using a normal size screen in a public location and the purpose behind the last character unmasking in mobile phones is to prevent typos created by the keyboard being to small and not having enough physical feedback. * Further more, both options are useless if you are not using alphanumeric characters or you are using a spatial keyboard pattern. The reasoning behind confirmation of the password is to help prevent mistyping. As [Dean wrote here](https://ux.stackexchange.com/a/20970/687) displaying the password to users isn't good enough (depends on convention used for the password). A password resetting process can be tiring and besides, the user may have mistyped his/her email address too (and that really shouldn't be confirmed: <https://ux.stackexchange.com/a/21063/687>). Also, remember that password resetting can lead to security risks: <https://ux.stackexchange.com/a/21744/687> Making the user type the password out twice isn't such a bad option - it can be checked via script before the user even hits the next button (e.g. **as soon as the user exits the field**). It gives users the chance the use their same method (for conceiving a password) over and confirms the result is the same. **If the password is too complex to type twice**, you are probably forcing your user to use illogical password complexity rules e.g. entering 8+ lower case and upper case letters and numbers when the complexity of passwords is actually about the same for: * 15 digits * 8 symbols from 16 in top row only + letters + letters both upper and lower + numbers. * 8-9 symbols from all 32 symbols in US keyboards + letters all upper or lower. * 8-9 symbols from all 32 symbols in US keyboards + letters all upper or lower + numbers. * 8 symbols from all 32 symbols in US keyboards + letters both upper and lower + numbers. * 9-10 symbols from 16 in top row only + letters + letters all upper or lower. * 9 symbols from 16 in top row only + letters + letters all upper or lower + numbers. * 8-9 symbols from 16 in top row only + letters + letters both upper and lower. * 10 letters all upper or all lower case + numbers. * 8-9 letters both upper and lower case + numbers. * 9 letters both upper and lower case. * 11 letters all upper or all lower case. * 3 random words in modern English
Smashing Magazine's article on [Innovative Techniques To Simplify Sign-Ups and Log-Ins](http://uxdesign.smashingmagazine.com/2011/05/05/innovative-techniques-to-simplify-signups-and-logins/) provides some interesting thinking around this where they have a section: > > **[REQUIRE USERS TO TYPE THEIR PASSWORD ONLY ONCE](http://uxdesign.smashingmagazine.com/2011/05/05/innovative-techniques-to-simplify-signups-and-logins/)** - Smashing Magazine > > > Many sign-up forms ask users to type their password in two different fields. The reason is understandable. Forms mask passwords for security reasons, so that snoopers can’t see them. And to cut down on typographical mistakes and increase the chances of correct input, two separate entries are required. > > > In reality, though, this allows for greater error, because it forces users to type more. They can’t see the characters they’re inputting, making it difficult to know whether they’re typing the right password each time. > > > To add on top of that I would suggest just making sure that you have a reliable *forgot password* functionality for when users forget what they typed.
34,589,919
I am trying to understand one PHP OOP concept, lets say i have two classes A and B. B extends A there fore A is Base/Parent class. If class A has a \_\_construct class B will automatically inherit it...? Example: ``` class Car { public $model; public $price; public function __construct() { $this->model = 'BMW'; $this->price = '29,00,00'; } } class Engine extends Car { parent::__construct(); } ``` By `parent::__construct();` class Engine will execute `Car __construct();` automatically? But I always though if I inherit from parent class the `__construct` will be executed automatically anyway why would I add this `parent::__construct()`?
2016/01/04
[ "https://Stackoverflow.com/questions/34589919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5127919/" ]
When one class `extends` another, it inherits all its methods. Yes, that includes the constructor. You can simply do `class Engine extends Car {}`, and `Engine` will have a constructor and all other properties and methods defined in `Car` (unless they're `private`, which we'll ignore here). If you define a method of the same name as already exists in `Car` in `Engine`, you're *overriding* that method implementation. That's exactly what it sounds like: *instead of* `Car`'s implementation, `Engine`'s method is called. > > why would I add this `parent::__construct()`? > > > If you're *overriding* a method, yet you *also* want to call the parent's implementation. E.g.: ``` class Engine extends Car { public function __construct() { parent::__construct(); echo 'Something extra'; } } ```
Overriding a constructor in a child class is exactly that, **overriding**... you're setting a new constructor for the child to **replace** the parent constructor because you want it to do something different, and generally you won't want it to call the parent constructor as well..... that's why you need to explicitly call the parent constructor from the child constructor if you want them both to be executed. If you don't create a child constructor, then you're not overriding the parent constructor, so the parent constructor will then be executed
20,353,945
I try to modify a value that is stored at a certain memory address. The address is stored in a certain pointer but altering it with a new int changes the memory address (of course). ``` int *toModify = (int *)(foo+5); //foo is a adress of a function. //The val to alter is 5bytes after it int newVal = 5; toModify = &newVal; //implementation of foo int foo(){ return 42; } ``` Lets say toModify has value 42. I want to change it to 5. How can I achieve to store the change in the address of toModify?
2013/12/03
[ "https://Stackoverflow.com/questions/20353945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1283056/" ]
You cannot do this in a portable, standards compliant way. Even if you wanted to do this in a non-portable way (which you may be able to do by manipulating the machine code directly), `foo` is likely in read-only memory, and so can't be modified. It would be better to define `foo` to access a global or static variable, which you could change. For example: ``` static int n = 42; int foo() { return n; } // when you want to modify it n = 5; ```
Perreal's (delete) answer is right: ``` *toModify = newVal; ``` ... but... you're trying to write a into the application's code space, and modern operating systems go to great lengths to prevent this, as it's a *major* security risk. That's probably why you'll probably get a segmentation fault. Also, you're writing an int (maybe a 4-byte value on your system?) at an address `(foo+5)` which is not aligned to a 4-byte boundary. Again, your hardware may not support this, If you want to modify a byte, you need this. ``` char * toModify; ```
87,512
I'm a fairly new user of wordpress.org. I have a wordpress.com site using the Confit theme and wish to transfer it to .org. I exported the site from .com and into imported to .org successfully, only to find that .org did not offer the Confit theme. I have since downloaded the directory for the Confit theme from here: <https://wpcom-themes.svn.automattic.com/> and saved it in the wp-content/themes/confit. The Confit theme option appears normally in the installed themes section of the .org suite, alongside twenty eleven and twenty twelve preinstalled themes. However, when trying to apply the theme to the site, the progress bar gets half way before the whole thing turns blank, no matter what address within the site I try and visit. I can no longer access the admin page to change the theme back. As a result, I wiped the databases on the domain, deleted and reinstalled wordpress on the site etc. Again the site works fine until I try to apply the theme. The last time, I have tried to preview the theme before applying it and, unsurprisingly, the preview is blank - no side bar or anything. Can anyone suggest what I might have done wrong when installing the theme? Cheers, Tom.
2013/02/19
[ "https://wordpress.stackexchange.com/questions/87512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27711/" ]
WordPress.com has now made the theme downloadable via a ZIP file from the theme's page at: <http://theme.wordpress.com/themes/confit/> After installing the theme from within your dashboard, it will then show a message asking if you also want to install their "WordPress.com Theme Updates" plugin.
Sure, you can svn the theme. But there will be some differences between running it on .com and self-hosted. You need to enable debugging <http://codex.wordpress.org/Debugging_in_WordPress> and see what's wrong. I've svn'd many themes from .com and the differences vary. You will need to debug and learn some php to remove functions that .com uses and are not going to wok self-hosted. And if you white screen, there's absolutely no need to wipe the install and start over. Simply use FTP to delete or rename the problem theme and then WP will default to twentyeleven.
26,365,570
Using a library called Velocity JS for animating: <http://julian.com/research/velocity/> I am using it as follows: ``` var velocity = new Velocity(element, { translateX: 250, complete: function() { return true; } }, 5); ``` What I am trying to do is **check if complete has returned true** on successful completion of the animation so that I can toggle the animation. What is the best method for checking if it is true ``` if(velocity.complete() === true) ``` This returns undefined. Any help is appreciated thanks.
2014/10/14
[ "https://Stackoverflow.com/questions/26365570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2920441/" ]
If I understood the question properly, you are not really concerned about the *values* in the second row, but the number of occurrences of the elements in row 1. This can be obtained with the `unique` and `histc` functions: ``` C(1,:)=unique(A(1,:)); C(2,:)=histc(A(1,:),C(1,:)); C = 1 2 3 4 5 4 2 2 1 1 ```
The answer depends on whether repeated columns should be counted repeatedly or not. Consider the following data: ``` A = [1 2 1 3 1 2 4 3 5 1; 2 3 4 5 6 6 6 5 7 8]; %// col [3;5] appears twice ``` 1. If repeated columns should be **counted according to their multiplicity**: you can use [`accumarray`](http://www.mathworks.es/es/help/matlab/ref/accumarray.html): ``` [ii, ~, kk] = unique((A(1,:))); jj = accumarray(kk.', A(2,:).', [], @(x) numel(x)).'; C = [ii; jj]; ``` Result with my example `A`: ``` C = 1 2 3 4 5 4 2 2 1 1 ``` Or you can use [`sparse`](http://www.mathworks.es/es/help/matlab/ref/sparse.html): ``` [~, ii, jj] = find(sum(sparse(A(2,:), A(1,:), 1))); C = [ii; jj]; ``` The result is the same as above. 2. If repeated columns should be **counted just once**: either of the two approaches is easily adapted to this case: ``` [ii, ~, kk] = unique((A(1,:))); jj = accumarray(kk.', A(2,:).', [], @(x) numel(unique(x))).'; %'// note: "unique" C = [ii; jj]; ``` or ``` [~, ii, jj] = find(sum(sparse(A(2,:), A(1,:), 1) > 0)); %// note: ">0" C = [ii; jj]; ``` Result (note third column is different than before): ``` C = 1 2 3 4 5 4 2 1 1 1 ```
18,050,918
not long ago twitter stopped supporting rest 1.0 and I had to find some suloutions using new OAuth system. I found **[this](https://stackoverflow.com/questions/17067996/authenticate-and-request-a-users-timeline-with-twitter-api-1-1-oauth/17071447#17071447).** That worked well and was simple in use. But recently I faced some strange behavior. This, lets call it module, didn't recieved any tweets from given screen name. It passed authentication, but json result was empty, although timeline wasn't empty on twitter. Did anyone faced such problem?
2013/08/05
[ "https://Stackoverflow.com/questions/18050918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1049397/" ]
I would personally like to choose ``` if (condition) { return x; } else { return y; } ``` This is much more readable for me, with or without the braces. These are return statements, so it might not make much difference. But lets say they are just statements, like the example below: ``` if (condition){ //some statements } else { //some related statements } ``` This code as time progresses might lead to something like below ``` if (condition){ //some statements } else { //some related statements } //some totally unrelated statements ``` In such a case you clearly distinguish which ones are the ones that are affected by the condition. In the future, when you need to refactor it out, it might be easier. As you might see, its just a personal taste. I would recommend you to check with your lead/architect/peers and see if they have a preference. As a thumb rule, it would be better to go with the team's preference than your own.
There is no difference in code's logic and I believe it could be even compiled into exactly the same bytecode in both cases. It's more about personal preferences. Here is a short list of factors involved in favor of the former approach: 1. There's no "third option" as in the first example. Although Java compiler is smart enough to detect that, there is no way for a function not to finish its execution (`return`) within `if` or `else` block, the first code looks like there could be such a case. Especially when your code grows up, and return statemenets are no longer so clearly visible. 2. Limit the number of opened curly brackets - that's more important in my opinion. You should always try to limit number of nested blocks (`{...}`) to the minimum - code is almost always much more readable that way: ``` for (...) { if (...) { if (...) { // this sucks, 3 levels of indention } } } for () { if (!...) { continue; } if (!...) { continue; } // maybe there's more code but it's much easier to read and maintain } ```
34,091,749
I have a table in my database like this : ``` id date origine 1 2015-12-04 16:54:38 1 ``` Now I want to get only data witch have the date = `2015-12-04`. So I tried like this : ``` select * from table where id = 1 and date = "2014-12-04" ``` But I have no data. Can you help me please ?
2015/12/04
[ "https://Stackoverflow.com/questions/34091749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5289843/" ]
A good rich-text editor is one of the harder things to do currently, and is pretty much a project by itself (unfriendly API, huge number of corner cases, cross-browser differences, the list goes on). I would strongly advise you to try and find an existing solution. Some libraries that can be used include: * Quill (<http://quilljs.com>) * WYSGIHTML (<http://wysihtml.com>) * CodeMirror library (<http://codemirror.net>)
This is what you asked for, in your bounty: on the following example you can see how to detect the exact number of characters of the actual point where you clicked the mouse on: ``` <!-- Text Editor --> <div id="editor" class="divClass" contenteditable="true">type here some text</div> <script> document.getElementById("editor").addEventListener("mouseup", function(key) { alert(getCaretCharacterOffsetWithin(document.getElementById("editor"))); }, false); function getCaretCharacterOffsetWithin(element) { var caretOffset = 0; var doc = element.ownerDocument || element.document; var win = doc.defaultView || doc.parentWindow; var sel; if (typeof win.getSelection != "undefined") { sel = win.getSelection(); if (sel.rangeCount > 0) { var range = win.getSelection().getRangeAt(0); var preCaretRange = range.cloneRange(); preCaretRange.selectNodeContents(element); preCaretRange.setEnd(range.endContainer, range.endOffset); caretOffset = preCaretRange.toString().length; } } else if ( (sel = doc.selection) && sel.type != "Control") { var textRange = sel.createRange(); var preCaretTextRange = doc.body.createTextRange(); preCaretTextRange.moveToElementText(element); preCaretTextRange.setEndPoint("EndToEnd", textRange); caretOffset = preCaretTextRange.text.length; } return caretOffset; } </script> ```
2,588,425
I am using the split view template to create a simple split view that has, of course, a popover in Portrait mode. I'm using the default code generated by template that adds/removes the toolbar item and sets the popover controller and removes it. These two methods are splitViewController:willShowViewController:... and splitViewController:willHideViewController:... I'm trying to figure out how to make the popover disappear if the user taps on the toolbar button while the popover is displayed. You can make the popover disappear without selecting an item if you tap anywhere outside the popover, but I would also like to make it disappear if the user taps the button again. Where I'm stuck is this: there doesn't seem to be an obvious, easy way to hook into the action for the toolbar button. I can tell, using the debugger, that the action that's being called on the button is showMasterInPopover. And I am new to working with selectors programmatically, I admit. Can I somehow write an action and set it on the toolbar item without overriding the action that's already there? e.g. add an action that calls the one that's there now? Or would I have to write an action that shows/hides the popover myself (behavior that's being done behind the scenes presumably by the split view controller now???). Or am I missing an easy way to add this behavior to this button without changing the existing behavior that's being set up for me? Thank you!
2010/04/06
[ "https://Stackoverflow.com/questions/2588425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/151894/" ]
So, the barButtonItem will have the UISplitViewController as the target and showMasterInPopover: as the action. I can't find it in the documentation, so I'm a bit worried it's not okay to call it, but I got it to work by changing the target to self (the view controller) and the action to a custom method, like this: ``` - (void)showMasterInPopover:(id)sender { // ...insert custom stuff here... [splitViewController showMasterInPopover:sender]; } ```
Elisabeth writes: > > You can make the popover disappear without selecting an item if you tap anywhere outside the popover, but I would also like to make it disappear if the user taps the button again. > > > First of all, let me say that none of what I am about to say is to be taken personally -- it is not meant that way. It all comes from years of designing programming interfaces and studying the Apple Human Interface Guidelines (as well as having a Graphic Designer who is contstantly **trying** to teach me the right way to do things). It is meant as an opposing viewpoint and not as a rant. What you are suggesting is a problem UI-wise for me, and will be an issue that causes trouble when Apple reviews the app. You are never supposed to have a known-UI-object perform a function that it does not perform normally (For instance: a button **never** shows **and then** releases a view/object/window. Toggles do this). For instance, a magnifying glass on the navbar means Search (as defined by Apple). They have in the past, and will continue in the future to, refuse apps that use this for zooming the interface. For example: [Apple Rejects ConvertBot](http://www.tuaw.com/2009/08/28/stupid-and-unjustified-app-store-rejection-letter-of-the-day/) or [The Odyssey: Trail of Tears](http://boredzo.org/killed-iphone-apps/) (search the page for it). The language in the rejection is always the same (bold marking what they would cite for your usage): > > “… uses standard iPhone/iPod screen images in a non-standard way, potentially resulting in user confusion. Changing the behavior of standard iPhone graphics, **actions**, and images, or simulating failures of those graphics, actions, or images is a violation of the iPhone Developer Program agreement which requires applications to abide by the Human Interface Guidelines.” > > > Also, if you really want this feature, ask yourself: "Why?". If it is because you, yourself, like it, then I would really skip it. Most users would be confused by this behavior and would not actually use it because **they would not know it was an option to use**. Apple spent the last 3 years training iPhoneOS users how to use their OS and interface elements. The last thing you, as a programmer or designer, want to do is spend time trying to train a user on how to use your app. They will generally remove your app from their device and move to another similar app instead of forcing themselves to learn **your** way of doing things. Just my $.02
34,534,927
Let's say I have a program in which I must use a global variable (of some class type). I would like to be able to use smart pointers so I won't have to worry about deleting it. in some file `Common.hpp` file I have the declaration: ``` extern unique_ptr<CommandBuffer> globalCommandBuffer; ``` and in my main.cpp: ``` #include "Common.hpp" int main(int argc, char* argv[]) { globalCommandBuffer(new CommandBuffer()); } ``` this creates many compilation errors. so obviously I'm doing it wrong. my questions are: * is it a good design choice to use smart pointers for global variables? * if so, what is the correct way of doing so? * which smart pointer is preferable?
2015/12/30
[ "https://Stackoverflow.com/questions/34534927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You want either: ``` globalCommandBuffer.reset(new CommandBuffer()); ``` Or: ``` globalCommandBuffer = std::make_unique<CommandBuffer>(); ``` Global variables are very rarely a good idea.
If you want a global (you probably don't, but just in case you do), just create a global. The whole point of a smart pointer is to manage ownership and lifetime. In the case of a global, those are generally quite trivial--you want them to exist before anything else happens, and continue existing until everything else quits happening. Unless you need something different from that, just create your object as a global object, not a smart pointer to a dynamically allocated object.
6,820,565
Can I pass `false` as a needle to `in_array()`? ``` if(in_array(false,$haystack_array)){ return '!'; }else{ return 'C'; } ``` The `$haystack_array` will contain only boolean values. The haystack represents the results of multiple write queries. I'm trying to find out if any of them returned false, and therefore not completed.
2011/07/25
[ "https://Stackoverflow.com/questions/6820565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1149/" ]
PHP won't care what you pass in as your 'needle', but you should probably also use the third (optional) parameter for in\_array to make it a 'strict' comparison. 'false' in PHP will test as equal to `0`, `''`, `""`, `null`, etc...
There's [got to be a better way](http://www.ideone.com/j9v1D). ``` <?php echo (in_array(false,array(true,true,true,false)) ? '!' : 'C'); echo (in_array(false,array(true,true,true,true)) ? '!' : 'C'); Output: !C ```
4,403,781
I did a clean jCarousel setup, meaning I didn't use the provided stylesheet or any of the skins and styled it from scratch. But the Next button isn't working. The weird thing is that it *does* work after I inspect it with FireBug or the built-in element inspector on Chrome. I assume it has something to do with the element being in focus, but I don't know how to fix the problem. I tried modifying the z-indexes of the elements but to no avail. Any ideas as to what's going on here? Thanks!
2010/12/09
[ "https://Stackoverflow.com/questions/4403781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/532742/" ]
Heres' a translation. ``` Dim random = New Random() Dim number = random.Next() Console.WriteLine(number) Dim GenerateRandom = Function () Dim random = New Random() Dim number = random.Next() End Function Console.WriteLine("Begin Call") GenerateRandom.DoAsync(Sub (number) Console.WriteLine(number)) Console.WriteLine("End Call") ```
[Reflector](http://www.red-gate.com/products/reflector/ "Reflector") is an easy and free way to convert between .NET languages.
48,763,985
I am trying to deploy my microservice in EC2 machine. I already launched my EC2 machine with Ubuntu 16.04 LTS AMI. And also I found that we can install Docker and run containers through Docker installation. Also I tried sample service deployment using Docker in my Ubuntu. I successfully run commands using -d option for running image in background also. Can I choose this EC2 + Docker for deployment of my microservice for actual production environment? Then I can deploy all my Spring Boot microservice in this option. I know that ECS is another option for me.To be frank trying to avoid ECR, ECS optimized AMI and its burdens, Looking for machine with full control that only belongs to me. But still I need to know about the feasibility of choosing EC2 + Docker through my Ubuntu machine. Also I am planning to deploy my Angular 2 app. I don't need to install, deploy and manage any application server for both Spring Boot and Angular, since it will gives me about a serverless production environment.
2018/02/13
[ "https://Stackoverflow.com/questions/48763985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8655052/" ]
What you are describing is a "traditional" single server environment and does not have much in common with a microservices deployment. However keep in mind that this may be OK if it is only you, or a small team working on the whole application. The microservices architectural style was introduced to be able to handle huge, complex applications with large development teams that require to scale out immensely due to fast business growth. Here an [example story from Uber](https://www.infoq.com/presentations/uber-darwin). Please read [this](https://martinfowler.com/microservices/) for more information about how and why the microservices architectural style was introduced as well as the benefits/drawbacks. Now about your question: > > "Can I choose this EC2 + Docker for deployment of my microservice for actual production environment? " > > > Your question can be simply answered: You can, but it is probably not a good idea assuming you have a large enough project to require a microservices architecture. You would have to implement all of the following deployment aspects yourself, which is typically covered by an orchestration system, like [kubernetes](https://kubernetes.io/docs/getting-started-guides/aws/): 1. Service Discovery and Load Balancing 2. Horizontal Scaling 3. Multi-Container Application Deployment 4. Container Health-Management / Self-Healing 5. Virtual Networking 6. Rolling Updates 7. Storage Orchestration > > "Since It will gives me about a serverless production environment to > me." > > > EC2 is by definition not serverless, of course. You will have to maintain your EC2 instances, including OS updates, security patches etc. And if you only have a single server you will have service outages because of it.
> > Can I choose this EC2 + Docker for deployment of my microservice for actual production environment? > > > Yes, this is totally possible, although I suggest using **kubernetes** as the container-orchestrator as it manages the lifecycle of the containers for you: 1. [Running Kubernetes on AWS EC2](https://kubernetes.io/docs/getting-started-guides/aws/) 2. [Amazon Elastic Container Service for Kubernetes](https://aws.amazon.com/blogs/aws/amazon-elastic-container-service-for-kubernetes/) 3. [Manage Kubernetes Clusters on AWS Using Kops](https://aws.amazon.com/blogs/compute/kubernetes-clusters-aws-kops/) 4. [Amazon EKS](https://aws.amazon.com/eks/)
30,197,213
How can i make two bindings on a column in grid, in the way that if first binding is empty or null, second binding will be used. I have tried to do that with FallbackValue property but you can't make binding inside it only static values. Here some code, which is more than words! ``` <telerik:RadGridView x:Name="radGridView"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName, FallbackValue=Binding FirstName2}" //You cant do that! Header="First Name" /> </telerik:RadGridView.Columns> </telerik:RadGridView> ``` There must be someway to do it in xaml! Please help!
2015/05/12
[ "https://Stackoverflow.com/questions/30197213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4519970/" ]
Use a function which will return a value at the specific key of each object in array: ``` $scope.filterFunc = function (obj){ return obj['ga:sessions']; } ``` And in the HTML: ``` <div ng-repeat="page in pages | orderBy:filterFunc:true"> ``` See also [this SO post](https://stackoverflow.com/a/12041694/2046306).
You can't use it this way because angular parser will not allow you. You can write your own filter or fix keys before converting them to object. UPD: Technically it's not valid attribute name according to ECMAScript 5.1 <https://es5.github.io/#x7.6>
982,628
[Google Earth was installed using this procedure on 16.10.](https://skagitsignal.com/how-to-install-google-earth-64-bit-in-ubuntu-16-04-lts-x64/) What is the file to invoke from the command line to launch the application? [![enter image description here](https://i.stack.imgur.com/G75yH.png)](https://i.stack.imgur.com/G75yH.png) UPDATE ====== Found a script that should be used to invoke the application: user@hostname:/opt/google/earth/pro$ google-earth-pro ``` #!/bin/sh # Always run Google Earth from this shell script and not # Google Earth directly! This script makes sure the app looks # in the right place for libraries that might also be installed # elsewhere on your system. # # Ryan C. Gordon, Thu Jul 20 14:32:33 PDT 2006 # Function to find the real directory a program resides in. FindPath() { fullpath="`echo $1 | grep /`" if [ "$fullpath" = "" ]; then oIFS="$IFS" IFS=: for path in $PATH do if [ -x "$path/$1" ]; then if [ "$path" = "" ]; then path="." fi fullpath="$path/$1" break fi done IFS="$oIFS" fi if [ "$fullpath" = "" ]; then fullpath="$1" fi # Is the sed/ls magic portable? if [ -L "$fullpath" ]; then #fullpath="`ls -l "$fullpath" | awk '{print $11}'`" fullpath=`ls -l "$fullpath" |sed -e 's/.* -> //' |sed -e 's/\*//'` fi dirname $fullpath } script_path=$(FindPath $0); cd $script_path; LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./googleearth-bin "$@" ```
2017/12/03
[ "https://askubuntu.com/questions/982628", "https://askubuntu.com", "https://askubuntu.com/users/545291/" ]
I suggest to find Google Earth executable by listing all installed files and searching here its executable or desktop file. I do not have Google Earth Pro installation, so here are examples for normal version: * list all installed files and find placed in *bin* here: ``` $ dpkg -L google-earth-stable | grep bin/ /usr/bin/google-earth $ file /usr/bin/google-earth /usr/bin/google-earth: symbolic link to /opt/google/earth/free/googleearth ``` so Google Earth executable is located in *`/usr/bin/google-earth`* and it is a symbolic link to *`/opt/google/earth/free/googleearth`*. * search desktop file and show *Exec* line: ``` $ dpkg -L google-earth-stable | grep desktop $ /opt/google/earth/free/google-earth.desktop $ cat /opt/google/earth/free/google-earth.desktop | grep Exec Exec=/opt/google/earth/free/google-earth %f ``` so executable file is located in *`/opt/google/earth/free/google-earth`*. I'm using MATE DE, so I can find Google Earth icon in the menu *Applications|Internet|Google Earth* - it is the most user-friendly solution.
You also can find it in the GUI: click on `Show Applications` (in 17.10 at the bottom of the Dashboard, in former version at the top) and begin typing `google earth`. While typing you should see Google Earth. While it is running, it appears with its icon in the Dashboard and you may pin it if you want to use it more often (right click on the icon and `add to favorites`).
10,039,275
I'm writing a program that listens to the System Clipboard for changes. The listener runs on a separate thread and performs some action (say, write to file) when the contents of the Clipboard changes. I'm polling the clipboard using the [ClipboardOwner interface](http://www.javapractices.com/topic/TopicAction.do?Id=82 "Example usage of ClipboardOwner interface"), so that when my program loses ownership of the Clipboard (meaning another process has modified the clipboard) an event is fired in my program letting me read the changes. ```java public class OwnershipClipboardListener extends Thread implements ClipboardOwner { private Clipboard clipB = Toolkit.getDefaultToolkit().getSystemClipboard(); public void run() { /* Initialize ClipboardListener and gain ownership of clipboard */ } @Override public void lostOwnership(Clipboard clipboard, Transferable transferable) { /* Auto-fired when I lose Clipboard ownership. Can do processing and regaining ownership here */ } } ``` The problem is, when running in OSX, any change to the clipboard is reflected only if I manually Cmd-Tab to the running process icon in the dock. So if there multiple clipboard operations before I switch to the dock icon, only the last one has any effect. I don't face this issue on Linux or Windows. It's like the thread goes to sleep when the program loses focus, but the last Event trigger still fires when it wakes up. Is there any way I can prevent this sleep?
2012/04/06
[ "https://Stackoverflow.com/questions/10039275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/793803/" ]
I suspect that OSX doesn't provide notification of clipboard changes, so Java is doing the best it can by notifying you whenever it gets woken for some other reason. My suspicion comes from the [NSPasteboard](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html#//apple_ref/occ/cl/NSPasteboard) docs, the `changeCount` routine in particular. It says "You can therefore record the change count at the time that you take ownership of the pasteboard and later compare it with the value returned from changeCount to determine whether you still have ownership." No mention of using an event to detect changes.
Seems Keith is right. However, you can do a workaround by sending the application to the background (on \*Nix): ``` java -jar clipboard-1.0.jar & ``` This opens the Java application in the background and does not need window focus for notifications to fire.
1,308,177
This may be a dumb question - and the title may need to be improved... I think my requirement is pretty simple: I want to send a request for data from a client to a server program, and the server (not the client) should respond with something like "Received your request - working on it". The client then does other work. Then when the server has obtained the data, it should send an asynchronous message (a popup?) saying "I've got your data; click on ... (presumably a URL) to obtain data". I have been assuming that the server could be written in Java and that client is html and JavaScript. I haven't been able to come up with a clean solution - help would be appreciated.
2009/08/20
[ "https://Stackoverflow.com/questions/1308177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/408718/" ]
Try to employ "Websocket Method" by using "SuperWebSocket" for server side, and "WebSocket4Net" for client side. It is working perfectly for my current project.
Are you trying to do this on the HTTP protocol? It sounds like you're talking about a web application here, but it's not clear from the question. If so, then there are a variety of techniques for accomplishing this using AJAX which collectively go under the name "Comet". Depending on exactly what you're trying to accomplish, a number of different implementation, on both the client and server side, may be appropriate.
452,502
I was reading the some contract termination terms, and came across a phrase that I could not derive the exact meaning of and it's still bothering me. Can somebody please explain 'without prejudice to damages' in other words? As far as I understand, it is a truncated version of 'without prejudice to claim for any damages', but that does not make it any more clear. I don't have the document on hand right now, but here's a short, approximate version of it: > > If Y fails to do something, X reserves the right to: > > > * Claim for compensation for any losses incurred > * Terminate the contract (**without prejudice to damages**) > > > If I'm understanding it correctly, in other words, terminating the contract does not bar X from claiming damages as well?
2018/06/29
[ "https://english.stackexchange.com/questions/452502", "https://english.stackexchange.com", "https://english.stackexchange.com/users/305369/" ]
Can't is widely considered an abbreviated form of 'cannot', and 'cannot you tell?' is a grammatical expression. > > Most contractions represent the joining of two words. “Can’t” is an > exception however. Following the rules that apply to most > contractions, you probably find yourself tempted to replace “can’t” > with “can not.” However, when replacing “can’t,” use “cannot.” > > > [Cannot or can not (Writing Guides)](https://web.archive.org/web/20180813012825/http://www.write.com:80/writing-guides/general-writing/word-choice/cannot-versus-can-not/) Both cannot and can not are acceptable spellings, but the first is much more usual. You would use can not when the ‘not’ forms part of another construction such as ‘not only’. For example: > > These green industries can not only create more jobs, but also promote > sustainable development of the land. > > > [Cannot or can not (Oxford)](https://web.archive.org/web/20220823030046/https://www.lexico.com/grammar/cannot-or-can-not)
"...can't you tell?" is valid usage. It would be understood as a contraction representing "... can you not tell?" even though the "n't" for "not" is moved left of the word "you" to join the word "can".
356,695
I work for a small company. We get computers in batches and every batch differs hardware-wise. When we get new PC's in I spend about half an hour on each one, wiping the hard drive, putting a fresh copy of Windows 7 on there (using the license key on the side of the machine which doesn't always work so I sometimes have to call Microsoft) and installing all of the software the staff need to do their job then finally hooking the computer up to the domain (SBS 2003). Every computer has an identical setup, I need a more professional way to go about this while keeping costs down (startup company). I know I'm doing it wrong but I don't know how to do it correctly! I need some guidance here
2011/11/12
[ "https://superuser.com/questions/356695", "https://superuser.com", "https://superuser.com/users/100543/" ]
Since you have an SBS2003 domain available to you, then why not check out the in-built [Software Distribution system](http://support.microsoft.com/kb/816102), at least for the application deployment part. > > * Assigning Software > > > You can assign a program distribution to users or computers. If you > assign the program to a user, it is installed when the user logs on to > the computer. When the user first runs the program, the installation > is finalized. If you assign the program to a computer, it is installed > when the computer starts, and it is available to all users who log on > to the computer. When a user first runs the program, the installation > is finalized. > > > * Publishing Software > > > You can publish a program distribution to users. When the user logs on > to the computer, the published program is displayed in the Add or > Remove Programs dialog box, and it can be installed from there. > > > Using this you can assign software by user and/or computer via Group Policy (using OUs and the like). You can then manage/update the packages to perform upgrades, uninstalls, etc. without visiting all the machines.
You can also look at using SysPrep. That's what I use, then I can mirror the Hard Disk to other machiines, and it's like doing the first boot period again (enter name, password, time, done)
31,778,790
Situation I have a form where the user selects from a few options in a select box. When the user select the option 'other' i want to select box to transform into an input box. This is my code. Head ``` <script> function chargeother(select) { if (select=="other") { document.getElementById('chargeother').innerHTML= '<input type="text" name="type">'; } } </script> ``` Body First Select Box ``` <td id="inputtype"> <select type="text" name="type" onchange="chargeother(this.value)"> <option value="Labour and Material">Labour and Material</option> <option value="Quoted">Quoted</option> <option value="Labour Only">Labour Only</option> <option value="Material Only">Material Only</option> <option value="other">Other</option> </select> </td> ``` Second Select Box ``` <td id="inputhazard"> <select type="text" name="hazard" onchange="chargeother(this.value)"> <option value="No Significant Hazard">No Significant Hazard</option> <option value="GC43 Attached">GC43 Attached</option> <option value="other">Other</option> </select> </td> ``` I need this function twice on my page is it possible to add an 'id' into the onchange function call
2015/08/03
[ "https://Stackoverflow.com/questions/31778790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3993589/" ]
You needed to specify a `<table>` and `<tr>` tag for `<td>` in the HTML, and use innerHTML on the element and make sure you comment out the double quotes for the attribute values //CODE ``` <!DOCTYPE html> <html> <head> <script> function chargeother(ele){ switch(ele.parentNode.id){ case "inputtype": if(ele.value === "other"){ document.getElementById("inputtype").innerHTML = "<input type=\"text\" name=\"type\">"; } break; case "inputhazard": if(ele.value === "other"){ document.getElementById("inputhazard").innerHTML = "<input type=\"text\" name=\"type\">"; } break; } } </script> </head> <body> <table> <tr> <td id="inputtype"> <select type="text" name="type" onchange="chargeother(this)"> <option value="Labour and Material">Labour and Material</option> <option value="Quoted">Quoted</option> <option value="Labour Only">Labour Only</option> <option value="Material Only">Material Only</option> <option value="other">Other</option> </select> </td> <td id="inputhazard"> <select type="text" name="hazard" onchange="chargeother(this)"> <option value="No Significant Hazard">No Significant Hazard</option> <option value="GC43 Attached">GC43 Attached</option> <option value="other">Other</option> </select> </td> </tr> </table> </body> </html> ```
You can achieve it like this: > > > ``` > function chargeother ( select ) { > if (select == "other") > { > var elem = document.getElementById(" selectId "); > elem.parentElement.removeChild (elem); > var inputElem= document.createElement ('input'); > inputElem. type='text'; > document.getElementById (" chargeother").appendChild(inputElem); > } > } > > ``` > >
33,718,048
I'm trying to learn how to create responsive design and actually have a few questions. First of all, can I move BLOCK2 under BLOCK4 in samller resolution? (my media queries have 736px max-width[![enter image description here](https://i.stack.imgur.com/uqFSK.png)](https://i.stack.imgur.com/uqFSK.png) Here's css: ``` div.block1 { float: left; width: 200px; text-align: center; ; background-color: #004e52 } div.right { margin-left: 200px; overflow: hidden } div.block2 { margin-top: 10px; float: right; width: 200px; text-align: center; background-color: #004e52 } div.center { margin-right: 200px } div.block3 { margin: 10px; text-align: center; background-color: #004e52 } div.block4 { margin: 10px; text-align: center; background-color: #004e52 } ``` And here's html: ``` <body> <div class="header"> header </div> <div class="main"> <div class="block1"> block1 </div> <div class="right"> <div class="block2"> block2 </div> <div class="center"> <div class="block3"> block3 </div> <div class="block4"> block4 </div> </div> </div> </div> </body> ``` Thanks!!
2015/11/15
[ "https://Stackoverflow.com/questions/33718048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4330010/" ]
If it's a real project (something that will be deployed in the real world) then yes, you absolutely need to care about byte ordering. You'll also need to care about other serialization issues including data type sizes and structure field alignment. You can eliminate some headaches by using types explicit sizes, for example use `int32_t` rather than `int`. The structure field alignment issue is much more involved. The short answer: don't `send()` a raw structure from one machine and `recv()` it on another. Doing so assumes the apps running on both systems lay out their structure fields in precisely the same way (with identical padding).
You probably should, everyone expect network bytes order when receiving data. Another problem that you have is the padding. The compiler is allowed to put empty space between struct members, cause of required alignment. You have to send just one, network-byteordered, struct member at the time to work around this problems. You could look up serialize functions.
18,066
Weiß jemand, woher der Begriff > > Baulöwe, > > > laut Duden ein > > "Bauunternehmer oder Bauherr, der [mit zweifelhaften Methoden] durch Errichten, Verkaufen o. Ä. vieler Bauten großen Profit zu machen versucht" > > > kommt?
2014/11/25
[ "https://german.stackexchange.com/questions/18066", "https://german.stackexchange.com", "https://german.stackexchange.com/users/10760/" ]
They are two totally separate verbs. *Steigen* means to rise, climb, ascend, soar, etc. whereas *steige**r**n* means to raise, boost, augment etc.
**1. steigen (Verb)** The word "steigen" is often used to describe a physical activity for climbing up somewhere. For example: *Den Berg besteigen.* However, there are several other possible usages for different scenarios. **2. steigern (Verb)** The most common usage for this Verb is in the sense of increasing or enhancing something. For example: *Den Umsatz eines Unternehmens steigern.* or *Der Sportler steigert das Tempo.* There are other possible usages. I hope this helps. :)
55,153,490
I currently have the variables below and want to know how much time elapsed in seconds. So CURRENT\_TIME - TEST\_START ``` TEST_START=$(date '+%d/%m/%Y %H:%M:%S') sleep 4 CURRENT_TIME=$(date '+%d/%m/%Y %H:%M:%S') ``` I tried below, but keep getting illegal action ``` START_IN_SECONDS=$(date --date "$(TEST_START)" +%s) ``` This is in Mac.
2019/03/14
[ "https://Stackoverflow.com/questions/55153490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5106912/" ]
Editing the `file`a bit to be more descriptive: ``` $ cat file username=user1 api=pass1 username=user2 api =pass2 ``` Notice the 2 spaces added to records 3 and 4. First with `==`: ``` $ awk -F= '$1=="username"||$1=="api"{print$2}' file user1 pass1 ``` Only records 1 and 2 were were matched. Now, if you use `=`, you are not matching anythingm instead you are setting `$1` : ``` $ awk -F= '$1="username"||$1=="api"{print$2}' file user1 pass1 user2 pass2 ``` What you set is: ``` $ awk -F= '$1="username"||$1=="api"{print $1,$2}' file 1 user1 1 pass1 1 user2 1 pass2 ``` Tl;dr: `==` is correct.
Could you please try following too. I am removing the starting space and ending space in line considering that you may not need it. Then checking if first field is either `username` or `api` then print last field of that line. ``` awk -F'=' '{gsub(/^[[:space:]]+|[[:space:]]+$/,"")} $1~/^username$|^api$/{print $NF}' Input_file ``` --- --- OR assuming your Input\_file have Control-M characters?(since your attempt works fine for me and assuming that your Input\_file is same as shown samples). Check once if you have control M(s) or not by doing `cat -v Input_file` in case you have them then you could try following command. ``` awk -F'=' '{gsub(/^[[:space:]]+|[[:space:]]+$|\r/,"")} $1~/^username$|^api$/{print $NF}' Input_file ```
2,530,744
How do I extract **foo** from the following URL and store it in a varialbe, using regex in php? ``` http://example.com/pages/foo/inside.php ``` I googled quite a bit for an answer but most regex examples were too complex for me to understand.
2010/03/27
[ "https://Stackoverflow.com/questions/2530744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/82985/" ]
Well, there could be multiple solutions, based on what rule you want the `foo` to be extracted. As you didn't specify it yet, I'll just guess that you want to get the folder name of the current file (if that's wrong, please expand your question). ``` <?php $str = 'http://example.com/pages/foo/inside.php'; preg_match( '#/([^/]+)/[^/]+$#', $str, $match ); print_r( $match ); ?> ```
*If* the first part is invariant: ``` $s = 'http://example.com/pages/foo/inside.php'; preg_match('@^http://example.com/pages/([^/]+).*$@', $s, $matches); $foo = $matches[1]; ``` The main part is `([^/]+)` which matches everything which is *not* a slash (`/`). That is, we're matching until finding the next slash or end of the string (if the "foo" part can be the last).
25,529,951
I am fairly new to CKEdtior and have just installed it on this website I'm working on, the version is 4.4.4 The editor itself loads into the page, but custom properties like language or uiColor aren't working, and with or without properties, I keep getting the error: ``` Uncaught TypeError: Cannot read property 'getEditor' of undefined ``` I know I'm doing something wrong, because it works in the samples. If it helps, the code is part of a Smarty template. I tried using an ID that doesn't have an underscore, and of course checking in different browsers—the error appears in IE, FF and Chrome. Relevant bits of code: ``` <script type="text/javascript" src="ckeditor/ckeditor.js"></script> <script type="text/javascript"> {literal} CKEDITOR.replace( 'show_description', { language: 'he' }); {/literal} </script> ``` --- ``` <textarea name="show_description" id="show_description" class="ckeditor"></textarea> ```
2014/08/27
[ "https://Stackoverflow.com/questions/25529951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1105417/" ]
You cannot call `CKEDITOR.replace()` before the place where the relevant `<textarea>` is in the code. You can see this in the [replace by code sample](http://cdn.ckeditor.com/4.4.4/standard/samples/replacebycode.html): ``` <textarea cols="80" id="editor1" name="editor1" rows="10">content</textarea> <script> // This call can be placed at any point after the // <textarea>, or inside a <head><script> in a // window.onload event handler. // Replace the <textarea id="editor"> with an CKEditor // instance, using default configurations. CKEDITOR.replace( 'editor1' ); </script> ```
You can write a function named `setTimeout()`. Example: ``` setTimeout(function(){CKEDITOR.replace('id-textarea')},time); ```
257,205
After a recent WP update I get this error message in the back-end. Front-end is working without issues: > > Fatal error: Call to a member function add\_filter() on array in /... > /wp-includes/plugin.php on line 111 > > > I already tried updating WP manually but the issue persists. Ideas anyone?
2017/02/20
[ "https://wordpress.stackexchange.com/questions/257205", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113778/" ]
Why images don't get imported ============================= It's the export step that causes the issue here with image attachments. WordPress’ export function doesn’t include the “attachment” post type unless you select the “All content” export option. But if you only want to import and export your posts from one site to another, you lose your attachments. There is more information about the why of this [here](https://mor10.com/wordpress-importer-not-importing-attachments-try-exporting-all-statuses/#comment-1151023). How to get images into your new website anyway ============================================== So if you're only exporting and importing posts, one option is to move your images manually. But that's potentially a lot of work, especially on larger sites. The other option is to import you posts without the images, and then use the [Auto Upload Images plugin](https://wordpress.org/plugins/auto-upload-images/) to add the images afterwards. This plugin does several things: * It looks for image URLs in your posts (imported posts do still have image URLs in them, but they point to the site the content was exported from); * It then gets those external images and uploads them to the local WordPress uploads directory and adds the images to the media library; * And finally, it replaces the old image URLs with new URLs. The process is semi-automatic and relatively quick. You can uninstall the plugin again when you're done, so you're not left with an extra plugin on your website. Using the plugin for this purpose isn't explicitly documented in the plugin's documentation, so here is a step-by-step guide. Step by step: Importing posts and images from one website into another with the WordPress Importer and Auto Upload Images plugin -------------------------------------------------------------------------------------------------------------------------------- **Step 1: Prepare your export file on the old site** On your old website go to 'Tools > Export' and export your posts only. **Step 2: Import your posts into the new site** On your new website go to 'Tools > Import' and import the posts you exported. The importer has an option to download and import file attachments, but this won't work if you're not migrating all content, so you can ignore this. **Step 3: Install and activate the Auto Upload Images plugin** It installs as any other plugin in the WordPress repository. Once activated the plugin adds a settings page under 'Settings > Auto Upload Images', but in my experience you can leave these to their defaults. **Step 4: Get the image from your old site into your new site** At the time of writing the plugin has no option to automatically go through your posts and bulk upload plus update all the images. Instead, it updates each post individually when you save it. If you have many posts this is a lot of work, but there is a little trick. You can go to your posts overview screen and *bulk update your posts*. There is a little more information on this [here](https://wordpress.org/support/topic/why-no-option-to-run-this-in-bulk-on-all-existing-posts/) (useful note on multisite). Essentially, you select multiple posts and then under 'bulk actions' choose 'edit' and press the 'apply' button. Then, without making any adjustments, click the 'Update' button. Depending on your server you may get a timeout as the process runs, so it's a good idea to do this maybe 20 to 50 posts at a time. [![Bulk-updating posts](https://i.stack.imgur.com/DKzjs.png)](https://i.stack.imgur.com/DKzjs.png) **Step 5: Check your posts and deactivate/uninstall the plugin** When all is done you can check your posts and confirm they now reference local images. You then no longer need the plugin and you can safely deactivate and delete it. Final thoughts ============== Probably a good idea to make a backup of your new site first (at least of your site's database). At the time of writing the Auto Upload Images plugin hasn't been updated for quite some time, but on testing it worked fine. With this method all images in posts get imported, not just featured images.
I´ve tried mentioned plugins and "DeMomentSomTres Export" - worked on featured images + some but not all regular images and "Auto Upload Images" - worked on all regular images but not on featured images. If you combine the two of them problem would be solved but not ideal to have two plugins for the same purpose. Instead i found another plugin that worked like a charm: **"Export Media with Selected Content"** Only needed on exporting site, the importing site can use the regular importer. Worked for me and ALL images were included.
30,250,215
I tried to create folder in my local git repo using mkdir. It didn't work, but `mkdir -p` works. Why? I'm using Mac OS by the way. I checked the definition of mkdir -p. But I still don't quite understand.
2015/05/15
[ "https://Stackoverflow.com/questions/30250215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4808432/" ]
Say you're in the directory: ``` /home/Users/john ``` And you want to make 3 new sub directories to end up with: ``` /home/Users/john/long/dir/path ``` While staying in "/home/Users/john", this will fail: ``` mkdir long/dir/path ``` You would have to make three separate calls: ``` mkdir long mkdir long/dir mkdir long/dir/path ``` The reason is that mkdir by default only creates directories one level down. By adding the "-p" flag, mkdir will make the entire set in one pass. That is, while this won't work: ``` mkdir long/dir/path ``` this will work: ``` mkdir -p long/dir/path ``` and create all three directories.
That flag will create parent directories when necessary. You were probably trying to create something with subdirectories and failing due to missing the -p flag
40,641,648
I am trying to make a php/html5 sound player that will: 1. scan the files in a folder called "sound" and select only mp3 files 2. at each page load, play a random sound from the ones in the "sound" folder. So far it works pretty well, except sometimes the path of the source is not a .mp3 but also "/sound/" and some times "/.." Do you have any suggestions? I there a way to scan for mp3's only and not dirs or other extensions? Thank you very much for any reply.. ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <?php $dir = 'sound/'; $scan = scandir($dir); $size = sizeof($scan); $random = rand(1, $size); $randomFile = $scan[$random]; $fileLocation = $dir. $randomFile; $explode = explode(".", $randomFile); $extension = $explode[1]; ?> <title>Test</title> </head> <body> <?php echo $fileLocation; ?> <audio autoplay> <source src="<?php echo $fileLocation; ?>" type="audio/<?php echo $extension; ?>"></source> </audio> </body> </html> ```
2016/11/16
[ "https://Stackoverflow.com/questions/40641648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302577/" ]
Data.table runs in the environment of the data table itself right, so you might need to specify where you want to get the value from ``` DT[cyl == get("cyl", envir = parent.frame())] ```
Just specify the scoping: `DT[cyl == globalenv()$cyl]`
3,053,181
I've just upgraded a VS 2008 project to VS 2010, converting the project but keeping the target as .NET 3.5 (SP1 is installed). My project worked without issue under VS 2008 on another machine. I've added references to System.Web.Extensions.dll but I'm still getting the following errors from code in the App\_Code folder: 1) Cannot find System.Web.Script.Service namespace. 2) Type 'System.Web.Script.Services.ScriptService' is not defined. 3) Type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' is not defined. Anyone have any ideas what the problem might be as I'm pretty stumped? :(
2010/06/16
[ "https://Stackoverflow.com/questions/3053181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/250254/" ]
In Visual Studio 2012, be sure to add reference for `System.Web.Extensions` as that is the one that holds `System.Web.Script.Serialization`.
* Check your web.config assembly entries. * Check your .NET Framework [target](http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx) in your Visual Studio 2010 project, default is 4.0 * Check IIS, make sure you are using the appropriate framework for your site. The new .NET 4.0 install can change your default Framework to 4.0.
54,402
Could anyone point me to a place where I could find Deligne's letter to Piatetskii-Shapiro from 1973? It is cited for example in Berkovich's "Vanishing cycles for formal schemes II".
2011/02/05
[ "https://mathoverflow.net/questions/54402", "https://mathoverflow.net", "https://mathoverflow.net/users/10701/" ]
I have typeset Deligne's letter, and placed the result here: <http://www.math.ias.edu/~jaredw/DeligneLetterToPiatetskiShapiro.pdf> I have made some minor edits so that the text reads more naturally to a native speaker of English. Also I made a few annotations where I truly believe there is an error in the original. Any other errors are mine. The letter struck me with how much it accomplishes in such a short space. Actually, I would say that the meat of the argument is confined to the final three pages, with the rest there only to establish notation. This letter ought to be required reading for anyone studying automorphic forms in arithmetic!
I think it was published obscurely and in a Russian transcription (the original is in English) . In endnote 25 of the review of Harris-Taylor on his website [here](http://www.jmilne.org/math/articles/2002b.pdf), Milne writes: [Deligne proved it] in an eleven-page handwritten letter to Piatetskii-Shapiro dated March 25, 1973, with a one-page typed covering letter dated April, 1973: “In it I claim (except at 2) to prove for the supercuspidal representations what in your notes [Antwerp Conference LNM 349] you prove for the principal (unramified) series. The idea is that 1. room is left for it in your notes only thanks to the supersingular elliptic curves; - supersingular elliptic curves correspond to ideal classes in the quaternion algebra ramified at p and 1; - this, by a global argument using Jacquet Langlands, forces the outcome.” Apparently (see MR 50 7095), the letter was published: Matematika — Period. Sb. Perevodov Inostrannykh Statei, 18 (1974), 110–122. It would be useful if someone would put it on the web, since it was the starting point for Carayol and H&T. In fact, Deligne’s proof of (b) was completed by J-L. Brylinski (appendix to Carayol 1986). --- Below is the complete typed covering letter. Bures-sur-Yvette, April 2, 1973. Dear Piatetski-Shapiro [the name is handwritten in Russian] I am ashamed the enclosed letter is so badly written, and written more for my sake than for yours. In it, I claim (except at 2) to prove for the supersingular cuspidal representations what in your notes you prove for the principal (unramified serie [sic]. The idea is that a) room is left for it in your notes only thanks to the supersingular elliptic curves; b) supersingular elliptic curves correspond to ideal classes in the quaternion algebra ramified at $p$ and $\infty$; c) this, by a global argument using Jacquet Langlands \S 14, forces the outcome Corollary 1: Let $E$ be an elliptic curve $/\mathbb{Q}$, which is a direct factor (up to isogeny) of a jacobian of a modular curve, corresponding to a new form $\omega\_E$. Then, except perhaps at $2$, the conductors of $E$ and $\omega\_E$ are the same (At 2, I still can prove $2|f\_E\iff 2|f\_{\omega\_E}$) Corollary 2: (Casselman-Morita): Let $H$ be a quaternion algebra over $\mathbb{Q}$ split at $\infty$, $p$ be a prime at which $H$ ramifies, $\mathcal{O}$ be an order of $H$ maximal at $p$ and $M=X/\mathcal{O}^\*$ [$X=$ Poincar\'e upper half plane]. Then, the irreducible components of the reduction of $M$ mod $p$ are rational. [$M$ is defined over a cyclotomic field unramified at $p$]. Mumford has nice ideas about the compactification of $K\backslash G/\Gamma$ ($K\backslash G$ hermitian symmetric). For the moduli of abelian varieties, I hope it will eventually give a nice compactification over $\mathbb{Z}[\frac{1}{\textrm{obvious primes}}]$. I am looking forward to meeting you again. Yours most sincerely, P. DELIGNE
30,851,729
I just installed the latest beta of Xcode to try **Swift 2** and the improvements made to the Apple Watch development section. I'm actually having an hard time figuring out WHY this basic `NSUserDefaults` method to share informations between **iOS** and **Watch OS2** isn't working. I followed [this *step-by-step* tutorial](http://iosmobappdev.blogspot.it/2014/12/watchkit-sharing-data-using.html) to check if I missed something in the process, like turning on the same group for both the phone application and the extension, but here's what I got: **NOTHING**. Here's what I wrote for the ViewController in the iPhone app: ``` import UIKit class ViewController: UIViewController { @IBOutlet weak var lb_testo: UITextField! let shared_defaults:NSUserDefaults = NSUserDefaults(suiteName: "group.saracanducci.test")! var name_data:NSString? = "" override func viewDidLoad() { super.viewDidLoad() name_data = shared_defaults.stringForKey("shared") lb_testo.text = name_data as? String } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } @IBAction func upgrade_name(sender: AnyObject) { name_data = lb_testo.text shared_defaults.setObject(name_data, forKey: "shared") lb_testo.resignFirstResponder() shared_defaults.synchronize() } } ``` And here's what I have in the InterfaceController for WatchKit: ``` import WatchKit import Foundation class InterfaceController: WKInterfaceController { @IBOutlet var lb_nome: WKInterfaceLabel! let shared_defaults:NSUserDefaults = NSUserDefaults(suiteName: "group.saracanducci.test")! var name_data:NSString? = "" override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) } override func willActivate() { super.willActivate() if (shared_defaults.stringForKey("shared") != ""){ name_data = shared_defaults.stringForKey("shared") lb_nome.setText(name_data as? String) }else{ lb_nome.setText("No Value") } } override func didDeactivate() { super.didDeactivate() } } ``` I made some tests and it seems like the iOS app and the Watch OS one take advantage of different groups...**they're not sharing information**, they store them locally. Is someone having the same issue? Any idea how to fix it?
2015/06/15
[ "https://Stackoverflow.com/questions/30851729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3588489/" ]
With watch OS2 you can no longer use shared group containers. [Apple Docs:](https://developer.apple.com/library/prerelease/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/UpdatetheAppCode.html#//apple_ref/doc/uid/TP40015234-CH6-SW1) > > Watch apps that shared data with their iOS apps using a shared group > container must be redesigned to handle data differently. In watchOS 2, > each process must manage its own copy of any shared data in the local > container directory. For data that is actually shared and updated by > both apps, this requires using the Watch Connectivity framework to > move that data between them. > > >
As mentioned already, shared NSUserDefaults no longer work on WatchOS2. Here's the swift version of @RichAble's answer with a few more notes. **In your iPhone App**, follow these steps: Pick the view controller that you want to push data to the Apple Watch from and add the framework at the top. ``` import WatchConnectivity ``` Now, establish a WatchConnectivity session with the watch and send some data. ``` if WCSession.isSupported() { //makes sure it's not an iPad or iPod let watchSession = WCSession.defaultSession() watchSession.delegate = self watchSession.activateSession() if watchSession.paired && watchSession.watchAppInstalled { do { try watchSession.updateApplicationContext(["foo": "bar"]) } catch let error as NSError { print(error.description) } } } ``` Please note, this will NOT work if you skip setting the delegate, so even if you never use it you must set it and add this extension: ``` extension MyViewController: WCSessionDelegate { } ``` **Now, in your watch app** (this exact code works for Glances and other watch kit app types as well) you add the framework: ``` import WatchConnectivity ``` Then you set up the connectivity session: ``` override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) let watchSession = WCSession.defaultSession() watchSession.delegate = self watchSession.activateSession() } ``` and you simply listen and handle the messages from the iOS app: ``` extension InterfaceController: WCSessionDelegate { func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) { print("\(applicationContext)") dispatch_async(dispatch_get_main_queue(), { //update UI here }) } } ``` That's all there is to it. Items of note: 1. You can send a new applicationContext as often as you like and it doesn't matter if the watch is nearby and connected or if the watch app is running. This delivers the data in the background in an intelligent way and that data is sitting there waiting when the watch app is launched. 2. If your watch app is actually active and running, it should receive the message immediately in most cases. 3. You can reverse this code to have the watch send messages to the iPhone app the same way. 4. applicationContext that your watch app receives when it is viewed will ONLY be the last message you sent. If you sent 20 messages before the watch app is viewed, it will ignore the first 19 and handle the 20th one. 5. For doing a direct/hard connection between the 2 apps or for background file transfers or queued messaging, check out the [WWDC vide](https://developer.apple.com/videos/play/wwdc2015-713/)o.
938,991
in a windows environment and in several applications, when we create a new file with the same name of an existing file, the user is not prompted with a message that the output file already exists, but it creates a new file with (1) at the end of the filename... ``` name.doc ``` will be ``` name(1).doc ``` I'm trying to create the same behavior in C# and my question is... can I reduce all this code? ``` FileInfo finfo = new FileInfo(fullOutputPath); if (finfo.Exists) { int iFile = 0; bool exitCreatingFile = false; while (!exitCreatingFile) { iFile++; if (fullOutputPath.Contains("(" + (iFile - 1) + ").")) fullOutputPath = fullOutputPath.Replace( "(" + (iFile - 1) + ").", "(" + iFile + ")."); // (1) --> (2) else fullOutputPath = fullOutputPath.Replace( Path.GetFileNameWithoutExtension(finfo.Name), Path.GetFileNameWithoutExtension(finfo.Name) + "(" + iFile + ")"); // name.doc --> name(1).doc finfo = new FileInfo(fullOutputPath); if (!finfo.Exists) exitCreatingFile = true; } } ```
2009/06/02
[ "https://Stackoverflow.com/questions/938991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28004/" ]
You can use SysInternals [Strings](http://technet.microsoft.com/en-us/sysinternals/bb897439.aspx) tool to view the strings in executables and object files.
Simple C# utility that extracts all **user strings** from a .NET assembly (.exe or .dll) by examining bits of a binary file. The source code from **vladob**'s answer can now be found [on github here](https://gist.github.com/vbelcik/01d0f803b9db6ec9b90e8693e4b0493b#file-extractexenetstrings-cs). The link from the original answer has been broken. vladob gave consent to this repost. Actually I gave consent to me.
21,489,775
I am learning FullCalendar JS plugin by Adam Shaw now. And first at all I want to say *"Thanks a lot"* to the plugin author. What is a Calendar view? This is **a list of records** (calendar events). And I have to control this list size, or I hit limits (no more than 1000 records can be passed from Controller to View). I see two ways: (1) Traditional Selectors above calendar ('Please select month' - and I retrieve from Database only that month records (calendar events). Good - but if to start switching months inside Calendar - the other months will be empty (have no events)... (2) To make 'pagination' of calendar events from month to month: 2-1. If you switch months by "<>" buttons (inside Calendar section) - a page makes postback (rerender full page or rerender only calendar section by AJAX) and retrieves records of picked month. 2-2. Probably the best way: If you switch months by "<>" buttons (regardless which calendar view - day, week, month - in use) - script upload new month records by ajax/json and place them in calendar. Don't know how to do that, but i am going to read over the documentation carefully. If you have experience how overcome this problem of fetching to many records in Calendar events - please share. Thanks
2014/01/31
[ "https://Stackoverflow.com/questions/21489775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3258779/" ]
fullCalendar already have this feature, check this out, <http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/>
you are looking for gotoDate (<http://arshaw.com/fullcalendar/docs/current_date/gotoDate/>) which will refetch your events for the given date object or year and month. From documentation: ``` .fullCalendar( 'gotoDate', year [, month, [ date ]] ) ```
759,401
On 3x4 chessboard (see below) there are 3 Black knights (B B B) and 3 white knights (WWW), exchange knights in the min # of turns (hint: use graph representation) B B B -> WWW 0 0 0 -> 0 0 0 0 0 0 -> 0 0 0 WWW -> B B B
2014/04/18
[ "https://math.stackexchange.com/questions/759401", "https://math.stackexchange.com", "https://math.stackexchange.com/users/144068/" ]
Preliminary, let us do a slight change in notation: I will indicate with $k \in \mathbb{Z}$ the discrete time, with $K$ the $k$ present in the summation and the period (if it exists) with $N \in \mathbb{N}\_0$. Firstly, let us refresh the following concepts. Let $\theta \in \mathbb{R}\_+$, $k \in \mathbb{Z}$, $i = \sqrt{-1}$, and consider the following (complex valued) function: $f(\theta) = e^{i \theta k}$. It is easy to check that this function is periodic with period $2\pi$, in fact $ \begin{align} f(\theta + 2\pi) = e^{i (\theta +2\pi) k} = e^{i \theta k} e^{i 2\pi k} = e^{i\theta k} = f(\theta) \end{align} $ since $e^{i 2 \pi k}=1$. Now, consider instead (with the same meaning of the symbols) the following (complex valued) function $ \begin{align} f(k) = e^{i \theta k} \end{align} $ Is it periodic? For discrete time functions, the period *must* be an integer, since the argument of the function must be an integer (the domain of $f(k)$ is $\mathbb{Z}$). A discrete time function can't be, e.g., periodic with period $\pi$. Thus, we must find, if it exists, an integer $N \in \mathbb{N}\_0$ such as that $f(k+N) = f(k)$. Repeating the same reasoning as above, $ \begin{align} f(k+N) = e^{i\theta(k+N)} = e^{i \theta k} e^{i \theta N} \end{align} $ Now, $e^{i \theta N}$ is equal to $1$ if and only if $\ \theta N = 2 \pi n$, with $n \in \mathbb{N}$, which means: $ \begin{align} (\*) \quad \theta = 2 \pi \frac{n}{N}, \quad n \in \mathbb{N}, N \in \mathbb{N}\_0 \end{align} $ The key concept is the following > > The function $e^{i \theta k}$ is periodic (with respect to $k \in \mathbb{Z}$) if and > only if the pulsation $\theta \in \mathbb{R}\_+$ satisfies $(\*)$, i.e., the pulsation is a rational multiple of $\pi$. > > > --- Now, back on your question. Your example is unfortunately ill-worded, since the period of discrete time functions/processes can't be $2 \pi$ ("the last part is periodic with period $2 \pi$" is, strictly speaking, wrong): as explained above, only integers are allowed. In fact, since $k$ is used as an (integer) index in the formalism $X\_k$, what means, e.g., $X\_{\pi}$ ? There exists only things like $X\_1, X\_2, X\_3, \dots$, because your process is discrete time (this is the reason why I asked and, as it's now clear, it is a crucial fact). Luckily enough, this means that it is very easy to prove that, in general, $X(k)$ (i.e., the process viewed as a function of discrete time) is not periodic, since the phasors are in general not periodic (with respect to $k$). However, I doubt your professor was referring to this: he probably was referring to something along the lines of $f(\theta)$ is $2 \pi$-periodic, i.e., viewing the process as a function not of time, but of the pulsations $\lambda\_j$. --- At this point, it is useless to describe in detail the fact about the spectral distribution. Thus, I will just give you a sketch. Using the Wiener-Khinchin theorem, we know that the spectral density of a random process is equal to the Fourier transform of the ACF (AutoCorrelation Function) of the process. But the ACF of a periodic function is periodic (and with the same period), thus the information on periodicity is "carried on" the spectral density. This is the same as what happens deterministically. Let $f(t)$, $t \in \mathbb{R}$, be a function of (continuous) time; the Fourier transform of $f(t)$, which we can denote with $F(\omega)$, where $\omega \in \mathbb{R}$ is the pulsation, contains all the information present in $f(t)$. In short, this is simply the usual time domain - frequency domain duality. --- **Example**: This is a trivial example to show that the process is in general not periodic. Starting with $ \begin{align} X\_k = \sum\_{j=-K}^{K} A\_j e^{i \lambda\_j k} \end{align} $ Now, choose $\lambda\_j = \lambda \ \forall j$ (single frequency process), from which $ \begin{align} X\_k = \sum\_{j=-K}^{K} A\_j e^{i \lambda k} = e^{i \lambda k} \underbrace{\sum\_{j=-K}^{K} A\_j}\_{=A} = A e^{i \lambda k} \end{align} $ The periodicity of $X\_k$ depends on the periodicity of the phasor $e^{i \lambda k}$, which depends on $\lambda$, remember the condition $(\*)$. Thus, we can easily conclude that $X\_k$ is, in general, not periodic.
It is possible that your professor is assuming all the frequencies in the sum are multiples of one, given, fundamental frequency and forgot to state this assertion. If they are all multiples, then indeed almost all paths are periodic. But even if they are not multiples, the paths are "quasi-periodic" in the sense of Harald Bohr (Niels Bohr's brother, a famous mathematician in his day): there exist infinitely many "quasi-periods" T in the sense that the particle returns to within epsilon of its value after T seconds. There are subtle technicalities in the definitions here, I am being deliberately vague. See the Collected Works of Norbert Wiener, vol. 2, the commentaries on his papers, pp. 102,111, 181, 325, 458. Some engineers and physicists have been known to loosely use the word "periodic" when all they mean is "quasi-periodic", and they use the word "quasi-periodic" to mean something even more vague, I have seen an engineering textbook call the function $\sin x \over x$ "quasi-periodic". Well!
29,110,161
Trying to convert this code for a for loop into a while loop: ``` int endData = myScanner.nextInt(); int row = 0; int cell = 0; int rowcell = 0; System.out.println("FOR LOOP: "); for (row = 1; row <= endData; row++) { if (row%2 == 0) { for (cell = 0; cell < row; cell++) { for (rowcell = 0; rowcell <= cell; rowcell++) { System.out.print(row); } System.out.println(""); } } else { for (cell = row; cell > 0; cell--) { for (rowcell = cell; rowcell > 0; rowcell--) { System.out.print(row); } System.out.println(""); } } } ``` So far I have tried this code but it came out completely wrong: ``` row2 = 1; while (row2 <= endData){ if(row2%2 == 0){ cell2=0; rowcell2 = 0; while(cell2<row2){ cell2++; while(rowcell2 <= cell2){ rowcell2++; System.out.print(row2); } System.out.println(""); } }else { cell2=row2; rowcell2 = cell2; while(cell2 >0){ cell2--; }while (rowcell2>0){ rowcell2--; System.out.print(row2); }System.out.println(""); } row2++; } ``` For example, when the user inputs a value of 3, the for loop returns the correct answer: 1 2 22 333 33 3 But the while loop outputs: 1 22 2 333 Any ideas as how to go about fixing this while loop?
2015/03/17
[ "https://Stackoverflow.com/questions/29110161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4595060/" ]
One of the mistakes i see is the initialisation ``` rowcell2 = 0; ``` it should be under ``` while(cell2<row2){ ```
All you have to do to convert it is declare the index before the while loop and add the incrementer to the end of the while loop. ``` int endData = myScanner.nextInt(); int row = 0; int cell = 0; int rowcell = 0; System.out.println("FOR LOOP: "); row = 1; while(row <= endData) { if (row%2 == 0) { cell = 0; while (cell < row) { rowcell = 0; while (rowcell <= cell) { System.out.print(row); rowcell++; } System.out.println(""); cell++; } row++; } else { cell = row; while (cell > 0;) { for (rowcell = cell; rowcell > 0; rowcell--) { System.out.print(row); cell--; } System.out.println(""); } } } ```
39,523
I have an old Thinkpad X60 that I'd like to wipe clean and rebuild. Seeing as this machine doesn't have an optical drive, what's the easiest way of installing Windows XP? I have an external USB hard drive available. Would it be possible to run the install from that instead? Otherwise, what options do I have? Edit: assuming we're using a USB mass storage device... Is there a BIOS setting that I would need to change, or will it configure itself automatically? Would the USB drive need to be configured in any special manner, or would simply having a copy of the Windows CD files in a directory there be sufficient? Since the first couple answers that came in were basically "yes", I guess I didn't phrase my question correctly. I'm asking for detailed instructions on how to do this, not just a sanity check that I'm headed in the right direction. Thanks!
2009/07/12
[ "https://serverfault.com/questions/39523", "https://serverfault.com", "https://serverfault.com/users/6681/" ]
As long as the BIOS supports booting from USB, you can use an external drive. If you're got a RIS server, you could do a netowrk install, or you could get a similar image, sysprep it, ghost it across (USB boot of clonezilla, ghost from a network share), and then set it up for the new machine. Edit: You might need to enable booting from USB-CD in the BIOS, but you can probably just go to the boot menu (normally F12 or Escape), and select it from there. It should then boot from your Windows disk, and let you install normally.
1. If you have USB CD Drive then just use it to install windows the way one does with normal CD drive. 2. If you have access to similar laptop then you can install Windows on similar laptop. And clone the harddisk of other laptop to laptop with no cdrom drive. 3. if you dont have access to USB CDROM or similar laptop with working CD Drive. Then install windows on any drive with same capacity. That is if your laptop is having 80GB harddisk then install Windows on another laptop (preferable)/ PC with exact 80GB harddisk. Do not install drivers for motherboard, soundcard, video, LAN etc. after installation. Clone this fresh image of windows with no drivers installed to laptop. Then you can install drivers specific to your laptop. To copy drivers to laptop use pen drive. Now if you do not have access to tools which can help you with cloning / You have not done it before. Then download Linux live CD image from [System Rescue CD download page](http://www.sysresccd.org/Download.en.php). System Rescue CD happens to be my favorite for cloning as it has only command line support so eats really less RAM. You can use any Linux Live CD Knoppix / Ubuntu etc. for the purpose of cloning. Connect both the computers so that they are on same LAN. You can do this by any 8 port unmanageable switch too. Boot from Live CD on both source and destination machines. Then use command ``` fdisk -l ``` to find name of harddisk device on both source and destination. The device name should be like /dev/hda, /dev/hdb, /dev/sda, /dev/sdb, etc. I hope you have only one harddisk in both source and destination to avoid confusion. If you have more than one harddisk I recommend removing one harddisk to avoid confusion if you are not comfortable with Linux drive naming conventions. You can also distinguish based on different hard disk sizes. Now on source use command ``` ifconfig eth0 10.10.10.1 netmask 255.255.255.0 dd if=/dev/sda bs=4000000 | nc -l 9000 ``` and on destination use command ``` ifconfig eth0 10.10.10.2 netmask 255.255.255.0 nc 10.10.10.1 9000 | dd of=/dev/sda bs=4000000 ``` You have to replace the device name /dev/sda in both above commands with device name you see when you run fdisk -l. If you uncomfortable with Linux you can seek help of some friend who is comfortable in Linux to do all this. This is absolutely free method of cloning without requiring purchase of commercial tools or opening PC to shift drives. If you have Norton ghost or something similar then you can use that instead of above process.
7,485
In StarCraft2, Protoss can change their gateways into warp gates. However, I'm puzzled that they can be changed *back* into gateways. Is there any advantage for gateways over warp gates ? What am I missing ?
2010/09/15
[ "https://gaming.stackexchange.com/questions/7485", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3436/" ]
One that hasn't been mentioned is that you don't need pylons to create units at a gateway. So if you're heading into enemy territory, want constant reinforcement, and don't want to mess with creating a pylon or flying around a warp prism, you can just waypoint your gateways to one of your units and have all your new units follow along as they're created. Granted, that's a lot of ifs.
Once in a game I used the warp prism to deploy a smal force on the platform where my opponent had his starting base (without destroying the garbage layed out before the main entrance). Before he realized that it is not-so-unreachable as he thought my five warp-gates released a nice army to overwhelm his base. But for mass-production the normal gateways are more usable.
20,148,857
I'm trying to check if an element exists before I can execute this line: `driver.findElement(webdriver.By.id('test'));` This throws an error "no such element" if the id `test` doesn't exist in the document, even in a `try`-block. I've found answers for Java, where you can check if the size is 0, but in Node.js this throws an error before I can check the size: `throw error; ^ NoSuchElementError: no such element`
2013/11/22
[ "https://Stackoverflow.com/questions/20148857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1493415/" ]
You can leverage the optional error handler argument of `then()`. ``` driver.findElement(webdriver.By.id('test')).then(function(webElement) { console.log('Element exists'); }, function(err) { if (err.state && err.state === 'no such element') { console.log('Element not found'); } else { webdriver.promise.rejected(err); } }); ``` I couldn't find it explicitly stated in the documentation, but determined this from the function definition in `webdriver/promise.js` in the `selenium-webdriver` module source: ``` /** * Registers a callback on this Deferred. * @param {Function=} opt_callback The callback. * @param {Function=} opt_errback The errback. * @return {!webdriver.promise.Promise} A new promise representing the result * of the callback. * @see webdriver.promise.Promise#then */ function then(opt_callback, opt_errback) { ```
[Aaron Silverman's answer](https://stackoverflow.com/questions/20148857/check-if-an-element-exists-with-selenium-javascript-and-node-js/20977989#20977989) did not work as expected (`err.state` was `undefined` and a `NoSuchElementError` was always thrown)—though the concept of using the optional callbacks still works. Since I was getting the same error as the OP is referencing, I believe [`NoSuchElementError`](http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/error_exports_NoSuchElementError.html) should be referenced when determining if the targeted element exists or not. As its name implies, it is the error that is thrown when an element does not exist. So the condition in the errorCallback should be: `err instanceof webdriver.error.NoSuchElementError` So the complete code block would be as follows (I also am using `async`/`await` for those taking advantage of that syntax): ``` var existed = await driver.findElement(webdriver.By.id('test')).then(function() { return true; // It existed }, function(err) { if (err instanceof webdriver.error.NoSuchElementError) { return false; // It was not found } else { webdriver.promise.rejected(err); } }); // Handle value of existed appropriately here ```
69,869,181
I've downloaded Android Studio from the official website, the one for M1 chip (arm). Basically running it for the first time, the error is the following: ``` An error occurred while trying to compute required packages ``` I was searching about it the whole day to figure out a way to make Android Studio work, but that error keeps showing. Not completely sure if it's related to M1 Macbook, as on my Intel one it works as expected. What I already tried to do: * Installing the command line tools, then placing it on SDK folder (Users/user/Library/Android/sdk). Then added the `bin` to the PATH ([Reference](https://stackoverflow.com/questions/42732684/error-dependent-package-with-key-emulator-not-found-while-updating-android-sdk/42733510#42733510)) + After doing that, when executing the sdkmanager on terminal I get the following message `Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli` + Then I searched again and it leaded me to [this thread](https://stackoverflow.com/questions/60727326/sdkmanager-error-could-not-find-or-load-main-class-com-android-sdklib-tool-sdk), then as on the answers I tried to rename the folder, then other tries not related. I fell into many links and references that did not work at all. * After that I try to check what happens if I click on `New Project`, then the following is shown: > > The Android SDK location cannot be at the filesystem root > > > * As the message indicates, the issue is `The Android SDK location cannot be at the filesystem root`, so I searched again about it + I looked into that and got to a few links, for example [this one](https://stackoverflow.com/questions/68046043/the-android-sdk-location-cannot-be-at-the-filesystem-root) and [this one](https://askubuntu.com/questions/1269092/ubuntu-android-sdk-location-can-not-be-at-the-filesystem-root). Before doing that search I clicked on the Edit button, which lead me to the Android SDK to be updated/installed (Nice!), so I had to delete the content I had on Android folder (inside Library) and clicked next...then, I got the same message `An error occurred while trying to compute required packages`. + Then I thought "ok, maybe if I change the SDK location", so I changed to ../Documents/sdk, which ended up in the same result Seems like no matter what I do, it ends up showing up that same message. When I run java -version that's what I see: ``` java version "1.8.0_311" Java(TM) SE Runtime Environment (build 1.8.0_311-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode) ``` Did anyone have the same issue? Am I doing something wrong? Not sure how to proceed from here, despite of the Android Studio version I download it's always the same result. Any help is appreciated.
2021/11/07
[ "https://Stackoverflow.com/questions/69869181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17346713/" ]
This is what solved it for me on my M1. 1. Go to Android Studio [Preview](https://developer.android.com/studio/preview) and download the latest Canary build for Apple chip (Chipmunk). Don't worry this is just to get through the initial setup. 2. Unpack it, run it, let it install all the SDK components, accept licenses, etc as usual. 3. Once it's done, simply close it and delete it. Now when you start your stable Android Studio (Arctic Fox) you should not see the error.
I tried over a dozen 2021 stable and Canary builds from <https://developer.android.com/studio/archive> and couldn't get any of them to work. This is the only thing I could find that worked: 1. Download, unpackage and run Android Studio 3.6.3 **android-studio-ide-192.6392135-mac.zip** from [here](https://developer.android.com/studio/archive). 2. Proceed through the initial setup and let it download and install the SDK. Ignore any errors at the end. 3. Delete this version and open the stable Android Studio like normal. 4. You can now proceed through setup!
38,323,226
I am using React JS to create a responsive UI. I want to create a collapsible sidebar like the following: [![enter image description here](https://i.stack.imgur.com/hMqth.png)](https://i.stack.imgur.com/hMqth.png) [![enter image description here](https://i.stack.imgur.com/M8ume.png)](https://i.stack.imgur.com/M8ume.png) So when I click the vertical bar(Graph information) it should expand like the second picture. I have seen some example like in `Jsfiddle`[Sample code](https://jsfiddle.net/4q89bmsL/) .But here, they have used a static button to control the collapse. Is there any library that I can use? Or any code suggestion? I am learning React JS. So any help or suggestion will be appreciated.
2016/07/12
[ "https://Stackoverflow.com/questions/38323226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1267491/" ]
You can have a button just like in the fiddle, but have it in the sidebar component. [I've updated the fiddle](https://jsfiddle.net/davidg707/cc96ku6t/1/) The beauty of React is separating the state. I think like this: 1. I want some global state (like, in a store) that says if the sidebar should be showing or not 2. I want my sidebar component to hide/show based on that prop 3. I will change/toggle that value from wherever I want and trust that the component will change itself accordingly. So `Parent` becomes (now passing in the function to the `SideBar`) ``` var Parent = React.createClass({ getInitialState: function(){ return {sidebarOpen: false}; }, handleViewSidebar: function(){ this.setState({sidebarOpen: !this.state.sidebarOpen}); }, render: function() { return ( <div> <Header onClick={this.handleViewSidebar} /> <SideBar isOpen={this.state.sidebarOpen} toggleSidebar={this.handleViewSidebar} /> <Content isOpen={this.state.sidebarOpen} /> </div> ); } }); ``` and the `SideBar` becomes (adding a button that calls that function): ``` var SideBar = React.createClass({ render: function() { var sidebarClass = this.props.isOpen ? 'sidebar open' : 'sidebar'; return ( <div className={sidebarClass}> <div>I slide into view</div> <div>Me too!</div> <div>Meee Threeeee!</div> <button onClick={this.props.toggleSidebar} className="sidebar-toggle">Toggle Sidebar</button> </div> ); } }); ```
I have implemented the side drawer without using any of these packages like slide-drawer or react-sidebar. You can check out **[Side Drawer](https://github.com/GhostWolfRider/ReactSideDrawer)** in my GitHub account **[GhostWolfRider](https://github.com/GhostWolfRider?tab=repositories)**. > > **Output Images for reference:** > > > **Before Slide:** [![enter image description here](https://i.stack.imgur.com/meQRD.png)](https://i.stack.imgur.com/meQRD.png) **After Slide:** [![enter image description here](https://i.stack.imgur.com/0y24o.png)](https://i.stack.imgur.com/0y24o.png)
71,509,993
I am having trouble running my import statement in VS code Jupyter. I split them into individual cells. I find when I run ``` import numpy as np ``` the cell hangs and I get a message > > Connecting to kernel: Python 3.6.9: Waiting for Jupyter Session to be idle > > > How do I fix this?
2022/03/17
[ "https://Stackoverflow.com/questions/71509993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/125673/" ]
I found my solution was to select the correct version of Python. I had 2 choices for Python 3.6.9. I chose the one called "base(Python 3.6.9)" which had a different location to "Python 3.6.9" and the base version worked. Something odd if going on here, maybe I should remove the other version?
For me, upgrading `ipython` to version 7.34.0 (from 7.32.0) fixed it. I'm using `jedi` version 0.18.1. [Related](https://stackoverflow.com/a/65862512/18758987) Update: this broke again for me when I upgraded my virtual environment to Python 3.8. I just upgraded my `ipykernel` package and now the notebook runs.
15,959,856
I'm just starting with Backbone.js. I'm building a Single Page Application and trying to figure out how I can handle this situation. Depending on the view I'm rendering, I need to output multiple templates, meaning I have a wrapper that I use for the main template, and other 2 templates that go on other parts of the HTML. I started by manually outputing the templates, but that got me thinking how correct that approach was, as it would require me to manually delete them whenever I navigate to other view. The question is, **How can I effeciently render multiple templates in a single view (that are appended in different places) and still have control over the deletion on the entire view and undelegating its events?**
2013/04/11
[ "https://Stackoverflow.com/questions/15959856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1161745/" ]
I'd check out Addy Osmani's walkthrough for developing with backbone.js. <http://addyosmani.github.io/backbone-fundamentals/> It walks through the example todo app, and then one more complicated one. What I think you want specifically is to use a framework such as Marionette.js to orchestrate and automate some of the event delegation and removal when you play with your views. If this is the case, skip to <http://addyosmani.github.io/backbone-fundamentals/#marionettejs-backbone.marionette> and read on about how marionette will help organizing views into regions and layouts as @NathanInMac said.
You need a layout with a couple of regions. Then put your sub-views in these regions.
57,819
My landlord fixed a leak from the baseboard heating system using a plumber who decided to run the red [guessing PEX pipes] from the water heater/boiler to the baseboards along the ceiling. The pipes are exposed on the inside [hall, closet, and 2 bedrooms]. There is no insulation around the pipes and they are held in place by plastic nails/fastener. To save money, she did not want to cut the gyprock and place the pipes inside the wall. Now, I can see some reddish hue along the ceiling above the pipes. Question: Is this safe? What dangers lurk by running exposed hot water pipes along the ceiling?
2015/01/14
[ "https://diy.stackexchange.com/questions/57819", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/31690/" ]
It is safe. No dangers lurk. Relax and be happy you don't own the place (so deciding what to spend money on when it breaks is not your problem.)
The only issue I see with this is the liability of the pipes themselves. It kind of sounds like a cheap hack job. When pipes are inside walls - 99.9% of the time - and they break the water just travels down. Usually the initial damage is minimal. Now when you have pipes in the open there is a chance that it could initially damage something expensive right away. Also if something did happen you would almost need to prove that you didn't hit the pipe or cause it.
477,250
The Helmholtz function $F$ is defined: $$F = U - TS$$ $$\implies dF = dU - TdS - SdT$$ Since by the Thermodynamic identity, $dU - TdS = - PdV$: $$\implies dF = -PdV - SdT$$ My textbook then notes that given the form of the above equation, $F$'s natural variables are $V$ and $T$. However, my last equation was just a rewriting of $dF = dU - TdS - SdT$ and is an equally valid equation for $F$. However, given the form of my most recent equation I'd say $F$'s natural variables are $U$, $S$ and $T$. Why is this wrong?
2019/05/01
[ "https://physics.stackexchange.com/questions/477250", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/153135/" ]
Playing with differentials in the way you report, can be done but with some care about the mathematical meaning of the manipulation. When we write a differential, we should know in advance which are the independent variables the function we differentiate depends on and there is no substitute for it coming from formal manipulations. Actually, the issue of the independent variables $F$ depends on, has to be solved much before writing differentials: it is the definition $F=U-TS$ which is there for the purpose of encoding the same information contained in $U(S,V)$ into a function of $T=\frac{\partial{U}}{\partial{S}},V$. This is a problem which is solved through a Legendre transform$^\*$: $$ F(T,V) = U(S(T,V),V)-TS(T,V) $$ where, I have put explicitly the way each quantity has to be interpreted from the mathematical point of view instead as using the sloppy notation $F=U-TS$ often used in the practice. The function $S(T,V)$ is obtained by using the inverse function theorem in connection with the definition $T=\frac{\partial{U}}{\partial{S}}(S,V)$. Once all this is clear, one can even use the formal manipulation reported in the textbook, but without possibility of confusion about how many and which variables $F$ depends on. A different way to see why formal manipulations alone are not enough could be the following. Let's assume that we would define $$ F(S,V) = U(S,V) -ST(S,V) $$ where $T=\frac{\partial{U}}{\partial{S}}(S,V)$. With the same formal manipulation one could "prove" that $F$ is again a function of $T$ and $V$, although we have clarly introduced a function of $S$ and $V$. And only on the basis of such previous knowledge, we can correctly interpret in this case $dT$ as the differential of a function of $S$ and $V$ instead as an independent variable. ($^\*$) I am referring to Legendre transforms for sake of simplicity, however, the right tool in thermodynamics is the [Legendre-Fenchel transform](https://en.wikipedia.org/wiki/Convex_conjugate). The conclusion of the above answer won't be changed by such generalization.
If some function $f$ is a function of three variables $x,y,z$, then $x,y,$ and $z$ need to be independent of one another in the sense that changing one while holding the others constant needs to make sense. This is not the case here. $U$ is not independent of $S$ and $T$ (in fact, it is just proportional to $T$ for an ideal gas), so quantities like $$\left(\frac{\partial F}{\partial T}\right)\_{U,S}$$ (the partial derivative of $F$ with respect to $T$ while holding $U$ and $S$ constant) don't make any sense. How can I change $T$ without changing $U$? --- A different way to put it is that $F$ and $U$ are not thermodynamic variables but rather thermodynamic *potentials*. Each potential is a function of some set of thermodynamic variables, chosen from sets of conjugate pairs ($p$ and $V$, $S$ and $T$, $\mu$ and $N$, etc). Note that $U=U(S,V)$ makes sense because entropy can be changed independently of volume and vice-versa. The same holds for the Helmholtz potential $F=F(T,V)$, the enthalpy $H=H(S,p)$, and the Gibbs potential $G=G(T,p)$.
67,109,657
What is the difference in returning state in default case in redux reducer between `return state` and `return { ...state }` ?
2021/04/15
[ "https://Stackoverflow.com/questions/67109657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6209704/" ]
Like React, Redux uses immutability to efficiently check updated object references for updated state, which is why you should never modify/mutate state directly. In the default case of most reducers no actions have modified the state so you can return the original state object (`return state`), this is safe as it won't have been modified. However, `return { ...state }` will return an identical state but with a different top level object reference which will cause unnecessary checks for changed state. If you're not modifying state at all you should always return the original object (`return state`). EDIT: added on a follow up question - if you `return { ...state }` Redux would broadcast the updated state to all React components connected to the store (be it by hooks or the connect function) and then React would go into it's lifestyle cycle update. React is actually very efficient and uses memoizing and other methods to stop any expensive re-renders or repainting/regenerating the DOM so the difference between the 2 in terms of process will be next to nothing, it's just unnecessary. I don't think it'd even get to rerunning hooks suck as useEffect, it'd see the redundancy before getting there or at least use the memoize cache and not recalculate
When you use `return state` you are returning the variable, this is bad because if that variable changes, the value delivered in the return will also change (this is known as a side effect). On the other hand, if you use `return { ... state }` what you are returning is a copy of the value of the variable at that moment
9,959
How to ask a good question. --------------------------- This thread has advice on the following aspects of writing a good question on this site. Each item in this list links to an answer below about that specific aspect of question writing. * [Provide context](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#9960), $\,$ [include the source and motivation for your question](https://math.meta.stackexchange.com/a/29298/9003), $\,$ and [avoid "no-clue" questions](https://math.meta.stackexchange.com/questions/9959/how-to-ask-a-good-question/27933#27933) * [Choose a good title](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#10144) * [Formatting and writing](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#10992) * [Tag your question correctly](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#9961) * [Mathematical typesetting: MathJax](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#10164) * [Pare question to its basics](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#31696) * [If the question you want to ask appeared in a Math contest, or a Contest training](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#32403) * [Use Approach0 to detect if your question has already been asked on this site](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#32652) * [Avoid confusing abbreviations and notation](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#30471) * [Ask one question per post](http://meta.math.stackexchange.com/questions/9959/how-to-ask-a-good-question#33671)
2013/06/14
[ "https://math.meta.stackexchange.com/questions/9959", "https://math.meta.stackexchange.com", "https://math.meta.stackexchange.com/users/1543/" ]
Provide Context --------------- **Context matters**. A question can sometimes be answered in one sentence when the discussion is between two experts familiar with each other's background, while the same question may take many paragraphs of detailed computation when being shown to an undergraduate student. By providing a context you help the potential responders to your question give you the best help you need. **Some different ways you can add context to your question** * **Include your work** You have a question, and if you post it here, you've probably attempted, and failed, to solve it yourself. It is much easier for others to judge the most appropriate "level" for an answer to your question if you provide these attempts. So you'll receive answers better suited to your specific needs. Including your work also shows to the community that you're not using this website as an answer machine -- as such, your question will be received more positively. A further benefit of writing down precisely what you've tried is that, in the process of doing so, you will very likely spot your error and [solve your problem yourself](https://math.meta.stackexchange.com/q/26702/272831). Bonus! * **You can provide some *motivation* to your question.** Instead of just asking us to find the roots of an equation, tell us where the equation comes from. This is especially the case when your equation comes from models of the physical worlds: those kinds of intuition are great guiding principles for formulating an answer. * **You can tell us where the question comes from.** If your question comes from studying a textbook, let us know which book. This way the answers can be phrased in a manner and in a notation more familiar to you. Exposition varies from one book to another, affecting which theorems are appropriate to cite in answers, and which definitions you are starting from (see below). * **Indicate your own background** In order to address your question in a useful manner, we need to be able to estimate your background to some degree. (Briefly) Indicate your familiarity with the subject matter so that the answerers have an easier job assessing the audience, and can adjust the level of their answer accordingly. * **Give full references.** If you run across a question when reading a scientific paper, be sure to link to that paper using its [doi](https://en.wikipedia.org/wiki/Digital_object_identifier) link, or provide a proper bibliographic information. A question that reads "A theorem of Smith says that Widget X is a type of Gadget Y, but I don't see why Property Z must hold" is likely not going to be very comprehensible to other users without telling us which Smith said what when and where. * **Give definitions.** Something that you are familiar with may not be so to another user. One should of course use one's best judgment in deciding what objects are sufficiently well-known to not need defining. But when in doubt, either provide the definition or provide a link to a resource that gives the definitions. Another case where this can be useful is when the same mathematical object can be defined in many ways, and the answer to your question may depend on the precise definitions used. For example, Widget X may be defined by Author A to satisfy property T. Practically everyone else may prefer to define it as satisfying property S. Showing the equivalence between property T and property S may happen to be one of the harder but lesser known theorems in the past fifty years. If you ask the question, after reading a treatise by Author A, that "Why is property S true for Widget X?"; the common answer "duh, that's by definition" will probably not be very useful to you.
A good title ------------ The title of a question is the first thing people see. Like headings in newspapers, book, song and album titles, their importance is not to be underestimated -- the presence of a good, descriptive title for your question often greatly improves the exposure (and hence the amount and quality of answers) it gets. To ensure maximal descriptiveness of your question's title, review it before posting and ensure that it (still) adequately describes your question's content. **How to choose a good title** * **Make your title your question** Use your title to convey as much information about your question as possible. Since the tags already convey the general subject area of your question, the title should communicate the question itself as faithfully as possible. If necessary, leave out hypotheses in the title, and in the body of the question, explain why the question requires those hypotheses. * **MathJax works in titles** Titles have MathJax support. This means you can e.g. include the integral your question is about in the title, and do not have to resort to vague descriptions like "difficult integral". In your use of MathJax, please adhere to the [community guidelines](http://meta.math.stackexchange.com/a/9730) for MathJax in titles. Most importantly, keep the vertical space your title uses to a minimum, and be sure to include at least *some* plain words. * **Don't be afraid to make the title long** Titles are allowed to be anywhere from 15 to 150 characters long. 140 characters (the length of a tweet) of plain text take up about two full lines on the home page, so try to keep it less than that. But 140 characters is a lot longer than you might think. Too many people restrict themselves to 20 character titles. They're trying not to waste your time by making you read a long title, but they end up wasting more of your time because you have to actually open the question to see if it's interesting to you. * **Make your title interesting for others** Mathematics.SE is designed to be a repository of good mathematical questions and answers. Thus, there is no need to refer to your personal situation in the title. Make your title a question of universal value. For example, the title *Help me solve $a^2+b^2=c^2$ for my exam preparation* is very specific to your personal situation. *Deriving the formula for Pythagorean triples* would be a more universal, better title for the same question. * **Your question should be clear without the title** After the title has drawn someone's attention to the question by giving a good description, its purpose is done. The title is *not* the first sentence of your question, so make sure that the question body does not rely on specific information in the title. ### Other Tips When you are posting a question, write your title first. The system will then suggest possible duplicates: take a look at them, opening links in another tab. If none of those are actual duplicates, write out the body of your question. Then *go back and put in a better title* for the body that you wrote. (From [Robert Harvey](https://meta.stackoverflow.com/questions/268437/titles-matter-in-questions-edit-those-first#comment76528_268437))
45,052,772
I have a SCNScene rendering in a SCNView. I have some \*.dae models that are rendered/moving in the scene. I have a transparent cube, when one of my models goes behind it, I would like the model to not be rendered, because at the moment, as the cube is transparent, you can see it through the cube. Is there any property/setting/shader I can apply to the transparent cube so that anything behind it is not rendered? Example: My eye is the green dot, the cube is the blue square, my model is the red circle, However the part of the circle hidden by the cube is purple...this would actually be invisible. The blue square would be invisible too. [![Cull](https://i.stack.imgur.com/bnCLy.png)](https://i.stack.imgur.com/bnCLy.png) This developer has an occlusion shader which does what I need, but it's Unity: <https://youtu.be/MK3D91kCKzM> Kind Regards Chris
2017/07/12
[ "https://Stackoverflow.com/questions/45052772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/174955/" ]
Here's a solution 1. For the cube, use a material with [`constant`](https://developer.apple.com/documentation/scenekit/scnmaterial.lightingmodel/1462538-constant) as its [`lightingModel`](https://developer.apple.com/documentation/scenekit/scnmaterial/1462518-lightingmodel). It's the cheapest one. 2. This material will have [`writesToDepthBuffer`](https://developer.apple.com/documentation/scenekit/scnmaterial/1462545-writestodepthbuffer) set to `true` and [`colorBufferWriteMask`](https://developer.apple.com/documentation/scenekit/scnmaterial/2867554-colorbufferwritemask) set to `[]` (empty option set). That way the cube will write in the depth buffer, but won't draw anything on screen. 3. Set the cube's [`renderingOrder`](https://developer.apple.com/documentation/scenekit/scnnode/1407978-renderingorder) to `-1` so that it's drawn before any other node in the scene. This will make the cube write in the depth buffer before any other object, preventing them from being drawn if they are behind the cube.
Based on [@mnuages answer](https://stackoverflow.com/a/45167391/1327557), you can use this class : ``` import SceneKit class OccludingNode : SCNNode { convenience init(geometry: SCNGeometry) { geometry.materials = [OccludingMaterial()] self.init() self.geometry = geometry self.renderingOrder = -1 } } class OccludingMaterial : SCNMaterial { override init() { super.init() isDoubleSided = true lightingModel = .constant writesToDepthBuffer = true colorBufferWriteMask = [] } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } ``` Create an `OccludingNode` from any geometry you want and anything behind it won't be rendered.
46,999,467
I need to pass function as a parameter like this: ``` procedure SomeProc(AParameter: TFunc<Integer, Integer>); ``` When I have this function... ``` function DoSomething(AInput: Integer): Integer; ... SomeProc(DoSomething); ... ``` ...the code works. But with parameter modificators like const, var, or default values like... ``` function DoSomething(const AInput: Integer = 0): Integer; ``` ...compiler returns error of mismatch parameter list. Is there any way to pass parameter modificators, or avoid this error? Many thanks for your suggestions.
2017/10/29
[ "https://Stackoverflow.com/questions/46999467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8851241/" ]
You can wrap it in an *Anonymous Method* like this: ``` SomeProc(function(Arg: Integer): Integer begin Result := DoSomething(Arg) end); ```
Only if you declare it as a Method reference: ``` type TDoSomething = reference to function(const AInput: Integer = 0): Integer; function SomeProc(AParameter: TDoSomething): Integer; begin Result := AParameter; end; function CallSomeProc: integer; begin Result := SomeProc(function(const AInput: Integer = 0): Integer begin Result := AInput end); end; ```
975,153
I am using jQuery's toggle() to show/hide table rows. It works fine in FireFox but does not work in IE 8. `.show()`/`.hide()` work fine though. [slideToggle()](https://stackoverflow.com/questions/903576/colums-resize-when-using-jquery-uis-toggle-in-ie) does not work in IE either - it shows for a split second then disappears again. Works fine in FireFox. My HTML looks similar to this ``` <a id="readOnlyRowsToggle">Click</a> <table> <tr><td>row</td></tr> <tr><td>row</td></tr> <tr class="readOnlyRow"><td>row</td></tr> <tr class="readOnlyRow"><td>row</td></tr> <tr class="readOnlyRow"><td>row</td></tr> </table> ``` JavaScript ``` $(document).ready(function() { $(".readOnlyRow").hide(); $("#readOnlyRowsToggle").click(function() { $(".readOnlyRow").toggle(); }); }); ```
2009/06/10
[ "https://Stackoverflow.com/questions/975153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53236/" ]
I've experienced this same error on tr's in tables. I did some investigation using IE8's script debugging tool. First I tried using toggle: ``` $(classname).toggle(); ``` This works in FF but not IE8. I then tried this: ``` if($(classname).is(":visible"))//IE8 always evaluates to true. $(classname).hide(); else $(classname).show(); ``` When I debugged this code, jquery always thought it was visible. So it would close it but then it would never open it back. I then changed it to this: ``` var elem = $(classname)[0]; if(elem.style.display == 'none') $(classname).show(); else { $(classname).hide(); } ``` That worked fine. jQuery's got [a bug](http://dev.jquery.com/ticket/4512) in it or maybe my html's a little screwy. Either way, this fixed my issue.
Just encountered this myself -- the easiest solution I've found is to check for: > > :not(:hidden) > > > instead of > > :visible > > > then act accordingly . .
15,051
In the 70s I read group of books. They were not quite conventional novels. There were references to science fiction/fantasy elements although they were not hard core genre stories. The protagonist was a bartender in a neighborhood bar in a large city, which is where most of the activity took place. There were some regulars in the bar who appeared in all the books. The only thing I can recall clearly is frequent references to "Alte Kameraden" beer. I have a feeling, but am not sure, that the stories were written not in a conventional narrative format but in a free verse style.
2012/04/18
[ "https://scifi.stackexchange.com/questions/15051", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/5885/" ]
**Short Answer:** The *Destiny*'s FTL drive system had been compromised and one of its 16 drives had been damaged and unable to be replaced. Rush presumed that any use of the system without proper calibration and without allowing the 3 hour recovery time could endanger the systems causing permanent damage. **Longer Answer:** *Destiny* has an FTL drive system. *Destiny* was originally equipped with sixteen FTL drives but one was damaged and could not be replaced. There was a question of whether it was possible to engage the FTL with fewer than fifteen drives. The FTL drives also required the ship's shield system to have at least 5% power to protect the ship until the FTL drive is completely active. The *Stargate* Wikia confirms: > > The *Destiny*'s FTL system must remain active for four hours after a > jump and inactive for three hours when they are disengaged. Jumps made > earlier than this can cause damage to the engine. > > > The [Faster-Than-Light](https://stargate.wikia.com/wiki/Faster-Than-Light_engine) engine, or FTL engine, is a technology used > on the Ancient ship *Destiny* and the Seed ships sent ahead of it. It is > capable of faster-than-light travel without entering [hyperspace](https://stargate.wikia.com/wiki/Hyperspace). > FTL has also become a Tau'ri expression for an engine capable of > travel at speeds greater than that of light, whether it is through use > of hyperspace or not. > > >
The explanation given was the drive would burn out/overload if it did not remain active for 4 hours after starting a jump and remain inactive 3 hours after completing an FTL jump. I believe this occurred with one of the Ancient "Seed Ships" during a battle with the Drones.
55,292,008
Can this be refactored into boolean? `board` is an array and `move` is and index. `position_taken?(board, move)` should return `false` if `board[move]` is `" "`, `""` or `nil` but return `true` if `board[move]` is `"X"` or `"O"`. ``` def position_taken?(board, move) if board[move] == " " false elsif board[move] == "" false elsif board[move] == nil false else true end end ```
2019/03/22
[ "https://Stackoverflow.com/questions/55292008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10732837/" ]
If only X or O is allowed, Why don't you specify them in the condition like this: ``` boared[idx] == 'X' || board[idx] == 'O' ``` I think it is much better for readability and simple.
Found the solution. It can be refactored to this: ``` def position_taken?(board, move) board[move] != " " && board[move] != "" end ```
8,459,841
Since a week I've set up 2 cronjobs. One is executed every minute, the other once per night. After checking in via FTP I noticed many files were created. These files are named after the cronjob-files. Atm I've cleaned up 6.000 unwanted files but I'm curious what's wrong? I'm executing the files via wget and they are stored in the root-folder (at the same level where the public\_html dir is located).
2011/12/10
[ "https://Stackoverflow.com/questions/8459841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/213633/" ]
Sounds like `wget` is saving its output as it does by default. You can specify `/dev/null` as the output file, and it will not save anything. ``` wget http://example.com/yourfile.php -O /dev/null ```
If you add the `-O` option to `wget`, and put `> /dev/null` to the end of your crontab entries, the problem will go away. `wget` downloads the file you point it to, but `-O` writes the file to STDOUT instead of disk, and `> /dev/null` blackholes the data.
2,207,393
I need help in indexing in MySQL. I have a table in MySQL with following rows: ID Store\_ID Feature\_ID Order\_ID Viewed\_Date Deal\_ID IsTrial The ID is auto generated. Store\_ID goes from 1 - 8. Feature\_ID from 1 - let's say 100. Viewed Date is Date and time on which the data is inserted. IsTrial is either 0 or 1. You can ignore Order\_ID and Deal\_ID from this discussion. There are millions of data in the table and we have a reporting backend that needs to view the number of views in a certain period or overall where trial is 0 for a particular store id and for a particular feature. The query takes the form of: ``` select count(viewed_date) from theTable where viewed_date between '2009-12-01' and '2010-12-31' and store_id = '2' and feature_id = '12' and Istrial = 0 ``` In SQL Server you can have a filtered index to use for Istrial. Is there anything similar to this in MySQL? Also, Store\_ID and Feature\_ID have a lot of duplicate data. I created an index using Store\_ID and Feature\_ID. Although this seems to have decreased the search period, I need better improvement than this. Right now I have more than 4 million rows. To search for a particular query like the one above, it looks at 3.5 million rows in order to give me the count of 500k rows. PS. I forgot to add view\_date filter in the query. Now I have done this.
2010/02/05
[ "https://Stackoverflow.com/questions/2207393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/243766/" ]
The resource consumption is way more influenced by the algorithmic approach than the language chosen. If you are comfortable with Java, program your application in that language - even though a C++ implementation might be 10% faster. That being said, you might be interested with [Artificial Intelligence API's for Java](https://aij.dev.java.net/).
I did a similar AI project a couple of years ago. I don't know what solution you will be implementing, but AI programs can generally be both resource consuming and may take a long time to run, but on the other hand, you'll need a language you're familiar with to get it done in time. Therefore, my advice is that if you feel you *know* C++ (or C), go with one of them. If you don't know them, then consider carefully the time you will need to invest in learning a new language before choosing.
57,222,897
I'm working with the basic Gatsby starter site and it compiles just fine, but the browser just shows the error mentioned in the title as well as a couple warnings. It's probably important to note that the error is gone when I completely remove the StaticQuery piece so the IndexPage component is just the opening and closing Layout tags. This gets rid of the error and the browser shows the header+footer of the Gatsby starter site. I've made sure that my versions of react and react-dom are up to date in the package.json, I've reinstalled the packages via npm install, I've tried other versions of react, nothing is working. The file that is failing (index.js): ``` import React from "react" import { StaticQuery, GraphQL, Link } from "gatsby" import Layout from "../components/layout" import Image from "../components/image" import SEO from "../components/seo" const IndexPage = () => ( <Layout> <StaticQuery query={GraphQL`{ allWordpressPage { edges { node { id title content } } } }`} render={props => ( <div> {props.allWordpressPage.edges.map(page => ( <div key={page.node.id}> <h1> {page.node.title} </h1> <div dangerouslySetInnerHTML={{__html: page.node.content}} /> </div> ))} </div> )} /> </Layout> ) export default IndexPage ``` The error and warnings that show in browser: ``` TypeError: Object(...) is not a function IndexPage src/pages/index.js:1 > 1 | import React from "react" 2 | import { Link } from "gatsby" 3 | 4 | import Layout from "../components/layout" View compiled ▶ 17 stack frames were collapsed. JSONStore._this.handleMittEvent /Users/kennansmith/Desktop/Temp_Task_Folder/gatsby-wp/.cache/json-store.js:1 > 1 | import React from "react" 2 | 3 | import PageRenderer from "./page-renderer" 4 | import normalizePagePath from "./normalize-page-path" View compiled ▶ 2 stack frames were collapsed. r.<anonymous> /Users/kennansmith/Desktop/Temp_Task_Folder/gatsby-wp/.cache/socketIo.js:20 17 | // Try to initialize web socket if we didn't do it already 18 | try { 19 | // eslint-disable-next-line no-undef > 20 | socket = io() 21 | 22 | const didDataChange = (msg, queryData) => { 23 | const id = View compiled ▶ 24 stack frames were collapsed. ```
2019/07/26
[ "https://Stackoverflow.com/questions/57222897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9975338/" ]
Finally, I got velocity like this. (I wonder why I can't access the velocity of DragGesture.value when print value) ```swift struct ContentView: View { @State private var previousDragValue: DragGesture.Value? func calcDragVelocity(previousValue: DragGesture.Value, currentValue: DragGesture.Value) -> (Double, Double)? { let timeInterval = currentValue.time.timeIntervalSince(previousValue.time) let diffXInTimeInterval = Double(currentValue.translation.width - previousValue.translation.width) let diffYInTimeInterval = Double(currentValue.translation.height - previousValue.translation.height) let velocityX = diffXInTimeInterval / timeInterval let velocityY = diffYInTimeInterval / timeInterval return (velocityX, velocityY) } var body: some View { return VStack { … } .gesture(DragGesture().onChanged {value in if let previousValue = self.previousDragValue { // calc velocity using currentValue and previousValue print(self.calcDragVelocity(previousValue: previousValue, currentValue: value)) } // save previous value self.previousDragValue = value } } } ```
You honestly don't even need the velocity. Just use `DragGesture.Value`'s `predictedEndTranslation`
635,779
I'm trying to configure the extension mcrypt in my Ubuntu Server VirtualBox for work in my phpMyAdmin page. I ran `vi /etc/php5/mods-available/mcrypt.ini` and then I changed `extension=mcrypt.so` to `extension=/usr/lib/php5/20121212/mcrypt.­so` and when I tried to save changes it said this: ``` E45 readonly option is set (add ! to override) ``` I think that maybe I made a mistake deleting something before `extension=mcrypt.os` and I don't know what to do.
2015/06/12
[ "https://askubuntu.com/questions/635779", "https://askubuntu.com", "https://askubuntu.com/users/419586/" ]
First come out of the vim editor using: `:qa!` Next, use `sudo vim filename` and later: `:wq`
This happens when the user is trying to write on a file without the right permissions. Login as root using `sudo su` and now you can do the edit...
56,596,752
As part of our CI testing we install a virtualenv with some pip packages from a constant requirements.txt file. this installation process randomly fails from time to time with no apparent reason as the requirements.txt file doesn't change. And each time it's for a different random package. The CI is on an AWS machine so I don't think it can be an internet issue The failure looks similar to that (with different package failing): ``` Collecting django-rest-auth==0.9.3 (from -r requirements.txt (line 7)) Could not find a version that satisfies the requirement django-rest-auth==0.9.3 (from -r requirements.txt (line 7)) (from versions: ) No matching distribution found for django-rest-auth==0.9.3 (from -r requirements.txt (line 7)) ``` Or ``` Collecting py>=1.5.0 (from pytest->-r requirements.txt (line 15)) Could not find a version that satisfies the requirement py>=1.5.0 (from pytest->-r requirements.txt (line 15)) (from versions: ) No matching distribution found for py>=1.5.0 (from pytest->-r requirements.txt (line 15)) ``` EDIT: Tried adding `--timeout 30 --retries 15` which didn't seem to change anything
2019/06/14
[ "https://Stackoverflow.com/questions/56596752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/972014/" ]
I have that problem when I have a heavy dependency, so I updated the timeout for pip and problem solved. i.e my .pip/pip.conf has a timeout of 30 seconds ``` [global] timeout = 30 ```
**Problem:** Their may be problem with your python and other libraries version. May be your django wheel require some-other library which is installed in your anaconda environment but not satisfying the versions. when you use pip command it just try to download the wheel not care about version and not if version are not matching it just give us error. Try using conda command because conda command will update your version according to the requirement. when you you conda command it will download library for all of the environments you are using in anaconda navigator. But Pip will only install library from which environment pip command is called. **Solution:** try to install this library using conda command like ``` conda install django-rest-auth==0.9.3 ``` This command will help you to solve version error.
193,645
I just bought a used iMac, and updated to 10.6.8 from 10.5.8. I created my first Apple ID, and verified it. Now I am trying to update to Yosemite, so that I can install Xcode. When I try to give my Apple ID it ends up telling me I need to give it credit card info. I do not own a credit card, for religious reasons, and I can't figure out how to update to Yosemite without it.
2015/06/30
[ "https://apple.stackexchange.com/questions/193645", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/120162/" ]
For AirDrop to work, you need 1. Wi-Fi and Bluetooth on —although you don't need to be connected to the same network for AirDrop to work. 2. AirDrop activated —probably the "Everyone" setting will help with visibility on iOS. 3. If your Mac is older than 2012, you may have some issues. 4. You have to be closer than 30 feet (9 m). 5. You may wish to check your firewall, but given your specific situation —you see the iPad— that may not be a problem. Check [this document](https://support.apple.com/en-us/HT203106) in case I missed something.
Didn't work with Wifi & Bluetooth & Airdrop turned on in both Mac and iPhone. After a while trying to figure this out: Turn of Firewall on mac, that's it!
539,610
I can only find examples of setting Readline key bindings using Control (`\C-`) or Escape (`\e`) as prefixes. In my case, on macOS, the `\C-` space is completely filled up by default key bindings, and the `\e` space is not practical on a Macbook with a touchbar. Entering `"\M-f": kill-word` in `~/.inputrc` results in: ``` bind -P | grep -F "\M-" kill-word can be found on "\e[3;5~" "\ed". ``` But `kill-word` cannot be executed using either of `Option`, `Command`, or `fn` as prefixes - Readline ignores it. Is this issue specific to macOS, and how can I solve it? Furthermore, how can I control the "timeout" that should occur before a key binding, that is a prefix of a longer key binding, is executed? @added (@laktak): `bind '"^[f": kill-word'` doesn't work, but instead results in `ƒ` on the terminal: [![enter image description here](https://i.stack.imgur.com/PqfY6.png)](https://i.stack.imgur.com/PqfY6.png)
2019/09/08
[ "https://unix.stackexchange.com/questions/539610", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/128739/" ]
The utility would be: ``` showkey (1) - examine the codes sent by the keyboard ``` but this seems to be missing on mac-os...here it is "Key Codes"...? Or you type ctrl-V (qouted insert) and then some special key. In bash, this prints `^[OP` in xterm and `^[[[A` in the console for the F1 key. The readline variable: ``` keyseq-timeout (500) ``` is the timeout to use for a half-finished sequence. Underneath this, there must be a sort of keymap file, where the keys get translated to symbols. This is from `/usr/share/kbd/keymaps/mac/` on linux: ``` keycode 51 = Delete Remove alt keycode 51 = Meta_Delete shift alt keycode 51 = Meta_Delete control keycode 51 = Remove keycode 53 = Escape alt keycode 53 = Meta_Escape shift alt keycode 53 = Meta_Escape keycode 54 = Control keycode 55 = Alt # Command/Apple key keycode 56 = Shift keycode 57 = Caps_Lock keycode 58 = AltGr # Alt/Option key ``` You see the flexibilty! The Meta-Delete symbol could become kill-word... --- > > bind '"^[f": kill-word > > > This `^[` must be a `\e`, or a ctrl-V, then Escape: one byte, not circumflex plus bracket. --- It is like saying: ^C means control-C, not a Shift-6 and then a Shift-c...in the shell (bash) or in vim when I type ctrl-v and then Esc I get `^[`, but it is just one character when you step back over it. Together with these meta-flag options in readline it can get complicated...I just illustrate the whole chain: keymap "default.map" (translates scancode and modifier to keysymbols) ``` keycode 105 = Left F150 F151 string F150 = "\033[150" string F151 = "\033[151" keycode 106 = Right F154 F155 string F154 = "\033[154" string F155 = "\033[155" ``` The F150 and F151 after default "Left" mean shift- and control-left-arrow. In a second step you can define a string, an escape sequence in this case. Here, `\e` did not work, but the octal 033 is ascii 27 is control-[ is Escape...this keymap is linux specific, but X Windows has a similar logic. And in .inputrc: ``` "\e[150": backward-word "\e[151": shell-backward-word "\e[154": forward-word "\e[155": shell-forward-word ``` This works very nice in the linux console. In xterm under X Windows (Xorg): not at all: Xorg scans the keys itself. ``` backward-word can be invoked via "\e[150", "\e[1;2D", "\e[1;3D", "\eb". ``` The two in the middle with semicolon are VTxxx style modified left arrows. This was preconfigured, and also gets bound to `backward-word` automatically.
If I understood your question correctly: ``` bind '"^[f": kill-word' ``` Will define `Option+F` to invoke `kill-word`
9,961
This is related to [another question](https://mathoverflow.net/questions/5143/pushouts-in-the-category-of-schemes). I've found many remarks that the category of schemes is not cocomplete. The category of locally ringed spaces is cocomplete, and in some special cases this turns out to be the colimit of schemes, but in other cases not (which is, of course, no evidence that the colimit does not exist). However, I want to understand in detail a counterexample where the colimit does not exist, but I hardly found one. In FGA explained I've found the reference, that Example 3.4.1 in Hartshorne, Appendix B is a smooth proper scheme over $\mathbb{C}$ with a free $\mathbb{Z}/2$-action, but the quotient does not exist (without proof). To be honest, this is too complicated to me. Are there easy examples? You won't help me just giving the example, because there are lots of them, but the hard part is to prove that the colimit really does not exist.
2009/12/28
[ "https://mathoverflow.net/questions/9961", "https://mathoverflow.net", "https://mathoverflow.net/users/2841/" ]
**Edit:** [BCnrd](https://mathoverflow.net/users/3927/bcnrd) gave a proof in the comments that this example works, so I've edited in that proof. A ~~possible~~ proven example ----------------------------- ~~I suspect~~ There is no scheme which is "two $\mathbb A^1$'s glued together along their generic points" (or "$\mathbb A^1$ with every closed point doubled"). In other words, the coequalizer of the two inclusions $Spec(k(t))\rightrightarrows \mathbb A^1\sqcup \mathbb A^1$ does not exist in the category of schemes. Intuitively, this coequalizer should be "too non-separated" to be a scheme. ~~I don't have a proof, but I thought other people might have ideas if I posted this here.~~ If a coequalizer $P$ does exist, then no two closed points of $\mathbb A^1\sqcup \mathbb A^1$ map to the same point in $P$. To show this, it is enough to find functions from $\mathbb A^1\sqcup \mathbb A^1$ to other schemes which agree on the generic points but disagree on any other given pair of points. The obvious map $\mathbb A^1\sqcup \mathbb A^1\to \mathbb A^1$ separates most pairs of closed points. To see that a point on one $\mathbb A^1$ is not identified with "the same point on the other $\mathbb A^1$", consider the map from $\mathbb A^1\sqcup \mathbb A^1$ to $\mathbb A^1$ with the given point doubled. On the other hand, let $U$ be an affine open around the image of the generic point in $P$. $U$ has dense open preimages $V$ and $V'$ in both affine lines. Let $W=V\cap V'$ inside the affine line, so we have two maps from $W$ to the affine $U$ which coincide at the generic point of $W$, and hence are equal (as $U$ is affine). In particular, the two maps from affine line to categorical pushout $P$ coincide at each "common pair" of closed points of the two copies of $W$, contradicting the previous paragraph. --- **Edit:** The questions below are no longer relevant, but I'd like to leave them there for some reason. Here are some questions that might be helpful to answer: > > If the coequalizer above *does* exist, must the map from $\mathbb A^1\sqcup \mathbb A^1$ be surjective? > > > (see the related question [Can a coequalizer of schemes fail to be surjective?](https://mathoverflow.net/questions/63/can-a-coequalizer-of-schemes-fail-to-be-surjective)) > > Is the coequalizer of $Spec(k(t))\rightrightarrows \mathbb A^1\sqcup \mathbb A^1$ in the category of **separated** schemes equal to $\mathbb A^1$? (probably) > > > > > What are some ways to determine that a functor $Sch\to Set$ *is not* corepresented by a scheme? > > >
Sounds to me like you don't want to hear the proof, but you want to hear "the point". The point is that a scheme must by definition be covered by affine schemes, and sometimes when doing exercises in Hartshorne the proofs go like this: first do the question for affine schemes, where the question becomes ring theory, and then do it for all schemes by glueing together. So here is how you might want to try and quotient out a scheme by a free action of $Z/2Z$: first let's say the scheme is affine, so $Spec(A)$, with $A$ having an action of $Z/2Z$, and try and figure out if the quotient exists, and then move onto the general case. In the affine case we have a ring $A$ with an action of $Z/2Z$, and if $B$ is the invariants, then you can convince yourself that $Spec(B)$ is the quotient. Now let' s do the general case. Say $X$ is a scheme with an action of $Z/2Z$. Choose a point $x$ in $X$. Now let $Spec(A)$ be an affine containing $x$. Now $Z/2Z$ acts on $Spec(A)\ldots$oh wait, no, no it doesn't, because the action will maybe move $Spec(A)$ to another affine $Spec(B)$. So let's try intersecting $Spec(A)$ and $Spec(B)$, The intersection will often be affine so let's consider this and call it $Spec(C)$ and$\ldots$oh no, wait, that doesn't work either, because $x$ might not be in $Spec(C)$. Hmm. The well-known 3-fold you mention in your question behaves in this way. You can't cover it by affines each one of which is preserved by the action, so you get stuck. Does that help?
32,984,180
Background ---------- For a technical interview I was tasked with implementing a missing algorithm in JavaScript. The interviewer supplied me with some code and 18 failing unit tests that once the algorithm was successfully implemented would pass. I'm sure there is a more efficient way to have solved this problem as I tried a few different approaches during my allotted time. This way is the first way that I got to work, which for the technical test was enough but I'd like to know a better way of solving the problem. Problem ------- Work out if the cards in a poker hand form a straight. (I've already ordered the hand in ascending order.) My Solution ----------- ``` PokerHand.prototype._check_straight_function = function(arr) { var isStraight = false; for (var j = i = 4; i >= 0 && j > 1; i--) if (arr[i].value() - 1 == arr[--j].value()) { isStraight = true; } else { isStraight = false; } }; return isStraight; }; ``` Other approaches ---------------- Things I didn't get working that I think *might* work faster, I'd really appreciate if someone could talk me through a working version of the below approach(es) and help me understand which is the fastest to evaluate. * recursive use of `arr.pop().value - 1 == arr.pop().value()` * `filter` the array to create a new array that contains only values where the next index (`arr[++i])`is the current index + 1 and then see if the new array is the same length. * a `for loop` with a `break / continue` to short circuit as soon as the straight ends.
2015/10/07
[ "https://Stackoverflow.com/questions/32984180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814038/" ]
There's no need to assign a variable isStraight at all. ``` PokerHand.prototype._check_straight_function = function(arr) { for (var i = i = 4; i++) { if (arr[i].value() - 1 != arr[i-1].value()) { return false; } }; return true; }; ```
Well, this is maybe a tiny bit tidier. I don't see a Ninja way ;( As far as comparing the solutions -- I'm an employer, and for my part, I'd prefer the answer which was clear and elegant over one which was a few nanoseconds faster :) ``` for (var i = 0; i < 5; i++) { if (a[i].value() != i + a[0].value()) return false; } return true; ```
12,094,326
How can I match variations on words in MySQL, for example a search for accountancy should match accountant, accountants, accounting etc. I'm on shared hosting so can't add any functions to MySQL such as levenshtein. I want something similar to how Google matches '**accounting course**' and '**accountancy courses**' when searching for '**accountant courses**'. [Example](https://www.google.com/search?q=accopunty%20course&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla%3aen-GB%3aunofficial&client=firefox-a&channel=fflb#hl=en&sugexp=les;&gs_nf=1&tok=ftDNvSv6wwuE-qs40cy62w&pq=accouncay%20course&cp=18&gs_id=cp&xhr=t&q=accountant%20courses&pf=p&client=firefox-a&hs=X2F&rls=org.mozilla%3aen-GB%3aunofficial&channel=fflb&sclient=psy-ab&oq=accountant%20courses&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.&fp=505ac51441bb0ee9&biw=1050&bih=1534). My server language is php, if it's only possible to implement it there and not in SQL. The current statement is as follows. ``` SELECT pjs.title, MATCH (pjs.title) AGAINST ('accountancy' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION) AS rel1, MATCH (pjs.description) AGAINST ('accountancy' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION) AS rel2, MATCH ( pjs.benefits, pjs.experienceRequirements, pjs.incentives, pjs.qualifications, pjs.responsibilities, pjs.skills ) AGAINST ('accountancy' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION) AS rel3 FROM pxl_jobsearch AS pjs ORDER BY (rel1 * 5) + (rel2 * 1.5) + (rel3) DESC; ```
2012/08/23
[ "https://Stackoverflow.com/questions/12094326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2674284/" ]
MySQL isn't very good at full text search and you'd probably want to use other engines. My favorite one is Sphinx (<http://sphinxsearch.com/>) but there are others as well. Most of these support stemming out of the box. If you have large tables and are going to use stemming the performance of MySQL will probably be very bad. If you can't use Sphinx, take a look at this php script <http://tartarus.org/~martin/PorterStemmer/php.txt> With this you can use stemming, and the search on the stemmed words.
I don't know much about `MATCH`, when I want to select a column with variations I do the following ``` SELECT pjs.title FROM pxl_jobsearch AS pjs WHERE pjs.title LIKE 'account%' ``` I work mostly in SQL Server but do some MySQL. I imagine that this works in MySQL as well.
6,534,193
So my first explanation was difficult to read nad It was'nt fully correct as well. I'll try to explain it again. I have a strongly typed view where you enter a number. This view also has several strongly typed partial-views created in a for-loop. Each partial view is strongly typed and the model-item of each partial has a "Number"-property. The value of this property should be the entered number of the "parent"-view. How do I link the value of the entered number with the number property of the partial view model elements. Thanks for reading.
2011/06/30
[ "https://Stackoverflow.com/questions/6534193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/810475/" ]
The linker isn't complaining about `pow((double) 2, (double) 3)` because the compiler is replacing it with a constant `8.0`. You shouldn't depend on this behavior; instead, you should always use the `-lm` option properly. (BTW, that's more clearly written as `pow(2.0, 3.0)`. Consider the following program: ``` #include <stdio.h> #include <math.h> int main(void) { double x = 0.1; printf("%g\n", pow(2.0, 3.0)); printf("%g\n", asin(x)); return 0; } ``` When I compile and link it on my system using ``` gcc c.c -o c ``` I get: ``` /tmp/ccXx8ZRL.o: In function `main': c.c:(.text+0x36): undefined reference to `asin' collect2: ld returned 1 exit status ``` Note that it complains about `asin` but not about `pow`. If I change the `pow` call to `pow(x, 3.0)`, I get: ``` /tmp/ccOeSaBK.o: In function `main': c.c:(.text+0x24): undefined reference to `pow' c.c:(.text+0x52): undefined reference to `asin' collect2: ld returned 1 exit status ``` Normally if you want to call a standard math library function, you need to have `#include <math.h>` at the top of the source file (I presume you already have that) *and* you need to pass the `-lm` option to the compiler *after* the file that needs it. (The linker keeps track of references that haven't been resolved yet, so it needs to see the object file that refers to `asin` first, so it can resolve it when it sees the math library.) The linker isn't complaining about the call to `pow(2.0, 3.0)` because gcc is clever enough to resolve it to a constant `8.0`. There's no call to the `pow` function in the compiled object file, so the linker doesn't need to resolve it. If I change `pow(2.0, 3.0)` to `pow(x, 3.0)`, the compiler doesn't know what the result is going to be, so it generates the call.
Are you including `<math.h>` everywhere? Notice that the names in the library are prefixed with `__ieee754_`, but the ones the linker can't find are not. What happens when you compile this code? ``` #include <math.h> int main(void) { double d = pow(2, 3); double e = asin(1.0 / d); return (int)(e+1); } ``` If the file is `mathtest.c`, then compile with: ``` gcc -o mathtest mathtest.c -lm ``` (Given that this fails to compile, what symbols are defined in `mathtest.o`?) --- I added a comment to the main question: > > Which platform are you on? Which C compiler are you using? Are you cross-compiling? What is the command line that is executed to do the linking? (I see DOS/Windows C: paths and PowerPC architecture.) Is there any chance you are using for type-generic math? > > > Looking at the LOAD paths you give, I see: > > > ``` > LOAD c:/gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/bin/../lib/gcc/powerpc-eabi/4.3.3/../../../../powerpc-eabi/lib/nof\libm.a > > ``` > > Which can, I think, be simplified to: > > > ``` > LOAD c:/gnu/powerpc-eabi/3pp.ronetix.powerpc-eabi/powerpc-eabi/lib/nof\libm.a > > ``` > > One part of that path that intrigues me is the `nof` part; could that be 'no floating point'? The other part that really intrigues me is the presence of `powerpc` with the `c:` prefix; it smacks of cross-compilation for PowerPC on a Windows platform. It is important to be forthright and explicit about such things; we need that sort of information to be able to help you sensibly. Was this the `libm.a` library that you tested, or did you experiment with another file?
10,739,016
Hopefully, this is an easy one. I have an array with lines that contain output from a CSV file. What I need to do is simply remove any commas that appear between double-quotes. I'm stumbling through regular expressions and having trouble. Here's my sad-looking code: ``` <?php $csv_input = '"herp","derp","hey, get rid of these commas, man",1234'; $pattern = '(?<=\")/\,/(?=\")'; //this doesn't work $revised_input = preg_replace ( $pattern , '' , $csv_input); echo $revised_input; //would like revised input to echo: "herp","derp,"hey get rid of these commas man",1234 ?> ``` Thanks VERY much, everyone.
2012/05/24
[ "https://Stackoverflow.com/questions/10739016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1415176/" ]
Original Answer --------------- You can use [`str_getcsv()`](http://php.net/manual/en/function.str-getcsv.php) for this as it is purposely designed for process CSV strings: ``` $out = array(); $array = str_getcsv($csv_input); foreach($array as $item) { $out[] = str_replace(',', '', $item); } ``` `$out` is now an array of elements without any commas in them, which you can then just implode as the quotes will no longer be required once the commas are removed: ``` $revised_input = implode(',', $out); ``` Update for comments ------------------- If the quotes are important to you then you can just add them back in like so: ``` $revised_input = '"' . implode('","', $out) . '"'; ``` Another option is to use one of the `str_putcsv()` (not a standard PHP function) implementations floating about out there on the web such as [this one](http://www.php.net/manual/en/function.str-getcsv.php#91170).
Not exactly an answer you've been looking for - But I've used it for cleaning commas in numbers in CSV. `$csv = preg_replace('%\"([^\"]*)(,)([^\"]*)\"%i','$1$3',$csv);` "3,120", 123, 345, 567 ==> 3120, 123, 345, 567
46,696,658
I need a formula in Excel, not VBA please, forbidden to have such functions on my work machine. My situation is I need a number from cell A, which is a result from Today(), combined with a number from cell B, which is a result from Now(), combined with a number from cell C which is a text number, to output as a single number. Example: ``` Cell A1 Cell A2 Cell A3 Formula: TODAY() NOW() 17709 Displays: 1011 1423 17709 Needed: 1011142317709 ``` What I'm trying is this, which is a fail: `=TEXT(O21,yy-mm)&""&TEXT(P21,hh,mm)&"""&VALUE(Q21)`
2017/10/11
[ "https://Stackoverflow.com/questions/46696658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8761294/" ]
``` =TEXT(O21,"yymm")&""&TEXT(P21,"hhmm")&""&VALUE(Q21) ``` Placed in quotes the number format and removed extra quote though not sure why you are adding null to the string. To match the sample output OP provided the formula would be: ``` =TEXT(A1,"mmdd")&""&TEXT(B1,"hhmm")&VALUE(C1) ```
If you **do not** need leading zeroes to fill 5 digit placeholders for the value in Q21, ``` =TEXT(NOW(),"yymmhhmm")&TEXT(Q21, "0") 'possibly, =TEXT(NOW(),"mmddhhmm")&TEXT(Q21, "0") ``` If you **do** need leading zeroes to fill 5 digit placeholders for the value in Q21, ``` =TEXT(NOW(),"yymmhhmm")&TEXT(Q21, "00000") 'possibly, =TEXT(NOW(),"mmddhhmm")&TEXT(Q21, "00000") ```
14,622,342
I am a little confused by the **elitism** concept in Genetic Algorithm (and other evolutionary algorithms). When I reserve and then copy 1 (or more) elite individuals to the next generation, * Should I consider the elite solution(s) in the parent selection of the current generation (making a new population)? * Or, should I use others (putting the elites aside) for making a new population and just copy the elites directly to the next generation? If the latter, what is the use of elitism? Is it just for not losing the best solution? Because in this scheme, it won't help the convergence at all. for example, [here](http://www.omgwiki.org/hpec/files/hpec-challenge/ga.html "here") under the crossover/mutation part, it is stated that the elites aren't participating. (Of course, the same question can be asked about the *survivor selection* part.)
2013/01/31
[ "https://Stackoverflow.com/questions/14622342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/336557/" ]
Elitism only means that the most fit handful of individuals are guaranteed a place in the next generation - generally without undergoing mutation. They should still be able to be selected as parents, in addition to being brought forward themselves. That article does take a slightly odd approach to elitism. It suggests duplicating the most fit individual - that individual gets **two** reserved slots in the next generation. One of these slots is mutated, the other is not. That means that, in the next generation, at least one of those slots will reenter the general population as a parent, and possibly two if both are overtaken. It does seem a viable approach. Either way - whether by selecting elites as parents while also perpetuating them, or by copying the elites and then mutating one - the elites should still be closely attached to the population at large so that they can share their beneficial genes around. [@Peladao's answer](https://stackoverflow.com/a/14623460/12268505) and comment are also absolutely spot on - especially on the need to maintain diversity and avoid premature convergence, and the elites should only represent a small portion of the population.
In nutshell the main points about using elitism are: 1. The number of elites in the population should not exceed say 10% of the total population to maintain diversity. 2. Out of this say 5% may be direct part of the next generation and the remaining should undergo crossover and mutation with other non-elite population.
126,227
I do interior photography occasionally. I'd like to replace my Canon M50 with the iPhone 13 Pro Max but I'm concerned about an external flash. * Is it possible to use an external flash with iPhone? * What's the best external flash dedicated? * I already own a great Canon Speedlite 430EX II. Can I use it with the iPhone?
2021/09/22
[ "https://photo.stackexchange.com/questions/126227", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/101870/" ]
> > I do interior photography occasionally. I'd like to replace my Canon > M50 with the iPhone 13 Pro Max but I'm concerned about an external > flash. > > > You should be. The rolling electronic shutters in most phone cameras eliminates using flash at all, since it [lowers the camera's flash sync speed](https://www.dpreview.com/articles/5816661591/electronic-shutter-rolling-shutter-and-flash-what-you-need-to-know) down to roughly 1/30s or slower (on my iPhone8, it was 1/25s). It's why the "flash" on most phone cameras is really a continuous LED light, rather than a Xenon bulb strobe. That LED 'flash' also cannot trip "dumb" optical slaves. > > Is it possible to use an external flash with iPhone? > > > It is, but at this time, the only company that's [cracked the problem](https://medium.com/profoto/the-tech-transformation-of-a-traditional-hardware-company-ecc8a2de72f1) of syncing an off-camera radio-triggered flash with an iPhone camera is **Profoto**. Which costs a kidney (e.g., the Profoto A10 speedlight is US$1100). But the [Protofo Camera app](https://profoto.com/us/profoto-camera) for iOS and Android lets you use Profoto lights with your iPhone camera via their AirX technology at any shutter speed. AFAIK, at the time of writing this (Sept. 2021), nobody else has managed to correctly sync a strobe with a smartphone camera. There was [the Godox A1](https://www.dpreview.com/news/1259675135/godox-a1-smartphone-flash-trigger-officially-released-costs-70) transmitter/flash which communicated with the phone via Bluetooth, but it stopped working after iOS 13 and the iPhone 11 came out, and has since been discontinued. It had a very narrow window of usage, anyway, because, unlike Profoto, they never found a way around the sync speed issue, and the Godox Photos app itself (which was what you had to use as your camera app) was badly designed and wonky. I detailed using one in [this 2017 dpreview post](https://www.dpreview.com/forums/post/60179238). > > What's the best external flash dedicated? > > > There is no such thing as a dedicated flash for iPhone, since the iPhone has no physical flash sync connectors on it. And all the "flash" units that can be connected via a lightning port are really continuous LED lights. > > I already own a great Canon Speedlite 430EX II. Can I use it with the iPhone? > > > No. Profoto does not make add-on receivers for speedlights for the Air system. And the only wireless protocol the 430EX II "speaks" is the Canon "smart" optical one. My advice would be to consider using continuous video (LED) lighting instead of strobes with your iPhone, or if flash photography is vital to what you need to accomplish, that you not move entirely to an iPhone, but also keep a camera with a flash hotshoe in the bag.
Look up Potech's TricCam. I use my speedlites with it on my iPhone 13. Sync speed is 1/60th. You have to use TricCam's app, which costs about $8.00. The device itself costs under $60.00. Once you can fire one speedlite, you can set the up others as optical slaves. The LED flash on the iPhone will trigger an optical slave, but it has to be placed about a half inch away from it to see it.
21,236,049
I am unable connect my Android to Ubuntu. I have added rule to `udev`, I have added device to `adb_usb.ini` and I'm still getting same empty list. My lsusb: ``` `Bus 002 Device 124: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II]` ``` adb\_usb.ini ``` # ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT. # USE 'android update adb' TO GENERATE. # 1 USB VENDOR ID PER LINE. 0x0e79 0x04e8 ``` 51-android.rules ``` SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666" ``` And I have usb debugging on. Is there anything else that I can try? **EDIT** I have tried to restart adb-server with `adb kill-server` and `adb start-server`, but it also doesn't help me.
2014/01/20
[ "https://Stackoverflow.com/questions/21236049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2265932/" ]
For those who are having intermittent problems with adb. Here's a simple procedure you can use to rectify the issue. Keep the device connected. run ``` sudo adb kill-server ``` then go into your mobile device and revoke all usb authorizations in your android developer section in settings on your mobile device. Next turn debugging off and then on again after 10 secs or so. You will get a pop up for authorization in your device. Select yes to it on the device and then run the following in terminal ``` sudo adb devices -l ``` Your device should be back in action.
Adding device in android rules file: ------------------------------------ ### Use the following commands in Ubuntu: How to get the device vendor id: ``` lsusb ``` Command for adding device rules, run the following commands: ``` sudo gedit /etc/udev/rules.d/51-android.rules sudo chmod a+r /etc/udev/rules.d/51-android.rules ```
4,193
I'm looking for an activity for highschoolers/college-freshmen that will demonstrate crypto topics (e.g., encryption, signatures, zero-knowledge), and will be fun and motivating. It is supposed consist of small tasks that the audience can do by themselves (=no complicated math). I vaguely remember seeing a website with suggestions for such activities, but I cannot find any information now. Any suggestions / ideas?
2018/01/19
[ "https://cseducators.stackexchange.com/questions/4193", "https://cseducators.stackexchange.com", "https://cseducators.stackexchange.com/users/4002/" ]
Have you considered a practical example like teaching PGP email encryption? [Keybase.io](https://keybase.io) has a browser based crypto solution for doing encryption / decryption and while I don't recommend for "real" crypto, it is a great convenience tool for showing how public/private key encryption works without the need to address pgp tools installed on a machine or access to a key server. An example lesson based scenario would look like: 1. Explain the basics of [PGP](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) and Key based Cryptography - the "Art of the Problem" [video](https://www.youtube.com/watch?v=YEBfamv-_do) linked elsewhere on the answers I agree is the *definitive* explanation of the Diffie-Hellman Key Exchange theory. This should be sufficient to work practically with encrypting /decrypting with PGP. 2. Students create a set of keys: public key for sharing, private key for keeping. 3. Students share their public keys in a place where everyone can see them and know who's is who's. This is where Keybase would be useful, but you could also just put them all in a public gist or paste bin. It is safe to share a public key. 4. Students can now use the public keys to send messages to each other and publish the encrypted messages in another public place (same pastebin, eg) or via email. Some interesting activities and discussions: * How can I decrypt a message meant for me? * What happens if I take a message encrypted for someone else and use my private key to decrypt? * What practical use cases could this type of encryption (key exchange) solve? (TLS/SSL probably the easiest reach). * What challenges does this type of technology create for law enforcement and regulators to protect against fraud or other nefarious activities (terrorism, money laundering, etc). How can this type of activity improve the transparency and accuracy of information (PGP signatures of code commits on open source projects, eg). If there are both nefarious and good uses of this technology, how do you decide if it should be legal, or illegal to use it?
When it comes to explaining asymmetric cryptography, I've seen an incredibly simple yet potent analogy used time and time again. This analogy can be found in this [Art of the Problem video](https://www.youtube.com/watch?v=YEBfamv-_do "Public key cryptography") around 2:40. This simple example could easily be done in the classroom, and can explain the basic principles of asymmetric cryptography without the usual requisite mathematics background.
25,524,638
I want to disable a button (`UIButton`) on iOS after it is clicked. I am new to developing for iOS but I think the equivalent code on objective - C is this: ``` button.enabled = NO; ``` But I couldn't do that on swift.
2014/08/27
[ "https://Stackoverflow.com/questions/25524638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2966808/" ]
Swift 5 / SwiftUI ----------------- Nowadays it's done like this. ``` Button(action: action) { Text(buttonLabel) } .disabled(!isEnabled) ```
in order for this to work: ``` yourButton.isEnabled = false ``` you need to create an outlet in addition to your UI button.
19,050,921
I filled array list with values. Each row is item with properties. Now I would like to sort items by one of properties and "print" them to textview. ``` ArrayList<String[]> arrayList = new ArrayList<String[]>(); final String[] rowToArray = new String[7]; rowToArray[0] = itemName; rowToArray[1] = itemProperties1; rowToArray[2] = itemProperties2; rowToArray[3] = itemProperties3; rowToArray[4] = itemProperties4; rowToArray[5] = itemProperties5; rowToArray[6] = itemProperties6; arrayList.add(rowToArray); ``` Could you please help me to sort it by properties and then show me how to print item one by one with properties. Thank you in advance. **EDIT:** **SOLVED BY [ppeterka66](https://stackoverflow.com/users/1667004/ppeterka-66)** I just had to add his code and call **Collections.sort(arrayList,new StringArrayComparator(column));** where column is required column to be sortby. ``` int i=0; final int column=2; Collections.sort(arrayList,new StringArrayComparator(column)); for(String[] line :arrayList) { Log.d(Integer.toString(i),line[column].toString()); } ```
2013/09/27
[ "https://Stackoverflow.com/questions/19050921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2463173/" ]
Well. You do ``` tmp.milisecondsCount = tmp.milisecondsCount - 1; if(tmp.milisecondsCount == 0){ tmp.milisecondsCount = 100; tmp.secondsCount -= 1; } ``` And right after that ``` if ((tmp.secondsCount == 0) && tmp.milisecondsCount == 0) { //stuff } ``` How could it ever happen that they're both 0 if, as soon as `milisecond` reaches `0`, you reset it to `100`? EDIT: Do instead something like: ``` if(tmp.milisecondsCount < 0){ tmp.secondsCount -= 1; if (tmp.secondsCount == 0){ //Stuff for when the timer reaches 0 //Also, are you sure you want to do [self setTimer] again //before checking if there are any lives left? } else tmp.milisecondsCount = 99; } ```
In your code, a first condition is met ``` if(tmp.milisecondsCount == 0){ tmp.milisecondsCount = 100; ``` so that the next conditional statment ``` && tmp.milisecondsCount == 0 ``` will never be true.
4,627,952
I need help finding all positive integer solutions to the following Diophantine equation: $$\frac1x+\frac1y+\frac1z=\frac12$$ --- What I figured out so far was that we essentially need to find $3$ divisors, $a$, $b$, and $c$ of some number $k$ such that $$a+b+c=\frac k2$$This is so that when we divide $k$ on both sides, we get $$\frac ak+\frac bk+\frac ck=\frac12$$which is the same as $$\frac1{\frac ka}+\frac1{\frac kb}+\frac1{\frac kc}=\frac12$$We know that $k/a$, $k/b$, and $k/c$ are all integers because $a$, $b$, and $c$ are divisors of $k$, so by definition, they divide $k$ evenly. Furthermore, I found through experimentation that for any $k$, we can automatically assume that one of $a$, $b$, or $c$ is going to be $1$. This is because if all of them were $>1$, then the resulting fractions would simplify to form a sum that was already previously covered by a lower case. So essentially, in order to find the solutions of this equation, we have to find two divisors $a$ and $b$ of some integer $k$ such that $a+b+1=k/2$. Then we would have the solution $$(x,y,z)=\left(\frac ka,\frac kb,k\right)$$ --- My question is: Is this a standard way of dealing with Diophantine equations of this form? Or is there a better way that I am unaware of? I would also like to know if this equation has a finite or infinite amount of solutions. From what I worked out, there intuitively seems to be infinite solutions, but I am not entirely sure if you can keep finding divisors that satisfy the conditions as $k$ grows bigger.
2023/01/29
[ "https://math.stackexchange.com/questions/4627952", "https://math.stackexchange.com", "https://math.stackexchange.com/users/743034/" ]
A common first step in solving such a problem is to clear denominators to get a polynomial equation. Multiplying by $2xyz$ yields $$2yz+2xz+2xy=xyz,\tag{1}$$ so every solution to $(1)$ with $xyz\neq0$ yields a solution to the original equation, and conversely every solution to the original equation yields a solution to $(1)$. Note that all solutions with $xyz=0$ are of the form $$(x,0,0),\qquad (0,y,0),\quad\text{ or }\quad (0,0,z).$$ A common next step is to find some divisibility restrictions on $x$, $y$ and $z$, and to take out common factors. This is possible because we have reduced the problem to finding the zeros of a polynomial. Let $(x,y,z)$ be a solution with $xyz\neq0$. Let $D:=\gcd(x,y,z)$ so that $x=DX$, $y=DY$ and $z=DY$ for integers $X$, $Y$ and $Z$ with $\gcd(X,Y,Z)=1$. Then $$2YZ+2XZ+2XY=DXYZ.\tag{2}$$ From $(2)$ we immediately see that $X$ divides $2YZ$, that $Y$ divides $2XZ$ and that $Z$ divides $2XY$. This is quite the restriction on $X$, $Y$ and $Z$, which becomes more clear by considering $$U:=\gcd(Y,Z),\qquad V:=\gcd(X,Z),\qquad W:=\gcd(X,Y).$$ First note that $U$, $V$ and $W$ are pairwise coprime because $\gcd(X,Y,Z)=1$. Then we have $$X=VWX',\qquad Y=UWY',\qquad Z=UVZ',$$ for integers $X'$, $Y'$ and $Z'$ that are also pairwise coprime. Now we see why the divisibility relations on $X$, $Y$ and $Z$ that we found are so restrictive: We saw that $X$ divides $2YZ$, where now $$X=VWX'\qquad\text{ and }\qquad 2YZ=2U^2VWY'Z',$$ and $X'$ is coprime to $U$, $Y'$ and $Z'$. It follows that $X'$ divides $2$, and entirely analogously that $Y'$ and $Z'$ divide $2$. In fact, because $X'$, $Y'$ and $Z'$ are pairwise coprime, we see that $X'Y'Z'$ divides $2$. From here we can reconstruct all solutions to $(1)$. We have just shown that $x$, $y$ and $z$ must be of the form \begin{eqnarray} x&=&DX&=&DVWX',\\ y&=&DY&=&DUWY'\\ z&=&DZ&=&DUVZ', \end{eqnarray} where $U$, $V$ and $W$ are pairwise coprime positive integers, and $X'Y'Z'$ divides $2$, and $D$ is a positive integer. Plugging this into $(1)$ yields $$2D^2U^2VWY'Z'+2D^2UV^2WX'Z'+2D^2UVW^2X'Y'=D^3UVWX'Y'Z'.$$ Because $X'Y'Z'$ divides $2$ we can divide out $D^2UVWX'Y'Z'$ to get $$D=\frac{2U}{X'}+\frac{2V}{Y'}+\frac{2W}{Z'}.$$ This means we can choose any three pairwise coprime positive integers $U$, $V$ and $W$, and three integers $X'$, $Y'$ and $Z'$ such that $X'Y'Z'$ divides $2$, and set $$D:=\frac{2U}{X'}+\frac{2V}{Y'}+\frac{2W}{Z'},$$ which is then also an integer, to get a solution $$(x,y,z)=(DVWX',DUWY',DUVZ').$$ Moreover, all solutions are of this form.
It was necessary to write the solution in a more General form: $$\frac{t}{q}=\frac{1}{x}+\frac{1}{y}+\frac{1}{z}$$ $t,q$ - integers. Decomposing on the factors as follows: $p^2-s^2=(p-s)(p+s)=2qL$ The solutions have the form: $$x=\frac{p(p-s)}{tL-q}$$ $$y=\frac{p(p+s)}{tL-q}$$ $$z=L$$ Decomposing on the factors as follows: $p^2-s^2=(p-s)(p+s)=qL$ The solutions have the form: $$x=\frac{2p(p-s)}{tL-q}$$ $$y=\frac{2p(p+s)}{tL-q}$$ $$z=L$$ It is enough to sort through the various options. $(tL-q)$ The overkill is insignificant. You can stop the search when the ratio becomes less than 2.
35,557,759
Take a random set of coordinates (x, y, z) that will be the center of my 3x3x3 matrix( considered local minimum as well). I have a function J that takes those coordinates, does the calculations and returns me a number. If any of those 26 points will be smaller, that would be the center for my next matrice. In case I don't find a smaller value, the radius of the matrice is increased by 1, and we run the loop again. My question is : **how to loop only through the "shell" of the cube and not call the function for the previously tested values?** I tried to illustrate it below ( it's in 2d here, but you get the point) .. the dots are the values that were tested, the "?" are the ones that need to be calculated and compared to the local min. [![enter image description here](https://i.stack.imgur.com/EPkpo.png)](https://i.stack.imgur.com/EPkpo.png) here is the code ``` minim=100; %%the initial size of the search matrix 2*level +1 level=1; x=input('Enter the starting coordinate for X : '); y=input('Enter the starting coordinate for Y : '); z=input('Enter the starting coordinate for Z : '); %%The loop if(level<=10) for m=x-level:x+level for n=y-level:y+level for p=z-level:z+level A(m,n,p)=J(m,n,p); if A(m,n,p)<minim minim=A(m,n,p); x=m;y=n;z=p; level=1; else level=level+1; %<<----shell loop here ---->> end end end end else %Display global min display(minim, 'Minim'); %Coordinates of the global min [r,c,d] = ind2sub(size(A),find(A ==minim)); display(r,'X'); display(c,'Y'); display(d,'Z'); end ```
2016/02/22
[ "https://Stackoverflow.com/questions/35557759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5952619/" ]
You need to compare it the same way, but with `double` values. Instead of using 0 (`int`) use 0.0 (`double`): ``` if ( n == 0.0 || c== 0.0 ){ System.out.println("What do i write instead of \"?\" "); } ```
You are comparing with ``` if ( num1 = 0 || num2 = 0) ``` when it should be ``` if ( num1 == 0 || num2 == 0) ``` One `=` is assignment, not comparison.
32,735,229
We are working on migrating data from different source systems(Firebird, Oracle, SQL Server) to one target system (SQL Server). We are getting *Error reading data from the connection* exception from Firebird connections. Code we are using > > Static DbFactory Class to Create SourceSystem Object > > > ``` public static class DbFactory { public static DbManager CreateDb(SourceDbType type) { switch (type) { case SourceDbType.Sql: return new SqlDbManager(); case SourceDbType.FireBird: return new FireBirdDbManager(); } return null; } } public enum SourceDbType { Sql, FireBird } ``` > > Base DbManager Class > > > ``` public abstract class DbManager { private DbConnection m_DbConnection; public virtual DbConnection DbConnection { get { if (m_DbConnection == null) { m_DbConnection = new SqlConnection(); } return m_DbConnection; } set { this.m_DbConnection = value; } } public virtual void SetConnectionString(Migration migration, DataTable dtConnectionDetails = null) { try { DbConnection.ConnectionString = string.Format("Server={0};Database={1};User ID={2};Password={3};", migration.NetworkPartnerData.Server, migration.NetworkPartnerData.Database, migration.NetworkPartnerData.User, AESEncryptionDecryptionUtility.DecodeBase64(migration.NetworkPartnerData.Password)); } catch { throw; } } public virtual void SetConnectionString(string connectionString) { try { DbConnection.ConnectionString = connectionString; } catch { throw; } } public virtual DataTable ExecuteDataTable(string ConnectionString, string queryText) { throw new NotImplementedException(); } } ``` > > FireBirdDbManager class inherited from DbManager > > > ``` public class FireBirdDbManager : DbManager { private FbConnection fbconnection; public override DbConnection DbConnection { get { if (fbconnection == null) { fbconnection = new FbConnection(); } return fbconnection; } set { this.fbconnection = value as FbConnection; } } public override void SetConnectionString(Migration migration, DataTable connectionDetails) { this.DbConnection.ConnectionString = string.Format("Server={0};Database={1};Port=3050;User ID={2};Password={3};Pooling=true;MinPoolSize=0;MaxPoolSize=50;", migration.NetworkPartnerData.Server, migration.NetworkPartnerData.Database + BuildDatabaseName(Convert.ToString(connectionDetails.Rows[0]["CL_NBR"])) + ApplicationConstants.FIREBIRD_DBFILE_EXTENSION, migration.NetworkPartnerData.User, iMigrationTool.Common.AESEncryptionDecryptionUtility.DecodeBase64(migration.NetworkPartnerData.Password)); } public override DataTable ExecuteDataTable(string ConnectionString, string queryText) { using (var connection = new FbConnection(ConnectionString)) { try { DataTable dt = new DataTable(); connection.Open(); using (FbTransaction readTransaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)) { FbCommand readCommand = new FbCommand(); try { readCommand.CommandText = queryText; readCommand.Connection = connection; readCommand.Transaction = readTransaction; FbDataAdapter da = new FbDataAdapter(readCommand); da.SelectCommand.CommandType = CommandType.Text; da.Fill(dt); readTransaction.Commit(); } catch { readTransaction.Rollback(); throw; } finally { readTransaction.Dispose(); if (connection.State == ConnectionState.Open) { connection.Close(); } connection.Dispose(); } return dt; } } catch (Exception ex) { int errorCode = ex.HResult; Logger.LogApplicationException(ex, null, "ERRORCODE:" + errorCode + "ConnectionString:" + ConnectionString, "MigrationWorker"); throw ex; } } } } ``` Exception Images [![Exception Image1](https://i.stack.imgur.com/SWKRG.png)](https://i.stack.imgur.com/SWKRG.png) [![Image 2](https://i.stack.imgur.com/QWMTT.png)](https://i.stack.imgur.com/QWMTT.png) [![Image 3](https://i.stack.imgur.com/bWJRN.png)](https://i.stack.imgur.com/bWJRN.png) [![Connection String built](https://i.stack.imgur.com/bkFzN.png)](https://i.stack.imgur.com/bkFzN.png) We are getting exception after running 3 to 4 migrations. If I restart the service again we are able to run 3 to 4 migrations. Code we use to call the respective source systems: ![Create SourceSytemOjbect](https://i.stack.imgur.com/Mb3uO.png) We are very new to Firebird database systems and unable to solve the problem. On a side note we are using Visual Studio 2012, Azure Cloud service
2015/09/23
[ "https://Stackoverflow.com/questions/32735229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3086075/" ]
I just got this error. I have a program working with Firebird 2.5.9 written using Delphi 10.3 and Fibplus 7.6. Recently I migrated this program to Lazarus using IBX library. Now I just returned from absence live and found that Delphi program after connect to Firebird database refuses to open any datasets returning subject error, but Lazarus program works fine. But within office network with backup server on one of workstations both programs work fine. Thank you for the tip, I'l try to change configuration parameters.
I get this error when execute query that length > **max query length** in FireBird 4.x i get Error reading data from the connection after update to 6.6 i get new error "**335544721** : Unable to complete network request to host..." it was fixed by split query to some less query (default 8191 characters when using UTF-8)
14,982,066
I am using ajax to dynamically load XML from a web service, the returned records are limited to just 25 items for each url 'load' or 'call'.... to work around that I have a process whereby the user scrolls down the page and when they reach 90% of the page height (or when they reach page bottom - not sure which I'll choose yet), a variable named startindexnum is incremented by 25. so startindexnum starts out at 25... then after the first 'fire' of the function, the startindexnum becomes 50, on the 3rd it becomes 75, etc. etc. my problem is that it fires multiple times and is somewhat erratic - processing multiple times when I scroll to the bottom and increasing by MORE than 25 sometimes (no doubt a result of running multiple times I think). anyone have any idea what I need to tweak to get this to correctly generate the incremental startindex variable to append to my ajax URL where Im retrieving XML? thanks. ``` var scrollcount = 1; var startindexnum = 25; var processing; $(document).ready(function(){ $(document).scroll(function(e){ if (processing) return false; window.onscroll = function(ev) { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight){ //if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.9){ // you're at x% of the page processing = true; scrollcount = scrollcount + 1; startindexnum = scrollcount * startindexnum; console.log(scrollcount); docall(); processing = false; }; }; }); }); ```
2013/02/20
[ "https://Stackoverflow.com/questions/14982066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1306792/" ]
The problem is I am betting `docall()` is an asynchronous call, so setting of `processing` to `false` after that call does nothing to block the future scroll events. The setting of false is happening before the results are returned. You want to set `processing` back to false when `docall()` is done doing its task. ``` if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight){ //if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.9){ // you're at x% of the page processing = true; scrollcount = scrollcount + 1; startindexnum = scrollcount * startindexnum; console.log(scrollcount); docall(); //processing = false; <--get rid of this }; ``` and ``` function docall(){ //When you are done fetching the new data and update the page set function AjaxCallIsDone() { processing = false; } } ```
In addition to epascarello's post... you don't need the $(document).scroll(fn) and the window.onscroll, which you are attaching to every time your document scroll handler is executed. A few things: 1) Firstly, take a look at this scroll post by John Resig. [Scrolling by J.Resig](http://ejohn.org/blog/learning-from-twitter/) 2) If you want the jquery method then use window instead of document $(window).scroll(fn). 3) If not then I think the following will work for you: ``` var scrollcount = 1; var startindexnum = 25; var processing; $(document).ready(function(){ window.onscroll = function(ev) { if (!processing) { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight){ processing = true; scrollcount = scrollcount + 1; startindexnum = scrollcount * startindexnum; console.log(scrollcount); docall(); } } } }); ```
1,086,658
There is a nice dialog that helps to search for Active Directory groups in Windows called `Find Users, Contacts, and Groups`. Unfortunately, I only know how to open it with this command: ```bsh Rundll32 dsquery.dll OpenQueryWindow ``` Is this dialog available from the Start Menu or Control Panel? I cannot find it. To clarify, I am regular user of Windows 7 Enterprise, and do not normally have local admin rights. Sample screenshot: [![AD - Find Users, Contacts, and Groups](https://i.stack.imgur.com/B9JMG.png)](https://i.stack.imgur.com/B9JMG.png)
2016/06/08
[ "https://superuser.com/questions/1086658", "https://superuser.com", "https://superuser.com/users/81913/" ]
If you want something clickable, you can create a .bat file with the following: ``` @echo off start Rundll32 dsquery.dll OpenQueryWindow ```
Windows OS version : 8.1 > > * Newtork and Internet -> Click on "View network computers and devices" > * Top Menu bar view -> Search Active Directory > * Find Users, Contacts and Groups popup would appear > > > You search for any user or group in this window and their access level to the folders.
31,689,360
Though I have `ui-boostrap` installed, the browser shoots me an error `Error: [$injector:unpr] Unknown provider: uniqueFilterProvider <- uniqueFilter` **json objects** ``` { "_id" : ObjectId("55b81956fde835be46f22294"), "life" : true, "domain" : { "hidden" : true, "name" : "Eukarya" }, "kingdom" : { "hidden" : true, "name" : "Animalia" }, "phylum" : { "hidden" : true, "name" : "Chordata" }, "klass" : { "hidden" : true, "name" : "Mammalia" }, "order" : { "hidden" : true, "name" : "carnivoria" }, "family" : { "hidden" : true, "name" : "herpestidae" }, "genus" : { "hidden" : true, "name" : "galerelaa" }, "species" : { "hidden" : true, "name" : "Mongoose" }, "photo" : { "hidden" : true, "url" : "http://room909.com/wp-content/gallery/drawings-by-jared-flynn/snake-v-mongoose-web.jpg" }, "__v" : 0 } { "_id" : ObjectId("55b81956fde835be46f22295"), "life" : true, "domain" : { "hidden" : true, "name" : "Eukarya" }, "kingdom" : { "hidden" : true, "name" : "Animalia" }, "klass" : {"name": "Bivalvia", "hidden": true}, "order" : { "hidden" : true, "name" : "Ostreoida" }, "family" : {"name": "Ostreidae", "hidden": true}, "genus" : { "hidden" : true, "name" : "" }, "species" : { "hidden" : true, "name" : "" }, "photo" : { "hidden" : true, "url" : "http://a-z-animals.com/media/animals/images/470x370/oyster5.jpg" }, "__v" : 0 } ``` **html** ``` <section class="footer"> <div id="explanation" class="container"> <div ng-repeat="animal in animals | unique: 'animal.domain'" ng-hide="domain" class="panel panel-default"> <p class="panel-body">{{animal.domain.name}}</p> </div> </div> </section> ``` I've also tried variations on the unique's value like `domain.name` and `domain`, but they all bring the same error.
2015/07/29
[ "https://Stackoverflow.com/questions/31689360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4893485/" ]
I found an answer. All we have to do is, instead, simply installed the wonderful, genius, un-replaceable [a8m](https://github.com/a8m/angular-filter) angular-filter library with `bower`/`npm`, added to my array of dependencies (@Joy), and used the syntax `ng-repeat="animal in animals | unique: 'domain.name'"` and everything works fine.
[Unique Filter example](http://plnkr.co/edit/kxJFSw?p=preview) will help you using unique filter. I think version of angular-ui you are using may not have unique filter. try to change the version of ui-bootstrap. As you see in example, filter accepts property of record item. ``` <tr ng-repeat="record in items | unique:attribute"> <td>{{record.firstName}}</td> <td>{{record.lastName}}</td> <td>{{record.id}}</td> <td>{{record.gender}}</td> </tr> ``` So, in your example it should be as following. See change for ng-hide and unique filter. ``` <section class="footer"> <div id="explanation" class="container"> <div ng-repeat="animal in zab | unique: 'domain'" ng-hide="animal.domain" class="panel panel-default"> <p class="panel-body">{{animal.domain.name}}</p> </div> </div> </section> ```
3,639,342
I've always thought of `git reset` and `git checkout` as the same, in the sense that both bring the project back to a specific commit. However, I feel they can't be exactly the same, as that would be redundant. What is the actual difference between the two? I'm a bit confused, as the svn only has `svn co` to revert the commit. ### ADDED VonC and Charles explained the differences between `git reset` and `git checkout` really well. My current understanding is that `git reset` reverts all of the changes back to a specific commit, whereas `git checkout` more or less prepares for a branch. I found the following two diagrams quite useful in coming to this understanding: ![http://a.imageshack.us/img651/1559/86421927.png](https://i.stack.imgur.com/C4BCo.png) ![http://a.imageshack.us/img801/1986/resetr.png](https://i.stack.imgur.com/Tiv4H.png) ### ADDED 3 From <http://think-like-a-git.net/sections/rebase-from-the-ground-up/using-git-cherry-pick-to-simulate-git-rebase.html>, checkout and reset can emulate the rebase. [![enter image description here](https://i.stack.imgur.com/EYijy.png)](https://i.stack.imgur.com/EYijy.png) ``` git checkout bar git reset --hard newbar git branch -d newbar ``` [![enter image description here](https://i.stack.imgur.com/6F3ZK.png)](https://i.stack.imgur.com/6F3ZK.png)
2010/09/03
[ "https://Stackoverflow.com/questions/3639342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/260127/" ]
The key difference in a nutshell is that `reset` **moves the current branch reference**, while `checkout` does not (it moves HEAD). As the Pro Git book explains under [Reset Demystified](https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified), > > The first thing `reset` will do is **move what HEAD points to**. This isn’t > the same as **changing HEAD itself** (which is what `checkout` does); `reset` > **moves the branch** that HEAD is pointing to. This means if HEAD is set > to the `master` branch (i.e. you’re currently on the `master` branch), > running `git reset 9e5e6a4` will start by making `master` point to > `9e5e6a4`. [emphasis added] > > > See also VonC's answer for a [very helpful text and diagram excerpt](https://stackoverflow.com/a/3639387/423105) from the same article, which I won't duplicate here. Of course there are a lot more details about what effects `checkout` and `reset` can have on the index and the working tree, depending on what parameters are used. There can be lots of similarities and differences between the two commands. But as I see it, the most crucial difference is whether they move the tip of the current branch.
Here's a clarification of the ambiguity: * git checkout will move the HEAD to another commit(*could be* a change using a branchname too), **but**: 1. on whatever branch you are, the pointer to the tip of that branch(e.g., "main") will remain unchanged (so you might end up in a *detached head* state). 2. Also, the staging area and the working directory will remain unchanged(in the similar state they were before the checkout). **Examples:** ``` git checkout 3ad2bcf <--- checkout to another commit git checkout another-branch <--- checkout to another commit using a branchname ``` * git reset **also moves the HEAD**, however again, with **two differences**: 1. It moves the pointer that points to the commit at the tip of the current branch too. For instance, let's say the pointer to the current branch is named "main", then you perform a git-reset, now, the main pointer will point to another commit, and the HEAD will point to that commit as well(well basically, HEAD points to that commit *indirectly* through pointing to the main pointer, it is still an *attached head(!)*, but it doesn't make any difference here). 2. Git-reset doesn't necessarily leave the staging area and the working directory on the same state they were in before the reset was performed. As you know, there are three types of reset: soft, mixed(default) and hard: + With the soft reset, the staging area and the working directory both remain in the state they've been on before the reset(similar to checkout in this regard, but don't forget the difference #1). + With the mixed reset which is the default type of reset, in addition to difference #1, the staging area's *proposed next commit*(what you've git-added basically), will also be set to the newly pointed-to-by-HEAD commit. BUT in the working directory, all the files will still have your latest edits to them (that's why this type of reset is the default one, so that you don't lose your work). + With the hard reset, in addition to difference #1, all the three trees HEAD, staging-area and ALSO the working-directory will change to the newly pointed-to-by-HEAD commit. **Examples:** ``` git reset --soft 3ad2bcf git reset da3b47 ```
73,934,426
I provide different services for my job, but my rates vary from client to client, I'd like a formula to get the rate value (0.04, in this case) using two values, the name of the client "Client 3" and the service in question "Service 2". I have created a spreadsheet to better illustrate what I am trying to accomplish, hopefully someone can help. Rates tab. | Client | Service 1 | Service 2 | Service 3 | | --- | --- | --- | --- | | Client 1 | 0.06 | 0.02 | 0.08 | | Client 2 | 0.07 | 0.03 | 0.09 | | Client 3 | 0.08 | 0.04 | 0.1 | | Client 4 | 0.09 | 0.05 | 0.11 | | Client 5 | 0.1 | 0.06 | 0.12 | | Client 6 | 0.11 | 0.07 | 0.13 | | Client 7 | 0.12 | 0.08 | 0.14 | | Client 8 | 0.13 | 0.09 | 0.15 | | Client 9 | 0.14 | 0.1 | 0.16 | | Client 10 | 0.15 | 0.11 | 0.17 | Sheet `1` where results go | Project name | Client 3 | Service 2 | {formula here}0.04 | | --- | --- | --- | --- | [Link of the example sheet](https://docs.google.com/spreadsheets/d/1_GXhOq4QWxDXdSvCHr3k0BlRxtfWM45QkyN7SolXLxY/edit?usp=sharing)
2022/10/03
[ "https://Stackoverflow.com/questions/73934426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20149018/" ]
This works regardless of how many **clients** or **services** you have. ``` =MAP(B1:B,C1:C, LAMBDA(c,s, IFERROR(INDEX(Rates!B2:D, MATCH(c,Rates!A2:A,0), MATCH (s,Rates!$B$1:1,0)),""))) ``` [![enter image description here](https://i.stack.imgur.com/Ce6Dj.png)](https://i.stack.imgur.com/Ce6Dj.png) **Demo** [![enter image description here](https://i.stack.imgur.com/GBxZO.gif)](https://i.stack.imgur.com/GBxZO.gif) Used formulas help [**`MAP`**](https://support.google.com/docs/answer/12568985) - [**`LAMBDA`**](https://support.google.com/docs/answer/12508718) - [**`IFERROR`**](https://support.google.com/docs/answer/3093304) - [**`INDEX`**](https://support.google.com/docs/answer/3098242) - [**`MATCH`**](https://support.google.com/docs/answer/3093378)
use: ``` =INDEX(VLOOKUP(B1&C1, SPLIT(FLATTEN(Rates!A2:A&Rates!B1:E1&"×"&Rates!B2:E), "×"), 2, )) ``` [![enter image description here](https://i.stack.imgur.com/XnHbj.png)](https://i.stack.imgur.com/XnHbj.png) or arrayformula of it: ``` =INDEX(IFNA(VLOOKUP(B1:B&C1:C, SPLIT(FLATTEN(Rates!A2:A&Rates!B1:E1&"×"&Rates!B2:E), "×"), 2, ))) ```
43,269
According to the Ford-Fulkerson algorithm, I thought that if there was no path from $s$ to $t$, then the flow would be a max flow. In the flow below, there are two paths between $s$ and $t$. Then, how can this be the max flow? ![graph](https://i.imgur.com/1CjOnRQ.png)
2015/06/05
[ "https://cs.stackexchange.com/questions/43269", "https://cs.stackexchange.com", "https://cs.stackexchange.com/users/34307/" ]
The flow is maximum if there is no augmenting(i.e. improving) path between `s` and `t`. A path would contribute to the maximum flow if all its edges have strictly positive capacity left. In your case although you have some paths between `s` and `t`, all of them will have at least one edge that has used its whole capacity. Thus you can't improve the current flow and it is maximum.
There is another way to see it that might help you: if you cut the net in two subnets, i.e. s,a,c and b,d,t you can see that the net flow from the source subnet to the sink subnet is maximized: there are two saturated paths and one empty one. In any net, if you can find such a bipartition that highlights such a property then you know you've found a max flow. That works even if there is some returning path that is not empty, as per [this](https://cs.stackexchange.com/a/43270/34317) answer: Kyle's bipartition is s,a and c,b,d,t. It works because if you have some non empty return path you can argue that emptying it would increase net flow towards the sink, but to decrease it you will certainly need to decrease also a going path thus keeping net total flow the same. For my cut net flow is 5+3-0=8 while Kyle's leads to 5+6-3=8, and of course that's the same.
12,744
Is there a way to 'mangle' a public data-source (for example, the current date in YYYYMMDD or the top New York Times headline) to form a one-time pad that will sufficiently hide the pad's source? What other issues would such a scheme be running into? Disclaimer: I am not an expert cryptographer and am just interested in the matter - I do not intend to implement this cryptosystem.
2014/01/06
[ "https://crypto.stackexchange.com/questions/12744", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/1653/" ]
What you've described is generally called a "book cipher" or "Ottendorf cipher", where the "key" is knowing which publication is being referenced, as well as the algorithm for recovering information from it. A hundred years ago they were quite secure because not only were books fairly rare, but trying every book against an unknown cipher was very time consuming. Some historically famous codes, such as the Beale Ciphers, used this method, and they withstood a lot of very motivated attackers for a very long time. But with the digitization of vast quantities of books and other print resources by huge organizations such as Google, (and security agencies) they are now pretty much a historical footnote.
I agree with [John Deter's answer](https://crypto.stackexchange.com/a/12746/12164). If you attempt to access some website to get some public information from it, then your favourite intelligence agency is going to have a record of that due to their extensive spy network which has taps on every internet backbone. If two people access the same site then appear to be communicating with each other using OTP then an intelligence agency could eventually figure out the secret scheme based on the content of that website. If you and your partner went to a *shared* computer (e.g. internet cafe, library) without your mobile phone/surveillance device and paid in cash then accessed some pre-agreed upon website and used the same secret key retrieval scheme then that would be less likely to be discovered by one of the intelligence agencies. As for the key construction you need something random, or pretty close to it for a one-time pad. One idea might be to meet in person first (without your mobile surveillance device listening in) and agree upon a daily key extraction method from a public source. Perhaps both of you buy a physical copy of a newspaper each day with cash which was printed at the same time (same edition). This newspaper might be distributed geographically so you need one that was printed in the same run or things might have changed between editions. That can be distinguished by the numbers/fine print on the inside of the first page, bottom corner (this depends on the newspaper). Once you have the same newspaper you can work out a scheme to extract your key data. Obviously you would devise your own secret method, but you could pick a page number, or group of pages, find certain headlines, paragraphs or sections of content that are in the same area of the page from day to day. Then extract every 2nd (or nth) letter from that content. Once you've gathered say 64 characters you could reverse the order of them, then group them up and run it through a 512 bit cryptographic hash such as Keccac or Skein which will give you a pseudo random uniform distribution of random bits. That would give you a key unpredictable enough that no intelligence agency could ever guess it. From there you get your plaintext (and your key cut to the same length), convert them to binary and XOR them together, MAC the ciphertext with an information-theoretically secure MAC and send your ciphertext and MAC off to the other person via whatever communications method you're using. This method might be good for a limited number of messages per day. Probably slightly time consuming to create the key each day too. The main problem with this method is it relies on a secret method to create the key. If either one of you is captured and interrogated by an intelligence agency then you might be forced to reveal your message extraction method, at which point your past communications would be compromised as they could dig up the old publications and recreate the keys. You could probably lie about it or say you randomly pre-created the keys when you met up one time but their extraction methods (waterboarding & sodium pentathol) are apparently pretty effective.
29,565,670
I'm working on a project that allows a user to create a company. If a user creates a company, the user will be the admin. However I would also like that user to then be able to invite users to sign up. So that all the users will belong to that company. So my question is that the company would technically I guess belong\_to the admin. However the company also has many users. What would be the right association setup for this?
2015/04/10
[ "https://Stackoverflow.com/questions/29565670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3826844/" ]
Try looking further up your stack trace too. I got this error due to a misconfigured logger but I had to look further up the trace to find this issue! In my case I had misnamed my environment variable `DJANGO_LOG_LEVL` as `DEGUB` instead of `DEBUG` (note the misspelling) and that caused the error.
Had troubles with this too, all I did was upgrade pip and it seemed to fix itself tried installing other dependencies but turned out I already had them all so if you are in the same position try upgrading your pip!
10,533,742
I have created a block which contains a link to another page. The block is in the footer on all pages. ``` <a href="terms_and_conditions">Terms and Conditions</a> ``` This works fine on pages with URLs of... ``` http://mywebs.localhost/site1/page1 ``` The link correctly resolves to: ``` http://mywebs.localhost/site1/terms_and_conditions ``` (where 'page1' is a value in the 'URL path settings' ie using the 'paths' module to create an alias for /node/56) But when I go to the a page which is part of the ubercart module... ``` http://mywebs.localhost/site1/cart/checkout ``` The link in the block incorrectly resolves to ... ``` http://mywebs.localhost/site1/cart/terms_and_conditions ``` Obviously I can get it to work if I use full absolute links, but I want it to work when I upload to the remote host without having to change everything. There is quite a bit of documentation and questions about relative paths. But as far as I can tell it is to do with links within the content section of pages. Can anyone point me in the correct direction please.
2012/05/10
[ "https://Stackoverflow.com/questions/10533742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/612091/" ]
why not just `<a href="/terms_and_conditions">Terms and Conditions</a>` ? Try to put trailing slash before your path. Just read a comment, sorry, i see other way with allowing PHP input `<?php print l('Terms and Conditions', 'terms_and_conditions'); ?>` But, without php input you can use a <http://drupal.org/project/shortcode>, it allow to transform tokens with url to a complete link, like in WordPress.
You should use [url()](http://api.drupal.org/api/drupal/includes!common.inc/function/url/6) function or [$base\_url](http://api.drupal.org/api/drupal/developer!globals.php/global/base_url/6) for generating the link ``` <a href="<?php echo url('terms_and_conditions'); ?>">Terms and Conditions</a> ``` or ``` <a href="<?php global $base_url; echo $base_url; ?>/terms_and_conditions">Terms and Conditions</a> ```
63,237,081
I try to launch a basic `npm start` to develop my reactnative project and I face the following report : > > ERROR: Node.js v13.13.0 is no longer supported. > > > expo-cli supports following Node.js versions: > > > * =>10.13.0 <11.0.0 (Maintenance LTS) > * =>12.13.0 <13.0.0 (Active LTS) > * =>14.0.0 <15.0.0 (Current Release) > > > While my `Node -v` says > > v14.7.0 > > > Can someone please help me to understand what is going on ?I really don't understand where I can update this dependancies or I don't know how to let npm know that I have the good version of Node (installes and reinstalled...) The log says : ``` > [...] 2 info using npm@6.14.7 > > 3 info using node@v14.7.0 > > [...] > > 9 verbose lifecycle @~start: CWD: E:\appics > > 10 silly lifecycle @~start: Args: [ '/d /s /c', 'expo start' ] > > 11 silly lifecycle @~start: Returned: code: 1 signal: null > > 12 info lifecycle @~start: Failed to exec start script > > 13 verbose stack Error: @ start: `expo start` > > 13 verbose stack Exit status 1 > > 13 verbose stack at EventEmitter.<anonymous> (C:\Program > Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) > > 13 verbose stack at EventEmitter.emit (events.js:314:20) > > 13 verbose stack at ChildProcess.<anonymous> (C:\Program > Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) > > 13 verbose stack at ChildProcess.emit (events.js:314:20) > > 13 verbose stack at maybeClose (internal/child_process.js:1051:16) > > 13 verbose stack at Process.ChildProcess._handle.onexit > (internal/child_process.js:287:5) > > 14 verbose pkgid @ > > 15 verbose cwd E:\appics > > 16 verbose Windows_NT 10.0.18363 > > 17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program > Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" > "--reset-cache" > > 18 verbose node v14.7.0 > > 19 verbose npm v6.14.7 > > 20 error code ELIFECYCLE > > 21 error errno 1 > > 22 error @ start: `expo start` > > 22 error Exit status 1 > > 23 error Failed at the @ start script. > > 23 error This is probably not a problem with npm. There is likely > additional logging output above. > > 24 verbose exit [ 1, true ] ```
2020/08/03
[ "https://Stackoverflow.com/questions/63237081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14044416/" ]
``` .container *:not([class^="mat"]) { background: red; } ``` That's the code you might be searching for. `[class^="mat"]` will match to any element which has a class starting with `mat`. `[class*="mat"]` will match to any element having `mat` anywhere in the class name. Use either of them according to your situation.
Well, what you want is a really really bad way to workaround things since it makes your stylings hard to maintain and may lead to unexpected issues, but hey, you can use this css to set `box-sizing` property to all elements except the ones starts with `mat-`. ``` .container *:not([class^="mat-"]) { box-sizing: border-box; } ```
6,497
Personally, I don't like them. But maybe this is beyond the point. Were we consulted about this?
2016/01/18
[ "https://tex.meta.stackexchange.com/questions/6497", "https://tex.meta.stackexchange.com", "https://tex.meta.stackexchange.com/users/3094/" ]
We tracked down the bug. The Tex community has a few special classes for text formatting and those happened to conflict with a recent mixin that was added to a global file. The change was unintentional and an update is rolling out soon. Thanks for the catch and your patience.
There's a difference in the colour of the tags. Here's a screen grab from the "legend" on the [tags page](https://tex.meta.stackexchange.com/tags): [![enter image description here](https://i.stack.imgur.com/SEVcQ.png)](https://i.stack.imgur.com/SEVcQ.png) * `{required-tag}` has RGB = (68,68,68) * `{tag}` has RGB = (85,85,85) However, this is too close to discern when both are **bold**. For example, on [Meta.TeX.SE](http://meta.tex.stackexchange.com) one is required to have one of the four tags [bug](/questions/tagged/bug "show questions tagged 'bug'"), [feature-request](/questions/tagged/feature-request "show questions tagged 'feature-request'"), [discussion](/questions/tagged/discussion "show questions tagged 'discussion'") or [support](/questions/tagged/support "show questions tagged 'support'") which are one-boxed in **bold**. With the current setup *all* tags are **bold**: [![enter image description here](https://i.stack.imgur.com/6YtS1.png)](https://i.stack.imgur.com/6YtS1.png) I enjoy the feature of having certain tags represent something other than the usual content. For example, the red colour of the moderator-only tags: [status-completed](/questions/tagged/status-completed "show questions tagged 'status-completed'"), [featured](/questions/tagged/featured "show questions tagged 'featured'"), [status-bydesign](/questions/tagged/status-bydesign "show questions tagged 'status-bydesign'"), [status-deferred](/questions/tagged/status-deferred "show questions tagged 'status-deferred'"), [status-planned](/questions/tagged/status-planned "show questions tagged 'status-planned'"), [status-reproduced](/questions/tagged/status-reproduced "show questions tagged 'status-reproduced'"), [status-review](/questions/tagged/status-review "show questions tagged 'status-review'"), [status-declined](/questions/tagged/status-declined "show questions tagged 'status-declined'") and [status-norepro](/questions/tagged/status-norepro "show questions tagged 'status-norepro'"). This is lost though with the addition of making all tags **bold**.
2,200,102
So given the following java class: ``` class Outer { private int x; public Outer(int x) { this.x = x; } public class Inner { private int y; public Inner(int y) { this.y = y; } public int sum() { return x + y; } } } ``` I can create an instance of the inner class from Java in the following manner: ``` Outer o = new Outer(1); Outer.Inner i = o.new Inner(2); ``` However, I can't seem how to do the same from JRuby ``` #!/usr/bin/env jruby require 'java' java_import 'Outer' o = Outer.new(1); i = o.Inner.new(2); #=> NoMethodError: undefined method `Inner' for #<Outer...> ``` What's the correct way to do this?
2010/02/04
[ "https://Stackoverflow.com/questions/2200102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9859/" ]
``` i = Outer::Inner.new(o,2) ```
From what can be seen in [this discussion](http://markmail.org/message/go53w4hge4gczjji), you'll have to do `Outer:Inner.new(o, 2)`
32,112,310
``` $this->Auth->user ( 'username' ); ``` is working perfectly fine in controller but I want to check whether any user is logged in or not in default.ctp file using ``` $this->Auth->user (); ``` How can I achieve that?
2015/08/20
[ "https://Stackoverflow.com/questions/32112310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5246416/" ]
try: ``` $this->request->session()->read('Auth.User'); ```
While it is possible to check for an authenticated user in your view using arilia method, you should do it in your controller and then send it to the view. One easy way is the following (in your AppController): ``` public function beforeRender (Cake\Event\Event $event) { $this->set('isAuthenticatedUser', (bool) $this->Auth->user('username')) ; return parent::beforeRender ($event) ; } ``` Using the above, in any of your view you will have access to the `$isAuthenticatedUser` variable telling you if a user is logged in or not.
61,499
I usually burn dried coconut husk and thorny stems from my lemon plants and I winder if the ash produced from burning such stems and leaves or paper can be a good way to fertilize plants? Or I need to mix it with compost? How or what do I do with that ash?
2021/11/22
[ "https://gardening.stackexchange.com/questions/61499", "https://gardening.stackexchange.com", "https://gardening.stackexchange.com/users/14009/" ]
Wood ash traditionally has a small amount of potassium, like a per-cent. It depends on the wood. So if mixed with compost, it will add a trace of potassium (K). I have read that potassium from wood ash was used to make soap; the difference is that for soap making, the potassium is leached (dissolved) out of a "large" amount of ash and concentrated. Looking on the net, I only find info on "artsy craftzy" fake soap. A little explanation: K - potassium, is the lye of real soap. The burned ash contains K2O ( potassium oxide) , very water soluble. In water it makes KOH, potassium hydroxide,= lye. Sodium can be be used but there is very little in ash.
"Wood ash is a source of potassium(K). But it (K) is easily washed away by water so if it has rained after the fire went out the potassium is gone." - a local gardening book in Bulgarian "Wood ash is a strong source of carbon for a compost pile. If your compost pile is mostly greens - grass, manure, kitchen scraps - adding a carbon source will improve the smell, rapidity and end result. It will also enable preserving the nitrogen from the decomposing matter." - plenty of [sources](https://www.lowimpact.org/composting-explaining-the-carbon-nitrogen-ratio/)
459
I have one habit. Every time I stumble upon a good site, I bookmark it and search it on the Twitter. As I joined SuperUser. I searched for "superuser" on Twitter to follow it. But the search yielded nothing, so I want to ask **why isn't SuperUser on Twitter?** If it's there, then what is its user name? I am really looking forward to follow it on Twitter.
2009/08/18
[ "https://meta.superuser.com/questions/459", "https://meta.superuser.com", "https://meta.superuser.com/users/-1/" ]
We have many sites on twitter now. <http://blog.stackoverflow.com/2011/01/twitter-question-feeds-for-stack-exchange/> Oddly enough "@superuser" is some kind of reserved username on Twitter, and we still haven't been able to figure out why.
I don't know why some of you are in denial of the usefulness of Twitter. There is no harm putting such a wonderful site on Twitter. After all social networking is good for any site and its followers.
42,344,356
I just came across the same combination: Fabric.js and Vue.js and was wondering, but I'm working with VueJs few days and I don't know how to set up fabric in vue. Can you share some experience for me?
2017/02/20
[ "https://Stackoverflow.com/questions/42344356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7587852/" ]
**Install Fabric** ```sh yarn add fabric # or npm install -s fabric ``` **Basic component** (based on @laverick's answer): ```html <template> <canvas ref="can" width="200" height="200"></canvas> </template> <script> import { fabric } from 'fabric'; export default { mounted() { const ref = this.$refs.can; const canvas = new fabric.Canvas(ref); const rect = new fabric.Rect({ fill: 'red', width: 20, height: 20 }); canvas.add(rect); } }; </script> ```
Fabric follows a pretty traditional distribution layout. You want to use files from the `dist` directory. `fabric.js` for development work and `fabric.min.js` for the live site.
3,683,681
The points of the function graph are known. Need to find function formula. All known points: A(2, 70); B(3, 66.5); C(4, 63.0); D(5, 59.5); E(6, 56.0); F(7, 52.5); G(8, 49.0); H(9, 45.5); I(10, 42.0); J(11, 38.5); K(12, 35.0); L(13, 31.5); M(14, 28.0); N(15, 24.5); O(16, 21.0); P(17, 17.5); Q(18, 14.0); R(19, 10.5); S(20, 7.0); Start from A (2, 70) to finish at S (20, 7). Probably is it "y = kx + b", but I'm not sure. X always increases by 1, and Y always decreases by 3.5
2020/05/20
[ "https://math.stackexchange.com/questions/3683681", "https://math.stackexchange.com", "https://math.stackexchange.com/users/790675/" ]
Hint: it's a straight line of the form $$ f(x) = kx+b $$ for some $k,b \in \mathbb{R}$. You can take any two points and solve for the coefficients $a$ and $b$, and you're done. Apparently you already found the value of $k$ ...
You need to know more about the function (is it a polynomial, is it monotonic, etc.) because otherwise there are infinitely many functions that pass those points and there is no single answer to your question. Effectively, any graph you draw that connects the points will be a function provided no $x$ value corresponds to two $y$ values. Knowing that a function is linear across a range of sampled points doesn't guarantee that it is necessarily linear in-between those points. For instance, it could be curved, oscillating, or even discontinuous between the sample points. See [Wikipedia: Interpolation](https://en.wikipedia.org/wiki/Interpolation) for more information. The method that you should use will depend on the assumptions you can make and what you are trying to accomplish. If you *can* make the assumption that it is a straight line, it suffices to find the slope between two points, $m=\frac{y\_2-y\_1}{x\_2-x\_1}$, and then find the $y$-intercept, $c$, by substituting some known values into $y=mx+c$.
11,061,188
I'm building a web site for marketing company. As per their requirement, when a customer makes a booking. A certain amount of bonus is distributed between employees based on their hierarchy. The distribution starts from 60 days after booking and bonus is given for 24 months. The tables are > > bookings > > > ``` bid book_date 1 2012-05-09 2 2012-05-10 ``` > > bonus > > > ``` bid empid amount 1 1 300 1 2 400 2 2 300 2 3 400 ``` Is it possible to write mysql views that generates monthly bonus an employee gets for every month. I didn't find solution on how to make update with mysql view. Any hint will of great help.
2012/06/16
[ "https://Stackoverflow.com/questions/11061188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1460163/" ]
``` double x, y; ``` Declares two local, class variables that make up the class. ``` PT() {} ``` Default constructor. Allows you to create a PT without any arguments. e.g. --> `PT myObj;` ``` PT(double x, double y) : x(x), y(y) {} ``` Constructor to create a point from two doubles. e.g. --> `PT myObj(3.5, 9.0);` After the declaration --> ***PT(double x, double y)*** : x(x), y(y) {} we have initialisation .--> PT(double x, double y) : ***x(x), y(y)*** {} `x(x)` is equivalent to `this->x = x;` i.e. initialise the class variable 'x' with the constructor parameter 'x'. It is somewhat confusing that they have given the parameters the same name as the class variables. A better example might have been: ``` PT(double xInit, double yInit) : x(xInit) , y(yInit) { } ``` ``` PT(const PT &p) : x(p.x), y(p.y) {} ``` Copy constructor to create a PT object from another PT object e.g. --> `PT myOtherObj(myObj);` ``` PT operator + (const PT &p) const { return PT(x+p.x, y+p.y); } PT operator - (const PT &p) const { return PT(x-p.x, y-p.y); } ``` Addition and subtraction operators to get the sum or difference of two points to make a third. e.g. --> ``` PT sumObj = myObj + myOtherObj; PT diffObj = myObj - myOtherObj; ``` `PT operator * (double c) const { return PT(x*c, y*c ); }` `PT operator / (double c) const { return PT(x/c, y/c ); }` Multiplication and division operators to multiply (or divide) a point by a constant. e.g. --> ``` PT prodObj = myObj * 2.7; PT divObj = myObj / 8.0; ```
Lines 4 & 5 are **constructors**, and the syntax `x(x)` highlights an idiomatic way to invoke constructor of the member variables (pass down, to say). Note that is *not* required a different identifier for a formal parameter. Assign from inside the body of the constructor would require a different naming, because a formal parameter 'hides' the member variables. I.e. we would need, for instance ``` PT(double x_, double y_) { x = x_; y = y_; } ``` Also note that this way we are *not* calling the constructor of member x, but the assignment operator. There is no difference for POD data, but the syntax allows for arbitrary, user defined, member functions on classes like `PT`.
45,179,108
I have created a small application locally on my machine using HTML, CSS and JavaScript. I am using a plugin to run the JavaScript on the site. My small application loads different pictures from drop down lists and uses a SendMail JavaScript function as well. How can I add this page as one of my WordPress pages? I used a BlankSlate plugin to clean one of my pages up and whenever I paste my code into the page it gets scrambled and doesent work. It loads my drop down lists and some titles but pictures are gone and background isnt present. I am new to using WordPress and I want to add this small app to my site. Any help would be great or suggestions and how to copy it over. ( Sorry for the messy, unorganized code. Still learning and practicing, but this is what I am trying to turn into a page ) ``` <html lang="en"><head> <meta charset="utf-8"> <meta name="description" content=" A page for exploring html documents"> <title>BuildIt-AR App</title> <head> <link href="https://fonts.googleapis.com/css?family=Rock+Salt" rel="stylesheet"> </head> <style> .body {max-width:1920px; margin:0 auto;} .centered {max-width:720px; margin:0 auto;} .floatLeft { float:left;} select { display:block; clear:both; } .myBox{ clear:both; max-width: 375px; max-height: 225px; padding-top:275px; } .textlines { padding-top:350px; } body{ background-image: url("https://www.xmple.com/wallpaper/grey-gradient-linear-1920x1080-c2-708090-dcdcdc-a-285-f-14.svg"); background-repeat: repeat-x; border: 5px inset lightgrey; } font{ font-family: 'Rock Salt', cursive; position: fixed; font-size: 350%; top: 20%; left: 50%; margin-top: -50px; margin-left: -100px; letter-spacing: 3px; text-shadow: 2.2px 1.5px grey; } select{ } </style> <script type="application/javascript"> var pictureList1 = [ "http://i66.tinypic.com/xds135.png", "http://i68.tinypic.com/28cdhxh.png", "http://i66.tinypic.com/169s4mc.png", ]; function change_image(id) { var idx = document.getElementById('picDD').value - 1; // javascript is zero-indexed document.getElementById('pic').src = pictureList1[idx]; y = document.getElementById("picDD"); //x.value = y.options[y.selectedIndex].text; document.getElementById("stock").value = stock[y.selectedIndex]; } var pictureList2 = [ "http://i65.tinypic.com/2wmqefs.png", "http://i63.tinypic.com/s4za11.png", "http://i66.tinypic.com/6e3ibq.png", ]; function change_image2(id) { var idx = document.getElementById('picDD2').value - 1; // javascript is zero-indexed document.getElementById('pic2').src = pictureList2[idx]; y = document.getElementById("picDD2"); //x.value = y.options[y.selectedIndex].text; document.getElementById("body").value = body[y.selectedIndex]; } var pictureList3 = [ "http://i65.tinypic.com/2n9dslt.png", " http://i65.tinypic.com/289h35y.png", "http://i64.tinypic.com/vxnpzd.png", ]; function change_image3(id) { var idx = document.getElementById('picDD3').value - 1; // javascript is zero-indexed document.getElementById('pic3').src = pictureList3[idx]; y = document.getElementById("picDD3"); //x.value = y.options[y.selectedIndex].text; document.getElementById("barrel").value = barrel[y.selectedIndex]; } var barrel = new Array(); var body = new Array(); var stock = new Array(); barrel[0] = "Assault Barrel $89.95"; body[0] = "BlackOut Body $231.95"; stock[0] = "Slide Stock $78.95"; barrel[1] = "Sniper Barrel $395.95"; body[1] = "SlideFire Body $278.95"; stock[1] = "Fold Stock $178.95"; barrel[2] = "Tactical Barrel $278.95"; body[2] = "Green Body $134.95"; stock[2] = "Steady Stock $78.95"; barrel[3] = 4; body[3] = "asmith"; stock[3] = "Andy Smith"; // function change_image3() { //x = document.getElementById("users"); // function sendMail() { var link = "mailto:example@gmail.com" + "?cc=gunbuilder@builditar.com" + "&subject=" + escape("BuildIt-AR Order Form") + "&body=" + escape(document.getElementById('name').value + "\n" + document.getElementById('barrel').value + "\n" + document.getElementById('body').value + "\n" + document.getElementById('stock').value); window.location.href = link; } </script> </head> <body> <div class="centered"> <div class="floatLeft"> <img id="pic" src="http://i66.tinypic.com/xds135.png" class="myBox"> <select id="picDD" onchange="change_image();"> <option value="1" selected="">Stock #1</option> <option value="2">Stock #2</option> <option value="3">Stock #3</option> </select> </div></div> <div class="floatLeft"> <img id="pic2" src="http://i65.tinypic.com/2wmqefs.png" class="myBox"> <select id="picDD2" onchange="change_image2();"> <option value="1" selected="">Body #1</option> <option value="2">Body #2</option> <option value="3">Body #3</option> </select> </div> <div class="floatLeft"> <img id="pic3" src="http://i64.tinypic.com/vxnpzd.png" class="myBox"> <select id="picDD3" onchange="change_image3();"> <option value="1" selected="">Barrel #1</option> <option value="2">Barrel #2</option> <option value="3">Barrel #3</option> </select> </div> <div class="textlines"> <input type="text" placeholder="<Name>" id="name"> <p>Barrel <input type="text" id="barrel" name="id" ></p> <p>Body <input type="text" id="body" name="username" ></p> <p>Stock <input type="text" id="stock" name="full_name" ></p> ``` ``` <font size="10">BuildIt-AR</font> <button onclick="sendMail(); return false">Send</button> </body></html> ```
2017/07/19
[ "https://Stackoverflow.com/questions/45179108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5790896/" ]
Another solution: ``` <input type="file" @change="previewFiles" multiple> methods: { previewFiles(event) { console.log(event.target.files); } } ```
Try this. ``` <input type="file" id="file" ref="myFiles" class="custom-file-input" @change="previewFiles" multiple> ``` and in your component options: ``` data() { return { files: [], } }, methods: { previewFiles() { this.files = this.$refs.myFiles.files } } ```
29,222,876
I am trying to create a new NSTimer object to simply increment my counter by 1sec (To calculate the lifetime of my game) now I've seen demos and examples on how to go about this, and have done the same thing but the project continues to fail. Any suggestions to there? This is the error message : unrecognized selector sent to instance 0x7a83c7d0 ``` import SpriteKit var timerObject = NSTimer() var count = 0 let timer = SKLabelNode(text: "0") class GameScene: SKScene , SKPhysicsContactDelegate { override func didMoveToView(view: SKView) { timerObject = NSTimer.scheduledTimerWithTimeInterval( 1 , target: self , selector: Selector("result"), userInfo: nil, repeats: true) func result(){ count++ timer.text = String(count) } ``` I also wrote the function "result" as such and still crashed ``` func result() { count+= 0 timer.text = "\(count)" } ```
2015/03/24
[ "https://Stackoverflow.com/questions/29222876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4413707/" ]
thank you so much for your answer **@kaho**, it helped me alot (even you calculated the distanceWidth and distanceHeight in the same way). Clarification: * **farLeft** LatLng object that defines the **top left corner** of the camera. * **farRight** LatLng object that defines the **top right corner** of the camera. * **nearLeft** LatLng object that defines the **bottom left corner** of the camera. * **nearRight** LatLng object that defines the **bottom right corner** of the camera. **EDITED**: I don't know why we made a simple calculation become a bit complicated, the visible radius is just **A HALF OF VISIBLE DIAGONAL LINE**, that's all! [![enter image description here](https://i.stack.imgur.com/6lkdA.jpg)](https://i.stack.imgur.com/6lkdA.jpg) ``` private double getMapVisibleRadius() { VisibleRegion visibleRegion = map.getProjection().getVisibleRegion(); float[] diagonalDistance = new float[1]; LatLng farLeft = visibleRegion.farLeft; LatLng nearRight = visibleRegion.nearRight; Location.distanceBetween( farLeft.latitude, farLeft.longitude, nearRight.latitude, nearRight.longitude, diagonalDistance ); return diagonalDistance[0] / 2; } ``` I also logged my results to compare with @jossef-harush 's results and it's approximately: [![enter image description here](https://i.stack.imgur.com/nudZu.png)](https://i.stack.imgur.com/nudZu.png)
edit: The following answer is for Google Maps JavaScript API v3 =-=-=-=-=-=-= I think the answer would be: Yes, you can. According to the [documentation](https://developers.google.com/maps/documentation/javascript/geometry#Distance), you can calculate distance between 2 points by: `computeDistanceBetween(LatLngFrom, LatLngTo)` Also you can get the boundary of the map by using `getBounds()` method, which is in the [google.maps.Map class](https://developers.google.com/maps/documentation/javascript/reference#Map).
8,913,671
I'm printing out a table with line totals but I also want to get the grand total of the columns. This following code doesn't work, instead of the grand totals it just prints out the values of the last iteration. ``` <% @shipments.each do |shipment| %> <tr> <td style="text-align:center;"><%= shipment.file_number %></td> <td><%= shipment.shipper.company_name %></td> <td><%= shipment.hbl %></td> <td><%= shipment.status %></td> <td><%= shipment.age %></td> <td><%= shipment.invoice.read_issued_at unless shipment.invoice.nil? %></td> <td><%= number_to_currency shipment.invoice.customer_total unless shipment.invoice.nil? %></td> <td><%= number_to_currency shipment.invoice.customer_amount_paid unless shipment.invoice.nil? %></td> <td><%= number_to_currency shipment.invoice.customer_open_balance unless shipment.invoice.nil? %></td> </tr> <% grand_customer_total = 0 grand_customer_amount_paid = 0 grand_customer_open_balance = 0 grand_customer_total += shipment.invoice.customer_total grand_customer_amount_paid += shipment.invoice.customer_amount_paid grand_customer_open_balance += shipment.invoice.customer_open_balance %> <% if @shipments.last == shipment %> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <th>Totals</th> <td><%= number_to_currency grand_customer_total %></td> <td><%= number_to_currency grand_customer_amount_paid %></td> <td><%= number_to_currency grand_customer_open_balance %></td> </tr> <% end %> ```
2012/01/18
[ "https://Stackoverflow.com/questions/8913671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/912895/" ]
The reason your code isn't working is that your variables are defined in the block, so they're considered block-local variables. Once the block is exited those variables are marked to be cleared; each iteration re-defines those variables. It also doesn't help that you're reassigning them to 0 on each iteration, but that isn't even coming into effect here because the variables aren't defined each time through. You could simply define the variables before the block, but that's still pretty messy. Since Ruby idioms and conventions put an emphasis on clean and well-organized code, I'd stray away from that and instead calculate these numbers separately, possibly in your controller. ``` @totals = { :overall => @shipments.reduce(0) { |total, shipment| total + shipment.invoice.customer_total }, :paid => @shipments.reduce(0) { |total, shipment| total + shipment.invoice.customer_amount_paid }, :balance => @shipments.reduce(0) { |total, shipment| total + shipment.invoice.customer_open_balance } } ``` Then, instead of using `@shipments.last` comparison, you can just do the following after your shipments table output: ``` <tr> <td colspan="5"></td> <th>Totals</th> <td><%= number_to_currency @totals[:overall] %></td> <td><%= number_to_currency @totals[:paid] %></td> <td><%= number_to_currency @totals[:balance] %></td> </tr> ```
You set the grand total to zero every time through the loop. move the initialization up before the loop.
14,845,177
HTTPS Displays on Chrome but not Safari unless I click on another page, and then click back. Then https displays, and I can click it and view the certificate. I installed both the the Webserver Certification and the Intermediate file. Has anyone experienced this problem, and if so, how did you fix it?
2013/02/13
[ "https://Stackoverflow.com/questions/14845177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1636510/" ]
Probably you have some external resource (img, scripts, etc) loaded through plain http. To check try with Chrome or Firefox. Chrome display a valid green lock on the navbar but on the right side you can see an icon of a shield if there are some resources loaded from an insecure source. (Firefox display a grey world instead of the lock. Safari instead fails silently removing the https+lock icon) ![Firefox and Chrome navbars with some resources over http ](https://i.stack.imgur.com/2qYuL.jpg)
I had the same problem, and fixed it by switching the user agent in the safari menu: Development-User Agent. You may choose any other UA, and for me , the site suddenly displays https. and after I change the UA to general version, it works fine.