Search Results

Search found 21356 results on 855 pages for 'check digit'.

Page 73/855 | < Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >

  • What is the proper way to check the previous value of a field before saving an object? (Using Django

    - by anonymous coward
    I have a Django Model with updated_by and an approved_by fields, both are ForeignKey fields to the built-in (auth) User models. I am aware that with updated_by, it's easy enough to simply over-ride the .save() method on the Model, and shove the request.user in that field before saving. However, for approved_by, this field should only ever be filled in when a related field (date_approved) is first filled in. I'm somewhat certain that I can check this logically, and fill in the field if the previous value was empty. What is the proper way to check the previous value of a field before saving an object? I do not anticipate that date_approved will ever be changed or updated, nor should there be any reason to ever update the approved_by entry. UPDATE: Regarding forms/validation, I should have mentioned that none of the fields in question are seen by or editable by users of the site. If I have misunderstood, I'm sorry, but I'm not sure how forms and validation apply to my question.

    Read the article

  • how can I reliably check that requests to my service file have come from my website?

    - by woot586
    I have a service.php class that I use to service AJAX calls from my website. To prevent other people accessing the service using PHP CURL I would normally check the request has come from mysite, and if they are not then just redirect to my home page e.g. if($_SERVER['HTTP_REFERER'] != "http://www.mysite.com"){ header('location: http://www.mysite.com'); exit; } I read in the PHP holy bible: http://www.php.net/manual/en/reserved.variables.server.php that "Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted." So if this method is not reliable, my question is how can I reliably check that requests to my service file have come from my website? Thanks for any help you can provide!

    Read the article

  • How to check if TypeIdenitifier(T) is an Object?

    - by John
    I'm creating a generic list class that has a member of type Array(Array of ). The problem is the class descruction,because the class is supposed to be used for types from byte to types inheriting TObject. Specifically: destructor Destroy; var elem:T; begin /*if(T is Tobject) then //Check if T inherits TObject {Compiler error!} for elem in FData do TObject(elem).Free;*/ // do not know how to do it SetLength(FItems,0); //FItems : Array of T inherited Destroy; end; How do I check if T is TObject so I can free every member if the typeidenitifier is a class,for example?

    Read the article

  • Lua : How to check if one of the values associated with the specified key of a table is nil, from ap

    - by felace
    In lua, it's legal to do this : table={} bar if(table[key]==nil) foo However, using C API, I couldn't find way to check if there's a nil value on the specified position. lua_getglobal(L,"table"); lua_gettable(L,key); If there's a nil value stored in table[key], lua_gettable would give me the "unprotected error in call to Lua API (attempt to index a nil value)" message. Is there any way to check if there's actually something associated with that key, before actually pushing the key to do so ?

    Read the article

  • Error accessing or executing Nagios / Icinga binary '/usr/sbin/nagios'. Cannot run the mandatory syntax check

    - by Zim3r
    I see an error while using NConf interface in Generate Nagios config Error accessing or executing Nagios / Icinga binary '/usr/sbin/nagios'. Cannot run the mandatory syntax check. I checked Apache Error_log and it says: sh: /usr/sbin/nagios: Permission denied I tried changing permissions and ownership but no change. How can I fix this? Edit: ls -l /usr/sbin/nagios -rwxrwxrwx. 1 apache apache 644184 Jul 2 02:10 /usr/sbin/nagios ps -ef | egrep 'httpd|apache' root 4175 1 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4177 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4178 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4179 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4180 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4181 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4182 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4183 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4184 4175 0 10:50 ? 00:00:00 /usr/sbin/httpd apache 4559 4175 0 11:31 ? 00:00:00 /usr/sbin/httpd root 4888 4854 0 12:26 pts/1 00:00:00 egrep httpd|apache

    Read the article

  • Automatically check for Security Updates on CentOS or Scientific Linux?

    - by Stefan Lasiewski
    We have machines running RedHat-based distros such as CentOS or Scientific Linux. We want the systems to automatically notify us if there are any known vulnerabilities to the installed packages. FreeBSD does this with the ports-mgmt/portaudit port. RedHat provides yum-plugin-security, which can check for vulnerabilities by their Bugzilla ID, CVE ID or advisory ID. In addition, Fedora recently started to support yum-plugin-security. I believe this was added in Fedora 16. Scientific Linux 6 did not support yum-plugin-security as of late 2011. It does ship with /etc/cron.daily/yum-autoupdate, which updates RPMs daily. I don't think this handles Security Updates only, however. CentOS does not support yum-plugin-security. I monitor the CentOS and Scientific Linux mailinglists for updates, but this is tedious and I want something which can be automated. For those of us who maintain CentOS and SL systems, are there any tools which can: Automatically (Progamatically, via cron) inform us if there are known vulnerabilities with my current RPMs. Optionally, automatically install the minimum upgrade required to address a security vulnerability, which would probably be yum update-minimal --security on the commandline? I have considered using yum-plugin-changelog to print out the changelog for each package, and then parse the output for certain strings. Are there any tools which do this already?

    Read the article

  • Converting projects to use Automatic NuGet restore

    - by terje
    Originally posted on: http://geekswithblogs.net/terje/archive/2014/06/11/converting-projects-to-use-automatic-nuget-restore.aspxDownload tool In version 2.7 of NuGet automatic nuget restore was introduced, meaning you no longer need to distort your msbuild project files with nuget target information.   Visual Studio and TFS 2013 build have this enabled by default.  However, if your project was created before this was introduced, and/or if you have used the “Enable NuGet Package Restore” afterwards, you now have a series of unwanted things in your projects, and a series of project files that have been modified – and – you no longer neither want nor need this !  You might also get into some unwanted issues due to these modifications.  This is a MSBuild modification that was needed only before NuGet 2.7 ! So: DON’T USE THIS FUNCTION !!! There is an issue https://nuget.codeplex.com/workitem/4019 on this on the NuGet project site to get this function removed, renamed or at least moved farther away from the top level (please help vote it up!).  The response seems to be that it WILL BE removed, around version 3.0. This function does nothing you need after the introduction of NuGet 2.7.  What is also unfortunate is the naming of it – it implies that it is needed, it is not, and what is worse, there is no corresponding function to remove what it does ! So to fix this use the tool named IFix, that will fix this issue for you   - all free of course, and the code is open source.  Also report issues there:  https://github.com/OsirisTerje/IFix    IFix information DOWNLOAD HERE This command line tool installs using an MSI, and add itself to the system path.  If you work in a team, you will probably need to use the  tool multiple times.  Anyone in the team may at any time use the “Enable NuGet Package Restore” function and mess up your project again.  The IFix program can be run either in a  check modus, where it does not write anything back – it only checks if you have any issues, or in a Fix mode, where it will also perform the necessary fixes for you. The IFix program is used like this: IFix <command> [-c/--check] [-f/--fix]  [-v/--verbose] The command in this case is “nugetrestore”.  It will do a check from the location where it is being called, and run through all subfolders from that location. So  “IFix nugetrestore  --check” , will do the check ,  and “IFix nugetrestore  --fix”  will perform the changes, for all files and folders below the current working directory. (Note that --check  can be replaced with only –c, and --fix with –f, and so on. ) BEWARE: When you run the fix option, all solutions to be affected must be closed in Visual Studio ! So, if you just want to DO it, then: IFix nugetrestore --check to see if you have issues then IFix nugetrestore  --fix to fix them. How does it work IFix nugetrestore  checks and optionally fixes four issues that the older enabling of nuget restore did.  The issues are related to the MSBuild projess, and are: Deleting the nuget.targets file. Deleting the nuget.exe that is located under the .nuget folder Removing all references to nuget.targets in the solution file Removing all properties and target imports of nuget.targets inside the csproj files. IFix fixes these issues in the same sequence. The first step, removing the nuget.targets file is the most critical one, and all instances of the nuget.targets file within the scope of a solution has to be removed, and in addition it has to be done with the solution closed in Visual Studio.  If Visual Studio finds a nuget.targets file, the csproj files will be automatically messed up again. This means the removal process above might need to be done multiple times, specially when you’re working with a team, and that solution context menu still has the “Enable NuGet Package Restore” function.  Someone on the team might inadvertently do this at any time. It can be a good idea to add this check to a checkin policy – if you run TFS standard version control, but that will have no effect if you use TFS Git version control of course. So, better be prepared to run the IFix check from time to time. Or, even better, install IFix on your build servers, and add a call to IFix nugetrestore --check in the TFS Build script.    How does it look As a first example I have run the IFix program from the top of a set of git repositories, so it spans multiple repositories with multiple solutions. The result from the check option is as follows: We see the four red lines, there is one for each of the four checks we talked about in the previous section. The fact that they are red, means we have that particular issue. The first section (above the first red text line) is the nuget targets section.  Notice  No.1, it says it has found no paths to copy.  What IFix does here is to check if there are any defined paths to other nuget galleries.  If there are, then those are copied over to the nuget.config file, where is where it should be in version 2.7 and above.   No.2 says it has found the particular nuget.targets file,  No.3  states it HAS found some other nuget galleries defines in the targets file, which then it would like to copy to the config.file. No.4 is the section for nuget.exe files, and list those it has found, and which it would like to delete. No 5 states it has found a reference to nuget.targets in the solution file.  This reference comes from the fact that the .nuget folder is a solution folder, and the items within are described in the solution file. It then checks the csproj files, and as can be seen from the last red line, it ha found issues in 96 out of 198 csproj files.  There are two possible issues in a csproj files.  No.6 is the first one, and the most common and most important one, an “Import project” section.  This is the section that calls the nuget.targets files.  No.7 is another issue, which seems to sometimes be there, sometimes not, it is a RestorePackages property, which also should go away. Now, if we run the IFix nugetrestore –fix command, and then the check again after that, the result is: All green !

    Read the article

  • Manipulate multiple check boxes by ID using unobtrusive java script?

    - by Dean
    I want to be able to select multiple check boxes onmouseover, but instead of applying onmouseover to every individual box, I've been trying to work out how to do so by manipulating check boxes by ID instead, although I'm not sure where to go from using getElementById,. So instead of what you see below. <html> <head> <script> var Toggle = true; var Highlight=false; function handleKeyPress(evt) { var nbr; if (window.Event) nbr = evt.which; else nbr = event.keyCode; if(nbr==16)Highlight=true; return true; } function MakeFalse(){Highlight=false;} function SelectIt(X){ if(X.checked && Toggle)X.checked=false; else X.checked=true; } function ChangeText() { var test1 = document.getElementById("1"); test1.innerHTML = "onmouseover=SelectIt(this)" } </script> </head> <body> <form name="A"> <input type="checkbox" name="C1" onmouseover="SelectIt(this)" id="1"><br> <input type="checkbox" name="C2" onmouseover="SelectIt(this)" id="2"><br> <input type="checkbox" name="C3" onmouseover="SelectIt(this)" id="3"><br> <input type="checkbox" name="C4" onmouseover="SelectIt(this)" checked="" disabled="disabled" id="4"><br> <input type="checkbox" name="C5" onmouseover="SelectIt(this)" id="5"><br> <input type="checkbox" name="C6" onmouseover="SelectIt(this)" id="6"><br> <input type="checkbox" name="C7" onmouseover="SelectIt(this)" id="7"><br> <input type="checkbox" name="C8" onmouseover="SelectIt(this)" id="8"><br> </form> </body> </html> I want to be able to apply the onmousover effect to an array of check boxes like this <form name="A"> <input type="checkbox" name="C1" id="1"><br> <input type="checkbox" name="C2" id="2"><br> <input type="checkbox" name="C3" id="3"><br> <input type="checkbox" name="C4" checked="" disabled="disabled" id="4"><br> <input type="checkbox" name="C5" id="5"><br> <input type="checkbox" name="C6" id="6"><br> <input type="checkbox" name="C7" id="7"><br> <input type="checkbox" name="C8" id="8"><br> </form> After trying the search feature of stackoverflow.com and looking around on Google I haven't been able to a find a solution that makes sense to me thus far, although I'm still in the process of learning so I fear I might be trying to do something too advanced for my level of knowledge.

    Read the article

  • Polymorphism problem: How to check type of derived class?

    - by malymato
    Hi, this is my first question here :) I know that I should not check for object type but instead use dynamic_cast, but that would not solve my problem. I have class called Extension and interfaces called IExtendable and IInitializable, IUpdatable, ILoadable, IDrawable (the last four are basicly the same). If Extension implements IExtendable interface, it can extend itself with different Extension objects. The problem is that I want to allow the Extension which implements IExtendable to extend only with Extension that implements the same interfaces as the original Extension. You probably don't unerstand that mess so I try to explain it with code: class IExtendable { public: IExtendable(void); void AddExtension(Extension*); void RemoveExtensionByID(unsigned int); vector<Extension*>* GetExtensionPtr(){return &extensions;}; private: vector<Extension*> extensions; }; class IUpdatable { public: IUpdatable(void); ~IUpdatable(void); virtual void Update(); }; class Extension { public: Extension(void); virtual ~Extension(void); void Enable(){enabled=true;}; void Disable(){enabled=false;}; unsigned int GetIndex(){return ID;}; private: bool enabled; unsigned int ID; static unsigned int _indexID; }; Now imagine the case that I create Extension like this: class MyExtension : public Extension, public IExtendable, public IUpdatable, public IDrawable { public: MyExtension(void); virtual ~MyExtension(void); virtual void AddExtension(Extension*); virtual void Update(); virtual void Draw(); }; And I want to allow this class to extend itself only with Extensions that implements the same interfaces (or less). For example I want it to be able to take Extension which implements IUpdatable; or both IUpdatable and IDrawable; but e.g. not Extension which implements ILoadable. I want to do this because when e.g. Update() will be called on some Extension which implements IExtendable and IUpdateable, it will be also called on these Extensions which extends this Extension. So when I'm adding some Extension to Extension which implements IExtendable and some of the IUpdatable, ILoadable... I'm forced to check if Extension that is going to be add implements these interfaces too. So In the IExtendable::AddExtension(Extension*) I would need to do something like this: void IExtendable::AddExtension(Extension* pEx) { bool ok = true; // check wheather this extension can take pEx // do this with every interface if ((*pEx is IUpdatable) && (*this is_not IUpdatable)) ok = false; if (ok) this->extensions.push_back(pEx); } But how? Any ideas what would be the best solution? I don't want to use dynamic_cast and see if it returns null... thanks

    Read the article

  • jQuery: How to check if a value exists in an array?

    - by Jannis
    Hello, I am trying to write a simple input field validation plugin at the moment (more of a learning exercise really) and thought this would not be too hard, seeing as all I should have to do is: Get input fields Store them in array with each one's value On submit of form check if array contains any empty strings But I seem to fail at writing something that checks for an empty string (read: input with no text inside) inside my array. Here is the code I have so far: var form = $(this), // passed in form element inputs = form.find('input'), // all of this forms input fields isValid = false; // initially set the form to not be valid function validate() { var fields = inputs.serializeArray(); // make an array out of input fields // start -- this does not work for (var n in fields) { if (fields[n].value == "") { isValid = false; console.log('failed'); } else { isValid = true; console.log('passed'); }; } // end -- this does not work }; // close validate() // TRIGGERS inputs.live('keyup blur', function(event) { validate(); }); Any help with how I can check if one of the fields is blank and if so return a isValid = false would be much appreciated. I also played around with the $.inArray("", fields) but this would never return 0 or 1 even when the console.log showed that the fields had no value. Thanks for reading.

    Read the article

  • How to check whether a user belongs to an AD group and nested groups?

    - by elsharpo
    hi guys, I have an ASP.NET 3.5 application using Windows Authentication and implementing our own RoleProvider. Problem is we want to restrict access to a set of pages to a few thousand users and rathern than inputing all of those one by one we found out they belong to an AD group. The answer is simple if the common group we are checking membership against the particular user is a direct member of it but the problem I'm having is that if the group is a member of another group and then subsequently member of another group then my code always returns false. For example: Say we want to check whether User is a member of group E, but User is not a direct member of *E", she is a member of "A" which a member of "B" which indeed is a member of E, therefore User is a member of *E" One of the solutions we have is very slow, although it gives the correct answer using (var context = new PrincipalContext(ContextType.Domain)) { using (var group = GroupPrincipal.FindByIdentity(context, IdentityType.Name, "DL-COOL-USERS")) { var users = group.GetMembers(true); // recursively enumerate return users.Any(a => a.Name == "userName"); } } The original solution and what I was trying to get to work, using .NET 3.5 System.DirectoryServices.AccountManagement and it does work when users are direct members of the group in question is as follows: public bool IsUserInGroup(string userName, string groupName) { var cxt = new PrincipalContext(ContextType.Domain, "DOMAIN"); var user = UserPrincipal.FindByIdentity(cxt, IdentityType.SamAccountName, userName); if (user == null) { return false; } var group = GroupPrincipal.FindByIdentity(cxt, groupName); if (group == null) { return false; } return user.IsMemberOf(group); } The bottom line is, we need to check for membership even though the groups are nested in many levels down. Thanks a lot!

    Read the article

  • cmake missing separator error

    - by user198729
    D:\Works\c\cmake\build>cmake .. -- The C compiler identification is MSVC -- The CXX compiler identification is MSVC -- Check for CL compiler version -- Check for CL compiler version - 1500 -- Check if this is a free VC compiler -- Check if this is a free VC compiler - no -- Check for working C compiler: D:/Tools/Microsoft Visual Studio 9.0/VC/bin/cl.exe -- Check for working C compiler: D:/Tools/Microsoft Visual Studio 9.0/VC/bin/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: D:/Tools/Microsoft Visual Studio 9.0/VC/bin/cl.exe -- Check for working CXX compiler: D:/Tools/Microsoft Visual Studio 9.0/VC/bin/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: D:/Works/c/cmake/build D:\Works\c\cmake\build>make Makefile:28: *** missing separator. Stop. I saw many similar problems,but not with cmake,and their solution is to use tabs instead of spaces,but the makefile is generated by cmake,has anyone else met this problem?

    Read the article

  • Is there a way to do 'correct' arithmetical rounding in .NET? / C#

    - by Markus
    I'm trying to round a number to it's first decimal place and, considering the different MidpointRounding options, that seems to work well. A problem arises though when that number has sunsequent decimal places that would arithmetically affect the rounding. An example: With 0.1, 0.11..0.19 and 0.141..0.44 it works: Math.Round(0.1, 1) == 0.1 Math.Round(0.11, 1) == 0.1 Math.Round(0.14, 1) == 0.1 Math.Round(0.15, 1) == 0.2 Math.Round(0.141, 1) == 0.1 But with 0.141..0.149 it always returns 0.1, although 0.146..0.149 should round to 0.2: Math.Round(0.145, 1, MidpointRounding.AwayFromZero) == 0.1 Math.Round(0.146, 1, MidpointRounding.AwayFromZero) == 0.1 Math.Round(0.146, 1, MidpointRounding.ToEven) == 0.1 Math.Round(0.146M, 1, MidpointRounding.ToEven) == 0.1M Math.Round(0.146M, 1, MidpointRounding.AwayFromZero) == 0.1M I tried to come up with a function that addresses this problem, and it works well for this case, but of course it glamorously fails if you try to round i.e. 0.144449 to it's first decimal digit (which should be 0.2, but results 0.1.) (That doesn't work with Math.Round() either.) private double round(double value, int digit) { // basically the old "add 0.5, then truncate to integer" trick double fix = 0.5D/( Math.Pow(10D, digit+1) )*( value = 0 ? 1D : -1D ); double fixedValue = value + fix; // 'truncate to integer' - shift left, round, shift right return Math.Round(fixedValue * Math.Pow(10D, digit)) / Math.Pow(10D, digit); } I assume a solution would be to enumerate all digits, find the first value larger than 4 and then round up, or else round down. Problem 1: That seems idiotic, Problem 2: I have no idea how to enumerate the digits without a gazillion of multiplications and subtractios. Long story short: What is the best way to do that?

    Read the article

  • Concatenation with Zero is not occurring properly in code?

    - by Vineet
    I was trying to reverse a number in PL/SQL. It's working fine, but when my number contains any 0, the output is unexpected. For example: 1234 output 4321 1000 output 1 1203 ouput 3021 10001 output 1 DECLARE r number(9); num number(9):=&p_num; BEGIN WHILE num>=1 LOOP IF mod(num,10)=0 THEN -- extracting last digit of a number . r:=r||0; --if end digit is 0 then concat r with 0 ELSE r:=r||mod(num,10);--if mod is not 0 then it would be last digit. END IF; num:=trunc(num/10);--Removing last digit from number END LOOP; dbms_output.put_line(r); END;

    Read the article

  • Concatenation with Zero is not occuring properly in code?

    - by Vineet
    I was trying to reverse a number in pl/sql ,its working fine but when my number contain any 0,output come unexpected .for eg 1234 output 4321 1000 output 1 1203 ouput 3021 10001 output 1 DECLARE r number(9); num number(9):=&p_num; BEGIN WHILE num>=1 LOOP IF mod(num,10)=0 THEN -- extracting last digit of a number . r:=r||0; --if end digit is 0 then concat r with 0 ELSE r:=r||mod(num,10);--if mod is not 0 then it would be last digit. END IF; num:=trunc(num/10);--Removing last digit from number END LOOP; dbms_output.put_line(r); END;

    Read the article

  • ffmpeg screen capture

    - by Mirai
    I wrote this script for some basic screen capture; it gets the window dimensions then uses the ffmpeg binary to record. I suspect there is a better way (maybe with the ffmpeg library), but scripting is what I know and ffmpeg generally works. Any software (other than recordmydesktop), or improvements to the script are welcome. info=`xwininfo -frame` H=`echo "$info" | grep Height | sed -E "s/^.*: ([[:digit:]]+)$/\1/"` W=`echo "$info" | grep Width | sed -E "s/^.*: ([[:digit:]]+)$/\1/"` offset=:0.0+`echo "$info" | grep Corners | sed -E "s/^.*:[[:space:]]+\+([[:digit:]]+\+[[:digit:]]+)[[:space:]]+.+/\1/" | tr + ,` /usr/local/bin/ffmpeg -f x11grab -s ${W}x${H} -r 45 -i $offset -sameq -f avi ~/videos/`date +%Y-%m-%d-%H%M%s`_vid & echo $! > /tmp/$(basename $0)-$USER

    Read the article

  • Extending Java Enums

    - by CaseyB
    Here's what I am looking to accomplish, I have a class that has an enum of some values and I want to subclass that and add more values to the enum. This is a bad example, but: public class Digits { public enum Digit { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } } public class HexDigits extends Digits { public enum Digit { A, B, C, D, E, F } } so that HexDigits.Digit contains all Hex Digits. Is that possible?

    Read the article

< Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >