qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
It's because in C++ this is what happens: ``` switch(a) { case 1: // do stuff case 2: // do other stuff } ``` If `a` is 1, then - according to C++ rules - both "do stuff" *and* "do other stuff" would happen. So that C++ programmers coming to C# do not get tripped up (and to make code clear...
According to <http://msdn.microsoft.com/en-us/library/06tc147t.aspx> > > You cannot "fall through" any switch section, including the last one. > > > Fall through can be avoided by any of the following: break, goto, or return.
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
Having a break after your switch's final case statement is good [defensive programming](http://en.wikipedia.org/wiki/Defensive_programming). If, perhaps in the future, another case statement is added below, it removes the risk of the program's flow *falling through* from the case above.
Consistency. Same reason as being able to have a comma after the last enum definition or the last assignment in an object instantiation statement with braces. And the last case might not always be the last case. It also makes it so there are fewer special cases. And if that's the case, then it is easier to learn, wri...
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
Having a break after your switch's final case statement is good [defensive programming](http://en.wikipedia.org/wiki/Defensive_programming). If, perhaps in the future, another case statement is added below, it removes the risk of the program's flow *falling through* from the case above.
When using a `switch`, to `break` is not the only option. You also have the option of going to another case, going to the default case, going to another label, or returning. It is also possible to have multiple cases that have a single implementation body. Since there are up to five options plus the ability to have mul...
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
It's because in C++ this is what happens: ``` switch(a) { case 1: // do stuff case 2: // do other stuff } ``` If `a` is 1, then - according to C++ rules - both "do stuff" *and* "do other stuff" would happen. So that C++ programmers coming to C# do not get tripped up (and to make code clear...
When using a `switch`, to `break` is not the only option. You also have the option of going to another case, going to the default case, going to another label, or returning. It is also possible to have multiple cases that have a single implementation body. Since there are up to five options plus the ability to have mul...
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
Actually **There is one case when you don't have to put break** Consider this code: ``` using System; public class Program { public static void DoStuff() { } public static void DoAnotherStuff() { } public static void Main() { switch(1) { case 1: DoStuff()...
When using a `switch`, to `break` is not the only option. You also have the option of going to another case, going to the default case, going to another label, or returning. It is also possible to have multiple cases that have a single implementation body. Since there are up to five options plus the ability to have mul...
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
Consistency. Same reason as being able to have a comma after the last enum definition or the last assignment in an object instantiation statement with braces. And the last case might not always be the last case. It also makes it so there are fewer special cases. And if that's the case, then it is easier to learn, wri...
As mentioned, you can use default:, but consider case null too. case null: does need a break; case null: iEvaluatedToNothing(); break; If you want to "waterfall" down you can do something like this; ``` switch (deliverMail) { case null: case "": case "Address0": deliverMail0(); goto case ...
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
Having a break after your switch's final case statement is good [defensive programming](http://en.wikipedia.org/wiki/Defensive_programming). If, perhaps in the future, another case statement is added below, it removes the risk of the program's flow *falling through* from the case above.
According to [this blog post](http://blogs.msdn.com/b/ericlippert/archive/2009/08/13/four-switch-oddities.aspx) by Eric Lippert (Case 2), it allows you to be able to arbitrarily re-order your switch sections without accidentally introducing a breaking change: > > It [the compiler] requires that every switch section, ...
3,455,208
Surely the compiler knows that it's the last label of the `switch` statement?
2010/08/11
[ "https://Stackoverflow.com/questions/3455208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327528/" ]
It's because in C++ this is what happens: ``` switch(a) { case 1: // do stuff case 2: // do other stuff } ``` If `a` is 1, then - according to C++ rules - both "do stuff" *and* "do other stuff" would happen. So that C++ programmers coming to C# do not get tripped up (and to make code clear...
According to [this blog post](http://blogs.msdn.com/b/ericlippert/archive/2009/08/13/four-switch-oddities.aspx) by Eric Lippert (Case 2), it allows you to be able to arbitrarily re-order your switch sections without accidentally introducing a breaking change: > > It [the compiler] requires that every switch section, ...
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
I would use: ``` <img src="picture.jpg?20130910043254"> ``` where "20130910043254" is the modification time of the file. > > When uploading an image, its filename is not kept in the database. It is renamed as Image.jpg (to simply things out when using it). When replacing the existing image with a new one, the name...
I checked all the answers around the web and the best one seemed to be: (actually it isn't) ``` <img src="image.png?cache=none"> ``` at first. However, if you add **cache=none** parameter (which is static "none" word), it doesn't effect anything, browser still loads from cache. Solution to this problem was: ``` <...
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
You may write a proxy script for serving images - that's a bit more of work though. Something likes this: HTML: ``` <img src="image.php?img=imageFile.jpg&some-random-number-262376" /> ``` Script: ``` // PHP if( isset( $_GET['img'] ) && is_file( IMG_PATH . $_GET['img'] ) ) { // read contents $f = open( IMG_PAT...
I've found Chrome specifically tries to get clever with the URL arguments solution on images. That method to avoid cache only works *some* of the time. The most reliable solution I've found is to add both a URL argument (E.g. time stamp or file version) **AND** also change the capitalisation of the image file extension...
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
You must use a unique filename(s). Like this ``` <img src="cars.png?1287361287" alt=""> ``` But this technique means high server usage and bandwidth wastage. Instead, you should use the version number or date. Example: ``` <img src="cars.png?2020-02-18" alt=""> ``` But you want it to never serve image from cache....
I made a PHP script that automatically appends the timestamps on all images and also on links. You just need to include this script in your pages. Enjoy! <http://alv90.altervista.org/how-to-force-the-browser-not-to-cache-images/>
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
I use [PHP's file modified time function](http://php.net/filemtime), for example: ``` echo <img src='Images/image.png?" . filemtime('Images/image.png') . "' />"; ``` If you change the image then the new image is used rather than the cached one, due to having a different modified timestamp.
I've found Chrome specifically tries to get clever with the URL arguments solution on images. That method to avoid cache only works *some* of the time. The most reliable solution I've found is to add both a URL argument (E.g. time stamp or file version) **AND** also change the capitalisation of the image file extension...
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
I'm a NEW Coder, but here's what I came up with, to stop the Browser from caching and holding onto my webcam views: ``` <meta Http-Equiv="Cache" content="no-cache"> <meta Http-Equiv="Pragma-Control" content="no-cache"> <meta Http-Equiv="Cache-directive" Content="no-cache"> <meta Http-Equiv="Pragma-directive" Content="...
Add a time stamp `<img src="picture.jpg?t=<?php echo time();?>">` will always give your file a random number at the end and stop it caching
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
I checked all the answers around the web and the best one seemed to be: (actually it isn't) ``` <img src="image.png?cache=none"> ``` at first. However, if you add **cache=none** parameter (which is static "none" word), it doesn't effect anything, browser still loads from cache. Solution to this problem was: ``` <...
I've found Chrome specifically tries to get clever with the URL arguments solution on images. That method to avoid cache only works *some* of the time. The most reliable solution I've found is to add both a URL argument (E.g. time stamp or file version) **AND** also change the capitalisation of the image file extension...
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
I use [PHP's file modified time function](http://php.net/filemtime), for example: ``` echo <img src='Images/image.png?" . filemtime('Images/image.png') . "' />"; ``` If you change the image then the new image is used rather than the cached one, due to having a different modified timestamp.
> > When uploading an image, its filename is not kept in the database. It is renamed as Image.jpg (to simply things out when using it). > > > Change this, and you've fixed your problem. I use timestamps, as with the solutions proposed above: **Image-<timestamp>.jpg** Presumably, whatever problems you're avoiding ...
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
All the Answers are valid as it works fine. But with that, the browser also creates another file in the cache every time it loads that image with a different URL. So instead of changing the URL by adding some query params to it. So, what we can do is we can update the browser cache using `cache.put` ```js caches.open...
I made a PHP script that automatically appends the timestamps on all images and also on links. You just need to include this script in your pages. Enjoy! <http://alv90.altervista.org/how-to-force-the-browser-not-to-cache-images/>
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
From my point of view, disable images caching is a bad idea. At all. The root problem here is - how to force browser to update image, when it has been updated on a server side. Again, from my personal point of view, the best solution is to disable direct access to images. Instead access images via server-side filte...
I made a PHP script that automatically appends the timestamps on all images and also on links. You just need to include this script in your pages. Enjoy! <http://alv90.altervista.org/how-to-force-the-browser-not-to-cache-images/>
126,772
Background ---------- I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t...
2008/09/24
[ "https://Stackoverflow.com/questions/126772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
use **Class="NO-CACHE"** sample html: ``` <div> <img class="NO-CACHE" src="images/img1.jpg" /> <img class="NO-CACHE" src="images/imgLogo.jpg" /> </div> ``` jQuery: ``` $(document).ready(function () { $('.NO-CACHE').attr('src',function () { return $(this).attr('src') + "?a=" + Mat...
I made a PHP script that automatically appends the timestamps on all images and also on links. You just need to include this script in your pages. Enjoy! <http://alv90.altervista.org/how-to-force-the-browser-not-to-cache-images/>
46,169,615
I want to delete a file, in case it is locked by another process even though I have set try catch, but the program is still dark cash at fi.Delete(), so how to fix it. > > A first chance exception of type 'System.UnauthorizedAccessException' > occurred in mscorlib.dll > > > Additional information: Access to the pa...
2017/09/12
[ "https://Stackoverflow.com/questions/46169615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766775/" ]
``` private void GView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { try { string cellValue = GView.Rows[e.RowIndex].Cells["NAME"].Value.ToString(); var confirmResult = MessageBox.Show("delete this item " + cellValue, "Confirm Del...
The user, whose account is used to run your application, must have access to that path There are 2 ways to achieve this: 1. Configure a special application pool for your application, that will run under a user that has necessary permissions (can access admin shares on remote server). So your entire application will r...
46,169,615
I want to delete a file, in case it is locked by another process even though I have set try catch, but the program is still dark cash at fi.Delete(), so how to fix it. > > A first chance exception of type 'System.UnauthorizedAccessException' > occurred in mscorlib.dll > > > Additional information: Access to the pa...
2017/09/12
[ "https://Stackoverflow.com/questions/46169615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766775/" ]
I read this [article](https://stackoverflow.com/questions/58380/avoiding-first-chance-exception-messages-when-the-exception-is-safely-handled/58392), as suggested by @Keyur PATEL, and figuring out this is a configuration of Visual Studio, I solved it by doing the following: * Navigate to "Debug / Exceptions / Common L...
The user, whose account is used to run your application, must have access to that path There are 2 ways to achieve this: 1. Configure a special application pool for your application, that will run under a user that has necessary permissions (can access admin shares on remote server). So your entire application will r...
1,569,678
What I am going after is to be able to do something like this ``` public class Class1 { public delegate CollsionType ValidateDelegate< T >(PlayerState<T> state, Vector2 position, CollsionType boundary); public static ValidateDelegate ValidateMove; public void AnotherFunction< T >(PlayerState< T > state) ...
2009/10/15
[ "https://Stackoverflow.com/questions/1569678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190266/" ]
You're almost there - just make Class1 generic, and the delegate generic: ``` public class Class1<T> { public delegate CollsionType ValidateDelegate<T>(PlayerState<T> state, Vector2 position, CollsionType boundary); public static ValidateDelegate<T> ValidateMove; public void AnotherFunction<T>(PlayerStat...
I solved the problem by making the function I was calling on Class 2 static(erasing the need for the delegate) and passing in the generic types of Class2 to the function in Class1 that was calling the function on Class2. There could still be more valid answers to this question. This one just works for me for now beca...
1,569,678
What I am going after is to be able to do something like this ``` public class Class1 { public delegate CollsionType ValidateDelegate< T >(PlayerState<T> state, Vector2 position, CollsionType boundary); public static ValidateDelegate ValidateMove; public void AnotherFunction< T >(PlayerState< T > state) ...
2009/10/15
[ "https://Stackoverflow.com/questions/1569678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190266/" ]
Here is the closest I could come to the correct answer to my question. I do admit that it goes against some coding standards(because it uses late binding) but it seems to work. public class Class1 { ``` public delegate CollsionType ValidateDelegate< T >(PlayerState<T> state, Vector2 position, CollsionType boundary);...
I solved the problem by making the function I was calling on Class 2 static(erasing the need for the delegate) and passing in the generic types of Class2 to the function in Class1 that was calling the function on Class2. There could still be more valid answers to this question. This one just works for me for now beca...
24,604,626
I want to check if the user ticked the checkbox BEFORE the file is uploaded to the server, so I created a validation on UploadStart with an alert message. I put the break point at this line and it did go through, but the alert message still didn't show. (AjaxFileUpload control is not put under any UpdatePanel) ``` p...
2014/07/07
[ "https://Stackoverflow.com/questions/24604626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3431239/" ]
You seem to be misunderstanding what [constants](http://php.net/manual/en/language.constants.php) actually are. In the specific case of `OCI_ASSOC` (and other [OCI constants](http://php.net/manual/en/oci8.constants.php)) it represents a simple integer value. This can be demonstrated by the output of `var_dump(OCI_ASSOC...
You have to be sure if the connection is succeeded or not. check the return if it's *resource* value of `$conn` in your code. wish this help you.
35,208,715
I malloc'd an array of structures called "locations". In said structure is an element called "country". I created a string you can see below that holds "United States" in it. I malloc'd space to hold the string (it's required that I do so) and attempted to use strncpy to place the string into the malloced space. This ...
2016/02/04
[ "https://Stackoverflow.com/questions/35208715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5403466/" ]
You can do something like this (maybe avoiding the recursion): ``` #include <iostream> #include <vector> #include <algorithm> using std::cout; using std::vector; void perm( const vector<int> &v, vector<vector<int>> &p, vector<int> &t, int k, int d) { for ( int i = k; i < v.size(); ++i ) { // skip the rep...
Here is a class I once wrote in my university times to handle bosons. It's quite long, but it's generally usable and seems to work well. Additionally, it also gives ranking and unranking functionality. Hope that helps -- but don't ever ask me what I was doing back then ... ;-) ``` struct SymmetricIndex { using Sta...
35,208,715
I malloc'd an array of structures called "locations". In said structure is an element called "country". I created a string you can see below that holds "United States" in it. I malloc'd space to hold the string (it's required that I do so) and attempted to use strncpy to place the string into the malloced space. This ...
2016/02/04
[ "https://Stackoverflow.com/questions/35208715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5403466/" ]
Combinations by definition do not respect order. This frees us to arrange the numbers in any order we see fit. Most notably we can rely on to provide a combination rank. Certainly the most logical way to rank combinations is in sorted order, so we'll be depending upon our inputs being sorted. There is already preceden...
Here is a class I once wrote in my university times to handle bosons. It's quite long, but it's generally usable and seems to work well. Additionally, it also gives ranking and unranking functionality. Hope that helps -- but don't ever ask me what I was doing back then ... ;-) ``` struct SymmetricIndex { using Sta...
4,246
I frequent the Electronics Stack Exchange and try to edit questions often which need a little bit of clean up. I am puzzled by a couple of recurring patterns by question authors: 1. failure to capitalize "I," the personal pronoun (even though they capitalize the first word of sentences), and 2. failure to place spac...
2013/10/23
[ "https://english.meta.stackexchange.com/questions/4246", "https://english.meta.stackexchange.com", "https://english.meta.stackexchange.com/users/2241/" ]
This is a bit of a cheeky "answer", but maybe we could change the tag on this question from "discussion" to "feature request"... > > Can we have a pop-up warning whenever uncapitalised **i** is used in the ***Ask Question*** screen? > > >
> > Forgive my naivety, but are we simply attracting people of a language or culture where punctuation and capitalization are not used, making these concepts difficult for people to grasp? > > > I see punctuation and capitalization going downhill across the board, so I don't think it has anything to do with the t...
52,529
I am extending the width of my stairs, and need to remove the existing sub treads and risers. They appear to be glued (construction adhesive I'm guessing because it is brown) and nailed. Is this going to destroy the stair stringer when I remove them? In case it is helpful, the reason why I am removing them is that I w...
2014/11/09
[ "https://diy.stackexchange.com/questions/52529", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/27245/" ]
I think the least invasive way to handle this is to add two more stingers, one right against the existing stairs(essentially just a nailer) and one out at the ultimate width of the new treads. This way you don't have to remove the old sub-treads/risers or change the height of your treads, which would cause you grief wh...
If you used 1" solid oak stair treads they could float that distance; you're going to use hardwood flooring? [stair-treads.com](http://www.stair-treads.com/red-oak-treads) ![enter image description here](https://i.stack.imgur.com/85IRsm.jpg) Stair treads could be directly applied to the existing sub, so long as it wil...
57,316,337
I have accidentally committed a password to a BitBucket git repository some time ago, several commits behind the current master. While I removed the password later by committing without it, it still exists in several past commits. I don't mind losing the history of changes during those commits. I'm also not worried ab...
2019/08/01
[ "https://Stackoverflow.com/questions/57316337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6086575/" ]
What I would do is: ``` git checkout revision-where-the-file-was-added git rm the-file-with-the-password git commit --amend --no-edit # fix the revision git cherry-pick revision-where-the-file-was-added..the-branch # replay all later revision # if you like the result git branch -f the-branch git push -f origin the-bra...
You can do a combination of a `rebase` and a `git push origin master --force` to rewrite the history of your repository and force-push your changes so that no one would be able to view the password in the commit history. From your main branch you can do `git rebase origin/master -i` and then `edit` the commit where y...
2,390,224
i have some WinForms app (Framework to develop some simple apps), written in C#. My framework later would be used to develop win forms applications. Other developers they are beginers often and sometimes do not use Parameters - they write direct SQL in code. So first i need somehow to do protection in my framework base...
2010/03/05
[ "https://Stackoverflow.com/questions/2390224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152006/" ]
I don't see how there is any means to protect any SQL-based library from *developer* misuse without crippling its functionality (i.e. never giving direct access to the database). Even with NHibernate or Linq to SQL it's possible to bypass the mapping layers and directly write a SQL statement. Personally I think your ...
Agree with Aaronaught, a framework will not completely prevent the possibility. I would never substitute stringent validation on the data layer. Also provide an abstraction layer around your data access that you open up as the API rather then allow developers to connect directly to database.
2,390,224
i have some WinForms app (Framework to develop some simple apps), written in C#. My framework later would be used to develop win forms applications. Other developers they are beginers often and sometimes do not use Parameters - they write direct SQL in code. So first i need somehow to do protection in my framework base...
2010/03/05
[ "https://Stackoverflow.com/questions/2390224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152006/" ]
I don't see how there is any means to protect any SQL-based library from *developer* misuse without crippling its functionality (i.e. never giving direct access to the database). Even with NHibernate or Linq to SQL it's possible to bypass the mapping layers and directly write a SQL statement. Personally I think your ...
It sounds like you need to train your developers to use parameter binding instead of looking for a technical solution. One other alternative would be to keep the database layer in a different project and only allow your SQL savy developers to code in it. The GUI can be in a different project. That way the GUI programm...
2,390,224
i have some WinForms app (Framework to develop some simple apps), written in C#. My framework later would be used to develop win forms applications. Other developers they are beginers often and sometimes do not use Parameters - they write direct SQL in code. So first i need somehow to do protection in my framework base...
2010/03/05
[ "https://Stackoverflow.com/questions/2390224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152006/" ]
I don't see how there is any means to protect any SQL-based library from *developer* misuse without crippling its functionality (i.e. never giving direct access to the database). Even with NHibernate or Linq to SQL it's possible to bypass the mapping layers and directly write a SQL statement. Personally I think your ...
Security is usually a process, not a product or api. It is also an evolving process, we have to adapt or get hacked. A heavy handed approach: You can force everyone to write stored procedures,and not allow direct table access from the accounts that are allowed to talk to the database. (GRANT EXECUTE ON etc) Then you...
2,390,224
i have some WinForms app (Framework to develop some simple apps), written in C#. My framework later would be used to develop win forms applications. Other developers they are beginers often and sometimes do not use Parameters - they write direct SQL in code. So first i need somehow to do protection in my framework base...
2010/03/05
[ "https://Stackoverflow.com/questions/2390224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152006/" ]
Agree with Aaronaught, a framework will not completely prevent the possibility. I would never substitute stringent validation on the data layer. Also provide an abstraction layer around your data access that you open up as the API rather then allow developers to connect directly to database.
Security is usually a process, not a product or api. It is also an evolving process, we have to adapt or get hacked. A heavy handed approach: You can force everyone to write stored procedures,and not allow direct table access from the accounts that are allowed to talk to the database. (GRANT EXECUTE ON etc) Then you...
2,390,224
i have some WinForms app (Framework to develop some simple apps), written in C#. My framework later would be used to develop win forms applications. Other developers they are beginers often and sometimes do not use Parameters - they write direct SQL in code. So first i need somehow to do protection in my framework base...
2010/03/05
[ "https://Stackoverflow.com/questions/2390224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/152006/" ]
It sounds like you need to train your developers to use parameter binding instead of looking for a technical solution. One other alternative would be to keep the database layer in a different project and only allow your SQL savy developers to code in it. The GUI can be in a different project. That way the GUI programm...
Security is usually a process, not a product or api. It is also an evolving process, we have to adapt or get hacked. A heavy handed approach: You can force everyone to write stored procedures,and not allow direct table access from the accounts that are allowed to talk to the database. (GRANT EXECUTE ON etc) Then you...
11,639,319
I can't seem to return an object from a function, the console.log inside the function prints out the property values fine but once outside the function I'm getting "Uncaught ReferenceError: firstOn is not defined" Any help would be appreciated, thanks! ``` myElement = document.getElementById("testButton"); function ...
2012/07/24
[ "https://Stackoverflow.com/questions/11639319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
That firstOn object was created in the local function scope. It will not be available globally in the second function.
I think this is the appropriate solution to my problem. ``` myElement = document.getElementById("testButton"); function Server(name,tables,startTime) { this.name = name; this.tables = tables; this.startTime = startTime; } var firstOn = new Server(); document.forms.server1.button.onclick = function() { ...
11,639,319
I can't seem to return an object from a function, the console.log inside the function prints out the property values fine but once outside the function I'm getting "Uncaught ReferenceError: firstOn is not defined" Any help would be appreciated, thanks! ``` myElement = document.getElementById("testButton"); function ...
2012/07/24
[ "https://Stackoverflow.com/questions/11639319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
That firstOn object was created in the local function scope. It will not be available globally in the second function.
`firstOn` is an object that was created and returned from the `document.forms.server1.button.onclick` event handler. The return value from that event handler went into the system (that's where event handlers return to) and was never stored anywhere so it was cleaned up by the system with garbage collection. Meanwhile,...
11,639,319
I can't seem to return an object from a function, the console.log inside the function prints out the property values fine but once outside the function I'm getting "Uncaught ReferenceError: firstOn is not defined" Any help would be appreciated, thanks! ``` myElement = document.getElementById("testButton"); function ...
2012/07/24
[ "https://Stackoverflow.com/questions/11639319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
That firstOn object was created in the local function scope. It will not be available globally in the second function.
``` var firstOn = new winMain.Server(name,tables,startTime); ```
11,639,319
I can't seem to return an object from a function, the console.log inside the function prints out the property values fine but once outside the function I'm getting "Uncaught ReferenceError: firstOn is not defined" Any help would be appreciated, thanks! ``` myElement = document.getElementById("testButton"); function ...
2012/07/24
[ "https://Stackoverflow.com/questions/11639319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
`firstOn` is an object that was created and returned from the `document.forms.server1.button.onclick` event handler. The return value from that event handler went into the system (that's where event handlers return to) and was never stored anywhere so it was cleaned up by the system with garbage collection. Meanwhile,...
I think this is the appropriate solution to my problem. ``` myElement = document.getElementById("testButton"); function Server(name,tables,startTime) { this.name = name; this.tables = tables; this.startTime = startTime; } var firstOn = new Server(); document.forms.server1.button.onclick = function() { ...
11,639,319
I can't seem to return an object from a function, the console.log inside the function prints out the property values fine but once outside the function I'm getting "Uncaught ReferenceError: firstOn is not defined" Any help would be appreciated, thanks! ``` myElement = document.getElementById("testButton"); function ...
2012/07/24
[ "https://Stackoverflow.com/questions/11639319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
`firstOn` is an object that was created and returned from the `document.forms.server1.button.onclick` event handler. The return value from that event handler went into the system (that's where event handlers return to) and was never stored anywhere so it was cleaned up by the system with garbage collection. Meanwhile,...
``` var firstOn = new winMain.Server(name,tables,startTime); ```
12,016,262
I have listview on the UI thread. I have some operations to be performed through the background worker's DoWork event handler since they are time consuming. But I cant acess the listview items in my DoWork handler since it raises an exception:`Cross-thread operation not valid: Control 'bufferedListView1' accessed from ...
2012/08/18
[ "https://Stackoverflow.com/questions/12016262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1528699/" ]
[Here's](http://www.perceler.com/articles1.php?art=crossthreads1) a good article on the topic of cross-threaded access to controls in winforms. Basically, whenever you access controls not from the UI thread, you have to use ``` control.Invoke ``` construct.
the mistake come from the fact that you try to access to UIThread from another thread (backgrounworker thread) to get a UI control use InvokeRequired you have to implement a delegate here a sample ``` delegate void valueDelegate(string value); private void SetValue(string value) { if (InvokeRequired...
12,016,262
I have listview on the UI thread. I have some operations to be performed through the background worker's DoWork event handler since they are time consuming. But I cant acess the listview items in my DoWork handler since it raises an exception:`Cross-thread operation not valid: Control 'bufferedListView1' accessed from ...
2012/08/18
[ "https://Stackoverflow.com/questions/12016262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1528699/" ]
All I wanted was to **read the listview in UI thread in other thread**. All the solutions given were using `invoke` method but I found a rather easy way to do this: ``` ListView lvItems = new ListView(); \\in global scope ``` At the required location in my code: ``` foreach (ListViewItem item in bufferedListView1.I...
the mistake come from the fact that you try to access to UIThread from another thread (backgrounworker thread) to get a UI control use InvokeRequired you have to implement a delegate here a sample ``` delegate void valueDelegate(string value); private void SetValue(string value) { if (InvokeRequired...
9,716,744
I want to send the form after clicking on the label next to checkbox. So I have created simple function below. Html code: ``` <input class="myinput" type="checkbox" name="photo"id="photo" value="1" /> <label class="autosend" for="photo">Photos</label> <input class="myinput" type="checkbox" name="text"id="photo" val...
2012/03/15
[ "https://Stackoverflow.com/questions/9716744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/907736/" ]
``` $('input:checkbox').change(function() { $('form#search').submit(); }); ```
First of all the `for` attribute of the `label` element should be set to the `id` of the related input. ``` <input class="myinput" type="checkbox" name="photo" id="photo" value="1" /> <label class="autosend" for="photo">Photos</label> <input class="myinput" type="checkbox" name="text" id="text" value="1" /> <label cl...
9,716,744
I want to send the form after clicking on the label next to checkbox. So I have created simple function below. Html code: ``` <input class="myinput" type="checkbox" name="photo"id="photo" value="1" /> <label class="autosend" for="photo">Photos</label> <input class="myinput" type="checkbox" name="text"id="photo" val...
2012/03/15
[ "https://Stackoverflow.com/questions/9716744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/907736/" ]
``` $('input:checkbox').change(function() { $('form#search').submit(); }); ```
The problem is that the `for` attribute of the `<label>` element corresponds to the **ID** not the name of the element that you want it to refer to. Your label and your checkbox aren't connected, so clicking the label won't toggle the checkbox.
9,716,744
I want to send the form after clicking on the label next to checkbox. So I have created simple function below. Html code: ``` <input class="myinput" type="checkbox" name="photo"id="photo" value="1" /> <label class="autosend" for="photo">Photos</label> <input class="myinput" type="checkbox" name="text"id="photo" val...
2012/03/15
[ "https://Stackoverflow.com/questions/9716744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/907736/" ]
You can send the form on the change event of checkbox: ``` $('input[name=text]').on('change', function(){ $(this).parents('form').submit(); }); ```
First of all the `for` attribute of the `label` element should be set to the `id` of the related input. ``` <input class="myinput" type="checkbox" name="photo" id="photo" value="1" /> <label class="autosend" for="photo">Photos</label> <input class="myinput" type="checkbox" name="text" id="text" value="1" /> <label cl...
9,716,744
I want to send the form after clicking on the label next to checkbox. So I have created simple function below. Html code: ``` <input class="myinput" type="checkbox" name="photo"id="photo" value="1" /> <label class="autosend" for="photo">Photos</label> <input class="myinput" type="checkbox" name="text"id="photo" val...
2012/03/15
[ "https://Stackoverflow.com/questions/9716744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/907736/" ]
You can send the form on the change event of checkbox: ``` $('input[name=text]').on('change', function(){ $(this).parents('form').submit(); }); ```
The problem is that the `for` attribute of the `<label>` element corresponds to the **ID** not the name of the element that you want it to refer to. Your label and your checkbox aren't connected, so clicking the label won't toggle the checkbox.
55,279,663
How to mask the last string using swift, I have made the code as below. but the code only shows the last number, my expectation is that the code displays the first 5 digits here my code: ``` extension StringProtocol { var masked: String { return String(repeating: "•", count: Swift.max(0, count-5)) + suffi...
2019/03/21
[ "https://Stackoverflow.com/questions/55279663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10003917/" ]
Use a prefix instead of a suffix ``` extension StringProtocol { var masked: String { return prefix(5) + String(repeating: "•", count: Swift.max(0, count-5)) } } ``` You could also create a function instead for parameterizing the number of digits and direction (or even the mask character) ``` extens...
If you have a case of wanting to mask an email address. here's the code ``` func maskingEmail(email: String) -> String { let emailComponents = email.components(separatedBy: "@") let emailDomainComponents = emailComponents[1].components(separatedBy: ".") let maskedEmailName = String(repeating: "•", count: S...
6,513,821
I have a page thisfile.htm, which is included in thisfile.php I used to load thisfile.htm into an iframe on thisfile.php but because of iPad scrolling trouble, I recently converted everything to scrolling divs and php includes. I need to prevent the htm file from being loaded independently of the php parent. When I u...
2011/06/28
[ "https://Stackoverflow.com/questions/6513821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/798124/" ]
If you are using `include` in php, the easiest way to protect the file you are including, is to place it outside of the web-root. That way php can get to it, but a browser can´t so it can never be loaded separately. You don´t need any javascript in the child if you do it like this.
If thisfile.htm is to be included in a div in thisfile.php, just include it in php, using `include`. You don't have to call thisfile.htm from the outside at all. In fact, you could place it outside your doc root, in which case you cannot reach it from outside at all. It will only be included in thisfile.php.
56,005,112
I have two dates as `datetime.date` objects, what is the most Pythonic way to find a number of workdays between these two dates (including starting and excluding ending date)? For example: ``` from datetime import date, timedelta d1 = date(2019, 3, 1) d2 = date(2019, 5, 6) # The difference between d2 and d1 is 46 wor...
2019/05/06
[ "https://Stackoverflow.com/questions/56005112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2609806/" ]
use the numpy function busday\_count: ``` from datetime import date import numpy as np d1 = date(2019, 3, 1) d2 = date(2019, 5, 6) days = np.busday_count( d1, d2 ) print (days) ``` or ``` from datetime import date,timedelta d1 = date(2019, 3, 1) d2 = date(2019, 5, 6) daygenerator = (d1 + timedelta(x + 1) for x in...
You can try this: It does not take holidays,.. into account: ``` import numpy as np np.busday_count(d1.strftime("%Y-%m-%d"), d2.strftime("%Y-%m-%d")) ```
68,419,840
I was doing my homework when I encountered this problem: > > Write a function, mysum\_bigger\_than , that works the same as mysum , > except that it takes a first argument that precedes \*args . That > argument indicates the threshold for including an argument in the sum. > Thus, calling mysum\_bigger > \_than(10, 5,...
2021/07/17
[ "https://Stackoverflow.com/questions/68419840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14270371/" ]
One problem with your attempt: You use the threshold (`output`) as a starting point of the summation. Another: You check for *bigger and equal than* the threshold. And I think you should actually model your function signature according to this part of the instructions: > > ... except that it takes a first argument th...
Try this approach: ```py def mysum_bigger_than(*values): if not values: return values cond = lambda x: x > values[0] return sum(filter(cond, values[1:])) ```
51,809,274
I develop a toy compiler, and trying to implement strings and arrays. I have noticed that clang creates always a global variable for those types, even if they where defined within a function. I guess that there is a good reason for that, so I try to do the same. My problem is that I cannot figure out how to do it via ...
2018/08/12
[ "https://Stackoverflow.com/questions/51809274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7441319/" ]
What you want is called a read-only [GlobalVariable](https://llvm.org/docs/LangRef.html#global-variables) and you need that variable, an initializer, and probably a [constant cast](https://llvm.org/docs/LangRef.html#constant-expressions) so that all of your strings can have the same type. Suppose your strings are the ...
Using the code and the help of @arnt on the answer above, and I ended up with the following code to implement a string initialization. It now works, and also avoids the call to new, so it does not require any cleanup later. I post it, hoping that it may be useful for someone. ``` llvm::Value* EulStringToken::generate...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
Ajax cannot access any database, since it's not a language, nor a precise technology. Do you mean javascript? I don't think js can open a socket directly to your sql server. Anyway, that would require your db server to be open wide, which is a bad idea in most cases. You could also use the localstorage api, if all yo...
AJAX is client side. You need a server-side connection to the database. This is mostly done in PHP, ASP.NET or Java. It is possible to connect to a database from the client, for example like this: ``` <script language="JavaScript" > function getSubmit() { var LastName; var Firstn = names.value ; var cn = new A...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
Ajax cannot access any database, since it's not a language, nor a precise technology. Do you mean javascript? I don't think js can open a socket directly to your sql server. Anyway, that would require your db server to be open wide, which is a bad idea in most cases. You could also use the localstorage api, if all yo...
It can if the database engine itself has public endpoints (a webserver) built into it. I don't know of any off the top of my head but some are not far off. For example, you already communicate with MongoDb via Json. [This question](https://stackoverflow.com/questions/2133246/access-mongodb-directly-via-javascript) impl...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
Ajax cannot access any database, since it's not a language, nor a precise technology. Do you mean javascript? I don't think js can open a socket directly to your sql server. Anyway, that would require your db server to be open wide, which is a bad idea in most cases. You could also use the localstorage api, if all yo...
First off, note that AJAX stands for [Asynchronous JavaScript And XML](http://en.wikipedia.org/wiki/Ajax_%28programming%29). Knowing that doesn't directly answer your question, but it is helpful. Anyway, AJAX is an umbrella term for a certain use of a cluster of client-side technologies, so by definition it isn't acce...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
Ajax cannot access any database, since it's not a language, nor a precise technology. Do you mean javascript? I don't think js can open a socket directly to your sql server. Anyway, that would require your db server to be open wide, which is a bad idea in most cases. You could also use the localstorage api, if all yo...
First of all, AJAX operates using HTTP protocol with JSON or XML payload. Most databases operate using proprietary protocols, with payload being SQL input, raw data as output. Second, most web application provide security at application level. Giving direct access to the database would be huge security hole. With web...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
It can if the database engine itself has public endpoints (a webserver) built into it. I don't know of any off the top of my head but some are not far off. For example, you already communicate with MongoDb via Json. [This question](https://stackoverflow.com/questions/2133246/access-mongodb-directly-via-javascript) impl...
AJAX is client side. You need a server-side connection to the database. This is mostly done in PHP, ASP.NET or Java. It is possible to connect to a database from the client, for example like this: ``` <script language="JavaScript" > function getSubmit() { var LastName; var Firstn = names.value ; var cn = new A...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
AJAX is client side. You need a server-side connection to the database. This is mostly done in PHP, ASP.NET or Java. It is possible to connect to a database from the client, for example like this: ``` <script language="JavaScript" > function getSubmit() { var LastName; var Firstn = names.value ; var cn = new A...
First off, note that AJAX stands for [Asynchronous JavaScript And XML](http://en.wikipedia.org/wiki/Ajax_%28programming%29). Knowing that doesn't directly answer your question, but it is helpful. Anyway, AJAX is an umbrella term for a certain use of a cluster of client-side technologies, so by definition it isn't acce...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
AJAX is client side. You need a server-side connection to the database. This is mostly done in PHP, ASP.NET or Java. It is possible to connect to a database from the client, for example like this: ``` <script language="JavaScript" > function getSubmit() { var LastName; var Firstn = names.value ; var cn = new A...
First of all, AJAX operates using HTTP protocol with JSON or XML payload. Most databases operate using proprietary protocols, with payload being SQL input, raw data as output. Second, most web application provide security at application level. Giving direct access to the database would be huge security hole. With web...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
It can if the database engine itself has public endpoints (a webserver) built into it. I don't know of any off the top of my head but some are not far off. For example, you already communicate with MongoDb via Json. [This question](https://stackoverflow.com/questions/2133246/access-mongodb-directly-via-javascript) impl...
First off, note that AJAX stands for [Asynchronous JavaScript And XML](http://en.wikipedia.org/wiki/Ajax_%28programming%29). Knowing that doesn't directly answer your question, but it is helpful. Anyway, AJAX is an umbrella term for a certain use of a cluster of client-side technologies, so by definition it isn't acce...
84,476
Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?
2011/06/16
[ "https://softwareengineering.stackexchange.com/questions/84476", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/27782/" ]
It can if the database engine itself has public endpoints (a webserver) built into it. I don't know of any off the top of my head but some are not far off. For example, you already communicate with MongoDb via Json. [This question](https://stackoverflow.com/questions/2133246/access-mongodb-directly-via-javascript) impl...
First of all, AJAX operates using HTTP protocol with JSON or XML payload. Most databases operate using proprietary protocols, with payload being SQL input, raw data as output. Second, most web application provide security at application level. Giving direct access to the database would be huge security hole. With web...
16,163,647
I tried to subclass `UISegmentedControl`. I'm passing an `NSArray` from the view and try to set the titles for the `UISegmentedControl` from that `NSArray`. I used the `initWithArray` method but it is not setting the value from the array. Here is my subclass of `UISegmentedControl`. **WTSegmentedControl.h** ``...
2013/04/23
[ "https://Stackoverflow.com/questions/16163647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/923370/" ]
Ok so you are creating the control in the Interface Builder or by code!? You cannot do both. If you want to create it in code, remove the `IBOutlet` part in your property and add the control to the subView after initializing: ``` // adding the control by code - (void)viewDidLoad { [super viewDidLoad]; NSArray...
If you have correctly connected your IBOutlet control, then the control variable is automatically set at this point. This is done when the view is loaded. So the line: ``` control = [[WTSegmentedControl alloc] initWithItems:names]; ``` should be changed to this: ``` [control initWithItems:names]; ```
677,508
I'm using ANTLR 3.1 and ANTLRWorks to generate a parser class in Java. The parser performs better if I mark the generated class with the Java final keyword. The problem is: I am adding this keyword manually after each time I re-generated the code from the ANTLR grammar. Is there anyway, in the grammar, of telling ANTLR...
2009/03/24
[ "https://Stackoverflow.com/questions/677508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What version of Java are you using? The more recent ones should detect leaf classes automatically, as should any since 1.3 in -server mode.
From [this thread](https://stackoverflow.com/questions/357695/how-do-you-specify-the-access-specifier-on-an-antlr-v3-generated-parser-or-lexer) (oops- my bad), it looks like it's not possible to do it yet. :(
22,163,199
I want to select a `RADIO button` when a click action is performed on a specific DIV. I am using following code and it is working fine but it is not validated by W3 as according to them, I cannot use DIV tag inside LABEL tag. I will not prefer JQuery as the whole work can be done using LABEL at proper place Following i...
2014/03/04
[ "https://Stackoverflow.com/questions/22163199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114966/" ]
Here is the code by which you can select radio onclick on div elements. ``` $("div").on("click", function(){ $("input[type='radio']").prop("checked", true); }); ```
Though i am clear enough about your question but what i`ll answer according to my understanding. First, labels are in-line elements where as div`s are block elements so it is obvious that you cannot use block elements inside an in-line element. Secondly, for on-click action on a div you can use jQuery .click() method...
1,853,309
Instead of appending "abc" (and thus eventually getting a file full of abcabcabc....), no matter how many times I run this, myfile only containst "abc".... how can I append? ``` #include <stdio.h> #include <string.h> int main(){ char strng[10]; strcpy(strng,"abc"); FILE *my_file; my_file = fopen("myfi...
2009/12/05
[ "https://Stackoverflow.com/questions/1853309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225532/" ]
Apart from the fact that: ``` fwrite(strng, sizeof(strng), 1, my_file); ``` should be: ``` fwrite(strng, strlen(strng), 1, my_file); ``` it works for me.
Don't use `sizeof`, use `strlen`. sizeof is 10, so you're writing "abc\0\0\0\0\0\0\0".
1,853,309
Instead of appending "abc" (and thus eventually getting a file full of abcabcabc....), no matter how many times I run this, myfile only containst "abc".... how can I append? ``` #include <stdio.h> #include <string.h> int main(){ char strng[10]; strcpy(strng,"abc"); FILE *my_file; my_file = fopen("myfi...
2009/12/05
[ "https://Stackoverflow.com/questions/1853309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225532/" ]
Apart from the fact that: ``` fwrite(strng, sizeof(strng), 1, my_file); ``` should be: ``` fwrite(strng, strlen(strng), 1, my_file); ``` it works for me.
That program works and does what you said to do: append 10 characters (`sizeof(strng)`) to file, including `\0` and rest of the array. Change `sizeof` to `strlen`. Besides that you should not only print "problem" when you can't open file, but also not write to it. And last problem in your code - you declared `main` a...
1,853,309
Instead of appending "abc" (and thus eventually getting a file full of abcabcabc....), no matter how many times I run this, myfile only containst "abc".... how can I append? ``` #include <stdio.h> #include <string.h> int main(){ char strng[10]; strcpy(strng,"abc"); FILE *my_file; my_file = fopen("myfi...
2009/12/05
[ "https://Stackoverflow.com/questions/1853309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225532/" ]
Apart from the fact that: ``` fwrite(strng, sizeof(strng), 1, my_file); ``` should be: ``` fwrite(strng, strlen(strng), 1, my_file); ``` it works for me.
When you fopen the file, the stream position is at the beginning of the file. Surely you have to seek to the end before writing in order to get the string appended?
1,853,309
Instead of appending "abc" (and thus eventually getting a file full of abcabcabc....), no matter how many times I run this, myfile only containst "abc".... how can I append? ``` #include <stdio.h> #include <string.h> int main(){ char strng[10]; strcpy(strng,"abc"); FILE *my_file; my_file = fopen("myfi...
2009/12/05
[ "https://Stackoverflow.com/questions/1853309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225532/" ]
That program works and does what you said to do: append 10 characters (`sizeof(strng)`) to file, including `\0` and rest of the array. Change `sizeof` to `strlen`. Besides that you should not only print "problem" when you can't open file, but also not write to it. And last problem in your code - you declared `main` a...
Don't use `sizeof`, use `strlen`. sizeof is 10, so you're writing "abc\0\0\0\0\0\0\0".
1,853,309
Instead of appending "abc" (and thus eventually getting a file full of abcabcabc....), no matter how many times I run this, myfile only containst "abc".... how can I append? ``` #include <stdio.h> #include <string.h> int main(){ char strng[10]; strcpy(strng,"abc"); FILE *my_file; my_file = fopen("myfi...
2009/12/05
[ "https://Stackoverflow.com/questions/1853309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225532/" ]
Don't use `sizeof`, use `strlen`. sizeof is 10, so you're writing "abc\0\0\0\0\0\0\0".
When you fopen the file, the stream position is at the beginning of the file. Surely you have to seek to the end before writing in order to get the string appended?
1,853,309
Instead of appending "abc" (and thus eventually getting a file full of abcabcabc....), no matter how many times I run this, myfile only containst "abc".... how can I append? ``` #include <stdio.h> #include <string.h> int main(){ char strng[10]; strcpy(strng,"abc"); FILE *my_file; my_file = fopen("myfi...
2009/12/05
[ "https://Stackoverflow.com/questions/1853309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225532/" ]
That program works and does what you said to do: append 10 characters (`sizeof(strng)`) to file, including `\0` and rest of the array. Change `sizeof` to `strlen`. Besides that you should not only print "problem" when you can't open file, but also not write to it. And last problem in your code - you declared `main` a...
When you fopen the file, the stream position is at the beginning of the file. Surely you have to seek to the end before writing in order to get the string appended?
38,401,301
Hi I have the plot below and there are 2 legends showing up. I have a question: Currently the legend I added has 6 entries "A Value", "Ad value", "au value", "b", "bD Value" and "bU value". I really want to the legend to show only 4 entries * "A" and in the legend this should be a blue solid line like it already is *...
2016/07/15
[ "https://Stackoverflow.com/questions/38401301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3022875/" ]
The second legend is showing up because you changed the labels and title in just one of the two guides. If you change the other to match it (or better yet, change the `title` column to match the labels you want), the color and linetype will show up together in one legend. Alternatively, if the groupings match up (i.e....
``` d1 <- data.frame(title = c("aU","A","ad","bU","b","bD"), title2 = c("aU & ad", "A", "aU & ad", "bU & bD", "b", "bU & bD")) d2 <- merge(d, d1, by = "title") ggplot(d2 , aes(x = time, y = value, group = title, colour = title2, linetype = title2)) + g...
17,982,537
this is my html ``` <a href="/name/nm3515425/?ref_=tt_cl_i1"><img height="44" width="32" alt="Ross Lynch" title="Ross Lynch" src="http://ia.media-imdb.com/images/G/01/imdb/images/nopicture/32x44/name-2138558783._V379389446_.png" class="loadlate hidden " loadlate="http://ia.media-imdb.com/images/M/MV5BMjYyODA4ODcyOF5BM...
2013/07/31
[ "https://Stackoverflow.com/questions/17982537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2640014/" ]
Actually, it's a bug (?), you cant use "Number" as a room id. Only string.
i think the problem is in this: "starting from 0". Dont use 0 for room name.
7,233,877
``` int f(int b[][3]); int main() { int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; f(a); printf("%d\n", a[2][1]); } int f(int b[][3]) { ++b; b[1][1] = 1; } ``` `3x3 => 9` elements contained in the 2-D array `a`. When it's passed, then `b` will contain the the base address of the `a`. If suppos...
2011/08/29
[ "https://Stackoverflow.com/questions/7233877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713179/" ]
The function heading ``` int f(int b[][3]) ``` is a nothing more than a confusing way to write (and is *exactly equivalent* to) ``` int f(int (*b)[3]) ``` The type of `b` is "pointer to three-element array of `int`". When you increment the `b` parameter you adjust it to point to the next three-element array of ...
> > How is b[1][1] corresponds to the address of 8 and not address of 5? > > > This is expected behavior: ``` int f(int b[][3]) { //at this point b[0][0] is 1, b[1][1] is 5 ++b; //now b[0][0] is 4, b[1][1] is 8 b[1][1]=1; } ``` The pointer has incremented to point to the next memory slot, whic...
7,233,877
``` int f(int b[][3]); int main() { int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; f(a); printf("%d\n", a[2][1]); } int f(int b[][3]) { ++b; b[1][1] = 1; } ``` `3x3 => 9` elements contained in the 2-D array `a`. When it's passed, then `b` will contain the the base address of the `a`. If suppos...
2011/08/29
[ "https://Stackoverflow.com/questions/7233877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713179/" ]
C multidimensional arrays are really linear, except that there is syntactic sugar to do the arithmetic correctly. so with `b[][3]`, it excepts a 1-D array and implicitly translates `b[i][j] --> b[3*i+j]` `++b` works as follows: `(++b)[i][j] = ORIGINAL_b[i+1][j]`. So in your case, you are accessing `ORIGINAL_b[1+1][1]...
> > How is b[1][1] corresponds to the address of 8 and not address of 5? > > > This is expected behavior: ``` int f(int b[][3]) { //at this point b[0][0] is 1, b[1][1] is 5 ++b; //now b[0][0] is 4, b[1][1] is 8 b[1][1]=1; } ``` The pointer has incremented to point to the next memory slot, whic...
7,233,877
``` int f(int b[][3]); int main() { int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; f(a); printf("%d\n", a[2][1]); } int f(int b[][3]) { ++b; b[1][1] = 1; } ``` `3x3 => 9` elements contained in the 2-D array `a`. When it's passed, then `b` will contain the the base address of the `a`. If suppos...
2011/08/29
[ "https://Stackoverflow.com/questions/7233877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713179/" ]
The function heading ``` int f(int b[][3]) ``` is a nothing more than a confusing way to write (and is *exactly equivalent* to) ``` int f(int (*b)[3]) ``` The type of `b` is "pointer to three-element array of `int`". When you increment the `b` parameter you adjust it to point to the next three-element array of ...
C multidimensional arrays are really linear, except that there is syntactic sugar to do the arithmetic correctly. so with `b[][3]`, it excepts a 1-D array and implicitly translates `b[i][j] --> b[3*i+j]` `++b` works as follows: `(++b)[i][j] = ORIGINAL_b[i+1][j]`. So in your case, you are accessing `ORIGINAL_b[1+1][1]...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
Personally, I'd use a combination of your (4) and (3): don't be too uptight about it, and make it as freely copyable as possible -- with a catch. > > Publish machine-readable information publicly, and contact those who use your information after the fact to ask them to give due credit. > > > For the purposes of t...
I try to take a practical approach: make it as easy as possible for people to give credit where it is due. One way towards this is to provide *actual citation text* for users to include in their sources (or in the material they cut-and-paste). The citation format will not always be the form they want, but it gets them ...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
"how best to protect that intellectual (and modest financial) effort?" 1. Protect it from copycat relatives? Hide it. 2. Protect it from being lost forever? Share it. 3. Protect it from both? Share it with all your distant relatives, encourage them to share it, and include a request for old pictures or updates on thei...
These comments have been very informative and have confirmed my own feelings. Since 1999 I have been working on my extended family trees, researching, connecting with newly found relatives, going to locations, cemeteries, finding skeletons in the closet and finding cherished pictures that would have been in the trash i...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
Personally, I'd use a combination of your (4) and (3): don't be too uptight about it, and make it as freely copyable as possible -- with a catch. > > Publish machine-readable information publicly, and contact those who use your information after the fact to ask them to give due credit. > > > For the purposes of t...
I publish (or will publish) all the results of my research online, with exclusions mentioned elsewhere in discussions about privacy. I don't publish material to which other people hold the copyright (e.g. copyrighted images of sources, or oral testimony which I don't have permission to share). My own copyright stateme...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
Personally, I'd use a combination of your (4) and (3): don't be too uptight about it, and make it as freely copyable as possible -- with a catch. > > Publish machine-readable information publicly, and contact those who use your information after the fact to ask them to give due credit. > > > For the purposes of t...
These comments have been very informative and have confirmed my own feelings. Since 1999 I have been working on my extended family trees, researching, connecting with newly found relatives, going to locations, cemeteries, finding skeletons in the closet and finding cherished pictures that would have been in the trash i...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
Personally, I'd use a combination of your (4) and (3): don't be too uptight about it, and make it as freely copyable as possible -- with a catch. > > Publish machine-readable information publicly, and contact those who use your information after the fact to ask them to give due credit. > > > For the purposes of t...
There are a couple of core issues here. In the research process, you will have typically assimilated information from some source and then used it as evidence for or against a number of conclusions. There are, therefore, a number of separate parts that could be published: the evidence, the citations for the sources, yo...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
Personally, I'd use a combination of your (4) and (3): don't be too uptight about it, and make it as freely copyable as possible -- with a catch. > > Publish machine-readable information publicly, and contact those who use your information after the fact to ask them to give due credit. > > > For the purposes of t...
As responsible and courteous users of published information, we all place a lot of emphasis on not breaching the copyright of others. Sometimes that focus gives us a distorted picture of just what we can hold copyright over in our own work. I certainly have no claim on any of the information in my records. The facts a...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
I publish (or will publish) all the results of my research online, with exclusions mentioned elsewhere in discussions about privacy. I don't publish material to which other people hold the copyright (e.g. copyrighted images of sources, or oral testimony which I don't have permission to share). My own copyright stateme...
These comments have been very informative and have confirmed my own feelings. Since 1999 I have been working on my extended family trees, researching, connecting with newly found relatives, going to locations, cemeteries, finding skeletons in the closet and finding cherished pictures that would have been in the trash i...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
I try to take a practical approach: make it as easy as possible for people to give credit where it is due. One way towards this is to provide *actual citation text* for users to include in their sources (or in the material they cut-and-paste). The citation format will not always be the form they want, but it gets them ...
These comments have been very informative and have confirmed my own feelings. Since 1999 I have been working on my extended family trees, researching, connecting with newly found relatives, going to locations, cemeteries, finding skeletons in the closet and finding cherished pictures that would have been in the trash i...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
Personally, I'd use a combination of your (4) and (3): don't be too uptight about it, and make it as freely copyable as possible -- with a catch. > > Publish machine-readable information publicly, and contact those who use your information after the fact to ask them to give due credit. > > > For the purposes of t...
"how best to protect that intellectual (and modest financial) effort?" 1. Protect it from copycat relatives? Hide it. 2. Protect it from being lost forever? Share it. 3. Protect it from both? Share it with all your distant relatives, encourage them to share it, and include a request for old pictures or updates on thei...
1,403
Say you've spent a considerable amount of time, and perhaps some money as well, documenting a set of families. The work has paid off, and one of the rewards is to share it with people who may be living descendants of those documented by your research. The problem is that once you publish your research on a public web...
2012/10/15
[ "https://genealogy.stackexchange.com/questions/1403", "https://genealogy.stackexchange.com", "https://genealogy.stackexchange.com/users/8/" ]
There are a couple of core issues here. In the research process, you will have typically assimilated information from some source and then used it as evidence for or against a number of conclusions. There are, therefore, a number of separate parts that could be published: the evidence, the citations for the sources, yo...
These comments have been very informative and have confirmed my own feelings. Since 1999 I have been working on my extended family trees, researching, connecting with newly found relatives, going to locations, cemeteries, finding skeletons in the closet and finding cherished pictures that would have been in the trash i...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
Now DRF allows permissions to be composed using bitwise operators: & -and- and | -or-. [From the docs](https://www.django-rest-framework.org/api-guide/permissions/): > > Provided they inherit from `rest_framework.permissions.BasePermission`, permissions can be composed using standard Python bitwise operators. For ex...
One way would be to add another [permission class](http://www.django-rest-framework.org/api-guide/permissions/) which combines existing classes the way you want it, e.g.: ``` class IsAdmin(BasePermission): """Allow access to admins""" def has_object_permission(self, request, view, obj): return request....
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
Here is a generic solution: ``` from functools import reduce from rest_framework.decorators import permission_classes from rest_framework.permissions import BasePermission def any_of(*perm_classes): """Returns permission class that allows access for one of permission classes provided in perm_classes""" ...
The easiest way would be to separate them out with `|` in `permission_classes` attribute or `get_permissions` method, but if you have complex rules, you can specify those rules in the `check_permissions` method in the viewsets class that you are defining. Something like this: ``` class UserProfileViewSet(viewsets.Mode...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
Now DRF allows permissions to be composed using bitwise operators: & -and- and | -or-. [From the docs](https://www.django-rest-framework.org/api-guide/permissions/): > > Provided they inherit from `rest_framework.permissions.BasePermission`, permissions can be composed using standard Python bitwise operators. For ex...
The easiest way would be to separate them out with `|` in `permission_classes` attribute or `get_permissions` method, but if you have complex rules, you can specify those rules in the `check_permissions` method in the viewsets class that you are defining. Something like this: ``` class UserProfileViewSet(viewsets.Mode...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
Now DRF allows permissions to be composed using bitwise operators: & -and- and | -or-. [From the docs](https://www.django-rest-framework.org/api-guide/permissions/): > > Provided they inherit from `rest_framework.permissions.BasePermission`, permissions can be composed using standard Python bitwise operators. For ex...
You need to build your own [custom http://www.django-rest-framework.org/api-guide/permissions/#custom-permissions](http://www.django-rest-framework.org/api-guide/authentication/#custom-authentication) as described in the docs. Something like: ``` from rest_framework import permissions class IsAdminOrStaff(permission...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
You need to build your own [custom http://www.django-rest-framework.org/api-guide/permissions/#custom-permissions](http://www.django-rest-framework.org/api-guide/authentication/#custom-authentication) as described in the docs. Something like: ``` from rest_framework import permissions class IsAdminOrStaff(permission...
Here is a generic solution: ``` from functools import reduce from rest_framework.decorators import permission_classes from rest_framework.permissions import BasePermission def any_of(*perm_classes): """Returns permission class that allows access for one of permission classes provided in perm_classes""" ...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
Now DRF allows permissions to be composed using bitwise operators: & -and- and | -or-. [From the docs](https://www.django-rest-framework.org/api-guide/permissions/): > > Provided they inherit from `rest_framework.permissions.BasePermission`, permissions can be composed using standard Python bitwise operators. For ex...
I think you might be able to use `django-rules` library here. [Link](https://github.com/dfunckt/django-rules) It is a rule based engine very similar to decision trees and it can be easily integrated with permissions\_class framework of DRF. The best part is you can perform set operations on simple permissions and c...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
I think you might be able to use `django-rules` library here. [Link](https://github.com/dfunckt/django-rules) It is a rule based engine very similar to decision trees and it can be easily integrated with permissions\_class framework of DRF. The best part is you can perform set operations on simple permissions and c...
Here is a generic solution: ``` from functools import reduce from rest_framework.decorators import permission_classes from rest_framework.permissions import BasePermission def any_of(*perm_classes): """Returns permission class that allows access for one of permission classes provided in perm_classes""" ...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
Now DRF allows permissions to be composed using bitwise operators: & -and- and | -or-. [From the docs](https://www.django-rest-framework.org/api-guide/permissions/): > > Provided they inherit from `rest_framework.permissions.BasePermission`, permissions can be composed using standard Python bitwise operators. For ex...
Aside from the custom permission which is simpler approach mentioned in the [earlier answer](https://stackoverflow.com/a/35557412/764592), you can also look for an existing [3rd party](http://www.django-rest-framework.org/api-guide/permissions/#third-party-packages) that handle a much complex permission handling if nec...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
I think you might be able to use `django-rules` library here. [Link](https://github.com/dfunckt/django-rules) It is a rule based engine very similar to decision trees and it can be easily integrated with permissions\_class framework of DRF. The best part is you can perform set operations on simple permissions and c...
Aside from the custom permission which is simpler approach mentioned in the [earlier answer](https://stackoverflow.com/a/35557412/764592), you can also look for an existing [3rd party](http://www.django-rest-framework.org/api-guide/permissions/#third-party-packages) that handle a much complex permission handling if nec...
35,557,156
It seems that permission classes are ANDed when REST framework checks permissions. That is every permission class needs to return True for permission to be granted. This makes things like "if you are a superuser, you can access anything, but if you are a regular user you need explicit permissions" a bit hard to impleme...
2016/02/22
[ "https://Stackoverflow.com/questions/35557156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302268/" ]
I think you might be able to use `django-rules` library here. [Link](https://github.com/dfunckt/django-rules) It is a rule based engine very similar to decision trees and it can be easily integrated with permissions\_class framework of DRF. The best part is you can perform set operations on simple permissions and c...
The easiest way would be to separate them out with `|` in `permission_classes` attribute or `get_permissions` method, but if you have complex rules, you can specify those rules in the `check_permissions` method in the viewsets class that you are defining. Something like this: ``` class UserProfileViewSet(viewsets.Mode...
60,238
I've got a low power application which will be powered from a Li coin cell. I've achieved satisfactory sleeping current with my chosen MCU. The application ADC IC however is a different matter: 900µA while inactive -- way too much for a coin cell application. So I thought why not isolate the power to the ADC when it...
2013/03/08
[ "https://electronics.stackexchange.com/questions/60238", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/18937/" ]
Powering a device through a GPIO pin is usually a bad idea. In the very low power regime, perhaps you could get away with it, but I would not recommend it unless you have very severe constraints. You've already noted that you've checked that the ADC's requirement is lower than the pin's drive capability. That is typic...
Yes, you can do that, just make sure all the constraints are met. I have done this a few times. Using a microcontroller output to actually power a small circuit instead of switcing its power can be a useful way to save space. I used this in one project, for example, to turn on a ultrasound receiver analog front end onl...
60,238
I've got a low power application which will be powered from a Li coin cell. I've achieved satisfactory sleeping current with my chosen MCU. The application ADC IC however is a different matter: 900µA while inactive -- way too much for a coin cell application. So I thought why not isolate the power to the ADC when it...
2013/03/08
[ "https://electronics.stackexchange.com/questions/60238", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/18937/" ]
Powering a device through a GPIO pin is usually a bad idea. In the very low power regime, perhaps you could get away with it, but I would not recommend it unless you have very severe constraints. You've already noted that you've checked that the ADC's requirement is lower than the pin's drive capability. That is typic...
Yes, you can do this. And many have. For example, [Adafruit shows this being done for a ds1307 RTC on an adruino, powered by two gpio (as vcc and gnd)](http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/wiring-it-up). This is also done for Nokia LCDs, which only need 1 mA for the screen (The backlight ...
2,469,933
While Compiling the WPF Application for many times in a day it give following error 'Exception of type 'System.OutOfMemoryException' was thrown.' Can anyone know why this error occured and how to remove that error. But if visual studio is restarted then there is no such problem. thanks in advance
2010/03/18
[ "https://Stackoverflow.com/questions/2469933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172718/" ]
It could be that your compiler has a memory leak, or that a plugin of your compiler has a memory leak. There is not your fault, though. It's most probably your compiler's fault. You are encouraged to reproduce the problem and send it to your compiler vendor for a detail investigation.
This happens to me frequently with visual studio 2008. I just assume there's a memory leak somewhere due to poor coding on Microsoft's part. Whenever i see this error I close down and reopen visual studio and it compiles without a hitch.
2,469,933
While Compiling the WPF Application for many times in a day it give following error 'Exception of type 'System.OutOfMemoryException' was thrown.' Can anyone know why this error occured and how to remove that error. But if visual studio is restarted then there is no such problem. thanks in advance
2010/03/18
[ "https://Stackoverflow.com/questions/2469933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172718/" ]
This happens to me frequently with visual studio 2008. I just assume there's a memory leak somewhere due to poor coding on Microsoft's part. Whenever i see this error I close down and reopen visual studio and it compiles without a hitch.
Is your machine up to the minimum specification for developing WPF applications
2,469,933
While Compiling the WPF Application for many times in a day it give following error 'Exception of type 'System.OutOfMemoryException' was thrown.' Can anyone know why this error occured and how to remove that error. But if visual studio is restarted then there is no such problem. thanks in advance
2010/03/18
[ "https://Stackoverflow.com/questions/2469933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172718/" ]
It could be that your compiler has a memory leak, or that a plugin of your compiler has a memory leak. There is not your fault, though. It's most probably your compiler's fault. You are encouraged to reproduce the problem and send it to your compiler vendor for a detail investigation.
Is your machine up to the minimum specification for developing WPF applications
2,469,933
While Compiling the WPF Application for many times in a day it give following error 'Exception of type 'System.OutOfMemoryException' was thrown.' Can anyone know why this error occured and how to remove that error. But if visual studio is restarted then there is no such problem. thanks in advance
2010/03/18
[ "https://Stackoverflow.com/questions/2469933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172718/" ]
It could be that your compiler has a memory leak, or that a plugin of your compiler has a memory leak. There is not your fault, though. It's most probably your compiler's fault. You are encouraged to reproduce the problem and send it to your compiler vendor for a detail investigation.
It sounds like you are saying that after compiling a WPF application many times in Visual Studio you receive an `OutOfMemoryException` error. Can you elaborate further on where exactly this error shows up? * In the Designer * In the output window * etc ... It's possible that there is a bug in either a 3rd party host...
2,469,933
While Compiling the WPF Application for many times in a day it give following error 'Exception of type 'System.OutOfMemoryException' was thrown.' Can anyone know why this error occured and how to remove that error. But if visual studio is restarted then there is no such problem. thanks in advance
2010/03/18
[ "https://Stackoverflow.com/questions/2469933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172718/" ]
It sounds like you are saying that after compiling a WPF application many times in Visual Studio you receive an `OutOfMemoryException` error. Can you elaborate further on where exactly this error shows up? * In the Designer * In the output window * etc ... It's possible that there is a bug in either a 3rd party host...
Is your machine up to the minimum specification for developing WPF applications
4,058,657
> > For a set $\mathscr{F}$, define > > > $$\bigcup!\mathscr{F}=\{x\mid\exists!A\in\mathscr{F}\, x\in A\}$$ > > > (a) If $\mathscr{F}=\big\{\{1,2,3\},\{2,3,4\},\{3,4,5\}\big\}$, what is $\bigcup!\mathscr{F}$? > > > (b) Suppose $\mathscr{F}$ is a set and $\bigcup!\mathscr{F}\cap\bigcap\mathscr{F}\ne\varnothing$. ...
2021/03/12
[ "https://math.stackexchange.com/questions/4058657", "https://math.stackexchange.com", "https://math.stackexchange.com/users/899057/" ]
For (b). Assume $[\cup !\mathscr F ]\cap [\cap \mathscr F]\ne \emptyset.$ If $f,g\in\mathscr F$ with $f\ne g$ then $\cup !\mathscr F\subseteq (f\setminus g)\cup (g\setminus f)$ and $\cap\mathscr F)\subseteq f\cap g.$ But for any $f,g$ we have $[(f\setminus g)\cup (g\setminus f)]\,\cap \, [f\cap g]=\emptyset.$ Therefor...
$(a)$ is $\{1,5\}$, the full union is $\{1,2,3,4,5\}$ but $2,3$ and $4$ occur in two sets in $\mathcal{F}$, so are not in $\bigcup !\mathcal{F}$. $(b)$: Let $x \in \bigcup !\mathcal{F}$ and $x \in \bigcap \mathcal{F}$. Suppose that $F\_1, F\_2 \in \mathcal{F}$ exist with $F\_1 \neq F\_2$. Then $x \in F\_1 \cap F\_2$ a...